blob: 02abfbb1f218d1e5ab5601facbfb6dd4d1bd85e3 [file] [log] [blame]
Reid Spencer832254e2007-02-02 02:16:23 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Reid Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +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 LOCALVAL_ID = 260,
70 GLOBALVAL_ID = 261,
71 FPVAL = 262,
72 VOID = 263,
73 INTTYPE = 264,
74 FLOAT = 265,
75 DOUBLE = 266,
76 LABEL = 267,
77 TYPE = 268,
78 LOCALVAR = 269,
79 GLOBALVAR = 270,
80 LABELSTR = 271,
81 STRINGCONSTANT = 272,
82 ATSTRINGCONSTANT = 273,
83 IMPLEMENTATION = 274,
84 ZEROINITIALIZER = 275,
85 TRUETOK = 276,
86 FALSETOK = 277,
87 BEGINTOK = 278,
88 ENDTOK = 279,
89 DECLARE = 280,
90 DEFINE = 281,
91 GLOBAL = 282,
92 CONSTANT = 283,
93 SECTION = 284,
94 VOLATILE = 285,
95 TO = 286,
96 DOTDOTDOT = 287,
97 NULL_TOK = 288,
98 UNDEF = 289,
99 INTERNAL = 290,
100 LINKONCE = 291,
101 WEAK = 292,
102 APPENDING = 293,
103 DLLIMPORT = 294,
104 DLLEXPORT = 295,
105 EXTERN_WEAK = 296,
106 OPAQUE = 297,
107 EXTERNAL = 298,
108 TARGET = 299,
109 TRIPLE = 300,
110 ALIGN = 301,
111 DEPLIBS = 302,
112 CALL = 303,
113 TAIL = 304,
114 ASM_TOK = 305,
115 MODULE = 306,
116 SIDEEFFECT = 307,
117 CC_TOK = 308,
118 CCC_TOK = 309,
119 FASTCC_TOK = 310,
120 COLDCC_TOK = 311,
121 X86_STDCALLCC_TOK = 312,
122 X86_FASTCALLCC_TOK = 313,
123 DATALAYOUT = 314,
124 RET = 315,
125 BR = 316,
126 SWITCH = 317,
127 INVOKE = 318,
128 UNWIND = 319,
129 UNREACHABLE = 320,
130 ADD = 321,
131 SUB = 322,
132 MUL = 323,
133 UDIV = 324,
134 SDIV = 325,
135 FDIV = 326,
136 UREM = 327,
137 SREM = 328,
138 FREM = 329,
139 AND = 330,
140 OR = 331,
141 XOR = 332,
142 SHL = 333,
143 LSHR = 334,
144 ASHR = 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 VAARG = 378,
188 EXTRACTELEMENT = 379,
189 INSERTELEMENT = 380,
190 SHUFFLEVECTOR = 381,
191 NORETURN = 382,
192 INREG = 383,
193 SRET = 384,
194 DEFAULT = 385,
195 HIDDEN = 386
196 };
197#endif
198/* Tokens. */
199#define ESINT64VAL 258
200#define EUINT64VAL 259
201#define LOCALVAL_ID 260
202#define GLOBALVAL_ID 261
203#define FPVAL 262
204#define VOID 263
205#define INTTYPE 264
206#define FLOAT 265
207#define DOUBLE 266
208#define LABEL 267
209#define TYPE 268
210#define LOCALVAR 269
211#define GLOBALVAR 270
212#define LABELSTR 271
213#define STRINGCONSTANT 272
214#define ATSTRINGCONSTANT 273
215#define IMPLEMENTATION 274
216#define ZEROINITIALIZER 275
217#define TRUETOK 276
218#define FALSETOK 277
219#define BEGINTOK 278
220#define ENDTOK 279
221#define DECLARE 280
222#define DEFINE 281
223#define GLOBAL 282
224#define CONSTANT 283
225#define SECTION 284
226#define VOLATILE 285
227#define TO 286
228#define DOTDOTDOT 287
229#define NULL_TOK 288
230#define UNDEF 289
231#define INTERNAL 290
232#define LINKONCE 291
233#define WEAK 292
234#define APPENDING 293
235#define DLLIMPORT 294
236#define DLLEXPORT 295
237#define EXTERN_WEAK 296
238#define OPAQUE 297
239#define EXTERNAL 298
240#define TARGET 299
241#define TRIPLE 300
242#define ALIGN 301
243#define DEPLIBS 302
244#define CALL 303
245#define TAIL 304
246#define ASM_TOK 305
247#define MODULE 306
248#define SIDEEFFECT 307
249#define CC_TOK 308
250#define CCC_TOK 309
251#define FASTCC_TOK 310
252#define COLDCC_TOK 311
253#define X86_STDCALLCC_TOK 312
254#define X86_FASTCALLCC_TOK 313
255#define DATALAYOUT 314
256#define RET 315
257#define BR 316
258#define SWITCH 317
259#define INVOKE 318
260#define UNWIND 319
261#define UNREACHABLE 320
262#define ADD 321
263#define SUB 322
264#define MUL 323
265#define UDIV 324
266#define SDIV 325
267#define FDIV 326
268#define UREM 327
269#define SREM 328
270#define FREM 329
271#define AND 330
272#define OR 331
273#define XOR 332
274#define SHL 333
275#define LSHR 334
276#define ASHR 335
277#define ICMP 336
278#define FCMP 337
279#define EQ 338
280#define NE 339
281#define SLT 340
282#define SGT 341
283#define SLE 342
284#define SGE 343
285#define ULT 344
286#define UGT 345
287#define ULE 346
288#define UGE 347
289#define OEQ 348
290#define ONE 349
291#define OLT 350
292#define OGT 351
293#define OLE 352
294#define OGE 353
295#define ORD 354
296#define UNO 355
297#define UEQ 356
298#define UNE 357
299#define MALLOC 358
300#define ALLOCA 359
301#define FREE 360
302#define LOAD 361
303#define STORE 362
304#define GETELEMENTPTR 363
305#define TRUNC 364
306#define ZEXT 365
307#define SEXT 366
308#define FPTRUNC 367
309#define FPEXT 368
310#define BITCAST 369
311#define UITOFP 370
312#define SITOFP 371
313#define FPTOUI 372
314#define FPTOSI 373
315#define INTTOPTR 374
316#define PTRTOINT 375
317#define PHI_TOK 376
318#define SELECT 377
319#define VAARG 378
320#define EXTRACTELEMENT 379
321#define INSERTELEMENT 380
322#define SHUFFLEVECTOR 381
323#define NORETURN 382
324#define INREG 383
325#define SRET 384
326#define DEFAULT 385
327#define HIDDEN 386
328
329
330
331
332/* Copy the first part of user declarations. */
333#line 14 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000334
335#include "ParserInternals.h"
336#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000337#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000338#include "llvm/Instructions.h"
339#include "llvm/Module.h"
340#include "llvm/SymbolTable.h"
341#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000342#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000343#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000344#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000345#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000346#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000347#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000348#include <list>
349#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000350#ifndef NDEBUG
351#define YYDEBUG 1
352#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000353
Reid Spencere4f47592006-08-18 17:32:55 +0000354// The following is a gross hack. In order to rid the libAsmParser library of
355// exceptions, we have to have a way of getting the yyparse function to go into
356// an error situation. So, whenever we want an error to occur, the GenerateError
357// function (see bottom of file) sets TriggerError. Then, at the end of each
358// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
359// (a goto) to put YACC in error state. Furthermore, several calls to
360// GenerateError are made from inside productions and they must simulate the
361// previous exception behavior by exiting the production immediately. We have
362// replaced these with the GEN_ERROR macro which calls GeneratError and then
363// immediately invokes YYERROR. This would be so much cleaner if it was a
364// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000365static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000366#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000367#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
368
Reid Spencer68a24bd2005-08-27 18:50:39 +0000369int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
370int yylex(); // declaration" of xxx warnings.
371int yyparse();
372
373namespace llvm {
374 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000375#if YYDEBUG
376static cl::opt<bool>
377Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
378 cl::Hidden, cl::init(false));
379#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000380}
381using namespace llvm;
382
383static Module *ParserResult;
384
385// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
386// relating to upreferences in the input stream.
387//
388//#define DEBUG_UPREFS 1
389#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000390#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000391#else
392#define UR_OUT(X)
393#endif
394
395#define YYERROR_VERBOSE 1
396
Chris Lattnerb475c422005-11-12 18:22:38 +0000397static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000398
399
400// This contains info used when building the body of a function. It is
401// destroyed when the function is completed.
402//
403typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000404
Reid Spencer68a24bd2005-08-27 18:50:39 +0000405static void
406ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
407 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
408
409static struct PerModuleInfo {
410 Module *CurrentModule;
411 std::map<const Type *, ValueList> Values; // Module level numbered definitions
412 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000413 std::vector<PATypeHolder> Types;
414 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000415
416 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000417 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000418 /// that we can resolve them later and print error messages as appropriate.
419 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
420
421 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
422 // references to global values. Global values may be referenced before they
423 // are defined, and if so, the temporary object that they represent is held
424 // here. This is used for forward references of GlobalValues.
425 //
426 typedef std::map<std::pair<const PointerType *,
427 ValID>, GlobalValue*> GlobalRefsType;
428 GlobalRefsType GlobalRefs;
429
430 void ModuleDone() {
431 // If we could not resolve some functions at function compilation time
432 // (calls to functions before they are defined), resolve them now... Types
433 // are resolved when the constant pool has been completely parsed.
434 //
435 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000436 if (TriggerError)
437 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000438
439 // Check to make sure that all global value forward references have been
440 // resolved!
441 //
442 if (!GlobalRefs.empty()) {
443 std::string UndefinedReferences = "Unresolved global references exist:\n";
444
445 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
446 I != E; ++I) {
447 UndefinedReferences += " " + I->first.first->getDescription() + " " +
448 I->first.second.getName() + "\n";
449 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000450 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000451 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000452 }
453
454 Values.clear(); // Clear out function local definitions
455 Types.clear();
456 CurrentModule = 0;
457 }
458
Reid Spencer68a24bd2005-08-27 18:50:39 +0000459 // GetForwardRefForGlobal - Check to see if there is a forward reference
460 // for this global. If so, remove it from the GlobalRefs map and return it.
461 // If not, just return null.
462 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
463 // Check to see if there is a forward reference to this global variable...
464 // if there is, eliminate it and patch the reference to use the new def'n.
465 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
466 GlobalValue *Ret = 0;
467 if (I != GlobalRefs.end()) {
468 Ret = I->second;
469 GlobalRefs.erase(I);
470 }
471 return Ret;
472 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000473
474 bool TypeIsUnresolved(PATypeHolder* PATy) {
475 // If it isn't abstract, its resolved
476 const Type* Ty = PATy->get();
477 if (!Ty->isAbstract())
478 return false;
479 // Traverse the type looking for abstract types. If it isn't abstract then
480 // we don't need to traverse that leg of the type.
481 std::vector<const Type*> WorkList, SeenList;
482 WorkList.push_back(Ty);
483 while (!WorkList.empty()) {
484 const Type* Ty = WorkList.back();
485 SeenList.push_back(Ty);
486 WorkList.pop_back();
487 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
488 // Check to see if this is an unresolved type
489 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
490 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
491 for ( ; I != E; ++I) {
492 if (I->second.get() == OpTy)
493 return true;
494 }
495 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
496 const Type* TheTy = SeqTy->getElementType();
497 if (TheTy->isAbstract() && TheTy != Ty) {
498 std::vector<const Type*>::iterator I = SeenList.begin(),
499 E = SeenList.end();
500 for ( ; I != E; ++I)
501 if (*I == TheTy)
502 break;
503 if (I == E)
504 WorkList.push_back(TheTy);
505 }
506 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
507 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
508 const Type* TheTy = StrTy->getElementType(i);
509 if (TheTy->isAbstract() && TheTy != Ty) {
510 std::vector<const Type*>::iterator I = SeenList.begin(),
511 E = SeenList.end();
512 for ( ; I != E; ++I)
513 if (*I == TheTy)
514 break;
515 if (I == E)
516 WorkList.push_back(TheTy);
517 }
518 }
519 }
520 }
521 return false;
522 }
523
524
Reid Spencer68a24bd2005-08-27 18:50:39 +0000525} CurModule;
526
527static struct PerFunctionInfo {
528 Function *CurrentFunction; // Pointer to current function being created
529
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000530 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000531 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000532 bool isDeclare; // Is this function a forward declararation?
533 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000534 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000535
536 /// BBForwardRefs - When we see forward references to basic blocks, keep
537 /// track of them here.
538 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
539 std::vector<BasicBlock*> NumberedBlocks;
540 unsigned NextBBNum;
541
542 inline PerFunctionInfo() {
543 CurrentFunction = 0;
544 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000545 Linkage = GlobalValue::ExternalLinkage;
546 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000547 }
548
549 inline void FunctionStart(Function *M) {
550 CurrentFunction = M;
551 NextBBNum = 0;
552 }
553
554 void FunctionDone() {
555 NumberedBlocks.clear();
556
557 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000558 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000559 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000560 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000561 return;
562 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000563
564 // Resolve all forward references now.
565 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
566
567 Values.clear(); // Clear out function local definitions
568 CurrentFunction = 0;
569 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000570 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000571 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000572 }
573} CurFun; // Info for the current function...
574
575static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
576
577
578//===----------------------------------------------------------------------===//
579// Code to handle definitions of all the types
580//===----------------------------------------------------------------------===//
581
582static int InsertValue(Value *V,
583 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
584 if (V->hasName()) return -1; // Is this a numbered definition?
585
586 // Yes, insert the value into the value table...
587 ValueList &List = ValueTab[V->getType()];
588 List.push_back(V);
589 return List.size()-1;
590}
591
592static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
593 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000594 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000595 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000596 if (D.Num < CurModule.Types.size())
597 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000598 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000599 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000600 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
601 D.destroy(); // Free old strdup'd memory...
602 return N;
603 }
604 break;
605 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000606 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000607 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000608 }
609
610 // If we reached here, we referenced either a symbol that we don't know about
611 // or an id number that hasn't been read yet. We may be referencing something
612 // forward, so just create an entry to be resolved later and get to it...
613 //
614 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
615
616
617 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000618 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000619 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000620 return 0;
621 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000622 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000623 return 0;
624 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000625 }
626
Reid Spencer861d9d62006-11-28 07:29:44 +0000627 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000628 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000629 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000630
Reid Spencer861d9d62006-11-28 07:29:44 +0000631 Type *Typ = OpaqueType::get();
632 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
633 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000634 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000635
Reid Spencer68a24bd2005-08-27 18:50:39 +0000636// getValNonImprovising - Look up the value specified by the provided type and
637// the provided ValID. If the value exists and has already been defined, return
638// it. Otherwise return null.
639//
640static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000641 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000642 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000643 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000644 return 0;
645 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000646
647 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000648 case ValID::LocalID: { // Is it a numbered definition?
649 // Module constants occupy the lowest numbered slots.
650 std::map<const Type*,ValueList>::iterator VI = CurFun.Values.find(Ty);
651 // Make sure that our type is within bounds.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000652 if (VI == CurFun.Values.end()) return 0;
653
Reid Spencer41dff5e2007-01-26 08:05:27 +0000654 // Check that the number is within bounds.
655 if (D.Num >= VI->second.size()) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000656
Reid Spencer41dff5e2007-01-26 08:05:27 +0000657 return VI->second[D.Num];
658 }
659 case ValID::GlobalID: { // Is it a numbered definition?
660 unsigned Num = D.Num;
661
662 // Module constants occupy the lowest numbered slots...
663 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
664 if (VI == CurModule.Values.end()) return 0;
665 if (D.Num >= VI->second.size()) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000666 return VI->second[Num];
667 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000668
669 case ValID::LocalName: { // Is it a named definition?
670 if (!inFunctionScope()) return 0;
671 SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
672 Value *N = SymTab.lookup(Ty, D.Name);
673 if (N == 0) return 0;
674
675 D.destroy(); // Free old strdup'd memory...
676 return N;
677 }
678 case ValID::GlobalName: { // Is it a named definition?
679 SymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
680 Value *N = SymTab.lookup(Ty, D.Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000681 if (N == 0) return 0;
682
683 D.destroy(); // Free old strdup'd memory...
684 return N;
685 }
686
687 // Check to make sure that "Ty" is an integral type, and that our
688 // value will fit into the specified type...
689 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000690 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000691 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000692 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000693 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000694 return 0;
695 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000696 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000697
698 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000699 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
700 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000701 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000702 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000703 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000704 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000705 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000706 }
707 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000708 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000709 }
710
711 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000712 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000713 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000714 return 0;
715 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000716 return ConstantFP::get(Ty, D.ConstPoolFP);
717
718 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000719 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000720 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000721 return 0;
722 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000723 return ConstantPointerNull::get(cast<PointerType>(Ty));
724
725 case ValID::ConstUndefVal: // Is it an undef value?
726 return UndefValue::get(Ty);
727
Chris Lattner7aa61892005-12-21 17:53:23 +0000728 case ValID::ConstZeroVal: // Is it a zero value?
729 return Constant::getNullValue(Ty);
730
Reid Spencer68a24bd2005-08-27 18:50:39 +0000731 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000732 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000733 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000734 return 0;
735 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000736 return D.ConstantValue;
737
Chris Lattner0e9c3762006-01-25 22:27:16 +0000738 case ValID::InlineAsmVal: { // Inline asm expression
739 const PointerType *PTy = dyn_cast<PointerType>(Ty);
740 const FunctionType *FTy =
741 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000742 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000743 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000744 return 0;
745 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000746 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
747 D.IAD->HasSideEffects);
748 D.destroy(); // Free InlineAsmDescriptor.
749 return IA;
750 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000751 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000752 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000753 return 0;
754 } // End of switch
755
Reid Spencera9720f52007-02-05 17:04:00 +0000756 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000757 return 0;
758}
759
760// getVal - This function is identical to getValNonImprovising, except that if a
761// value is not already defined, it "improvises" by creating a placeholder var
762// that looks and acts just like the requested variable. When the value is
763// defined later, all uses of the placeholder variable are replaced with the
764// real thing.
765//
766static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000768 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000769 return 0;
770 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000771
772 // See if the value has already been defined.
773 Value *V = getValNonImprovising(Ty, ID);
774 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000775 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000776
Reid Spencer5b7e7532006-09-28 19:28:24 +0000777 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000778 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000779 return 0;
780 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000781
782 // If we reached here, we referenced either a symbol that we don't know about
783 // or an id number that hasn't been read yet. We may be referencing something
784 // forward, so just create an entry to be resolved later and get to it...
785 //
786 V = new Argument(Ty);
787
788 // Remember where this forward reference came from. FIXME, shouldn't we try
789 // to recycle these things??
790 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
791 llvmAsmlineno)));
792
793 if (inFunctionScope())
794 InsertValue(V, CurFun.LateResolveValues);
795 else
796 InsertValue(V, CurModule.LateResolveValues);
797 return V;
798}
799
800/// getBBVal - This is used for two purposes:
801/// * If isDefinition is true, a new basic block with the specified ID is being
802/// defined.
803/// * If isDefinition is true, this is a reference to a basic block, which may
804/// or may not be a forward reference.
805///
806static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
Reid Spencera9720f52007-02-05 17:04:00 +0000807 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000808
809 std::string Name;
810 BasicBlock *BB = 0;
811 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000812 default:
813 GenerateError("Illegal label reference " + ID.getName());
814 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000815 case ValID::LocalID: // Is it a numbered definition?
816 if (ID.Num >= CurFun.NumberedBlocks.size())
Reid Spencer68a24bd2005-08-27 18:50:39 +0000817 CurFun.NumberedBlocks.resize(ID.Num+1);
818 BB = CurFun.NumberedBlocks[ID.Num];
819 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000820 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000821 Name = ID.Name;
822 if (Value *N = CurFun.CurrentFunction->
Reid Spencer78d033e2007-01-06 07:24:44 +0000823 getValueSymbolTable().lookup(Type::LabelTy, Name))
Reid Spencer68a24bd2005-08-27 18:50:39 +0000824 BB = cast<BasicBlock>(N);
825 break;
826 }
827
828 // See if the block has already been defined.
829 if (BB) {
830 // If this is the definition of the block, make sure the existing value was
831 // just a forward reference. If it was a forward reference, there will be
832 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000833 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000834 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000835 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000836 return 0;
837 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000838
839 ID.destroy(); // Free strdup'd memory.
840 return BB;
841 }
842
843 // Otherwise this block has not been seen before.
844 BB = new BasicBlock("", CurFun.CurrentFunction);
Reid Spencer41dff5e2007-01-26 08:05:27 +0000845 if (ID.Type == ValID::LocalName) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000846 BB->setName(ID.Name);
847 } else {
848 CurFun.NumberedBlocks[ID.Num] = BB;
849 }
850
851 // If this is not a definition, keep track of it so we can use it as a forward
852 // reference.
853 if (!isDefinition) {
854 // Remember where this forward reference came from.
855 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
856 } else {
857 // The forward declaration could have been inserted anywhere in the
858 // function: insert it into the correct place now.
859 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
860 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
861 }
862 ID.destroy();
863 return BB;
864}
865
866
867//===----------------------------------------------------------------------===//
868// Code to handle forward references in instructions
869//===----------------------------------------------------------------------===//
870//
871// This code handles the late binding needed with statements that reference
872// values not defined yet... for example, a forward branch, or the PHI node for
873// a loop body.
874//
875// This keeps a table (CurFun.LateResolveValues) of all such forward references
876// and back patchs after we are done.
877//
878
879// ResolveDefinitions - If we could not resolve some defs at parsing
880// time (forward branches, phi functions for loops, etc...) resolve the
881// defs now...
882//
883static void
884ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
885 std::map<const Type*,ValueList> *FutureLateResolvers) {
886 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
887 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
888 E = LateResolvers.end(); LRI != E; ++LRI) {
889 ValueList &List = LRI->second;
890 while (!List.empty()) {
891 Value *V = List.back();
892 List.pop_back();
893
894 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
895 CurModule.PlaceHolderInfo.find(V);
Reid Spencera9720f52007-02-05 17:04:00 +0000896 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000897
898 ValID &DID = PHI->second.first;
899
900 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000901 if (TriggerError)
902 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000903 if (TheRealValue) {
904 V->replaceAllUsesWith(TheRealValue);
905 delete V;
906 CurModule.PlaceHolderInfo.erase(PHI);
907 } else if (FutureLateResolvers) {
908 // Functions have their unresolved items forwarded to the module late
909 // resolver table
910 InsertValue(V, *FutureLateResolvers);
911 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000912 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000913 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000914 "' of type '" + V->getType()->getDescription() + "'",
915 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000916 return;
917 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000918 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000919 itostr(DID.Num) + " of type '" +
920 V->getType()->getDescription() + "'",
921 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000922 return;
923 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000924 }
925 }
926 }
927
928 LateResolvers.clear();
929}
930
931// ResolveTypeTo - A brand new type was just declared. This means that (if
932// name is not null) things referencing Name can be resolved. Otherwise, things
933// refering to the number can be resolved. Do this now.
934//
935static void ResolveTypeTo(char *Name, const Type *ToTy) {
936 ValID D;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000937 if (Name) D = ValID::createLocalName(Name);
938 else D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000939
Reid Spencer861d9d62006-11-28 07:29:44 +0000940 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000941 CurModule.LateResolveTypes.find(D);
942 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000943 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000944 CurModule.LateResolveTypes.erase(I);
945 }
946}
947
948// setValueName - Set the specified value to the name given. The name may be
949// null potentially, in which case this is a noop. The string passed in is
950// assumed to be a malloc'd string buffer, and is free'd by this function.
951//
952static void setValueName(Value *V, char *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000953 if (!NameStr) return;
954 std::string Name(NameStr); // Copy string
955 free(NameStr); // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000956
Reid Spencer41dff5e2007-01-26 08:05:27 +0000957 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000958 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000959 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000960 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000961
Reid Spencera9720f52007-02-05 17:04:00 +0000962 assert(inFunctionScope() && "Must be in function scope!");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000963 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
964 if (ST.lookup(V->getType(), Name)) {
965 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000966 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000967 return;
968 }
969
970 // Set the name.
971 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000972}
973
974/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
975/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000976static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000977ParseGlobalVariable(char *NameStr,
978 GlobalValue::LinkageTypes Linkage,
979 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +0000980 bool isConstantGlobal, const Type *Ty,
981 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000982 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000983 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000984 return 0;
985 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000986
987 const PointerType *PTy = PointerType::get(Ty);
988
989 std::string Name;
990 if (NameStr) {
991 Name = NameStr; // Copy string
992 free(NameStr); // Free old string
993 }
994
995 // See if this global value was forward referenced. If so, recycle the
996 // object.
997 ValID ID;
998 if (!Name.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000999 ID = ValID::createGlobalName((char*)Name.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001000 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001001 ID = ValID::createGlobalID(CurModule.Values[PTy].size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001002 }
1003
1004 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1005 // Move the global to the end of the list, from whereever it was
1006 // previously inserted.
1007 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1008 CurModule.CurrentModule->getGlobalList().remove(GV);
1009 CurModule.CurrentModule->getGlobalList().push_back(GV);
1010 GV->setInitializer(Initializer);
1011 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001012 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001013 GV->setConstant(isConstantGlobal);
1014 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001015 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001016 }
1017
1018 // If this global has a name, check to see if there is already a definition
Reid Spencer63c34452007-01-05 21:51:07 +00001019 // of this global in the module. If so, it is an error.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001020 if (!Name.empty()) {
1021 // We are a simple redefinition of a value, check to see if it is defined
1022 // the same as the old one.
Reid Spencer63c34452007-01-05 21:51:07 +00001023 if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001024 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencerb5334b02007-02-05 10:18:06 +00001025 "' of type '" + Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001026 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001027 }
1028 }
1029
1030 // Otherwise there is no existing GV to use, create one now.
1031 GlobalVariable *GV =
1032 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1033 CurModule.CurrentModule);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001034 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001035 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001036 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001037}
1038
1039// setTypeName - Set the specified type to the name given. The name may be
1040// null potentially, in which case this is a noop. The string passed in is
1041// assumed to be a malloc'd string buffer, and is freed by this function.
1042//
1043// This function returns true if the type has already been defined, but is
1044// allowed to be redefined in the specified context. If the name is a new name
1045// for the type plane, it is inserted and false is returned.
1046static bool setTypeName(const Type *T, char *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001047 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001048 if (NameStr == 0) return false;
1049
1050 std::string Name(NameStr); // Copy string
1051 free(NameStr); // Free old string
1052
1053 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001054 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001055 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001056 return false;
1057 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001058
1059 // Set the type name, checking for conflicts as we do so.
1060 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1061
1062 if (AlreadyExists) { // Inserting a name that is already defined???
1063 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001064 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001065
1066 // There is only one case where this is allowed: when we are refining an
1067 // opaque type. In this case, Existing will be an opaque type.
1068 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1069 // We ARE replacing an opaque type!
1070 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1071 return true;
1072 }
1073
1074 // Otherwise, this is an attempt to redefine a type. That's okay if
1075 // the redefinition is identical to the original. This will be so if
1076 // Existing and T point to the same Type object. In this one case we
1077 // allow the equivalent redefinition.
1078 if (Existing == T) return true; // Yes, it's equal.
1079
1080 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001081 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001082 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001083 }
1084
1085 return false;
1086}
1087
1088//===----------------------------------------------------------------------===//
1089// Code for handling upreferences in type names...
1090//
1091
1092// TypeContains - Returns true if Ty directly contains E in it.
1093//
1094static bool TypeContains(const Type *Ty, const Type *E) {
1095 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1096 E) != Ty->subtype_end();
1097}
1098
1099namespace {
1100 struct UpRefRecord {
1101 // NestingLevel - The number of nesting levels that need to be popped before
1102 // this type is resolved.
1103 unsigned NestingLevel;
1104
1105 // LastContainedTy - This is the type at the current binding level for the
1106 // type. Every time we reduce the nesting level, this gets updated.
1107 const Type *LastContainedTy;
1108
1109 // UpRefTy - This is the actual opaque type that the upreference is
1110 // represented with.
1111 OpaqueType *UpRefTy;
1112
1113 UpRefRecord(unsigned NL, OpaqueType *URTy)
1114 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1115 };
1116}
1117
1118// UpRefs - A list of the outstanding upreferences that need to be resolved.
1119static std::vector<UpRefRecord> UpRefs;
1120
1121/// HandleUpRefs - Every time we finish a new layer of types, this function is
1122/// called. It loops through the UpRefs vector, which is a list of the
1123/// currently active types. For each type, if the up reference is contained in
1124/// the newly completed type, we decrement the level count. When the level
1125/// count reaches zero, the upreferenced type is the type that is passed in:
1126/// thus we can complete the cycle.
1127///
1128static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001129 // If Ty isn't abstract, or if there are no up-references in it, then there is
1130 // nothing to resolve here.
1131 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1132
Reid Spencer68a24bd2005-08-27 18:50:39 +00001133 PATypeHolder Ty(ty);
1134 UR_OUT("Type '" << Ty->getDescription() <<
1135 "' newly formed. Resolving upreferences.\n" <<
1136 UpRefs.size() << " upreferences active!\n");
1137
1138 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1139 // to zero), we resolve them all together before we resolve them to Ty. At
1140 // the end of the loop, if there is anything to resolve to Ty, it will be in
1141 // this variable.
1142 OpaqueType *TypeToResolve = 0;
1143
1144 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1145 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1146 << UpRefs[i].second->getDescription() << ") = "
1147 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1148 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1149 // Decrement level of upreference
1150 unsigned Level = --UpRefs[i].NestingLevel;
1151 UpRefs[i].LastContainedTy = Ty;
1152 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1153 if (Level == 0) { // Upreference should be resolved!
1154 if (!TypeToResolve) {
1155 TypeToResolve = UpRefs[i].UpRefTy;
1156 } else {
1157 UR_OUT(" * Resolving upreference for "
1158 << UpRefs[i].second->getDescription() << "\n";
1159 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1160 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1161 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1162 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1163 }
1164 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1165 --i; // Do not skip the next element...
1166 }
1167 }
1168 }
1169
1170 if (TypeToResolve) {
1171 UR_OUT(" * Resolving upreference for "
1172 << UpRefs[i].second->getDescription() << "\n";
1173 std::string OldName = TypeToResolve->getDescription());
1174 TypeToResolve->refineAbstractTypeTo(Ty);
1175 }
1176
1177 return Ty;
1178}
1179
Reid Spencer68a24bd2005-08-27 18:50:39 +00001180//===----------------------------------------------------------------------===//
1181// RunVMAsmParser - Define an interface to this parser
1182//===----------------------------------------------------------------------===//
1183//
Reid Spencer14310612006-12-31 05:40:51 +00001184static Module* RunParser(Module * M);
1185
Reid Spencer68a24bd2005-08-27 18:50:39 +00001186Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1187 set_scan_file(F);
1188
1189 CurFilename = Filename;
1190 return RunParser(new Module(CurFilename));
1191}
1192
1193Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1194 set_scan_string(AsmString);
1195
1196 CurFilename = "from_memory";
1197 if (M == NULL) {
1198 return RunParser(new Module (CurFilename));
1199 } else {
1200 return RunParser(M);
1201 }
1202}
1203
1204
Reid Spencer832254e2007-02-02 02:16:23 +00001205
1206/* Enabling traces. */
1207#ifndef YYDEBUG
1208# define YYDEBUG 0
1209#endif
1210
1211/* Enabling verbose error messages. */
1212#ifdef YYERROR_VERBOSE
1213# undef YYERROR_VERBOSE
1214# define YYERROR_VERBOSE 1
1215#else
1216# define YYERROR_VERBOSE 0
1217#endif
1218
1219/* Enabling the token table. */
1220#ifndef YYTOKEN_TABLE
1221# define YYTOKEN_TABLE 0
1222#endif
1223
1224#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1225#line 886 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
1226typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001227 llvm::Module *ModuleVal;
1228 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001229 llvm::BasicBlock *BasicBlockVal;
1230 llvm::TerminatorInst *TermInstVal;
1231 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001232 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001233
Reid Spencera132e042006-12-03 05:46:11 +00001234 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001235 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001236 llvm::PATypeHolder *TypeVal;
1237 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001238 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001239 llvm::ArgListType *ArgList;
1240 llvm::TypeWithAttrs TypeWithAttrs;
1241 llvm::TypeWithAttrsList *TypeWithAttrsList;
1242 llvm::ValueRefList *ValueRefList;
1243
Reid Spencer68a24bd2005-08-27 18:50:39 +00001244 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001245 std::list<std::pair<llvm::Value*,
1246 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001247 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001248 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001249
1250 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001251 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer14310612006-12-31 05:40:51 +00001252 llvm::FunctionType::ParameterAttributes ParamAttrs;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001253 int64_t SInt64Val;
1254 uint64_t UInt64Val;
1255 int SIntVal;
1256 unsigned UIntVal;
1257 double FPVal;
1258 bool BoolVal;
1259
1260 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001261 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001262
Reid Spencera132e042006-12-03 05:46:11 +00001263 llvm::Instruction::BinaryOps BinaryOpVal;
1264 llvm::Instruction::TermOps TermOpVal;
1265 llvm::Instruction::MemoryOps MemOpVal;
1266 llvm::Instruction::CastOps CastOpVal;
1267 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001268 llvm::ICmpInst::Predicate IPredicate;
1269 llvm::FCmpInst::Predicate FPredicate;
Reid Spencer5cbf9852007-01-30 20:08:39 +00001270} YYSTYPE;
Reid Spencer832254e2007-02-02 02:16:23 +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
Reid Spencer41dff5e2007-01-26 08:05:27 +00001278
Reid Spencer68a24bd2005-08-27 18:50:39 +00001279
Reid Spencer832254e2007-02-02 02:16:23 +00001280/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001281
1282
Reid Spencer832254e2007-02-02 02:16:23 +00001283/* Line 219 of yacc.c. */
1284#line 1285 "llvmAsmParser.tab.c"
Reid Spencer41dff5e2007-01-26 08:05:27 +00001285
Reid Spencer832254e2007-02-02 02:16:23 +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
Reid Spencer41dff5e2007-01-26 08:05:27 +00001299
Reid Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +00001426#if defined (__STDC__) || defined (__cplusplus)
1427 typedef signed char yysigned_char;
Reid Spencer5cbf9852007-01-30 20:08:39 +00001428#else
Reid Spencer832254e2007-02-02 02:16:23 +00001429 typedef short int yysigned_char;
Reid Spencer5cbf9852007-01-30 20:08:39 +00001430#endif
1431
Reid Spencer832254e2007-02-02 02:16:23 +00001432/* YYFINAL -- State number of the termination state. */
1433#define YYFINAL 40
1434/* YYLAST -- Last index in YYTABLE. */
1435#define YYLAST 1439
1436
1437/* YYNTOKENS -- Number of terminals. */
1438#define YYNTOKENS 146
1439/* YYNNTS -- Number of nonterminals. */
1440#define YYNNTS 78
1441/* YYNRULES -- Number of rules. */
1442#define YYNRULES 284
1443/* YYNRULES -- Number of states. */
1444#define YYNSTATES 557
1445
1446/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1447#define YYUNDEFTOK 2
1448#define YYMAXUTOK 386
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 136, 137, 134, 2, 133, 2, 2, 2, 2, 2,
1461 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1462 141, 132, 142, 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, 138, 135, 140, 2, 2, 2, 2, 2, 145,
1466 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1467 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1468 139, 2, 2, 143, 2, 144, 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
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, 121, 122, 125, 126, 128, 130, 133, 134, 136,
1509 138, 140, 142, 144, 146, 148, 150, 151, 153, 154,
1510 156, 158, 159, 161, 163, 165, 167, 168, 170, 172,
1511 174, 176, 178, 181, 183, 185, 187, 189, 190, 193,
1512 195, 197, 198, 201, 202, 205, 206, 210, 213, 214,
1513 216, 217, 221, 223, 226, 228, 230, 232, 234, 236,
1514 238, 241, 243, 246, 252, 258, 264, 270, 274, 277,
1515 283, 288, 291, 293, 295, 297, 301, 303, 307, 309,
1516 310, 312, 316, 321, 325, 329, 334, 339, 343, 350,
1517 356, 359, 362, 365, 368, 371, 374, 377, 380, 383,
1518 386, 393, 399, 408, 415, 422, 430, 438, 445, 454,
1519 463, 467, 469, 471, 473, 475, 476, 478, 481, 482,
1520 486, 487, 491, 495, 497, 501, 505, 506, 513, 514,
1521 522, 523, 531, 534, 538, 540, 544, 548, 552, 556,
1522 558, 559, 565, 569, 571, 575, 577, 578, 588, 590,
1523 592, 597, 599, 601, 604, 608, 609, 611, 613, 615,
1524 617, 619, 621, 623, 625, 627, 631, 633, 639, 641,
1525 643, 645, 647, 649, 651, 654, 657, 660, 664, 667,
1526 668, 670, 673, 676, 680, 690, 700, 709, 724, 726,
1527 728, 735, 741, 744, 751, 759, 763, 769, 770, 771,
1528 775, 778, 780, 786, 792, 799, 806, 811, 818, 823,
1529 828, 835, 842, 845, 854, 856, 858, 859, 863, 870,
1530 874, 881, 884, 889, 896
1531};
1532
1533/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1534static const short int yyrhs[] =
1535{
1536 186, 0, -1, 66, -1, 67, -1, 68, -1, 69,
1537 -1, 70, -1, 71, -1, 72, -1, 73, -1, 74,
1538 -1, 78, -1, 79, -1, 80, -1, 75, -1, 76,
1539 -1, 77, -1, 109, -1, 110, -1, 111, -1, 112,
1540 -1, 113, -1, 114, -1, 115, -1, 116, -1, 117,
1541 -1, 118, -1, 119, -1, 120, -1, 83, -1, 84,
1542 -1, 85, -1, 86, -1, 87, -1, 88, -1, 89,
1543 -1, 90, -1, 91, -1, 92, -1, 93, -1, 94,
1544 -1, 95, -1, 96, -1, 97, -1, 98, -1, 99,
1545 -1, 100, -1, 101, -1, 102, -1, 89, -1, 90,
1546 -1, 91, -1, 92, -1, 21, -1, 22, -1, 9,
1547 -1, 10, -1, 11, -1, 14, -1, 17, -1, 154,
1548 -1, -1, 154, 132, -1, -1, 15, -1, 18, -1,
1549 157, 132, -1, -1, 35, -1, 37, -1, 36, -1,
1550 38, -1, 40, -1, 39, -1, 41, -1, 43, -1,
1551 -1, 131, -1, -1, 39, -1, 41, -1, -1, 35,
1552 -1, 36, -1, 37, -1, 40, -1, -1, 54, -1,
1553 55, -1, 56, -1, 57, -1, 58, -1, 53, 4,
1554 -1, 110, -1, 111, -1, 128, -1, 129, -1, -1,
1555 166, 165, -1, 127, -1, 165, -1, -1, 168, 167,
1556 -1, -1, 46, 4, -1, -1, 133, 46, 4, -1,
1557 29, 17, -1, -1, 171, -1, -1, 133, 174, 173,
1558 -1, 171, -1, 46, 4, -1, 9, -1, 10, -1,
1559 11, -1, 12, -1, 42, -1, 175, -1, 176, 134,
1560 -1, 208, -1, 135, 4, -1, 176, 136, 180, 137,
1561 168, -1, 8, 136, 180, 137, 168, -1, 138, 4,
1562 139, 176, 140, -1, 141, 4, 139, 176, 142, -1,
1563 143, 181, 144, -1, 143, 144, -1, 141, 143, 181,
1564 144, 142, -1, 141, 143, 144, 142, -1, 176, 166,
1565 -1, 176, -1, 8, -1, 177, -1, 179, 133, 177,
1566 -1, 179, -1, 179, 133, 32, -1, 32, -1, -1,
1567 176, -1, 181, 133, 176, -1, 176, 138, 184, 140,
1568 -1, 176, 138, 140, -1, 176, 145, 17, -1, 176,
1569 141, 184, 142, -1, 176, 143, 184, 144, -1, 176,
1570 143, 144, -1, 176, 141, 143, 184, 144, 142, -1,
1571 176, 141, 143, 144, 142, -1, 176, 33, -1, 176,
1572 34, -1, 176, 208, -1, 176, 183, -1, 176, 20,
1573 -1, 152, 3, -1, 152, 4, -1, 9, 21, -1,
1574 9, 22, -1, 153, 7, -1, 149, 136, 182, 31,
1575 176, 137, -1, 108, 136, 182, 219, 137, -1, 122,
1576 136, 182, 133, 182, 133, 182, 137, -1, 147, 136,
1577 182, 133, 182, 137, -1, 148, 136, 182, 133, 182,
1578 137, -1, 81, 150, 136, 182, 133, 182, 137, -1,
1579 82, 151, 136, 182, 133, 182, 137, -1, 124, 136,
1580 182, 133, 182, 137, -1, 125, 136, 182, 133, 182,
1581 133, 182, 137, -1, 126, 136, 182, 133, 182, 133,
1582 182, 137, -1, 184, 133, 182, -1, 182, -1, 27,
1583 -1, 28, -1, 187, -1, -1, 188, -1, 187, 188,
1584 -1, -1, 26, 189, 204, -1, -1, 25, 190, 205,
1585 -1, 51, 50, 194, -1, 19, -1, 156, 13, 176,
1586 -1, 156, 13, 8, -1, -1, 158, 161, 185, 182,
1587 191, 173, -1, -1, 158, 159, 161, 185, 182, 192,
1588 173, -1, -1, 158, 160, 161, 185, 176, 193, 173,
1589 -1, 44, 195, -1, 47, 132, 196, -1, 17, -1,
1590 45, 132, 17, -1, 59, 132, 17, -1, 138, 197,
1591 140, -1, 197, 133, 17, -1, 17, -1, -1, 198,
1592 133, 176, 166, 155, -1, 176, 166, 155, -1, 198,
1593 -1, 198, 133, 32, -1, 32, -1, -1, 164, 178,
1594 157, 136, 199, 137, 168, 172, 169, -1, 23, -1,
1595 143, -1, 163, 161, 200, 201, -1, 24, -1, 144,
1596 -1, 211, 203, -1, 162, 161, 200, -1, -1, 52,
1597 -1, 3, -1, 4, -1, 7, -1, 21, -1, 22,
1598 -1, 33, -1, 34, -1, 20, -1, 141, 184, 142,
1599 -1, 183, -1, 50, 206, 17, 133, 17, -1, 5,
1600 -1, 6, -1, 154, -1, 157, -1, 208, -1, 207,
1601 -1, 176, 209, -1, 211, 212, -1, 202, 212, -1,
1602 213, 156, 214, -1, 213, 216, -1, -1, 16, -1,
1603 60, 210, -1, 60, 8, -1, 61, 12, 209, -1,
1604 61, 9, 209, 133, 12, 209, 133, 12, 209, -1,
1605 62, 152, 209, 133, 12, 209, 138, 215, 140, -1,
1606 62, 152, 209, 133, 12, 209, 138, 140, -1, 63,
1607 164, 178, 209, 136, 218, 137, 168, 31, 12, 209,
1608 64, 12, 209, -1, 64, -1, 65, -1, 215, 152,
1609 207, 133, 12, 209, -1, 152, 207, 133, 12, 209,
1610 -1, 156, 221, -1, 176, 138, 209, 133, 209, 140,
1611 -1, 217, 133, 138, 209, 133, 209, 140, -1, 176,
1612 209, 166, -1, 218, 133, 176, 209, 166, -1, -1,
1613 -1, 219, 133, 210, -1, 49, 48, -1, 48, -1,
1614 147, 176, 209, 133, 209, -1, 148, 176, 209, 133,
1615 209, -1, 81, 150, 176, 209, 133, 209, -1, 82,
1616 151, 176, 209, 133, 209, -1, 149, 210, 31, 176,
1617 -1, 122, 210, 133, 210, 133, 210, -1, 123, 210,
1618 133, 176, -1, 124, 210, 133, 210, -1, 125, 210,
1619 133, 210, 133, 210, -1, 126, 210, 133, 210, 133,
1620 210, -1, 121, 217, -1, 220, 164, 178, 209, 136,
1621 218, 137, 168, -1, 223, -1, 30, -1, -1, 103,
1622 176, 170, -1, 103, 176, 133, 9, 209, 170, -1,
1623 104, 176, 170, -1, 104, 176, 133, 9, 209, 170,
1624 -1, 105, 210, -1, 222, 106, 176, 209, -1, 222,
1625 107, 210, 133, 176, 209, -1, 108, 176, 209, 219,
1626 -1
1627};
1628
1629/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1630static const unsigned short int yyrline[] =
1631{
1632 0, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033, 1033,
1633 1033, 1034, 1034, 1034, 1034, 1034, 1034, 1035, 1035, 1035,
1634 1035, 1035, 1035, 1036, 1036, 1036, 1036, 1036, 1036, 1039,
1635 1039, 1040, 1040, 1041, 1041, 1042, 1042, 1043, 1043, 1047,
1636 1047, 1048, 1048, 1049, 1049, 1050, 1050, 1051, 1051, 1052,
1637 1052, 1053, 1053, 1054, 1055, 1060, 1061, 1061, 1063, 1063,
1638 1064, 1064, 1068, 1072, 1077, 1077, 1079, 1083, 1089, 1090,
1639 1091, 1092, 1093, 1097, 1098, 1099, 1103, 1104, 1108, 1109,
1640 1110, 1114, 1115, 1116, 1117, 1118, 1121, 1122, 1123, 1124,
1641 1125, 1126, 1127, 1134, 1135, 1136, 1137, 1140, 1141, 1146,
1642 1147, 1150, 1151, 1158, 1159, 1165, 1166, 1174, 1182, 1183,
1643 1188, 1189, 1190, 1195, 1208, 1208, 1208, 1208, 1211, 1215,
1644 1219, 1226, 1231, 1239, 1257, 1275, 1280, 1292, 1302, 1306,
1645 1316, 1323, 1330, 1337, 1342, 1347, 1354, 1355, 1362, 1369,
1646 1377, 1382, 1393, 1421, 1437, 1466, 1494, 1519, 1538, 1563,
1647 1582, 1594, 1601, 1667, 1677, 1687, 1693, 1699, 1704, 1709,
1648 1717, 1729, 1750, 1758, 1764, 1775, 1780, 1785, 1791, 1797,
1649 1806, 1810, 1818, 1818, 1829, 1834, 1842, 1843, 1847, 1847,
1650 1851, 1851, 1854, 1857, 1869, 1893, 1904, 1904, 1914, 1914,
1651 1922, 1922, 1932, 1935, 1941, 1954, 1958, 1963, 1965, 1970,
1652 1975, 1984, 1994, 2005, 2009, 2018, 2027, 2032, 2138, 2138,
1653 2140, 2149, 2149, 2151, 2156, 2168, 2172, 2177, 2181, 2185,
1654 2189, 2193, 2197, 2201, 2205, 2209, 2234, 2238, 2252, 2256,
1655 2260, 2264, 2270, 2270, 2276, 2285, 2289, 2298, 2309, 2318,
1656 2330, 2343, 2347, 2351, 2356, 2366, 2385, 2394, 2461, 2465,
1657 2472, 2483, 2496, 2505, 2516, 2526, 2534, 2542, 2545, 2546,
1658 2553, 2557, 2562, 2583, 2600, 2613, 2626, 2638, 2646, 2653,
1659 2659, 2665, 2671, 2686, 2750, 2755, 2759, 2766, 2773, 2781,
1660 2788, 2796, 2804, 2818, 2835
1661};
1662#endif
1663
1664#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1665/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1666 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1667static const char *const yytname[] =
1668{
1669 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL",
1670 "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE", "FLOAT",
1671 "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
1672 "STRINGCONSTANT", "ATSTRINGCONSTANT", "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", "ALIGN", "DEPLIBS", "CALL", "TAIL",
1678 "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK",
1679 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1680 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1681 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1682 "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT",
1683 "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT",
1684 "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE",
1685 "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC",
1686 "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR",
1687 "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT",
1688 "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET", "DEFAULT",
1689 "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'",
1690 "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps",
1691 "LogicalOps", "CastOps", "IPredicates", "FPredicates", "IntType",
1692 "FPType", "LocalName", "OptLocalName", "OptLocalAssign", "GlobalName",
1693 "OptGlobalAssign", "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 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1702 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1703 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1704 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1705 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1706 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1707 "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, 61, 44, 42, 92, 40, 41, 91, 120,
1730 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, 146, 147, 147, 147, 147, 147, 147, 147, 147,
1738 147, 148, 148, 148, 148, 148, 148, 149, 149, 149,
1739 149, 149, 149, 149, 149, 149, 149, 149, 149, 150,
1740 150, 150, 150, 150, 150, 150, 150, 150, 150, 151,
1741 151, 151, 151, 151, 151, 151, 151, 151, 151, 151,
1742 151, 151, 151, 151, 151, 152, 153, 153, 154, 154,
1743 155, 155, 156, 156, 157, 157, 158, 158, 159, 159,
1744 159, 159, 159, 160, 160, 160, 161, 161, 162, 162,
1745 162, 163, 163, 163, 163, 163, 164, 164, 164, 164,
1746 164, 164, 164, 165, 165, 165, 165, 166, 166, 167,
1747 167, 168, 168, 169, 169, 170, 170, 171, 172, 172,
1748 173, 173, 174, 174, 175, 175, 175, 175, 176, 176,
1749 176, 176, 176, 176, 176, 176, 176, 176, 176, 176,
1750 176, 177, 178, 178, 179, 179, 180, 180, 180, 180,
1751 181, 181, 182, 182, 182, 182, 182, 182, 182, 182,
1752 182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
1753 183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
1754 184, 184, 185, 185, 186, 186, 187, 187, 189, 188,
1755 190, 188, 188, 188, 188, 188, 191, 188, 192, 188,
1756 193, 188, 188, 188, 194, 195, 195, 196, 197, 197,
1757 197, 198, 198, 199, 199, 199, 199, 200, 201, 201,
1758 202, 203, 203, 204, 205, 206, 206, 207, 207, 207,
1759 207, 207, 207, 207, 207, 207, 207, 207, 208, 208,
1760 208, 208, 209, 209, 210, 211, 211, 212, 213, 213,
1761 213, 214, 214, 214, 214, 214, 214, 214, 214, 214,
1762 215, 215, 216, 217, 217, 218, 218, 218, 219, 219,
1763 220, 220, 221, 221, 221, 221, 221, 221, 221, 221,
1764 221, 221, 221, 221, 221, 222, 222, 223, 223, 223,
1765 223, 223, 223, 223, 223
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 1, 0, 2, 0, 1, 1, 2, 0, 1, 1,
1778 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
1779 1, 0, 1, 1, 1, 1, 0, 1, 1, 1,
1780 1, 1, 2, 1, 1, 1, 1, 0, 2, 1,
1781 1, 0, 2, 0, 2, 0, 3, 2, 0, 1,
1782 0, 3, 1, 2, 1, 1, 1, 1, 1, 1,
1783 2, 1, 2, 5, 5, 5, 5, 3, 2, 5,
1784 4, 2, 1, 1, 1, 3, 1, 3, 1, 0,
1785 1, 3, 4, 3, 3, 4, 4, 3, 6, 5,
1786 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1787 6, 5, 8, 6, 6, 7, 7, 6, 8, 8,
1788 3, 1, 1, 1, 1, 0, 1, 2, 0, 3,
1789 0, 3, 3, 1, 3, 3, 0, 6, 0, 7,
1790 0, 7, 2, 3, 1, 3, 3, 3, 3, 1,
1791 0, 5, 3, 1, 3, 1, 0, 9, 1, 1,
1792 4, 1, 1, 2, 3, 0, 1, 1, 1, 1,
1793 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
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, 6, 4, 4,
1798 6, 6, 2, 8, 1, 1, 0, 3, 6, 3,
1799 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 67, 58, 64, 59, 65, 183, 180, 178, 0, 0,
1808 0, 0, 0, 0, 76, 0, 67, 176, 78, 81,
1809 0, 0, 192, 0, 0, 62, 0, 66, 68, 70,
1810 69, 71, 73, 72, 74, 75, 77, 76, 76, 0,
1811 1, 177, 79, 80, 76, 181, 82, 83, 84, 85,
1812 76, 239, 179, 239, 0, 0, 200, 193, 194, 182,
1813 228, 229, 185, 114, 115, 116, 117, 118, 0, 0,
1814 0, 0, 230, 231, 119, 184, 121, 0, 0, 172,
1815 173, 0, 86, 86, 240, 236, 63, 211, 212, 213,
1816 235, 195, 196, 199, 0, 139, 122, 0, 0, 0,
1817 0, 128, 140, 0, 120, 139, 0, 0, 114, 115,
1818 116, 0, 0, 0, 186, 0, 87, 88, 89, 90,
1819 91, 0, 214, 0, 276, 238, 0, 197, 138, 97,
1820 134, 136, 0, 0, 0, 0, 0, 0, 127, 0,
1821 188, 190, 157, 158, 155, 156, 159, 154, 150, 151,
1822 2, 3, 4, 5, 6, 7, 8, 9, 10, 14,
1823 15, 16, 11, 12, 13, 0, 0, 0, 17, 18,
1824 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
1825 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1826 0, 153, 152, 110, 92, 133, 132, 0, 208, 209,
1827 210, 275, 261, 0, 0, 0, 0, 86, 248, 249,
1828 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1829 0, 0, 0, 0, 0, 237, 86, 252, 0, 274,
1830 198, 131, 0, 101, 0, 0, 130, 0, 141, 101,
1831 110, 110, 29, 30, 31, 32, 33, 34, 35, 36,
1832 37, 38, 0, 53, 54, 49, 50, 51, 52, 39,
1833 40, 41, 42, 43, 44, 45, 46, 47, 48, 0,
1834 0, 0, 0, 0, 0, 143, 171, 0, 0, 0,
1835 147, 0, 144, 0, 0, 0, 0, 187, 0, 260,
1836 242, 0, 241, 0, 0, 55, 0, 0, 0, 0,
1837 105, 105, 281, 0, 0, 272, 0, 0, 0, 0,
1838 0, 0, 0, 0, 0, 0, 0, 93, 94, 95,
1839 96, 98, 137, 135, 124, 125, 126, 129, 123, 189,
1840 191, 0, 0, 258, 0, 0, 0, 0, 0, 142,
1841 128, 140, 0, 145, 146, 0, 0, 0, 0, 0,
1842 112, 110, 206, 217, 218, 219, 224, 220, 221, 222,
1843 223, 215, 0, 226, 233, 232, 234, 0, 243, 0,
1844 0, 0, 0, 0, 277, 0, 279, 258, 0, 0,
1845 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1846 0, 99, 100, 102, 0, 0, 0, 0, 0, 0,
1847 0, 170, 149, 0, 0, 0, 0, 107, 113, 111,
1848 205, 97, 203, 0, 216, 0, 0, 0, 0, 0,
1849 0, 0, 0, 0, 0, 284, 0, 0, 0, 268,
1850 269, 0, 0, 0, 0, 266, 0, 282, 0, 0,
1851 0, 0, 161, 0, 0, 0, 0, 148, 0, 0,
1852 0, 61, 0, 101, 0, 225, 0, 0, 257, 0,
1853 0, 105, 106, 105, 0, 0, 0, 0, 0, 262,
1854 263, 257, 0, 0, 0, 259, 0, 167, 0, 0,
1855 163, 164, 160, 60, 202, 204, 97, 108, 0, 0,
1856 0, 0, 0, 264, 265, 0, 278, 280, 0, 0,
1857 267, 270, 271, 0, 283, 165, 166, 0, 0, 0,
1858 61, 109, 103, 227, 0, 0, 97, 0, 101, 253,
1859 0, 101, 162, 168, 169, 201, 0, 207, 0, 246,
1860 0, 0, 255, 0, 0, 254, 273, 104, 244, 0,
1861 245, 0, 97, 0, 0, 0, 256, 0, 0, 0,
1862 0, 251, 0, 0, 250, 0, 247
1863};
1864
1865/* YYDEFGOTO[NTERM-NUM]. */
1866static const short int yydefgoto[] =
1867{
1868 -1, 188, 189, 190, 252, 269, 111, 112, 72, 484,
1869 12, 73, 14, 37, 38, 39, 44, 50, 121, 321,
1870 231, 393, 324, 527, 374, 350, 512, 287, 351, 74,
1871 113, 130, 197, 131, 132, 103, 276, 363, 277, 81,
1872 15, 16, 17, 19, 18, 193, 240, 241, 59, 22,
1873 57, 94, 412, 413, 122, 200, 51, 89, 52, 45,
1874 415, 364, 76, 366, 292, 53, 85, 86, 225, 531,
1875 125, 305, 492, 396, 226, 227, 228, 229
1876};
1877
1878/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1879 STATE-NUM. */
1880#define YYPACT_NINF -399
1881static const short int yypact[] =
1882{
1883 406, -399, -399, -399, -399, -399, -399, -399, -26, -114,
1884 -16, -53, 92, -11, 54, 136, 526, -399, 247, 173,
1885 43, 49, -399, 62, 194, -399, 814, -399, -399, -399,
1886 -399, -399, -399, -399, -399, -399, -399, 134, 134, 99,
1887 -399, -399, -399, -399, 134, -399, -399, -399, -399, -399,
1888 134, 212, -399, -1, 219, 225, 253, -399, -399, -399,
1889 -399, -399, 135, -399, -399, -399, -399, -399, 271, 275,
1890 3, 33, -399, -399, -399, 160, -399, 99, 99, -399,
1891 -399, 1029, 287, 287, -399, -399, 220, -399, -399, -399,
1892 -399, -399, -399, -399, 20, 1071, -399, 141, 148, 105,
1893 135, -399, 160, -75, -399, 1071, 1029, 1174, 32, 286,
1894 293, 151, 294, 590, -399, 298, -399, -399, -399, -399,
1895 -399, 1190, -399, -13, 1313, -399, 289, -399, -399, 160,
1896 -399, 170, 167, 1174, 1174, 165, -68, 1174, -399, 174,
1897 -399, 160, -399, -399, -399, -399, -399, -399, -399, -399,
1898 -399, -399, -399, -399, -399, -399, -399, -399, -399, -399,
1899 -399, -399, -399, -399, -399, 495, 591, 176, -399, -399,
1900 -399, -399, -399, -399, -399, -399, -399, -399, -399, -399,
1901 177, 178, 182, 183, 776, 1212, 123, 305, 187, 188,
1902 189, -399, -399, 193, -399, 135, 160, 266, -399, -399,
1903 -399, -399, -399, 284, 1229, 283, 325, 287, -399, -399,
1904 495, 591, 1174, 1174, 1174, 1174, 1174, 1174, 1174, 1174,
1905 1174, 1174, 1174, 1174, 1174, -399, 287, -399, 144, -399,
1906 -399, -4, 1110, -399, -63, -110, -399, 204, 160, -399,
1907 193, 193, -399, -399, -399, -399, -399, -399, -399, -399,
1908 -399, -399, 211, -399, -399, -399, -399, -399, -399, -399,
1909 -399, -399, -399, -399, -399, -399, -399, -399, -399, 214,
1910 1029, 1029, 1029, 1029, 1029, -399, -399, 79, 494, -111,
1911 -399, -66, -399, 1029, 1029, 1029, 39, -399, 216, -399,
1912 135, 733, -399, 858, 858, -399, 858, 1190, 1174, 1174,
1913 50, 111, -399, 733, 97, 215, 230, 231, 232, 233,
1914 234, 733, 733, 322, 1190, 1174, 1174, -399, -399, -399,
1915 -399, -399, -399, -399, -27, -399, -399, -399, -27, -399,
1916 -399, 1029, 1029, -399, 235, 236, 239, 240, 1029, -399,
1917 237, 590, 26, -399, -399, 241, 242, 345, 360, 374,
1918 -399, 193, 1126, -399, -399, -399, -399, -399, -399, -399,
1919 -399, 328, 1029, -399, -399, -399, -399, 249, -399, 252,
1920 858, 733, 733, 11, -399, 18, -399, -399, 858, 250,
1921 1174, 1174, 1174, 1174, 1174, 256, 257, 1174, 858, 733,
1922 259, -399, -399, -399, 262, 264, -34, 1029, 1029, 1029,
1923 1029, -399, -399, 258, 1029, 1029, 1174, -399, -399, -399,
1924 -399, 160, 265, 267, -399, 384, -61, 390, 393, 272,
1925 281, 282, 858, 413, 858, 295, 296, 858, 297, 160,
1926 -399, 301, 302, 858, 858, 160, 300, -399, 1174, 1029,
1927 1029, 1174, -399, 304, 285, 306, 307, -399, 308, 310,
1928 118, 38, 1145, -399, 311, -399, 858, 858, 1174, 858,
1929 858, 315, -399, 315, 858, 316, 1174, 1174, 1174, -399,
1930 -399, 1174, 733, 317, 319, -399, 1029, -399, 1029, 1029,
1931 -399, -399, -399, -399, -399, -399, 160, 149, 421, 326,
1932 314, 733, 19, -399, -399, 412, -399, -399, 321, 858,
1933 -399, -399, -399, 36, -399, -399, -399, 327, 329, 330,
1934 38, -399, 416, -399, 451, 2, -399, 1174, -399, -399,
1935 333, -399, -399, -399, -399, -399, 461, -399, 858, -399,
1936 982, 5, -4, 733, 210, -399, -27, -399, -399, 335,
1937 -399, 982, -399, 457, 464, 344, -4, 858, 858, 468,
1938 417, -399, 858, 471, -399, 858, -399
1939};
1940
1941/* YYPGOTO[NTERM-NUM]. */
1942static const short int yypgoto[] =
1943{
1944 -399, 361, 362, 363, 274, 279, -198, -399, 0, -19,
1945 407, 9, -399, -399, -399, 113, -399, -399, -177, -307,
1946 -398, -399, -236, -399, -299, 7, -399, -212, -399, -399,
1947 -25, 263, -210, -399, 391, 398, -69, -109, -180, 179,
1948 -399, -399, 482, -399, -399, -399, -399, -399, -399, -399,
1949 -399, -399, -399, -399, 418, -399, -399, -399, -399, -399,
1950 -399, -369, -73, 100, -158, -399, 454, -399, -399, -399,
1951 -399, -399, 42, 137, -399, -399, -399, -399
1952};
1953
1954/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1955 positive, shift that token. If negative, reduce the rule which
1956 number is the opposite. If zero, do what YYDEFACT says.
1957 If YYTABLE_NINF, syntax error. */
1958#define YYTABLE_NINF -176
1959static const short int yytable[] =
1960{
1961 11, 75, 376, 328, 191, 279, 281, 98, 296, 13,
1962 198, 295, 114, 451, 295, 84, 11, 392, 23, 20,
1963 422, 392, 338, 87, 104, 13, 105, 424, 329, 330,
1964 297, 343, 326, 21, 24, -55, -55, 140, 60, 61,
1965 192, 100, 63, 64, 65, 66, 102, 1, 2, 314,
1966 3, 4, 1, 142, 143, 3, 302, 423, 137, 306,
1967 307, 308, 309, 310, 423, 137, 313, 338, 348, 138,
1968 129, 104, 338, 105, 102, 67, 237, 325, 344, 25,
1969 129, 455, 141, 317, 318, 349, 11, 370, 510, 28,
1970 29, 30, 31, 32, 33, 34, 196, 35, 342, 441,
1971 391, 319, 320, 442, 388, 26, 317, 318, 234, 235,
1972 60, 61, 238, 100, 63, 64, 65, 66, 532, 1,
1973 2, 27, 3, 4, 319, 320, 79, 80, 60, 61,
1974 199, 100, 108, 109, 110, 66, 40, 1, 2, 409,
1975 3, 4, 529, 88, 546, 540, 99, 67, 317, 318,
1976 77, 78, 517, 126, 144, 145, 518, 82, 390, 338,
1977 127, 539, 496, 83, 497, 67, 319, 320, 68, 517,
1978 403, 69, 545, 521, 70, 54, 71, 101, 348, 291,
1979 392, 55, 416, 373, 104, 36, 105, 300, 301, 291,
1980 303, 304, 291, 291, 291, 291, 291, 311, 312, 291,
1981 56, 333, 334, 335, 336, 337, 288, 129, 46, 47,
1982 48, 58, 338, 49, 345, 346, 347, 487, 365, 339,
1983 365, 365, 428, 365, 430, 431, 432, 392, 84, 392,
1984 365, 104, 191, 105, 1, 378, 91, 3, 365, 365,
1985 68, 543, 92, 69, 375, 104, 70, 105, 71, 135,
1986 315, 316, 104, 341, 105, 482, 106, 107, 68, 317,
1987 318, 69, 394, 395, 70, 36, 71, 280, 192, 401,
1988 93, 95, 196, 371, 372, 96, 391, 319, 320, 97,
1989 133, 2, 534, 475, 4, 536, 42, 134, 43, 196,
1990 389, 291, 293, -56, 104, 294, 105, 365, 365, 365,
1991 -57, 146, 194, 232, 233, 365, 230, 236, 500, 501,
1992 502, 239, 270, 271, 272, 365, 365, 530, 273, 274,
1993 317, 318, 282, 283, 284, 285, 286, 411, 443, 444,
1994 445, 446, 289, 541, 295, 448, 449, 391, 319, 320,
1995 115, 116, 117, 118, 119, 120, 327, 331, 379, 365,
1996 332, 365, 352, 387, 365, 291, 429, 291, 291, 291,
1997 365, 365, 435, 380, 381, 382, 383, 384, 397, 398,
1998 473, 474, 399, 400, 404, 405, 406, 407, 408, 402,
1999 414, 450, 417, 365, 365, 418, 365, 365, 427, 433,
2000 434, 365, 438, 367, 368, 439, 369, 440, 452, 365,
2001 447, 454, 456, 377, 453, 457, -175, 507, 458, 508,
2002 509, 385, 386, 472, 459, 460, 291, 462, 365, -63,
2003 1, 2, 477, 3, 4, 5, 365, 486, 441, 464,
2004 466, 6, 7, 491, 467, 468, 471, 476, 513, 478,
2005 479, 291, 291, 291, 488, 480, 491, 481, 495, 499,
2006 8, 483, 515, 9, 505, 365, 506, 10, 423, 514,
2007 365, 519, 526, 528, 522, 537, 523, 524, 544, 547,
2008 419, 420, 421, 535, 365, 365, 548, 549, 426, 365,
2009 552, 553, 365, 555, 298, 222, 223, 224, 436, 437,
2010 299, 525, 533, 124, 511, 323, 139, 136, 41, 60,
2011 61, 123, 100, 108, 109, 110, 66, 90, 1, 2,
2012 483, 3, 4, 503, 425, 0, 0, 0, 0, 0,
2013 0, 0, 461, 0, 463, 0, -174, 465, 0, 0,
2014 0, 0, 0, 469, 470, 0, 67, 0, 0, -63,
2015 1, 2, 0, 3, 4, 5, 0, 0, 0, 0,
2016 0, 6, 7, 0, 0, 0, 489, 490, 0, 493,
2017 494, 0, 0, 0, 498, 0, 0, 0, 0, 0,
2018 8, 0, 504, 9, 0, 0, 0, 10, 242, 243,
2019 244, 245, 246, 247, 248, 249, 250, 251, 0, 0,
2020 0, 516, 0, 0, 0, 60, 61, 0, 0, 520,
2021 0, 0, 0, 0, 1, 2, 0, 3, 4, 0,
2022 147, 0, 253, 254, 0, 0, 0, 0, 0, 0,
2023 0, 0, 0, 148, 149, 0, 0, 0, 538, 68,
2024 0, 0, 69, 542, 0, 70, 0, 71, 340, 0,
2025 0, 0, 0, 0, 0, 0, 0, 550, 551, 0,
2026 0, 0, 554, 0, 0, 556, 150, 151, 152, 153,
2027 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
2028 164, 165, 166, 0, 0, 0, 0, 0, 0, 0,
2029 255, 256, 257, 258, 259, 260, 261, 262, 263, 264,
2030 265, 266, 267, 268, 0, 0, 0, 0, 167, 168,
2031 169, 170, 171, 172, 173, 174, 175, 176, 177, 178,
2032 179, 0, 180, 0, 181, 182, 183, 0, 0, 0,
2033 0, 0, 0, 0, 104, 0, 105, 0, 184, 0,
2034 0, 185, 0, 186, 0, 187, 353, 354, 60, 61,
2035 355, 0, 0, 0, 0, 0, 0, 1, 2, 0,
2036 3, 4, 0, 356, 357, 358, 0, 0, 0, 0,
2037 0, 0, 0, 0, 0, 0, 359, 360, 0, 0,
2038 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2039 0, 60, 61, 361, 100, 108, 109, 110, 66, 0,
2040 1, 2, 0, 3, 4, 0, 0, 0, 0, 150,
2041 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
2042 161, 162, 163, 164, 165, 166, 0, 0, 67, 60,
2043 61, 0, 62, 63, 64, 65, 66, 0, 1, 2,
2044 0, 3, 4, 0, 0, 0, 0, 0, 0, 0,
2045 0, 167, 168, 169, 170, 171, 172, 173, 174, 175,
2046 176, 177, 178, 179, 0, 180, 67, 181, 182, 183,
2047 0, 353, 354, 60, 61, 355, 0, 104, 0, 105,
2048 0, 0, 1, 2, 362, 3, 4, 0, 356, 357,
2049 358, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2050 0, 359, 360, 0, 0, 0, 0, 0, 0, 0,
2051 0, 0, 0, 0, 0, 0, 0, 0, 361, 0,
2052 0, 68, 0, 0, 69, 0, 275, 70, 0, 71,
2053 0, 0, 0, 0, 150, 151, 152, 153, 154, 155,
2054 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
2055 166, 0, 0, 0, 0, 0, 0, 0, 0, 68,
2056 0, 0, 69, 0, 0, 70, 0, 71, 0, 0,
2057 0, 0, 0, 0, 0, 0, 167, 168, 169, 170,
2058 171, 172, 173, 174, 175, 176, 177, 178, 179, 0,
2059 180, 0, 181, 182, 183, 353, 354, 0, 0, 355,
2060 0, 0, 0, 0, 0, 0, 0, 0, 0, 362,
2061 0, 0, 356, 357, 358, 0, 0, 0, 0, 0,
2062 0, 0, 0, 0, 0, 359, 360, 0, 0, 0,
2063 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2064 0, 0, 361, 0, 60, 61, 0, 100, 108, 109,
2065 110, 66, 0, 1, 2, 0, 3, 4, 150, 151,
2066 152, 153, 154, 155, 156, 157, 158, 159, 160, 161,
2067 162, 163, 164, 165, 166, 0, 0, 0, 0, 0,
2068 0, 67, 0, 0, 0, 0, 60, 61, 0, 100,
2069 63, 64, 65, 66, 0, 1, 2, 0, 3, 4,
2070 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
2071 177, 178, 179, 128, 180, 0, 181, 182, 183, 0,
2072 0, 0, 0, 67, 0, 60, 61, 0, 100, 63,
2073 64, 65, 66, 362, 1, 2, 0, 3, 4, 0,
2074 0, 60, 61, 0, 100, 63, 64, 65, 66, 0,
2075 1, 2, 322, 3, 4, 0, 0, 0, 0, 0,
2076 60, 61, 67, 100, 63, 64, 65, 66, 410, 1,
2077 2, 0, 3, 4, 68, 0, 0, 69, 67, 0,
2078 70, 0, 71, 0, 0, 0, 0, 485, 0, 60,
2079 61, 0, 100, 63, 64, 65, 66, 67, 1, 2,
2080 0, 3, 4, 0, 0, 60, 61, 0, 195, 63,
2081 64, 65, 66, 0, 1, 2, 68, 3, 4, 69,
2082 0, 0, 70, 0, 71, 0, 67, 60, 61, 0,
2083 100, 108, 109, 110, 66, 0, 1, 2, 0, 3,
2084 4, 0, 67, 0, 60, 61, 0, 290, 63, 64,
2085 65, 66, 0, 1, 2, 68, 3, 4, 69, 0,
2086 0, 70, 0, 71, 67, 0, 0, 0, 0, 0,
2087 0, 68, 0, 0, 69, 0, 0, 70, 0, 71,
2088 0, 67, 0, 0, 0, 0, 0, 0, 0, 0,
2089 68, 0, 0, 69, 0, 0, 70, 0, 71, 0,
2090 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2091 0, 0, 0, 0, 0, 0, 0, 0, 0, 68,
2092 0, 0, 69, 0, 0, 70, 0, 71, 0, 0,
2093 0, 0, 0, 0, 0, 68, 0, 0, 69, 0,
2094 0, 70, 0, 71, 0, 0, 0, 0, 0, 0,
2095 0, 0, 0, 201, 0, 0, 0, 68, 0, 0,
2096 69, 0, 0, 70, 0, 278, 0, 0, 0, 0,
2097 0, 202, 203, 0, 68, 0, 0, 69, 0, 0,
2098 70, 0, 71, 204, 205, 206, 207, 208, 209, 150,
2099 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
2100 161, 162, 163, 164, 210, 211, 0, 0, 0, 0,
2101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2102 0, 0, 0, 0, 0, 0, 212, 213, 214, 0,
2103 0, 215, 168, 169, 170, 171, 172, 173, 174, 175,
2104 176, 177, 178, 179, 216, 217, 218, 219, 220, 221
2105};
2106
2107static const short int yycheck[] =
2108{
2109 0, 26, 301, 239, 113, 185, 186, 4, 206, 0,
2110 23, 9, 81, 411, 9, 16, 16, 324, 132, 45,
2111 9, 328, 133, 24, 134, 16, 136, 9, 240, 241,
2112 207, 142, 142, 59, 50, 3, 4, 106, 5, 6,
2113 113, 8, 9, 10, 11, 12, 71, 14, 15, 226,
2114 17, 18, 14, 21, 22, 17, 214, 46, 133, 217,
2115 218, 219, 220, 221, 46, 133, 224, 133, 29, 144,
2116 95, 134, 133, 136, 99, 42, 144, 140, 144, 132,
2117 105, 142, 107, 110, 111, 46, 86, 297, 486, 35,
2118 36, 37, 38, 39, 40, 41, 121, 43, 278, 133,
2119 127, 128, 129, 137, 314, 13, 110, 111, 133, 134,
2120 5, 6, 137, 8, 9, 10, 11, 12, 516, 14,
2121 15, 132, 17, 18, 128, 129, 27, 28, 5, 6,
2122 143, 8, 9, 10, 11, 12, 0, 14, 15, 351,
2123 17, 18, 140, 144, 542, 140, 143, 42, 110, 111,
2124 37, 38, 133, 133, 3, 4, 137, 44, 316, 133,
2125 140, 530, 461, 50, 463, 42, 128, 129, 135, 133,
2126 144, 138, 541, 137, 141, 132, 143, 144, 29, 204,
2127 487, 132, 362, 133, 134, 131, 136, 212, 213, 214,
2128 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
2129 138, 270, 271, 272, 273, 274, 197, 232, 35, 36,
2130 37, 17, 133, 40, 283, 284, 285, 453, 291, 140,
2131 293, 294, 380, 296, 382, 383, 384, 534, 16, 536,
2132 303, 134, 341, 136, 14, 138, 17, 17, 311, 312,
2133 135, 31, 17, 138, 133, 134, 141, 136, 143, 144,
2134 106, 107, 134, 278, 136, 137, 77, 78, 135, 110,
2135 111, 138, 331, 332, 141, 131, 143, 144, 341, 338,
2136 17, 136, 297, 298, 299, 4, 127, 128, 129, 4,
2137 139, 15, 518, 441, 18, 521, 39, 139, 41, 314,
2138 315, 316, 9, 7, 134, 12, 136, 370, 371, 372,
2139 7, 7, 4, 133, 137, 378, 17, 142, 466, 467,
2140 468, 137, 136, 136, 136, 388, 389, 515, 136, 136,
2141 110, 111, 17, 136, 136, 136, 133, 352, 397, 398,
2142 399, 400, 48, 531, 9, 404, 405, 127, 128, 129,
2143 53, 54, 55, 56, 57, 58, 142, 136, 133, 422,
2144 136, 424, 136, 31, 427, 380, 381, 382, 383, 384,
2145 433, 434, 387, 133, 133, 133, 133, 133, 133, 133,
2146 439, 440, 133, 133, 133, 133, 31, 17, 4, 142,
2147 52, 406, 133, 456, 457, 133, 459, 460, 138, 133,
2148 133, 464, 133, 293, 294, 133, 296, 133, 133, 472,
2149 142, 17, 12, 303, 137, 12, 0, 476, 136, 478,
2150 479, 311, 312, 438, 133, 133, 441, 4, 491, 13,
2151 14, 15, 137, 17, 18, 19, 499, 452, 133, 133,
2152 133, 25, 26, 458, 133, 133, 136, 133, 17, 133,
2153 133, 466, 467, 468, 133, 137, 471, 137, 133, 133,
2154 44, 451, 138, 47, 137, 528, 137, 51, 46, 133,
2155 533, 140, 46, 12, 137, 4, 137, 137, 133, 12,
2156 370, 371, 372, 140, 547, 548, 12, 133, 378, 552,
2157 12, 64, 555, 12, 210, 124, 124, 124, 388, 389,
2158 211, 510, 517, 86, 487, 232, 105, 99, 16, 5,
2159 6, 83, 8, 9, 10, 11, 12, 53, 14, 15,
2160 510, 17, 18, 471, 377, -1, -1, -1, -1, -1,
2161 -1, -1, 422, -1, 424, -1, 0, 427, -1, -1,
2162 -1, -1, -1, 433, 434, -1, 42, -1, -1, 13,
2163 14, 15, -1, 17, 18, 19, -1, -1, -1, -1,
2164 -1, 25, 26, -1, -1, -1, 456, 457, -1, 459,
2165 460, -1, -1, -1, 464, -1, -1, -1, -1, -1,
2166 44, -1, 472, 47, -1, -1, -1, 51, 83, 84,
2167 85, 86, 87, 88, 89, 90, 91, 92, -1, -1,
2168 -1, 491, -1, -1, -1, 5, 6, -1, -1, 499,
2169 -1, -1, -1, -1, 14, 15, -1, 17, 18, -1,
2170 20, -1, 21, 22, -1, -1, -1, -1, -1, -1,
2171 -1, -1, -1, 33, 34, -1, -1, -1, 528, 135,
2172 -1, -1, 138, 533, -1, 141, -1, 143, 144, -1,
2173 -1, -1, -1, -1, -1, -1, -1, 547, 548, -1,
2174 -1, -1, 552, -1, -1, 555, 66, 67, 68, 69,
2175 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2176 80, 81, 82, -1, -1, -1, -1, -1, -1, -1,
2177 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
2178 99, 100, 101, 102, -1, -1, -1, -1, 108, 109,
2179 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
2180 120, -1, 122, -1, 124, 125, 126, -1, -1, -1,
2181 -1, -1, -1, -1, 134, -1, 136, -1, 138, -1,
2182 -1, 141, -1, 143, -1, 145, 3, 4, 5, 6,
2183 7, -1, -1, -1, -1, -1, -1, 14, 15, -1,
2184 17, 18, -1, 20, 21, 22, -1, -1, -1, -1,
2185 -1, -1, -1, -1, -1, -1, 33, 34, -1, -1,
2186 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2187 -1, 5, 6, 50, 8, 9, 10, 11, 12, -1,
2188 14, 15, -1, 17, 18, -1, -1, -1, -1, 66,
2189 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2190 77, 78, 79, 80, 81, 82, -1, -1, 42, 5,
2191 6, -1, 8, 9, 10, 11, 12, -1, 14, 15,
2192 -1, 17, 18, -1, -1, -1, -1, -1, -1, -1,
2193 -1, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2194 117, 118, 119, 120, -1, 122, 42, 124, 125, 126,
2195 -1, 3, 4, 5, 6, 7, -1, 134, -1, 136,
2196 -1, -1, 14, 15, 141, 17, 18, -1, 20, 21,
2197 22, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2198 -1, 33, 34, -1, -1, -1, -1, -1, -1, -1,
2199 -1, -1, -1, -1, -1, -1, -1, -1, 50, -1,
2200 -1, 135, -1, -1, 138, -1, 140, 141, -1, 143,
2201 -1, -1, -1, -1, 66, 67, 68, 69, 70, 71,
2202 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2203 82, -1, -1, -1, -1, -1, -1, -1, -1, 135,
2204 -1, -1, 138, -1, -1, 141, -1, 143, -1, -1,
2205 -1, -1, -1, -1, -1, -1, 108, 109, 110, 111,
2206 112, 113, 114, 115, 116, 117, 118, 119, 120, -1,
2207 122, -1, 124, 125, 126, 3, 4, -1, -1, 7,
2208 -1, -1, -1, -1, -1, -1, -1, -1, -1, 141,
2209 -1, -1, 20, 21, 22, -1, -1, -1, -1, -1,
2210 -1, -1, -1, -1, -1, 33, 34, -1, -1, -1,
2211 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2212 -1, -1, 50, -1, 5, 6, -1, 8, 9, 10,
2213 11, 12, -1, 14, 15, -1, 17, 18, 66, 67,
2214 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2215 78, 79, 80, 81, 82, -1, -1, -1, -1, -1,
2216 -1, 42, -1, -1, -1, -1, 5, 6, -1, 8,
2217 9, 10, 11, 12, -1, 14, 15, -1, 17, 18,
2218 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2219 118, 119, 120, 32, 122, -1, 124, 125, 126, -1,
2220 -1, -1, -1, 42, -1, 5, 6, -1, 8, 9,
2221 10, 11, 12, 141, 14, 15, -1, 17, 18, -1,
2222 -1, 5, 6, -1, 8, 9, 10, 11, 12, -1,
2223 14, 15, 32, 17, 18, -1, -1, -1, -1, -1,
2224 5, 6, 42, 8, 9, 10, 11, 12, 32, 14,
2225 15, -1, 17, 18, 135, -1, -1, 138, 42, -1,
2226 141, -1, 143, -1, -1, -1, -1, 32, -1, 5,
2227 6, -1, 8, 9, 10, 11, 12, 42, 14, 15,
2228 -1, 17, 18, -1, -1, 5, 6, -1, 8, 9,
2229 10, 11, 12, -1, 14, 15, 135, 17, 18, 138,
2230 -1, -1, 141, -1, 143, -1, 42, 5, 6, -1,
2231 8, 9, 10, 11, 12, -1, 14, 15, -1, 17,
2232 18, -1, 42, -1, 5, 6, -1, 8, 9, 10,
2233 11, 12, -1, 14, 15, 135, 17, 18, 138, -1,
2234 -1, 141, -1, 143, 42, -1, -1, -1, -1, -1,
2235 -1, 135, -1, -1, 138, -1, -1, 141, -1, 143,
2236 -1, 42, -1, -1, -1, -1, -1, -1, -1, -1,
2237 135, -1, -1, 138, -1, -1, 141, -1, 143, -1,
2238 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2239 -1, -1, -1, -1, -1, -1, -1, -1, -1, 135,
2240 -1, -1, 138, -1, -1, 141, -1, 143, -1, -1,
2241 -1, -1, -1, -1, -1, 135, -1, -1, 138, -1,
2242 -1, 141, -1, 143, -1, -1, -1, -1, -1, -1,
2243 -1, -1, -1, 30, -1, -1, -1, 135, -1, -1,
2244 138, -1, -1, 141, -1, 143, -1, -1, -1, -1,
2245 -1, 48, 49, -1, 135, -1, -1, 138, -1, -1,
2246 141, -1, 143, 60, 61, 62, 63, 64, 65, 66,
2247 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2248 77, 78, 79, 80, 81, 82, -1, -1, -1, -1,
2249 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2250 -1, -1, -1, -1, -1, -1, 103, 104, 105, -1,
2251 -1, 108, 109, 110, 111, 112, 113, 114, 115, 116,
2252 117, 118, 119, 120, 121, 122, 123, 124, 125, 126
2253};
2254
2255/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2256 symbol of state STATE-NUM. */
2257static const unsigned char yystos[] =
2258{
2259 0, 14, 15, 17, 18, 19, 25, 26, 44, 47,
2260 51, 154, 156, 157, 158, 186, 187, 188, 190, 189,
2261 45, 59, 195, 132, 50, 132, 13, 132, 35, 36,
2262 37, 38, 39, 40, 41, 43, 131, 159, 160, 161,
2263 0, 188, 39, 41, 162, 205, 35, 36, 37, 40,
2264 163, 202, 204, 211, 132, 132, 138, 196, 17, 194,
2265 5, 6, 8, 9, 10, 11, 12, 42, 135, 138,
2266 141, 143, 154, 157, 175, 176, 208, 161, 161, 27,
2267 28, 185, 161, 161, 16, 212, 213, 24, 144, 203,
2268 212, 17, 17, 17, 197, 136, 4, 4, 4, 143,
2269 8, 144, 176, 181, 134, 136, 185, 185, 9, 10,
2270 11, 152, 153, 176, 182, 53, 54, 55, 56, 57,
2271 58, 164, 200, 200, 156, 216, 133, 140, 32, 176,
2272 177, 179, 180, 139, 139, 144, 181, 133, 144, 180,
2273 182, 176, 21, 22, 3, 4, 7, 20, 33, 34,
2274 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
2275 76, 77, 78, 79, 80, 81, 82, 108, 109, 110,
2276 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
2277 122, 124, 125, 126, 138, 141, 143, 145, 147, 148,
2278 149, 183, 208, 191, 4, 8, 176, 178, 23, 143,
2279 201, 30, 48, 49, 60, 61, 62, 63, 64, 65,
2280 81, 82, 103, 104, 105, 108, 121, 122, 123, 124,
2281 125, 126, 147, 148, 149, 214, 220, 221, 222, 223,
2282 17, 166, 133, 137, 176, 176, 142, 144, 176, 137,
2283 192, 193, 83, 84, 85, 86, 87, 88, 89, 90,
2284 91, 92, 150, 21, 22, 89, 90, 91, 92, 93,
2285 94, 95, 96, 97, 98, 99, 100, 101, 102, 151,
2286 136, 136, 136, 136, 136, 140, 182, 184, 143, 184,
2287 144, 184, 17, 136, 136, 136, 133, 173, 157, 48,
2288 8, 176, 210, 9, 12, 9, 152, 164, 150, 151,
2289 176, 176, 210, 176, 176, 217, 210, 210, 210, 210,
2290 210, 176, 176, 210, 164, 106, 107, 110, 111, 128,
2291 129, 165, 32, 177, 168, 140, 142, 142, 168, 173,
2292 173, 136, 136, 182, 182, 182, 182, 182, 133, 140,
2293 144, 176, 184, 142, 144, 182, 182, 182, 29, 46,
2294 171, 174, 136, 3, 4, 7, 20, 21, 22, 33,
2295 34, 50, 141, 183, 207, 208, 209, 209, 209, 209,
2296 178, 176, 176, 133, 170, 133, 170, 209, 138, 133,
2297 133, 133, 133, 133, 133, 209, 209, 31, 178, 176,
2298 210, 127, 165, 167, 182, 182, 219, 133, 133, 133,
2299 133, 182, 142, 144, 133, 133, 31, 17, 4, 173,
2300 32, 176, 198, 199, 52, 206, 184, 133, 133, 209,
2301 209, 209, 9, 46, 9, 219, 209, 138, 210, 176,
2302 210, 210, 210, 133, 133, 176, 209, 209, 133, 133,
2303 133, 133, 137, 182, 182, 182, 182, 142, 182, 182,
2304 176, 166, 133, 137, 17, 142, 12, 12, 136, 133,
2305 133, 209, 4, 209, 133, 209, 133, 133, 133, 209,
2306 209, 136, 176, 182, 182, 210, 133, 137, 133, 133,
2307 137, 137, 137, 154, 155, 32, 176, 168, 133, 209,
2308 209, 176, 218, 209, 209, 133, 170, 170, 209, 133,
2309 210, 210, 210, 218, 209, 137, 137, 182, 182, 182,
2310 166, 171, 172, 17, 133, 138, 209, 133, 137, 140,
2311 209, 137, 137, 137, 137, 155, 46, 169, 12, 140,
2312 152, 215, 166, 176, 168, 140, 168, 4, 209, 207,
2313 140, 152, 209, 31, 133, 207, 166, 12, 12, 133,
2314 209, 209, 12, 64, 209, 12, 209
2315};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002316
2317#define yyerrok (yyerrstatus = 0)
2318#define yyclearin (yychar = YYEMPTY)
Reid Spencer832254e2007-02-02 02:16:23 +00002319#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002320#define YYEOF 0
Reid Spencer832254e2007-02-02 02:16:23 +00002321
Reid Spencer68a24bd2005-08-27 18:50:39 +00002322#define YYACCEPT goto yyacceptlab
Reid Spencer832254e2007-02-02 02:16:23 +00002323#define YYABORT goto yyabortlab
2324#define YYERROR goto yyerrorlab
2325
2326
2327/* Like YYERROR except do call yyerror. This remains here temporarily
2328 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002329 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer832254e2007-02-02 02:16:23 +00002330
Reid Spencer68a24bd2005-08-27 18:50:39 +00002331#define YYFAIL goto yyerrlab
Reid Spencer832254e2007-02-02 02:16:23 +00002332
Reid Spencer68a24bd2005-08-27 18:50:39 +00002333#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer832254e2007-02-02 02:16:23 +00002334
2335#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002336do \
2337 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer832254e2007-02-02 02:16:23 +00002338 { \
2339 yychar = (Token); \
2340 yylval = (Value); \
2341 yytoken = YYTRANSLATE (yychar); \
Reid Spencer5cbf9852007-01-30 20:08:39 +00002342 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002343 goto yybackup; \
2344 } \
2345 else \
Reid Spencer832254e2007-02-02 02:16:23 +00002346 { \
2347 yyerror (YY_("syntax error: cannot back up")); \
2348 YYERROR; \
2349 } \
Reid Spencer5cbf9852007-01-30 20:08:39 +00002350while (0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002351
Reid Spencer832254e2007-02-02 02:16:23 +00002352
Reid Spencer68a24bd2005-08-27 18:50:39 +00002353#define YYTERROR 1
2354#define YYERRCODE 256
2355
Reid Spencer832254e2007-02-02 02:16:23 +00002356
2357/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2358 If N is 0, then set CURRENT to the empty location which ends
2359 the previous symbol: RHS[0] (always defined). */
2360
2361#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2362#ifndef YYLLOC_DEFAULT
2363# define YYLLOC_DEFAULT(Current, Rhs, N) \
2364 do \
2365 if (N) \
2366 { \
2367 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2368 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2369 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2370 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2371 } \
2372 else \
2373 { \
2374 (Current).first_line = (Current).last_line = \
2375 YYRHSLOC (Rhs, 0).last_line; \
2376 (Current).first_column = (Current).last_column = \
2377 YYRHSLOC (Rhs, 0).last_column; \
2378 } \
2379 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002380#endif
2381
Reid Spencer832254e2007-02-02 02:16:23 +00002382
2383/* YY_LOCATION_PRINT -- Print the location on the stream.
2384 This macro was not mandated originally: define only if we know
2385 we won't break user code: when these are the locations we know. */
2386
2387#ifndef YY_LOCATION_PRINT
2388# if YYLTYPE_IS_TRIVIAL
2389# define YY_LOCATION_PRINT(File, Loc) \
2390 fprintf (File, "%d.%d-%d.%d", \
2391 (Loc).first_line, (Loc).first_column, \
2392 (Loc).last_line, (Loc).last_column)
2393# else
2394# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2395# endif
2396#endif
2397
2398
2399/* YYLEX -- calling `yylex' with the right arguments. */
2400
Reid Spencer41dff5e2007-01-26 08:05:27 +00002401#ifdef YYLEX_PARAM
Reid Spencer832254e2007-02-02 02:16:23 +00002402# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer41dff5e2007-01-26 08:05:27 +00002403#else
Reid Spencer832254e2007-02-02 02:16:23 +00002404# define YYLEX yylex ()
Chris Lattnerf7469af2007-01-31 04:44:08 +00002405#endif
Reid Spencer832254e2007-02-02 02:16:23 +00002406
2407/* Enable debugging if requested. */
2408#if YYDEBUG
2409
2410# ifndef YYFPRINTF
2411# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2412# define YYFPRINTF fprintf
2413# endif
2414
2415# define YYDPRINTF(Args) \
2416do { \
2417 if (yydebug) \
2418 YYFPRINTF Args; \
2419} while (0)
2420
2421# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2422do { \
2423 if (yydebug) \
2424 { \
2425 YYFPRINTF (stderr, "%s ", Title); \
2426 yysymprint (stderr, \
2427 Type, Value); \
2428 YYFPRINTF (stderr, "\n"); \
2429 } \
2430} while (0)
2431
2432/*------------------------------------------------------------------.
2433| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2434| TOP (included). |
2435`------------------------------------------------------------------*/
2436
2437#if defined (__STDC__) || defined (__cplusplus)
2438static void
2439yy_stack_print (short int *bottom, short int *top)
Chris Lattnerf7469af2007-01-31 04:44:08 +00002440#else
Reid Spencer832254e2007-02-02 02:16:23 +00002441static void
2442yy_stack_print (bottom, top)
2443 short int *bottom;
2444 short int *top;
Chris Lattnerf7469af2007-01-31 04:44:08 +00002445#endif
Reid Spencer832254e2007-02-02 02:16:23 +00002446{
2447 YYFPRINTF (stderr, "Stack now");
2448 for (/* Nothing. */; bottom <= top; ++bottom)
2449 YYFPRINTF (stderr, " %d", *bottom);
2450 YYFPRINTF (stderr, "\n");
2451}
2452
2453# define YY_STACK_PRINT(Bottom, Top) \
2454do { \
2455 if (yydebug) \
2456 yy_stack_print ((Bottom), (Top)); \
2457} while (0)
2458
2459
2460/*------------------------------------------------.
2461| Report that the YYRULE is going to be reduced. |
2462`------------------------------------------------*/
2463
2464#if defined (__STDC__) || defined (__cplusplus)
2465static void
2466yy_reduce_print (int yyrule)
2467#else
2468static void
2469yy_reduce_print (yyrule)
2470 int yyrule;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002471#endif
Reid Spencer832254e2007-02-02 02:16:23 +00002472{
2473 int yyi;
2474 unsigned long int yylno = yyrline[yyrule];
2475 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2476 yyrule - 1, yylno);
2477 /* Print the symbols being reduced, and their result. */
2478 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2479 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2480 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2481}
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002482
Reid Spencer832254e2007-02-02 02:16:23 +00002483# define YY_REDUCE_PRINT(Rule) \
2484do { \
2485 if (yydebug) \
2486 yy_reduce_print (Rule); \
2487} while (0)
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002488
Reid Spencer832254e2007-02-02 02:16:23 +00002489/* Nonzero means print parse trace. It is left uninitialized so that
2490 multiple parsers can coexist. */
2491int yydebug;
2492#else /* !YYDEBUG */
2493# define YYDPRINTF(Args)
2494# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2495# define YY_STACK_PRINT(Bottom, Top)
2496# define YY_REDUCE_PRINT(Rule)
2497#endif /* !YYDEBUG */
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002498
Reid Spencer41dff5e2007-01-26 08:05:27 +00002499
Reid Spencer832254e2007-02-02 02:16:23 +00002500/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002501#ifndef YYINITDEPTH
Reid Spencer832254e2007-02-02 02:16:23 +00002502# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002503#endif
2504
Reid Spencer832254e2007-02-02 02:16:23 +00002505/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2506 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002507
Reid Spencer832254e2007-02-02 02:16:23 +00002508 Do not make this value too large; the results are undefined if
2509 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2510 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002511
2512#ifndef YYMAXDEPTH
Reid Spencer832254e2007-02-02 02:16:23 +00002513# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002514#endif
Reid Spencer832254e2007-02-02 02:16:23 +00002515
Reid Spencer68a24bd2005-08-27 18:50:39 +00002516
2517
Reid Spencer832254e2007-02-02 02:16:23 +00002518#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002519
Reid Spencer832254e2007-02-02 02:16:23 +00002520# ifndef yystrlen
2521# if defined (__GLIBC__) && defined (_STRING_H)
2522# define yystrlen strlen
2523# else
2524/* Return the length of YYSTR. */
2525static YYSIZE_T
2526# if defined (__STDC__) || defined (__cplusplus)
2527yystrlen (const char *yystr)
2528# else
2529yystrlen (yystr)
2530 const char *yystr;
2531# endif
Chris Lattnerf7469af2007-01-31 04:44:08 +00002532{
Reid Spencer832254e2007-02-02 02:16:23 +00002533 const char *yys = yystr;
Chris Lattnerf7469af2007-01-31 04:44:08 +00002534
Reid Spencer832254e2007-02-02 02:16:23 +00002535 while (*yys++ != '\0')
2536 continue;
2537
2538 return yys - yystr - 1;
Chris Lattnerf7469af2007-01-31 04:44:08 +00002539}
Reid Spencer832254e2007-02-02 02:16:23 +00002540# endif
2541# endif
Chris Lattnerf7469af2007-01-31 04:44:08 +00002542
Reid Spencer832254e2007-02-02 02:16:23 +00002543# ifndef yystpcpy
2544# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2545# define yystpcpy stpcpy
2546# else
2547/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2548 YYDEST. */
2549static char *
2550# if defined (__STDC__) || defined (__cplusplus)
2551yystpcpy (char *yydest, const char *yysrc)
2552# else
2553yystpcpy (yydest, yysrc)
2554 char *yydest;
2555 const char *yysrc;
2556# endif
Chris Lattnerf7469af2007-01-31 04:44:08 +00002557{
Reid Spencer832254e2007-02-02 02:16:23 +00002558 char *yyd = yydest;
2559 const char *yys = yysrc;
Chris Lattnerf7469af2007-01-31 04:44:08 +00002560
Reid Spencer832254e2007-02-02 02:16:23 +00002561 while ((*yyd++ = *yys++) != '\0')
2562 continue;
2563
2564 return yyd - 1;
Chris Lattnerf7469af2007-01-31 04:44:08 +00002565}
Reid Spencer832254e2007-02-02 02:16:23 +00002566# endif
2567# endif
Chris Lattnerf7469af2007-01-31 04:44:08 +00002568
Reid Spencer832254e2007-02-02 02:16:23 +00002569# ifndef yytnamerr
2570/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2571 quotes and backslashes, so that it's suitable for yyerror. The
2572 heuristic is that double-quoting is unnecessary unless the string
2573 contains an apostrophe, a comma, or backslash (other than
2574 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2575 null, do not copy; instead, return the length of what the result
2576 would have been. */
2577static YYSIZE_T
2578yytnamerr (char *yyres, const char *yystr)
2579{
2580 if (*yystr == '"')
2581 {
2582 size_t yyn = 0;
2583 char const *yyp = yystr;
2584
2585 for (;;)
2586 switch (*++yyp)
2587 {
2588 case '\'':
2589 case ',':
2590 goto do_not_strip_quotes;
2591
2592 case '\\':
2593 if (*++yyp != '\\')
2594 goto do_not_strip_quotes;
2595 /* Fall through. */
2596 default:
2597 if (yyres)
2598 yyres[yyn] = *yyp;
2599 yyn++;
2600 break;
2601
2602 case '"':
2603 if (yyres)
2604 yyres[yyn] = '\0';
2605 return yyn;
2606 }
2607 do_not_strip_quotes: ;
2608 }
2609
2610 if (! yyres)
2611 return yystrlen (yystr);
2612
2613 return yystpcpy (yyres, yystr) - yyres;
2614}
2615# endif
2616
2617#endif /* YYERROR_VERBOSE */
2618
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002619
2620
Reid Spencer832254e2007-02-02 02:16:23 +00002621#if YYDEBUG
2622/*--------------------------------.
2623| Print this symbol on YYOUTPUT. |
2624`--------------------------------*/
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002625
Reid Spencer832254e2007-02-02 02:16:23 +00002626#if defined (__STDC__) || defined (__cplusplus)
2627static void
2628yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattnerf7469af2007-01-31 04:44:08 +00002629#else
Reid Spencer832254e2007-02-02 02:16:23 +00002630static void
2631yysymprint (yyoutput, yytype, yyvaluep)
2632 FILE *yyoutput;
2633 int yytype;
2634 YYSTYPE *yyvaluep;
2635#endif
2636{
2637 /* Pacify ``unused variable'' warnings. */
2638 (void) yyvaluep;
2639
2640 if (yytype < YYNTOKENS)
2641 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2642 else
2643 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2644
2645
2646# ifdef YYPRINT
2647 if (yytype < YYNTOKENS)
2648 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2649# endif
2650 switch (yytype)
2651 {
2652 default:
2653 break;
2654 }
2655 YYFPRINTF (yyoutput, ")");
2656}
2657
2658#endif /* ! YYDEBUG */
2659/*-----------------------------------------------.
2660| Release the memory associated to this symbol. |
2661`-----------------------------------------------*/
2662
2663#if defined (__STDC__) || defined (__cplusplus)
2664static void
2665yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2666#else
2667static void
2668yydestruct (yymsg, yytype, yyvaluep)
2669 const char *yymsg;
2670 int yytype;
2671 YYSTYPE *yyvaluep;
2672#endif
2673{
2674 /* Pacify ``unused variable'' warnings. */
2675 (void) yyvaluep;
2676
2677 if (!yymsg)
2678 yymsg = "Deleting";
2679 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2680
2681 switch (yytype)
2682 {
2683
2684 default:
2685 break;
2686 }
2687}
2688
2689
2690/* Prevent warnings from -Wmissing-prototypes. */
2691
2692#ifdef YYPARSE_PARAM
2693# if defined (__STDC__) || defined (__cplusplus)
2694int yyparse (void *YYPARSE_PARAM);
2695# else
2696int yyparse ();
2697# endif
2698#else /* ! YYPARSE_PARAM */
2699#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002700int yyparse (void);
Chris Lattnerf7469af2007-01-31 04:44:08 +00002701#else
Reid Spencer832254e2007-02-02 02:16:23 +00002702int yyparse ();
2703#endif
2704#endif /* ! YYPARSE_PARAM */
2705
2706
2707
2708/* The look-ahead symbol. */
2709int yychar;
2710
2711/* The semantic value of the look-ahead symbol. */
2712YYSTYPE yylval;
2713
2714/* Number of syntax errors so far. */
2715int yynerrs;
2716
2717
2718
2719/*----------.
2720| yyparse. |
2721`----------*/
2722
2723#ifdef YYPARSE_PARAM
2724# if defined (__STDC__) || defined (__cplusplus)
2725int yyparse (void *YYPARSE_PARAM)
2726# else
2727int yyparse (YYPARSE_PARAM)
2728 void *YYPARSE_PARAM;
2729# endif
2730#else /* ! YYPARSE_PARAM */
2731#if defined (__STDC__) || defined (__cplusplus)
2732int
2733yyparse (void)
2734#else
2735int
2736yyparse ()
2737
2738#endif
2739#endif
2740{
2741
2742 int yystate;
2743 int yyn;
2744 int yyresult;
2745 /* Number of tokens to shift before error messages enabled. */
2746 int yyerrstatus;
2747 /* Look-ahead token as an internal (translated) token number. */
2748 int yytoken = 0;
2749
2750 /* Three stacks and their tools:
2751 `yyss': related to states,
2752 `yyvs': related to semantic values,
2753 `yyls': related to locations.
2754
2755 Refer to the stacks thru separate pointers, to allow yyoverflow
2756 to reallocate them elsewhere. */
2757
2758 /* The state stack. */
2759 short int yyssa[YYINITDEPTH];
2760 short int *yyss = yyssa;
2761 short int *yyssp;
2762
2763 /* The semantic value stack. */
2764 YYSTYPE yyvsa[YYINITDEPTH];
2765 YYSTYPE *yyvs = yyvsa;
2766 YYSTYPE *yyvsp;
2767
2768
2769
Reid Spencer5cbf9852007-01-30 20:08:39 +00002770#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002771
Reid Spencer832254e2007-02-02 02:16:23 +00002772 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002773
Reid Spencer832254e2007-02-02 02:16:23 +00002774 /* The variables used to return semantic value and location from the
2775 action routines. */
2776 YYSTYPE yyval;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002777
2778
Reid Spencer832254e2007-02-02 02:16:23 +00002779 /* When reducing, the number of symbols on the RHS of the reduced
2780 rule. */
Reid Spencer5cbf9852007-01-30 20:08:39 +00002781 int yylen;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002782
Reid Spencer832254e2007-02-02 02:16:23 +00002783 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002784
Reid Spencer68a24bd2005-08-27 18:50:39 +00002785 yystate = 0;
2786 yyerrstatus = 0;
2787 yynerrs = 0;
2788 yychar = YYEMPTY; /* Cause a token to be read. */
2789
2790 /* Initialize stack pointers.
2791 Waste one element of value and location stack
2792 so that they stay on the same level as the state stack.
2793 The wasted elements are never initialized. */
2794
Reid Spencer832254e2007-02-02 02:16:23 +00002795 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002796 yyvsp = yyvs;
2797
Reid Spencer832254e2007-02-02 02:16:23 +00002798 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002799
Reid Spencer832254e2007-02-02 02:16:23 +00002800/*------------------------------------------------------------.
2801| yynewstate -- Push a new state, which is found in yystate. |
2802`------------------------------------------------------------*/
2803 yynewstate:
2804 /* In all cases, when you get here, the value and location stacks
2805 have just been pushed. so pushing a state here evens the stacks.
2806 */
2807 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002808
Reid Spencer832254e2007-02-02 02:16:23 +00002809 yysetstate:
2810 *yyssp = yystate;
2811
2812 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002813 {
2814 /* Get the current used size of the three stacks, in elements. */
Reid Spencer832254e2007-02-02 02:16:23 +00002815 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002816
2817#ifdef yyoverflow
Reid Spencer832254e2007-02-02 02:16:23 +00002818 {
2819 /* Give user a chance to reallocate the stack. Use copies of
2820 these so that the &'s don't force the real ones into
2821 memory. */
2822 YYSTYPE *yyvs1 = yyvs;
2823 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002824
Reid Spencer832254e2007-02-02 02:16:23 +00002825
2826 /* Each stack pointer address is followed by the size of the
2827 data in use in that stack, in bytes. This used to be a
2828 conditional around just the two extra args, but that might
2829 be undefined if yyoverflow is a macro. */
2830 yyoverflow (YY_("memory exhausted"),
2831 &yyss1, yysize * sizeof (*yyssp),
2832 &yyvs1, yysize * sizeof (*yyvsp),
2833
2834 &yystacksize);
2835
2836 yyss = yyss1;
2837 yyvs = yyvs1;
2838 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002839#else /* no yyoverflow */
Reid Spencer832254e2007-02-02 02:16:23 +00002840# ifndef YYSTACK_RELOCATE
2841 goto yyexhaustedlab;
2842# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002843 /* Extend the stack our own way. */
Reid Spencer832254e2007-02-02 02:16:23 +00002844 if (YYMAXDEPTH <= yystacksize)
2845 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002846 yystacksize *= 2;
Reid Spencer832254e2007-02-02 02:16:23 +00002847 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002848 yystacksize = YYMAXDEPTH;
Reid Spencer832254e2007-02-02 02:16:23 +00002849
2850 {
2851 short int *yyss1 = yyss;
2852 union yyalloc *yyptr =
2853 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2854 if (! yyptr)
2855 goto yyexhaustedlab;
2856 YYSTACK_RELOCATE (yyss);
2857 YYSTACK_RELOCATE (yyvs);
2858
2859# undef YYSTACK_RELOCATE
2860 if (yyss1 != yyssa)
2861 YYSTACK_FREE (yyss1);
2862 }
2863# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002864#endif /* no yyoverflow */
2865
Reid Spencer832254e2007-02-02 02:16:23 +00002866 yyssp = yyss + yysize - 1;
2867 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002868
2869
Reid Spencer832254e2007-02-02 02:16:23 +00002870 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2871 (unsigned long int) yystacksize));
2872
2873 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002874 YYABORT;
2875 }
2876
Reid Spencer832254e2007-02-02 02:16:23 +00002877 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002878
2879 goto yybackup;
Reid Spencer832254e2007-02-02 02:16:23 +00002880
2881/*-----------.
2882| yybackup. |
2883`-----------*/
2884yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002885
Reid Spencer5cbf9852007-01-30 20:08:39 +00002886/* Do appropriate processing given the current state. */
Reid Spencer832254e2007-02-02 02:16:23 +00002887/* Read a look-ahead token if we need one and don't already have one. */
Reid Spencer5cbf9852007-01-30 20:08:39 +00002888/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002889
Reid Spencer832254e2007-02-02 02:16:23 +00002890 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer5cbf9852007-01-30 20:08:39 +00002891
Reid Spencer68a24bd2005-08-27 18:50:39 +00002892 yyn = yypact[yystate];
Reid Spencer832254e2007-02-02 02:16:23 +00002893 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002894 goto yydefault;
2895
Reid Spencer832254e2007-02-02 02:16:23 +00002896 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002897
Reid Spencer832254e2007-02-02 02:16:23 +00002898 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002899 if (yychar == YYEMPTY)
2900 {
Reid Spencer832254e2007-02-02 02:16:23 +00002901 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002902 yychar = YYLEX;
2903 }
2904
Reid Spencer832254e2007-02-02 02:16:23 +00002905 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002906 {
Reid Spencer832254e2007-02-02 02:16:23 +00002907 yychar = yytoken = YYEOF;
2908 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002909 }
2910 else
2911 {
Reid Spencer832254e2007-02-02 02:16:23 +00002912 yytoken = YYTRANSLATE (yychar);
2913 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002914 }
2915
Reid Spencer832254e2007-02-02 02:16:23 +00002916 /* If the proper action on seeing token YYTOKEN is to reduce or to
2917 detect an error, take that action. */
2918 yyn += yytoken;
2919 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002920 goto yydefault;
2921 yyn = yytable[yyn];
Reid Spencer832254e2007-02-02 02:16:23 +00002922 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002923 {
Reid Spencer832254e2007-02-02 02:16:23 +00002924 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002925 goto yyerrlab;
2926 yyn = -yyn;
2927 goto yyreduce;
2928 }
2929
2930 if (yyn == YYFINAL)
2931 YYACCEPT;
2932
Reid Spencer832254e2007-02-02 02:16:23 +00002933 /* Shift the look-ahead token. */
2934 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer5cbf9852007-01-30 20:08:39 +00002935
2936 /* Discard the token being shifted unless it is eof. */
2937 if (yychar != YYEOF)
2938 yychar = YYEMPTY;
2939
2940 *++yyvsp = yylval;
2941
Reid Spencer832254e2007-02-02 02:16:23 +00002942
2943 /* Count tokens shifted since error; after three, turn off error
2944 status. */
2945 if (yyerrstatus)
2946 yyerrstatus--;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002947
Reid Spencer68a24bd2005-08-27 18:50:39 +00002948 yystate = yyn;
2949 goto yynewstate;
2950
Chris Lattnerf7469af2007-01-31 04:44:08 +00002951
Reid Spencer832254e2007-02-02 02:16:23 +00002952/*-----------------------------------------------------------.
2953| yydefault -- do the default action for the current state. |
2954`-----------------------------------------------------------*/
2955yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002956 yyn = yydefact[yystate];
2957 if (yyn == 0)
2958 goto yyerrlab;
Reid Spencer832254e2007-02-02 02:16:23 +00002959 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002960
Reid Spencer832254e2007-02-02 02:16:23 +00002961
2962/*-----------------------------.
2963| yyreduce -- Do a reduction. |
2964`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00002965yyreduce:
Reid Spencer832254e2007-02-02 02:16:23 +00002966 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002967 yylen = yyr2[yyn];
2968
Reid Spencer832254e2007-02-02 02:16:23 +00002969 /* If YYLEN is nonzero, implement the default value of the action:
2970 `$$ = $1'.
2971
2972 Otherwise, the following line sets YYVAL to garbage.
2973 This behavior is undocumented and Bison
2974 users should not rely upon it. Assigning to YYVAL
2975 unconditionally makes the parser a bit smaller, and it avoids a
2976 GCC warning that YYVAL may be used uninitialized. */
2977 yyval = yyvsp[1-yylen];
2978
2979
2980 YY_REDUCE_PRINT (yyn);
2981 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002982 {
Reid Spencer832254e2007-02-02 02:16:23 +00002983 case 29:
2984#line 1039 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
2985 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
2986 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002987
Reid Spencer832254e2007-02-02 02:16:23 +00002988 case 30:
2989#line 1039 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
2990 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
2991 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002992
Reid Spencer832254e2007-02-02 02:16:23 +00002993 case 31:
2994#line 1040 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
2995 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
2996 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002997
Reid Spencer832254e2007-02-02 02:16:23 +00002998 case 32:
2999#line 1040 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3000 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3001 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003002
Reid Spencer832254e2007-02-02 02:16:23 +00003003 case 33:
3004#line 1041 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3005 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3006 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003007
Reid Spencer832254e2007-02-02 02:16:23 +00003008 case 34:
3009#line 1041 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3010 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3011 break;
3012
3013 case 35:
3014#line 1042 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3015 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3016 break;
3017
3018 case 36:
3019#line 1042 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3020 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3021 break;
3022
3023 case 37:
3024#line 1043 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3025 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3026 break;
3027
3028 case 38:
3029#line 1043 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3030 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3031 break;
3032
3033 case 39:
3034#line 1047 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3035 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3036 break;
3037
3038 case 40:
3039#line 1047 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3040 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3041 break;
3042
3043 case 41:
3044#line 1048 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3045 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3046 break;
3047
3048 case 42:
3049#line 1048 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3050 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3051 break;
3052
3053 case 43:
3054#line 1049 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3055 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3056 break;
3057
3058 case 44:
3059#line 1049 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3060 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3061 break;
3062
3063 case 45:
3064#line 1050 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3065 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3066 break;
3067
3068 case 46:
3069#line 1050 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3070 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3071 break;
3072
3073 case 47:
3074#line 1051 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3075 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3076 break;
3077
3078 case 48:
3079#line 1051 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3080 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3081 break;
3082
3083 case 49:
3084#line 1052 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3085 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3086 break;
3087
3088 case 50:
3089#line 1052 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3090 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3091 break;
3092
3093 case 51:
3094#line 1053 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3095 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3096 break;
3097
3098 case 52:
3099#line 1053 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3100 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3101 break;
3102
3103 case 53:
3104#line 1054 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3105 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3106 break;
3107
3108 case 54:
3109#line 1055 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3110 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3111 break;
3112
3113 case 61:
3114#line 1064 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3115 { (yyval.StrVal) = 0; ;}
3116 break;
3117
3118 case 62:
3119#line 1068 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3120 {
3121 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003122 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003123 ;}
3124 break;
3125
3126 case 63:
3127#line 1072 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3128 {
3129 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003130 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003131 ;}
3132 break;
3133
3134 case 66:
3135#line 1079 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3136 {
3137 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003138 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003139 ;}
3140 break;
3141
3142 case 67:
3143#line 1083 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3144 {
3145 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003146 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003147 ;}
3148 break;
3149
3150 case 68:
3151#line 1089 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3152 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3153 break;
3154
3155 case 69:
3156#line 1090 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3157 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3158 break;
3159
3160 case 70:
3161#line 1091 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3162 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3163 break;
3164
3165 case 71:
3166#line 1092 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3167 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3168 break;
3169
3170 case 72:
3171#line 1093 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3172 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3173 break;
3174
3175 case 73:
3176#line 1097 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3177 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3178 break;
3179
3180 case 74:
3181#line 1098 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3182 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3183 break;
3184
3185 case 75:
3186#line 1099 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3187 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3188 break;
3189
3190 case 76:
3191#line 1103 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3192 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3193 break;
3194
3195 case 77:
3196#line 1104 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3197 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3198 break;
3199
3200 case 78:
3201#line 1108 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3202 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3203 break;
3204
3205 case 79:
3206#line 1109 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3207 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3208 break;
3209
3210 case 80:
3211#line 1110 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3212 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3213 break;
3214
3215 case 81:
3216#line 1114 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3217 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3218 break;
3219
3220 case 82:
3221#line 1115 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3222 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3223 break;
3224
3225 case 83:
3226#line 1116 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3227 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3228 break;
3229
3230 case 84:
3231#line 1117 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3232 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3233 break;
3234
3235 case 85:
3236#line 1118 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3237 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3238 break;
3239
3240 case 86:
3241#line 1121 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3242 { (yyval.UIntVal) = CallingConv::C; ;}
3243 break;
3244
3245 case 87:
3246#line 1122 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3247 { (yyval.UIntVal) = CallingConv::C; ;}
3248 break;
3249
3250 case 88:
3251#line 1123 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3252 { (yyval.UIntVal) = CallingConv::Fast; ;}
3253 break;
3254
3255 case 89:
3256#line 1124 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3257 { (yyval.UIntVal) = CallingConv::Cold; ;}
3258 break;
3259
3260 case 90:
3261#line 1125 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3262 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3263 break;
3264
3265 case 91:
3266#line 1126 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3267 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3268 break;
3269
3270 case 92:
3271#line 1127 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3272 {
3273 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencerb5334b02007-02-05 10:18:06 +00003274 GEN_ERROR("Calling conv too large");
Reid Spencer832254e2007-02-02 02:16:23 +00003275 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003276 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003277 ;}
3278 break;
3279
3280 case 93:
3281#line 1134 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3282 { (yyval.ParamAttrs) = FunctionType::ZExtAttribute; ;}
3283 break;
3284
3285 case 94:
3286#line 1135 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3287 { (yyval.ParamAttrs) = FunctionType::SExtAttribute; ;}
3288 break;
3289
3290 case 95:
3291#line 1136 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3292 { (yyval.ParamAttrs) = FunctionType::InRegAttribute; ;}
3293 break;
3294
3295 case 96:
3296#line 1137 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3297 { (yyval.ParamAttrs) = FunctionType::StructRetAttribute; ;}
3298 break;
3299
3300 case 97:
3301#line 1140 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3302 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3303 break;
3304
3305 case 98:
3306#line 1141 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3307 {
3308 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
3309 ;}
3310 break;
3311
3312 case 99:
3313#line 1146 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3314 { (yyval.ParamAttrs) = FunctionType::NoReturnAttribute; ;}
3315 break;
3316
3317 case 101:
3318#line 1150 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3319 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3320 break;
3321
3322 case 102:
3323#line 1151 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3324 {
3325 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
3326 ;}
3327 break;
3328
3329 case 103:
3330#line 1158 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3331 { (yyval.UIntVal) = 0; ;}
3332 break;
3333
3334 case 104:
3335#line 1159 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3336 {
3337 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3338 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003339 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003340 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003341;}
3342 break;
3343
3344 case 105:
3345#line 1165 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3346 { (yyval.UIntVal) = 0; ;}
3347 break;
3348
3349 case 106:
3350#line 1166 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3351 {
3352 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3353 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003354 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003355 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003356;}
3357 break;
3358
3359 case 107:
3360#line 1174 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3361 {
3362 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3363 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencerb5334b02007-02-05 10:18:06 +00003364 GEN_ERROR("Invalid character in section name");
Reid Spencer832254e2007-02-02 02:16:23 +00003365 (yyval.StrVal) = (yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003366 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003367;}
3368 break;
3369
3370 case 108:
3371#line 1182 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3372 { (yyval.StrVal) = 0; ;}
3373 break;
3374
3375 case 109:
3376#line 1183 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3377 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3378 break;
3379
3380 case 110:
3381#line 1188 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3382 {;}
3383 break;
3384
3385 case 111:
3386#line 1189 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3387 {;}
3388 break;
3389
3390 case 112:
3391#line 1190 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3392 {
3393 CurGV->setSection((yyvsp[0].StrVal));
3394 free((yyvsp[0].StrVal));
Reid Spencer6f407902007-01-13 05:00:46 +00003395 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003396 ;}
3397 break;
3398
3399 case 113:
3400#line 1195 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3401 {
3402 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003403 GEN_ERROR("Alignment must be a power of two");
Reid Spencer832254e2007-02-02 02:16:23 +00003404 CurGV->setAlignment((yyvsp[0].UInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003405 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003406 ;}
3407 break;
3408
3409 case 118:
3410#line 1211 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3411 {
3412 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003413 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003414 ;}
3415 break;
3416
3417 case 119:
3418#line 1215 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3419 {
3420 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003421 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003422 ;}
3423 break;
3424
3425 case 120:
3426#line 1219 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3427 { // Pointer type?
3428 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003429 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencer832254e2007-02-02 02:16:23 +00003430 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3431 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003432 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003433 ;}
3434 break;
3435
3436 case 121:
3437#line 1226 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3438 { // Named types are also simple types...
3439 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003440 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003441 (yyval.TypeVal) = new PATypeHolder(tmp);
3442 ;}
3443 break;
3444
3445 case 122:
3446#line 1231 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3447 { // Type UpReference
Reid Spencerb5334b02007-02-05 10:18:06 +00003448 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003449 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer832254e2007-02-02 02:16:23 +00003450 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3451 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003452 UR_OUT("New Upreference!\n");
3453 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003454 ;}
3455 break;
3456
3457 case 123:
3458#line 1239 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3459 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003460 std::vector<const Type*> Params;
3461 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencer832254e2007-02-02 02:16:23 +00003462 Attrs.push_back((yyvsp[0].ParamAttrs));
3463 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003464 Params.push_back(I->Ty->get());
3465 if (I->Ty->get() != Type::VoidTy)
3466 Attrs.push_back(I->Attrs);
3467 }
3468 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3469 if (isVarArg) Params.pop_back();
3470
Reid Spencer832254e2007-02-02 02:16:23 +00003471 FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, Attrs);
3472 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3473 delete (yyvsp[-4].TypeVal); // Delete the return type handle
3474 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003475 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003476 ;}
3477 break;
3478
3479 case 124:
3480#line 1257 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3481 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003482 std::vector<const Type*> Params;
3483 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencer832254e2007-02-02 02:16:23 +00003484 Attrs.push_back((yyvsp[0].ParamAttrs));
3485 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003486 Params.push_back(I->Ty->get());
3487 if (I->Ty->get() != Type::VoidTy)
3488 Attrs.push_back(I->Attrs);
3489 }
3490 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3491 if (isVarArg) Params.pop_back();
3492
Reid Spencer832254e2007-02-02 02:16:23 +00003493 FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, Attrs);
3494 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3495 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003496 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003497 ;}
3498 break;
3499
3500 case 125:
3501#line 1275 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3502 { // Sized array type?
3503 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3504 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003505 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003506 ;}
3507 break;
3508
3509 case 126:
3510#line 1280 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3511 { // Packed array type?
3512 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3513 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003514 GEN_ERROR("Unsigned result not equal to signed result");
3515 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3516 GEN_ERROR("Element type of a PackedType must be primitive");
Reid Spencer832254e2007-02-02 02:16:23 +00003517 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003518 GEN_ERROR("Vector length should be a power of 2");
Reid Spencer832254e2007-02-02 02:16:23 +00003519 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3520 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003521 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003522 ;}
3523 break;
3524
3525 case 127:
3526#line 1292 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3527 { // Structure type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003528 std::vector<const Type*> Elements;
Reid Spencer832254e2007-02-02 02:16:23 +00003529 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3530 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003531 Elements.push_back(*I);
3532
Reid Spencer832254e2007-02-02 02:16:23 +00003533 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3534 delete (yyvsp[-1].TypeList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003535 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003536 ;}
3537 break;
3538
3539 case 128:
3540#line 1302 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3541 { // Empty structure type?
3542 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003543 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003544 ;}
3545 break;
3546
3547 case 129:
3548#line 1306 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3549 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003550 std::vector<const Type*> Elements;
Reid Spencer832254e2007-02-02 02:16:23 +00003551 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3552 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003553 Elements.push_back(*I);
3554
Reid Spencer832254e2007-02-02 02:16:23 +00003555 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3556 delete (yyvsp[-2].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003557 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003558 ;}
3559 break;
3560
3561 case 130:
3562#line 1316 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3563 { // Empty structure type?
3564 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003565 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003566 ;}
3567 break;
3568
3569 case 131:
3570#line 1323 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3571 {
3572 (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal);
3573 (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs);
3574 ;}
3575 break;
3576
3577 case 132:
3578#line 1330 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3579 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003580 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00003581 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3582 if (!(*(yyvsp[0].TypeVal))->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00003583 GEN_ERROR("LLVM functions cannot return aggregate types");
Reid Spencer832254e2007-02-02 02:16:23 +00003584 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3585 ;}
3586 break;
3587
3588 case 133:
3589#line 1337 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3590 {
3591 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3592 ;}
3593 break;
3594
3595 case 134:
3596#line 1342 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3597 {
3598 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3599 (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer6f407902007-01-13 05:00:46 +00003600 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003601 ;}
3602 break;
3603
3604 case 135:
3605#line 1347 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3606 {
3607 ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00003608 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003609 ;}
3610 break;
3611
3612 case 137:
3613#line 1355 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3614 {
3615 (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003616 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3617 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer832254e2007-02-02 02:16:23 +00003618 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003619 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003620 ;}
3621 break;
3622
3623 case 138:
3624#line 1362 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3625 {
3626 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003627 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3628 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer832254e2007-02-02 02:16:23 +00003629 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003630 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003631 ;}
3632 break;
3633
3634 case 139:
3635#line 1369 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3636 {
3637 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003638 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003639 ;}
3640 break;
3641
3642 case 140:
3643#line 1377 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3644 {
3645 (yyval.TypeList) = new std::list<PATypeHolder>();
3646 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003647 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003648 ;}
3649 break;
3650
3651 case 141:
3652#line 1382 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3653 {
3654 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003655 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003656 ;}
3657 break;
3658
3659 case 142:
3660#line 1393 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3661 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003662 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00003663 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3664 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003665 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003666 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00003667 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003668 const Type *ETy = ATy->getElementType();
3669 int NumElements = ATy->getNumElements();
3670
3671 // Verify that we have the correct size...
Reid Spencer832254e2007-02-02 02:16:23 +00003672 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003673 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer832254e2007-02-02 02:16:23 +00003674 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003675 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003676
3677 // Verify all elements are correct type!
Reid Spencer832254e2007-02-02 02:16:23 +00003678 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3679 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003680 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3681 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer832254e2007-02-02 02:16:23 +00003682 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003683 }
3684
Reid Spencer832254e2007-02-02 02:16:23 +00003685 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3686 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003687 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003688 ;}
3689 break;
3690
3691 case 143:
3692#line 1421 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3693 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003694 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00003695 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3696 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003697 if (ATy == 0)
3698 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00003699 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003700
Andrew Lenharth6353e052006-12-08 18:07:09 +00003701 int NumElements = ATy->getNumElements();
3702 if (NumElements != -1 && NumElements != 0)
3703 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003704 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencer832254e2007-02-02 02:16:23 +00003705 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3706 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003707 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003708 ;}
3709 break;
3710
3711 case 144:
3712#line 1437 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3713 {
Reid Spencer14310612006-12-31 05:40:51 +00003714 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00003715 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3716 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003717 if (ATy == 0)
3718 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00003719 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer61c83e02006-08-18 08:43:06 +00003720
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003721 int NumElements = ATy->getNumElements();
3722 const Type *ETy = ATy->getElementType();
Reid Spencer832254e2007-02-02 02:16:23 +00003723 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3724 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003725 GEN_ERROR("Can't build string constant of size " +
Reid Spencer832254e2007-02-02 02:16:23 +00003726 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003727 " when array has size " + itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003728 std::vector<Constant*> Vals;
3729 if (ETy == Type::Int8Ty) {
Reid Spencer832254e2007-02-02 02:16:23 +00003730 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003731 C != (unsigned char*)EndStr; ++C)
3732 Vals.push_back(ConstantInt::get(ETy, *C));
3733 } else {
Reid Spencer832254e2007-02-02 02:16:23 +00003734 free((yyvsp[0].StrVal));
Reid Spencerb5334b02007-02-05 10:18:06 +00003735 GEN_ERROR("Cannot build string arrays of non byte sized elements");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003736 }
Reid Spencer832254e2007-02-02 02:16:23 +00003737 free((yyvsp[0].StrVal));
3738 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3739 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003740 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003741 ;}
3742 break;
3743
3744 case 145:
3745#line 1466 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3746 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003747 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00003748 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3749 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003750 if (PTy == 0)
3751 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00003752 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003753 const Type *ETy = PTy->getElementType();
3754 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003755
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003756 // Verify that we have the correct size...
Reid Spencer832254e2007-02-02 02:16:23 +00003757 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003758 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer832254e2007-02-02 02:16:23 +00003759 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003760 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003761
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003762 // Verify all elements are correct type!
Reid Spencer832254e2007-02-02 02:16:23 +00003763 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3764 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003765 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3766 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer832254e2007-02-02 02:16:23 +00003767 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003768 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003769
Reid Spencer832254e2007-02-02 02:16:23 +00003770 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector));
3771 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003772 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003773 ;}
3774 break;
3775
3776 case 146:
3777#line 1494 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3778 {
3779 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003780 if (STy == 0)
3781 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00003782 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003783
Reid Spencer832254e2007-02-02 02:16:23 +00003784 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003785 GEN_ERROR("Illegal number of initializers for structure type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003786
3787 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer832254e2007-02-02 02:16:23 +00003788 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3789 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003790 GEN_ERROR("Expected type '" +
3791 STy->getElementType(i)->getDescription() +
3792 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003793 " of structure initializer");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003794
3795 // Check to ensure that Type is not packed
3796 if (STy->isPacked())
3797 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3798
Reid Spencer832254e2007-02-02 02:16:23 +00003799 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3800 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003801 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003802 ;}
3803 break;
3804
3805 case 147:
3806#line 1519 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3807 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003808 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00003809 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3810 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003811 if (STy == 0)
3812 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00003813 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003814
3815 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003816 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003817
3818 // Check to ensure that Type is not packed
3819 if (STy->isPacked())
3820 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3821
Reid Spencer832254e2007-02-02 02:16:23 +00003822 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3823 delete (yyvsp[-2].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003824 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003825 ;}
3826 break;
3827
3828 case 148:
3829#line 1538 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3830 {
3831 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003832 if (STy == 0)
3833 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00003834 (*(yyvsp[-5].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003835
Reid Spencer832254e2007-02-02 02:16:23 +00003836 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003837 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003838
3839 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer832254e2007-02-02 02:16:23 +00003840 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i)
3841 if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003842 GEN_ERROR("Expected type '" +
3843 STy->getElementType(i)->getDescription() +
3844 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003845 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003846
3847 // Check to ensure that Type is packed
3848 if (!STy->isPacked())
3849 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3850
Reid Spencer832254e2007-02-02 02:16:23 +00003851 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector));
3852 delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003853 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003854 ;}
3855 break;
3856
3857 case 149:
3858#line 1563 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3859 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003860 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00003861 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
3862 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003863 if (STy == 0)
3864 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00003865 (*(yyvsp[-4].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003866
3867 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003868 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003869
3870 // Check to ensure that Type is packed
3871 if (!STy->isPacked())
3872 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3873
Reid Spencer832254e2007-02-02 02:16:23 +00003874 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3875 delete (yyvsp[-4].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003876 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003877 ;}
3878 break;
3879
3880 case 150:
3881#line 1582 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3882 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003883 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00003884 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3885 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003886 if (PTy == 0)
3887 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00003888 (*(yyvsp[-1].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003889
Reid Spencer832254e2007-02-02 02:16:23 +00003890 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3891 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003892 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003893 ;}
3894 break;
3895
3896 case 151:
3897#line 1594 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3898 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003899 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00003900 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3901 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3902 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003903 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003904 ;}
3905 break;
3906
3907 case 152:
3908#line 1601 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3909 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003910 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00003911 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3912 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003913 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003914 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003915
3916 // ConstExprs can exist in the body of a function, thus creating
3917 // GlobalValues whenever they refer to a variable. Because we are in
3918 // the context of a function, getValNonImprovising will search the functions
3919 // symbol table instead of the module symbol table for the global symbol,
3920 // which throws things all off. To get around this, we just tell
3921 // getValNonImprovising that we are at global scope here.
3922 //
3923 Function *SavedCurFn = CurFun.CurrentFunction;
3924 CurFun.CurrentFunction = 0;
3925
Reid Spencer832254e2007-02-02 02:16:23 +00003926 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003927 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003928
3929 CurFun.CurrentFunction = SavedCurFn;
3930
3931 // If this is an initializer for a constant pointer, which is referencing a
3932 // (currently) undefined variable, create a stub now that shall be replaced
3933 // in the future with the right type of variable.
3934 //
3935 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00003936 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003937 const PointerType *PT = cast<PointerType>(Ty);
3938
3939 // First check to see if the forward references value is already created!
3940 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer832254e2007-02-02 02:16:23 +00003941 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003942
3943 if (I != CurModule.GlobalRefs.end()) {
3944 V = I->second; // Placeholder already exists, use it...
Reid Spencer832254e2007-02-02 02:16:23 +00003945 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003946 } else {
3947 std::string Name;
Reid Spencer832254e2007-02-02 02:16:23 +00003948 if ((yyvsp[0].ValIDVal).Type == ValID::GlobalName)
3949 Name = (yyvsp[0].ValIDVal).Name;
3950 else if ((yyvsp[0].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003951 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003952
3953 // Create the forward referenced global.
3954 GlobalValue *GV;
3955 if (const FunctionType *FTy =
3956 dyn_cast<FunctionType>(PT->getElementType())) {
3957 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3958 CurModule.CurrentModule);
3959 } else {
3960 GV = new GlobalVariable(PT->getElementType(), false,
3961 GlobalValue::ExternalLinkage, 0,
3962 Name, CurModule.CurrentModule);
3963 }
3964
3965 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer832254e2007-02-02 02:16:23 +00003966 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003967 V = GV;
3968 }
3969 }
3970
Reid Spencer832254e2007-02-02 02:16:23 +00003971 (yyval.ConstVal) = cast<GlobalValue>(V);
3972 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003973 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003974 ;}
3975 break;
3976
3977 case 153:
3978#line 1667 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3979 {
Reid Spencer14310612006-12-31 05:40:51 +00003980 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00003981 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3982 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003983 GEN_ERROR("Mismatched types for constant expression: " +
Reid Spencer832254e2007-02-02 02:16:23 +00003984 (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription());
3985 (yyval.ConstVal) = (yyvsp[0].ConstVal);
3986 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003987 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00003988 ;}
3989 break;
3990
3991 case 154:
3992#line 1677 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3993 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003994 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00003995 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3996 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003997 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencerb5334b02007-02-05 10:18:06 +00003998 GEN_ERROR("Cannot create a null initialized value of this type");
Reid Spencer832254e2007-02-02 02:16:23 +00003999 (yyval.ConstVal) = Constant::getNullValue(Ty);
4000 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004001 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004002 ;}
4003 break;
4004
4005 case 155:
4006#line 1687 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4007 { // integral constants
4008 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004009 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer832254e2007-02-02 02:16:23 +00004010 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004011 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004012 ;}
4013 break;
4014
4015 case 156:
4016#line 1693 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4017 { // integral constants
4018 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004019 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer832254e2007-02-02 02:16:23 +00004020 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004021 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004022 ;}
4023 break;
4024
4025 case 157:
4026#line 1699 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4027 { // Boolean constants
4028 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4029 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004030 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004031 ;}
4032 break;
4033
4034 case 158:
4035#line 1704 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4036 { // Boolean constants
4037 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4038 (yyval.ConstVal) = ConstantInt::getFalse();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004039 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004040 ;}
4041 break;
4042
4043 case 159:
4044#line 1709 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4045 { // Float & Double constants
4046 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004047 GEN_ERROR("Floating point constant invalid for type");
Reid Spencer832254e2007-02-02 02:16:23 +00004048 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004049 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004050 ;}
4051 break;
4052
4053 case 160:
4054#line 1717 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4055 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004056 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00004057 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4058 Constant *Val = (yyvsp[-3].ConstVal);
4059 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4060 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004061 GEN_ERROR("invalid cast opcode for cast from '" +
4062 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004063 DestTy->getDescription() + "'");
Reid Spencer832254e2007-02-02 02:16:23 +00004064 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
4065 delete (yyvsp[-1].TypeVal);
4066 ;}
4067 break;
4068
4069 case 161:
4070#line 1729 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4071 {
4072 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004073 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004074
4075 const Type *IdxTy =
Reid Spencer832254e2007-02-02 02:16:23 +00004076 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004077 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004078 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004079
Chris Lattnerf7469af2007-01-31 04:44:08 +00004080 SmallVector<Constant*, 8> IdxVec;
Reid Spencer832254e2007-02-02 02:16:23 +00004081 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
4082 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004083 IdxVec.push_back(C);
4084 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004085 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004086
Reid Spencer832254e2007-02-02 02:16:23 +00004087 delete (yyvsp[-1].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004088
Reid Spencer832254e2007-02-02 02:16:23 +00004089 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004090 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004091 ;}
4092 break;
4093
4094 case 162:
4095#line 1750 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4096 {
4097 if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00004098 GEN_ERROR("Select condition must be of boolean type");
Reid Spencer832254e2007-02-02 02:16:23 +00004099 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004100 GEN_ERROR("Select operand types must match");
Reid Spencer832254e2007-02-02 02:16:23 +00004101 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004102 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004103 ;}
4104 break;
4105
4106 case 163:
4107#line 1758 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4108 {
4109 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004110 GEN_ERROR("Binary operator types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004111 CHECK_FOR_ERROR;
Reid Spencer832254e2007-02-02 02:16:23 +00004112 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4113 ;}
4114 break;
4115
4116 case 164:
4117#line 1764 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4118 {
4119 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004120 GEN_ERROR("Logical operator types must match");
Reid Spencer832254e2007-02-02 02:16:23 +00004121 if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) {
4122 if (Instruction::isShift((yyvsp[-5].BinaryOpVal)) || !isa<PackedType>((yyvsp[-3].ConstVal)->getType()) ||
4123 !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00004124 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004125 }
Reid Spencer832254e2007-02-02 02:16:23 +00004126 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004127 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004128 ;}
4129 break;
4130
4131 case 165:
4132#line 1775 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4133 {
4134 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004135 GEN_ERROR("icmp operand types must match");
Reid Spencer832254e2007-02-02 02:16:23 +00004136 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4137 ;}
4138 break;
4139
4140 case 166:
4141#line 1780 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4142 {
4143 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004144 GEN_ERROR("fcmp operand types must match");
Reid Spencer832254e2007-02-02 02:16:23 +00004145 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4146 ;}
4147 break;
4148
4149 case 167:
4150#line 1785 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4151 {
4152 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004153 GEN_ERROR("Invalid extractelement operands");
Reid Spencer832254e2007-02-02 02:16:23 +00004154 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004155 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004156 ;}
4157 break;
4158
4159 case 168:
4160#line 1791 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4161 {
4162 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004163 GEN_ERROR("Invalid insertelement operands");
Reid Spencer832254e2007-02-02 02:16:23 +00004164 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004165 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004166 ;}
4167 break;
4168
4169 case 169:
4170#line 1797 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4171 {
4172 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004173 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer832254e2007-02-02 02:16:23 +00004174 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004175 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004176 ;}
4177 break;
4178
4179 case 170:
4180#line 1806 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4181 {
4182 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004183 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004184 ;}
4185 break;
4186
4187 case 171:
4188#line 1810 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4189 {
4190 (yyval.ConstVector) = new std::vector<Constant*>();
4191 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004192 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004193 ;}
4194 break;
4195
4196 case 172:
4197#line 1818 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4198 { (yyval.BoolVal) = false; ;}
4199 break;
4200
4201 case 173:
4202#line 1818 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4203 { (yyval.BoolVal) = true; ;}
4204 break;
4205
4206 case 174:
4207#line 1829 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4208 {
4209 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004210 CurModule.ModuleDone();
4211 CHECK_FOR_ERROR;
Reid Spencer832254e2007-02-02 02:16:23 +00004212 ;}
4213 break;
4214
4215 case 175:
4216#line 1834 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4217 {
4218 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004219 CurModule.ModuleDone();
4220 CHECK_FOR_ERROR;
Reid Spencer832254e2007-02-02 02:16:23 +00004221 ;}
4222 break;
4223
4224 case 178:
4225#line 1847 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4226 { CurFun.isDeclare = false; ;}
4227 break;
4228
4229 case 179:
4230#line 1847 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4231 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004232 CurFun.FunctionDone();
4233 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004234 ;}
4235 break;
4236
4237 case 180:
4238#line 1851 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4239 { CurFun.isDeclare = true; ;}
4240 break;
4241
4242 case 181:
4243#line 1851 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4244 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004245 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004246 ;}
4247 break;
4248
4249 case 182:
4250#line 1854 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4251 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004252 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004253 ;}
4254 break;
4255
4256 case 183:
4257#line 1857 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4258 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004259 // Emit an error if there are any unresolved types left.
4260 if (!CurModule.LateResolveTypes.empty()) {
4261 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004262 if (DID.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +00004263 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
4264 } else {
4265 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
4266 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004267 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004268 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004269 ;}
4270 break;
4271
4272 case 184:
4273#line 1869 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4274 {
Reid Spencer14310612006-12-31 05:40:51 +00004275 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00004276 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004277 // Eagerly resolve types. This is not an optimization, this is a
4278 // requirement that is due to the fact that we could have this:
4279 //
4280 // %list = type { %list * }
4281 // %list = type { %list * } ; repeated type decl
4282 //
4283 // If types are not resolved eagerly, then the two types will not be
4284 // determined to be the same type!
4285 //
Reid Spencer832254e2007-02-02 02:16:23 +00004286 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004287
Reid Spencer832254e2007-02-02 02:16:23 +00004288 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004289 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004290 // If this is a named type that is not a redefinition, add it to the slot
4291 // table.
Reid Spencer832254e2007-02-02 02:16:23 +00004292 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004293 }
Reid Spencera132e042006-12-03 05:46:11 +00004294
Reid Spencer832254e2007-02-02 02:16:23 +00004295 delete (yyvsp[0].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004296 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004297 ;}
4298 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004299
Reid Spencer832254e2007-02-02 02:16:23 +00004300 case 185:
4301#line 1893 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4302 {
4303 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType));
4304
4305 if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004306 CHECK_FOR_ERROR
4307 // If this is a named type that is not a redefinition, add it to the slot
4308 // table.
Reid Spencer832254e2007-02-02 02:16:23 +00004309 CurModule.Types.push_back((yyvsp[0].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004310 }
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004311 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004312 ;}
4313 break;
4314
4315 case 186:
4316#line 1904 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4317 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004318 /* "Externally Visible" Linkage */
Reid Spencer832254e2007-02-02 02:16:23 +00004319 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004320 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer832254e2007-02-02 02:16:23 +00004321 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage,
4322 (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004323 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004324 ;}
4325 break;
4326
4327 case 187:
4328#line 1911 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4329 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004330 CurGV = 0;
Reid Spencer832254e2007-02-02 02:16:23 +00004331 ;}
4332 break;
4333
4334 case 188:
4335#line 1914 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4336 {
4337 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004338 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer832254e2007-02-02 02:16:23 +00004339 CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004340 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004341 ;}
4342 break;
4343
4344 case 189:
4345#line 1919 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4346 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004347 CurGV = 0;
Reid Spencer832254e2007-02-02 02:16:23 +00004348 ;}
4349 break;
4350
4351 case 190:
4352#line 1922 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4353 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004354 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00004355 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
4356 CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004357 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004358 delete (yyvsp[0].TypeVal);
4359 ;}
4360 break;
4361
4362 case 191:
4363#line 1928 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4364 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004365 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004366 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004367 ;}
4368 break;
4369
4370 case 192:
4371#line 1932 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4372 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004373 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004374 ;}
4375 break;
4376
4377 case 193:
4378#line 1935 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4379 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004380 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004381 ;}
4382 break;
4383
4384 case 194:
4385#line 1941 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4386 {
Chris Lattner66316012006-01-24 04:14:29 +00004387 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer832254e2007-02-02 02:16:23 +00004388 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4389 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4390 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004391
4392 if (AsmSoFar.empty())
4393 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4394 else
4395 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004396 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004397;}
4398 break;
4399
4400 case 195:
4401#line 1954 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4402 {
4403 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4404 free((yyvsp[0].StrVal));
4405 ;}
4406 break;
4407
4408 case 196:
4409#line 1958 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4410 {
4411 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4412 free((yyvsp[0].StrVal));
4413 ;}
4414 break;
4415
4416 case 198:
4417#line 1965 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4418 {
4419 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4420 free((yyvsp[0].StrVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004421 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004422 ;}
4423 break;
4424
4425 case 199:
4426#line 1970 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4427 {
4428 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4429 free((yyvsp[0].StrVal));
Reid Spencera54b7cb2007-01-12 07:05:14 +00004430 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004431 ;}
4432 break;
4433
4434 case 200:
4435#line 1975 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4436 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004437 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004438 ;}
4439 break;
4440
4441 case 201:
4442#line 1984 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4443 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004444 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00004445 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4446 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004447 GEN_ERROR("void typed arguments are invalid");
Reid Spencer832254e2007-02-02 02:16:23 +00004448 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4449 (yyval.ArgList) = (yyvsp[-4].ArgList);
4450 (yyvsp[-4].ArgList)->push_back(E);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004451 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004452 ;}
4453 break;
4454
4455 case 202:
4456#line 1994 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4457 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004458 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00004459 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4460 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004461 GEN_ERROR("void typed arguments are invalid");
Reid Spencer832254e2007-02-02 02:16:23 +00004462 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4463 (yyval.ArgList) = new ArgListType;
4464 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004465 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004466 ;}
4467 break;
4468
4469 case 203:
4470#line 2005 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4471 {
4472 (yyval.ArgList) = (yyvsp[0].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004473 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004474 ;}
4475 break;
4476
4477 case 204:
4478#line 2009 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4479 {
4480 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004481 struct ArgListEntry E;
4482 E.Ty = new PATypeHolder(Type::VoidTy);
4483 E.Name = 0;
4484 E.Attrs = FunctionType::NoAttributeSet;
Reid Spencer832254e2007-02-02 02:16:23 +00004485 (yyval.ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004486 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004487 ;}
4488 break;
4489
4490 case 205:
4491#line 2018 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4492 {
4493 (yyval.ArgList) = new ArgListType;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004494 struct ArgListEntry E;
4495 E.Ty = new PATypeHolder(Type::VoidTy);
4496 E.Name = 0;
4497 E.Attrs = FunctionType::NoAttributeSet;
Reid Spencer832254e2007-02-02 02:16:23 +00004498 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004499 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004500 ;}
4501 break;
4502
4503 case 206:
4504#line 2027 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4505 {
4506 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004507 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004508 ;}
4509 break;
4510
4511 case 207:
4512#line 2033 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4513 {
4514 UnEscapeLexed((yyvsp[-6].StrVal));
4515 std::string FunctionName((yyvsp[-6].StrVal));
4516 free((yyvsp[-6].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004517
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004518 // Check the function result for abstractness if this is a define. We should
4519 // have no abstract types at this point
Reid Spencer832254e2007-02-02 02:16:23 +00004520 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal)))
4521 GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004522
Reid Spencer68a24bd2005-08-27 18:50:39 +00004523 std::vector<const Type*> ParamTypeList;
Reid Spencer14310612006-12-31 05:40:51 +00004524 std::vector<FunctionType::ParameterAttributes> ParamAttrs;
Reid Spencer832254e2007-02-02 02:16:23 +00004525 ParamAttrs.push_back((yyvsp[-2].ParamAttrs));
4526 if ((yyvsp[-4].ArgList)) { // If there are arguments...
4527 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004528 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004529 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4530 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004531 ParamTypeList.push_back(Ty);
4532 if (Ty != Type::VoidTy)
4533 ParamAttrs.push_back(I->Attrs);
4534 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004535 }
4536
4537 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4538 if (isVarArg) ParamTypeList.pop_back();
4539
Reid Spencer832254e2007-02-02 02:16:23 +00004540 FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg,
Reid Spencer14310612006-12-31 05:40:51 +00004541 ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004542 const PointerType *PFT = PointerType::get(FT);
Reid Spencer832254e2007-02-02 02:16:23 +00004543 delete (yyvsp[-7].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004544
4545 ValID ID;
4546 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004547 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004548 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004549 ID = ValID::createGlobalID(CurModule.Values[PFT].size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004550 }
4551
4552 Function *Fn = 0;
4553 // See if this function was forward referenced. If so, recycle the object.
4554 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4555 // Move the function to the end of the list, from whereever it was
4556 // previously inserted.
4557 Fn = cast<Function>(FWRef);
4558 CurModule.CurrentModule->getFunctionList().remove(Fn);
4559 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4560 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4561 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4562 // If this is the case, either we need to be a forward decl, or it needs
4563 // to be.
Reid Spencer5cbf9852007-01-30 20:08:39 +00004564 if (!CurFun.isDeclare && !Fn->isDeclaration())
Reid Spencerb5334b02007-02-05 10:18:06 +00004565 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004566
4567 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer5cbf9852007-01-30 20:08:39 +00004568 if (Fn->isDeclaration())
Reid Spencer68a24bd2005-08-27 18:50:39 +00004569 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4570 AI != AE; ++AI)
4571 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004572 } else { // Not already defined?
4573 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4574 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004575
Reid Spencer68a24bd2005-08-27 18:50:39 +00004576 InsertValue(Fn, CurModule.Values);
4577 }
4578
4579 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004580
4581 if (CurFun.isDeclare) {
4582 // If we have declaration, always overwrite linkage. This will allow us to
4583 // correctly handle cases, when pointer to function is passed as argument to
4584 // another function.
4585 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004586 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004587 }
Reid Spencer832254e2007-02-02 02:16:23 +00004588 Fn->setCallingConv((yyvsp[-8].UIntVal));
4589 Fn->setAlignment((yyvsp[0].UIntVal));
4590 if ((yyvsp[-1].StrVal)) {
4591 Fn->setSection((yyvsp[-1].StrVal));
4592 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004593 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004594
4595 // Add all of the arguments we parsed to the function...
Reid Spencer832254e2007-02-02 02:16:23 +00004596 if ((yyvsp[-4].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004597 if (isVarArg) { // Nuke the last entry
Reid Spencer832254e2007-02-02 02:16:23 +00004598 assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0&&
Reid Spencera9720f52007-02-05 17:04:00 +00004599 "Not a varargs marker!");
Reid Spencer832254e2007-02-02 02:16:23 +00004600 delete (yyvsp[-4].ArgList)->back().Ty;
4601 (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004602 }
4603 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencer14310612006-12-31 05:40:51 +00004604 unsigned Idx = 1;
Reid Spencer832254e2007-02-02 02:16:23 +00004605 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004606 delete I->Ty; // Delete the typeholder...
4607 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004608 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004609 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004610 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004611 }
Reid Spencera132e042006-12-03 05:46:11 +00004612
Reid Spencer832254e2007-02-02 02:16:23 +00004613 delete (yyvsp[-4].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004614 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004615 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004616;}
4617 break;
4618
4619 case 210:
4620#line 2140 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4621 {
4622 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004623
4624 // Make sure that we keep track of the linkage type even if there was a
4625 // previous "declare".
Reid Spencer832254e2007-02-02 02:16:23 +00004626 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
4627 (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility));
4628;}
4629 break;
4630
4631 case 213:
4632#line 2151 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4633 {
4634 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004635 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004636;}
4637 break;
4638
4639 case 214:
4640#line 2156 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4641 {
4642 CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage));
4643 CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility));
4644 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004645 CurFun.FunctionDone();
4646 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004647 ;}
4648 break;
4649
4650 case 215:
4651#line 2168 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4652 {
4653 (yyval.BoolVal) = false;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004654 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004655 ;}
4656 break;
4657
4658 case 216:
4659#line 2172 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4660 {
4661 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004662 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004663 ;}
4664 break;
4665
4666 case 217:
4667#line 2177 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4668 { // A reference to a direct constant
4669 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004670 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004671 ;}
4672 break;
4673
4674 case 218:
4675#line 2181 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4676 {
4677 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Reid Spencer6f407902007-01-13 05:00:46 +00004678 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004679 ;}
4680 break;
4681
4682 case 219:
4683#line 2185 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4684 { // Perhaps it's an FP constant?
4685 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004686 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004687 ;}
4688 break;
4689
4690 case 220:
4691#line 2189 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4692 {
4693 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004694 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004695 ;}
4696 break;
4697
4698 case 221:
4699#line 2193 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4700 {
4701 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004702 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004703 ;}
4704 break;
4705
4706 case 222:
4707#line 2197 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4708 {
4709 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004710 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004711 ;}
4712 break;
4713
4714 case 223:
4715#line 2201 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4716 {
4717 (yyval.ValIDVal) = ValID::createUndef();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004718 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004719 ;}
4720 break;
4721
4722 case 224:
4723#line 2205 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4724 { // A vector zero constant.
4725 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00004726 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004727 ;}
4728 break;
4729
4730 case 225:
4731#line 2209 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4732 { // Nonempty unsized packed vector
4733 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4734 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004735
4736 PackedType* pt = PackedType::get(ETy, NumElements);
4737 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004738 HandleUpRefs(
4739 PackedType::get(
4740 ETy,
4741 NumElements)
4742 )
4743 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004744
4745 // Verify all elements are correct type!
Reid Spencer832254e2007-02-02 02:16:23 +00004746 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4747 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004748 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004749 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer832254e2007-02-02 02:16:23 +00004750 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004751 }
4752
Reid Spencer832254e2007-02-02 02:16:23 +00004753 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector)));
4754 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004755 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004756 ;}
4757 break;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004758
Reid Spencer832254e2007-02-02 02:16:23 +00004759 case 226:
4760#line 2234 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4761 {
4762 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004763 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004764 ;}
4765 break;
4766
4767 case 227:
4768#line 2238 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4769 {
4770 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4771 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4772 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4773 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4774 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4775 free((yyvsp[-2].StrVal));
4776 free((yyvsp[0].StrVal));
4777 CHECK_FOR_ERROR
4778 ;}
4779 break;
4780
4781 case 228:
4782#line 2252 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4783 { // Is it an integer reference...?
4784 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[0].UIntVal));
4785 CHECK_FOR_ERROR
4786 ;}
4787 break;
4788
4789 case 229:
4790#line 2256 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4791 {
4792 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[0].UIntVal));
4793 CHECK_FOR_ERROR
4794 ;}
4795 break;
4796
4797 case 230:
4798#line 2260 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4799 { // Is it a named reference...?
4800 (yyval.ValIDVal) = ValID::createLocalName((yyvsp[0].StrVal));
4801 CHECK_FOR_ERROR
4802 ;}
4803 break;
4804
4805 case 231:
4806#line 2264 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4807 { // Is it a named reference...?
4808 (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[0].StrVal));
4809 CHECK_FOR_ERROR
4810 ;}
4811 break;
4812
4813 case 234:
4814#line 2276 "/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 2285 "/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 2289 "/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 2298 "/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 2309 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4856 {
4857 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004858 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4859 if (CI2->getParent() == 0)
Reid Spencer832254e2007-02-02 02:16:23 +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 Korobeynikov9adeaa22007-01-28 13:37:39 +00004863 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004864 ;}
4865 break;
4866
4867 case 239:
4868#line 2318 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4869 {
4870 (yyval.BasicBlockVal) = getBBVal(ValID::createLocalID(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 Spencer832254e2007-02-02 02:16:23 +00004878 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004879 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004880 ;}
4881 break;
4882
4883 case 240:
4884#line 2330 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4885 {
4886 (yyval.BasicBlockVal) = getBBVal(ValID::createLocalName((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 Spencer832254e2007-02-02 02:16:23 +00004894 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004895 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004896 ;}
4897 break;
Reid Spencer3822ff52006-11-08 06:47:33 +00004898
Reid Spencer832254e2007-02-02 02:16:23 +00004899 case 241:
4900#line 2343 "/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 2347 "/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 2351 "/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 2356 "/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 2366 "/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 Spencerb5334b02007-02-05 10:18:06 +00004954 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004955 }
Reid Spencer832254e2007-02-02 02:16:23 +00004956 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00004957 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004958 ;}
4959 break;
4960
4961 case 246:
4962#line 2385 "/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 Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +00004969 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00004970 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00004971 ;}
4972 break;
4973
4974 case 247:
4975#line 2395 "/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 Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +00005001 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005002 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +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 "
Reid Spencerb5334b02007-02-05 10:18:06 +00005012 "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 Spencer832254e2007-02-02 02:16:23 +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 Spencerb5334b02007-02-05 10:18:06 +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 Spencerb5334b02007-02-05 10:18: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 Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +00005041 ;}
5042 break;
5043
5044 case 248:
5045#line 2461 "/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 Spencer832254e2007-02-02 02:16:23 +00005049 ;}
5050 break;
5051
5052 case 249:
5053#line 2465 "/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 Spencer832254e2007-02-02 02:16:23 +00005057 ;}
5058 break;
5059
5060 case 250:
5061#line 2472 "/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)
Reid Spencerb5334b02007-02-05 10:18:06 +00005067 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005068
Reid Spencer832254e2007-02-02 02:16:23 +00005069 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005070 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005071 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5072 ;}
5073 break;
5074
5075 case 251:
5076#line 2483 "/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)
Reid Spencerb5334b02007-02-05 10:18:06 +00005083 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005084
Reid Spencer832254e2007-02-02 02:16:23 +00005085 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005086 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005087 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5088 ;}
5089 break;
5090
5091 case 252:
5092#line 2496 "/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 Spencer832254e2007-02-02 02:16:23 +00005095 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005096 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005097 InsertValue((yyvsp[0].InstVal));
5098 (yyval.InstVal) = (yyvsp[0].InstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005099 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005100;}
5101 break;
5102
5103 case 253:
5104#line 2505 "/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 Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +00005111 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005112 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005113 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5114 delete (yyvsp[-5].TypeVal);
5115 ;}
5116 break;
5117
5118 case 254:
5119#line 2516 "/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));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005123 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005124 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005125 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005126 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5127 ;}
5128 break;
5129
5130 case 255:
5131#line 2526 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5132 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005133 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00005134 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005135 // Used for call and invoke instructions
Reid Spencer832254e2007-02-02 02:16:23 +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 2534 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5144 {
Reid Spencer14310612006-12-31 05:40:51 +00005145 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +00005151 ;}
5152 break;
5153
5154 case 257:
5155#line 2542 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5156 { (yyval.ValueRefList) = new ValueRefList(); ;}
5157 break;
5158
5159 case 258:
5160#line 2545 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5161 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5162 break;
5163
5164 case 259:
5165#line 2546 "/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 Spencer832254e2007-02-02 02:16:23 +00005170 ;}
5171 break;
5172
5173 case 260:
5174#line 2553 "/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 Spencer832254e2007-02-02 02:16:23 +00005178 ;}
5179 break;
5180
5181 case 261:
5182#line 2557 "/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 Spencer832254e2007-02-02 02:16:23 +00005186 ;}
5187 break;
5188
5189 case 262:
5190#line 2562 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5191 {
Reid Spencer14310612006-12-31 05:40:51 +00005192 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +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(
Reid Spencerb5334b02007-02-05 10:18:06 +00005197 "Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer832254e2007-02-02 02:16:23 +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 Spencerb5334b02007-02-05 10:18:06 +00005202 GEN_ERROR("U/S/FRem not supported on packed types");
Reid Spencer832254e2007-02-02 02:16:23 +00005203 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005204 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005205 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005206 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005207 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
5208 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005209 GEN_ERROR("binary operator returned null");
Reid Spencer832254e2007-02-02 02:16:23 +00005210 delete (yyvsp[-3].TypeVal);
5211 ;}
5212 break;
5213
5214 case 263:
5215#line 2583 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5216 {
Reid Spencer14310612006-12-31 05:40:51 +00005217 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00005218 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5219 if (!(*(yyvsp[-3].TypeVal))->isInteger()) {
5220 if (Instruction::isShift((yyvsp[-4].BinaryOpVal)) || !isa<PackedType>((yyvsp[-3].TypeVal)->get()) ||
5221 !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00005222 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005223 }
Reid Spencer832254e2007-02-02 02:16:23 +00005224 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005225 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005226 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005227 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005228 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
5229 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005230 GEN_ERROR("binary operator returned null");
Reid Spencer832254e2007-02-02 02:16:23 +00005231 delete (yyvsp[-3].TypeVal);
5232 ;}
5233 break;
5234
5235 case 264:
5236#line 2600 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5237 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005238 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +00005242 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005243 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005244 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005245 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005246 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5247 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005248 GEN_ERROR("icmp operator returned null");
Reid Spencer832254e2007-02-02 02:16:23 +00005249 ;}
5250 break;
5251
5252 case 265:
5253#line 2613 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5254 {
Reid Spencer14310612006-12-31 05:40:51 +00005255 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +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 Spencer832254e2007-02-02 02:16:23 +00005259 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005260 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005261 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005262 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005263 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5264 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005265 GEN_ERROR("fcmp operator returned null");
Reid Spencer832254e2007-02-02 02:16:23 +00005266 ;}
5267 break;
5268
5269 case 266:
5270#line 2626 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5271 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005272 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00005273 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5274 Value* Val = (yyvsp[-2].ValueVal);
5275 const Type* DestTy = (yyvsp[0].TypeVal)->get();
5276 if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005277 GEN_ERROR("invalid cast opcode for cast from '" +
5278 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005279 DestTy->getDescription() + "'");
Reid Spencer832254e2007-02-02 02:16:23 +00005280 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy);
5281 delete (yyvsp[0].TypeVal);
5282 ;}
5283 break;
5284
5285 case 267:
5286#line 2638 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5287 {
5288 if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00005289 GEN_ERROR("select condition must be boolean");
Reid Spencer832254e2007-02-02 02:16:23 +00005290 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00005291 GEN_ERROR("select value types should match");
Reid Spencer832254e2007-02-02 02:16:23 +00005292 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005293 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005294 ;}
5295 break;
5296
5297 case 268:
5298#line 2646 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5299 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005300 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00005301 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5302 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5303 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005304 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005305 ;}
5306 break;
5307
5308 case 269:
5309#line 2653 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5310 {
5311 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005312 GEN_ERROR("Invalid extractelement operands");
Reid Spencer832254e2007-02-02 02:16:23 +00005313 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005314 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005315 ;}
5316 break;
5317
5318 case 270:
5319#line 2659 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5320 {
5321 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005322 GEN_ERROR("Invalid insertelement operands");
Reid Spencer832254e2007-02-02 02:16:23 +00005323 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005324 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005325 ;}
5326 break;
5327
5328 case 271:
5329#line 2665 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5330 {
5331 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005332 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer832254e2007-02-02 02:16:23 +00005333 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005334 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005335 ;}
5336 break;
5337
5338 case 272:
5339#line 2671 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5340 {
5341 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005342 if (!Ty->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00005343 GEN_ERROR("PHI node operands must be of first class type");
Reid Spencer832254e2007-02-02 02:16:23 +00005344 (yyval.InstVal) = new PHINode(Ty);
5345 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5346 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5347 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00005348 GEN_ERROR("All elements of a PHI node must be of the same type");
Reid Spencer832254e2007-02-02 02:16:23 +00005349 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5350 (yyvsp[0].PHIList)->pop_front();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005351 }
Reid Spencer832254e2007-02-02 02:16:23 +00005352 delete (yyvsp[0].PHIList); // Free the list...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005353 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005354 ;}
5355 break;
5356
5357 case 273:
5358#line 2687 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5359 {
Reid Spencer14310612006-12-31 05:40:51 +00005360
5361 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005362 const PointerType *PFTy = 0;
5363 const FunctionType *Ty = 0;
Reid Spencer832254e2007-02-02 02:16:23 +00005364 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005365 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5366 // Pull out the types of all of the arguments...
5367 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005368 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer832254e2007-02-02 02:16:23 +00005369 ParamAttrs.push_back((yyvsp[0].ParamAttrs));
5370 for (ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005371 const Type *Ty = I->Val->getType();
5372 if (Ty == Type::VoidTy)
5373 GEN_ERROR("Short call syntax cannot be used with varargs");
5374 ParamTypes.push_back(Ty);
5375 ParamAttrs.push_back(I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005376 }
5377
Reid Spencer832254e2007-02-02 02:16:23 +00005378 Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005379 PFTy = PointerType::get(Ty);
5380 }
5381
Reid Spencer832254e2007-02-02 02:16:23 +00005382 Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005383 CHECK_FOR_ERROR
5384
Reid Spencer14310612006-12-31 05:40:51 +00005385 // Check the arguments
5386 ValueList Args;
Reid Spencer832254e2007-02-02 02:16:23 +00005387 if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005388 // Make sure no arguments is a good thing!
5389 if (Ty->getNumParams() != 0)
5390 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005391 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005392 } else { // Has arguments?
5393 // Loop through FunctionType's arguments and ensure they are specified
5394 // correctly!
5395 //
5396 FunctionType::param_iterator I = Ty->param_begin();
5397 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer832254e2007-02-02 02:16:23 +00005398 ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005399
Reid Spencer14310612006-12-31 05:40:51 +00005400 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5401 if (ArgI->Val->getType() != *I)
5402 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005403 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005404 Args.push_back(ArgI->Val);
5405 }
5406 if (Ty->isVarArg()) {
5407 if (I == E)
5408 for (; ArgI != ArgE; ++ArgI)
5409 Args.push_back(ArgI->Val); // push the remaining varargs
5410 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005411 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005412 }
Reid Spencer14310612006-12-31 05:40:51 +00005413 // Create the call node
5414 CallInst *CI = new CallInst(V, Args);
Reid Spencer832254e2007-02-02 02:16:23 +00005415 CI->setTailCall((yyvsp[-7].BoolVal));
5416 CI->setCallingConv((yyvsp[-6].UIntVal));
5417 (yyval.InstVal) = CI;
5418 delete (yyvsp[-2].ValueRefList);
5419 delete (yyvsp[-5].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005420 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005421 ;}
5422 break;
5423
5424 case 274:
5425#line 2750 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5426 {
5427 (yyval.InstVal) = (yyvsp[0].InstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005428 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005429 ;}
5430 break;
5431
5432 case 275:
5433#line 2755 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5434 {
5435 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005436 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005437 ;}
5438 break;
5439
5440 case 276:
5441#line 2759 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5442 {
5443 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005444 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005445 ;}
5446 break;
5447
5448 case 277:
5449#line 2766 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5450 {
Reid Spencer6f407902007-01-13 05:00:46 +00005451 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00005452 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5453 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5454 delete (yyvsp[-1].TypeVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005455 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005456 ;}
5457 break;
5458
5459 case 278:
5460#line 2773 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5461 {
Reid Spencer14310612006-12-31 05:40:51 +00005462 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00005463 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5464 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005465 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005466 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5467 delete (yyvsp[-4].TypeVal);
5468 ;}
5469 break;
5470
5471 case 279:
5472#line 2781 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5473 {
Reid Spencer14310612006-12-31 05:40:51 +00005474 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00005475 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5476 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5477 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005478 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005479 ;}
5480 break;
5481
5482 case 280:
5483#line 2788 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5484 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005485 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00005486 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5487 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005488 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005489 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5490 delete (yyvsp[-4].TypeVal);
5491 ;}
5492 break;
5493
5494 case 281:
5495#line 2796 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5496 {
5497 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005498 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencerb5334b02007-02-05 10:18:06 +00005499 (yyvsp[0].ValueVal)->getType()->getDescription() + "");
Reid Spencer832254e2007-02-02 02:16:23 +00005500 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005501 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005502 ;}
5503 break;
5504
5505 case 282:
5506#line 2804 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5507 {
Reid Spencer14310612006-12-31 05:40:51 +00005508 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00005509 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5510 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005511 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencer832254e2007-02-02 02:16:23 +00005512 (*(yyvsp[-1].TypeVal))->getDescription());
5513 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005514 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencer832254e2007-02-02 02:16:23 +00005515 (*(yyvsp[-1].TypeVal))->getDescription());
5516 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005517 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005518 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5519 delete (yyvsp[-1].TypeVal);
5520 ;}
5521 break;
5522
5523 case 283:
5524#line 2818 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5525 {
Reid Spencer14310612006-12-31 05:40:51 +00005526 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00005527 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5528 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005529 if (!PT)
5530 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencer832254e2007-02-02 02:16:23 +00005531 (*(yyvsp[-1].TypeVal))->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005532 const Type *ElTy = PT->getElementType();
Reid Spencer832254e2007-02-02 02:16:23 +00005533 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5534 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencerb5334b02007-02-05 10:18:06 +00005535 "' into space of type '" + ElTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005536
Reid Spencer832254e2007-02-02 02:16:23 +00005537 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005538 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005539 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5540 delete (yyvsp[-1].TypeVal);
5541 ;}
5542 break;
5543
5544 case 284:
5545#line 2835 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
5546 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005547 if (!UpRefs.empty())
Reid Spencer832254e2007-02-02 02:16:23 +00005548 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5549 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005550 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005551
Reid Spencer832254e2007-02-02 02:16:23 +00005552 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005553 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005554 (*(yyvsp[-2].TypeVal))->getDescription()+ "'");
Reid Spencer832254e2007-02-02 02:16:23 +00005555 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005556 CHECK_FOR_ERROR
Reid Spencer832254e2007-02-02 02:16:23 +00005557 (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList));
5558 delete (yyvsp[-2].TypeVal);
5559 delete (yyvsp[0].ValueList);
5560 ;}
5561 break;
5562
5563
5564 default: break;
5565 }
5566
5567/* Line 1126 of yacc.c. */
5568#line 5569 "llvmAsmParser.tab.c"
Reid Spencer5cbf9852007-01-30 20:08:39 +00005569
5570 yyvsp -= yylen;
5571 yyssp -= yylen;
5572
Reid Spencer832254e2007-02-02 02:16:23 +00005573
5574 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005575
5576 *++yyvsp = yyval;
5577
5578
Reid Spencer832254e2007-02-02 02:16:23 +00005579 /* Now `shift' the result of the reduction. Determine what state
5580 that goes to, based on the state we popped back to and the rule
5581 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005582
5583 yyn = yyr1[yyn];
5584
Reid Spencer832254e2007-02-02 02:16:23 +00005585 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5586 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005587 yystate = yytable[yystate];
5588 else
Reid Spencer832254e2007-02-02 02:16:23 +00005589 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005590
5591 goto yynewstate;
5592
5593
Reid Spencer832254e2007-02-02 02:16:23 +00005594/*------------------------------------.
5595| yyerrlab -- here on detecting error |
5596`------------------------------------*/
5597yyerrlab:
5598 /* If not already recovering from an error, report this error. */
5599 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005600 {
5601 ++yynerrs;
Reid Spencer832254e2007-02-02 02:16:23 +00005602#if YYERROR_VERBOSE
Reid Spencer5cbf9852007-01-30 20:08:39 +00005603 yyn = yypact[yystate];
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005604
Reid Spencer832254e2007-02-02 02:16:23 +00005605 if (YYPACT_NINF < yyn && yyn < YYLAST)
Reid Spencer5cbf9852007-01-30 20:08:39 +00005606 {
Reid Spencer832254e2007-02-02 02:16:23 +00005607 int yytype = YYTRANSLATE (yychar);
5608 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5609 YYSIZE_T yysize = yysize0;
5610 YYSIZE_T yysize1;
5611 int yysize_overflow = 0;
5612 char *yymsg = 0;
5613# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5614 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5615 int yyx;
Reid Spencer5cbf9852007-01-30 20:08:39 +00005616
Reid Spencer832254e2007-02-02 02:16:23 +00005617#if 0
5618 /* This is so xgettext sees the translatable formats that are
5619 constructed on the fly. */
5620 YY_("syntax error, unexpected %s");
5621 YY_("syntax error, unexpected %s, expecting %s");
5622 YY_("syntax error, unexpected %s, expecting %s or %s");
5623 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5624 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5625#endif
5626 char *yyfmt;
5627 char const *yyf;
5628 static char const yyunexpected[] = "syntax error, unexpected %s";
5629 static char const yyexpecting[] = ", expecting %s";
5630 static char const yyor[] = " or %s";
5631 char yyformat[sizeof yyunexpected
5632 + sizeof yyexpecting - 1
5633 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5634 * (sizeof yyor - 1))];
5635 char const *yyprefix = yyexpecting;
5636
5637 /* Start YYX at -YYN if negative to avoid negative indexes in
5638 YYCHECK. */
5639 int yyxbegin = yyn < 0 ? -yyn : 0;
5640
5641 /* Stay within bounds of both yycheck and yytname. */
5642 int yychecklim = YYLAST - yyn;
5643 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5644 int yycount = 1;
5645
5646 yyarg[0] = yytname[yytype];
5647 yyfmt = yystpcpy (yyformat, yyunexpected);
5648
5649 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5650 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5651 {
5652 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5653 {
5654 yycount = 1;
5655 yysize = yysize0;
5656 yyformat[sizeof yyunexpected - 1] = '\0';
5657 break;
5658 }
5659 yyarg[yycount++] = yytname[yyx];
5660 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5661 yysize_overflow |= yysize1 < yysize;
5662 yysize = yysize1;
5663 yyfmt = yystpcpy (yyfmt, yyprefix);
5664 yyprefix = yyor;
5665 }
5666
5667 yyf = YY_(yyformat);
5668 yysize1 = yysize + yystrlen (yyf);
5669 yysize_overflow |= yysize1 < yysize;
5670 yysize = yysize1;
5671
5672 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5673 yymsg = (char *) YYSTACK_ALLOC (yysize);
5674 if (yymsg)
Reid Spencer5cbf9852007-01-30 20:08:39 +00005675 {
Reid Spencer832254e2007-02-02 02:16:23 +00005676 /* Avoid sprintf, as that infringes on the user's name space.
5677 Don't have undefined behavior even if the translation
5678 produced a string with the wrong number of "%s"s. */
5679 char *yyp = yymsg;
5680 int yyi = 0;
5681 while ((*yyp = *yyf))
Reid Spencer5cbf9852007-01-30 20:08:39 +00005682 {
Reid Spencer832254e2007-02-02 02:16:23 +00005683 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5684 {
5685 yyp += yytnamerr (yyp, yyarg[yyi++]);
5686 yyf += 2;
5687 }
5688 else
5689 {
5690 yyp++;
5691 yyf++;
5692 }
Reid Spencer5cbf9852007-01-30 20:08:39 +00005693 }
Reid Spencer832254e2007-02-02 02:16:23 +00005694 yyerror (yymsg);
5695 YYSTACK_FREE (yymsg);
Reid Spencer5cbf9852007-01-30 20:08:39 +00005696 }
5697 else
Reid Spencer832254e2007-02-02 02:16:23 +00005698 {
5699 yyerror (YY_("syntax error"));
5700 goto yyexhaustedlab;
5701 }
Reid Spencer5cbf9852007-01-30 20:08:39 +00005702 }
5703 else
5704#endif /* YYERROR_VERBOSE */
Reid Spencer832254e2007-02-02 02:16:23 +00005705 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005706 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00005707
Reid Spencer832254e2007-02-02 02:16:23 +00005708
Reid Spencer41dff5e2007-01-26 08:05:27 +00005709
5710 if (yyerrstatus == 3)
5711 {
Reid Spencer832254e2007-02-02 02:16:23 +00005712 /* If just tried and failed to reuse look-ahead token after an
5713 error, discard it. */
Reid Spencer41dff5e2007-01-26 08:05:27 +00005714
Reid Spencer832254e2007-02-02 02:16:23 +00005715 if (yychar <= YYEOF)
5716 {
5717 /* Return failure if at end of input. */
5718 if (yychar == YYEOF)
5719 YYABORT;
5720 }
5721 else
5722 {
5723 yydestruct ("Error: discarding", yytoken, &yylval);
5724 yychar = YYEMPTY;
5725 }
5726 }
5727
5728 /* Else will try to reuse look-ahead token after shifting the error
5729 token. */
5730 goto yyerrlab1;
5731
5732
5733/*---------------------------------------------------.
5734| yyerrorlab -- error raised explicitly by YYERROR. |
5735`---------------------------------------------------*/
5736yyerrorlab:
5737
5738 /* Pacify compilers like GCC when the user code never invokes
5739 YYERROR and the label yyerrorlab therefore never appears in user
5740 code. */
5741 if (0)
5742 goto yyerrorlab;
5743
5744yyvsp -= yylen;
5745 yyssp -= yylen;
5746 yystate = *yyssp;
5747 goto yyerrlab1;
5748
5749
5750/*-------------------------------------------------------------.
5751| yyerrlab1 -- common code for both syntax error and YYERROR. |
5752`-------------------------------------------------------------*/
5753yyerrlab1:
5754 yyerrstatus = 3; /* Each real token shifted decrements this. */
5755
5756 for (;;)
5757 {
5758 yyn = yypact[yystate];
5759 if (yyn != YYPACT_NINF)
5760 {
5761 yyn += YYTERROR;
5762 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5763 {
5764 yyn = yytable[yyn];
5765 if (0 < yyn)
5766 break;
5767 }
5768 }
5769
5770 /* Pop the current state because it cannot handle the error token. */
5771 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005772 YYABORT;
5773
Reid Spencere4d87aa2006-12-23 06:05:41 +00005774
Reid Spencer832254e2007-02-02 02:16:23 +00005775 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5776 YYPOPSTACK;
5777 yystate = *yyssp;
5778 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005779 }
5780
5781 if (yyn == YYFINAL)
5782 YYACCEPT;
5783
Reid Spencer68a24bd2005-08-27 18:50:39 +00005784 *++yyvsp = yylval;
Reid Spencer832254e2007-02-02 02:16:23 +00005785
5786
5787 /* Shift the error token. */
5788 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer41dff5e2007-01-26 08:05:27 +00005789
Reid Spencer68a24bd2005-08-27 18:50:39 +00005790 yystate = yyn;
5791 goto yynewstate;
5792
Chris Lattnerf7469af2007-01-31 04:44:08 +00005793
Reid Spencer832254e2007-02-02 02:16:23 +00005794/*-------------------------------------.
5795| yyacceptlab -- YYACCEPT comes here. |
5796`-------------------------------------*/
5797yyacceptlab:
5798 yyresult = 0;
5799 goto yyreturn;
5800
5801/*-----------------------------------.
5802| yyabortlab -- YYABORT comes here. |
5803`-----------------------------------*/
5804yyabortlab:
5805 yyresult = 1;
5806 goto yyreturn;
5807
5808#ifndef yyoverflow
5809/*-------------------------------------------------.
5810| yyexhaustedlab -- memory exhaustion comes here. |
5811`-------------------------------------------------*/
5812yyexhaustedlab:
5813 yyerror (YY_("memory exhausted"));
5814 yyresult = 2;
5815 /* Fall through. */
Chris Lattnerf7469af2007-01-31 04:44:08 +00005816#endif
Reid Spencer832254e2007-02-02 02:16:23 +00005817
5818yyreturn:
5819 if (yychar != YYEOF && yychar != YYEMPTY)
5820 yydestruct ("Cleanup: discarding lookahead",
5821 yytoken, &yylval);
5822 while (yyssp != yyss)
5823 {
5824 yydestruct ("Cleanup: popping",
5825 yystos[*yyssp], yyvsp);
5826 YYPOPSTACK;
Chris Lattnerf7469af2007-01-31 04:44:08 +00005827 }
Reid Spencer832254e2007-02-02 02:16:23 +00005828#ifndef yyoverflow
5829 if (yyss != yyssa)
5830 YYSTACK_FREE (yyss);
5831#endif
5832 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005833}
Reid Spencer832254e2007-02-02 02:16:23 +00005834
5835
5836#line 2852 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005837
5838
Reid Spencer14310612006-12-31 05:40:51 +00005839// common code from the two 'RunVMAsmParser' functions
5840static Module* RunParser(Module * M) {
5841
5842 llvmAsmlineno = 1; // Reset the current line number...
5843 CurModule.CurrentModule = M;
5844#if YYDEBUG
5845 yydebug = Debug;
5846#endif
5847
5848 // Check to make sure the parser succeeded
5849 if (yyparse()) {
5850 if (ParserResult)
5851 delete ParserResult;
5852 return 0;
5853 }
5854
5855 // Check to make sure that parsing produced a result
5856 if (!ParserResult)
5857 return 0;
5858
5859 // Reset ParserResult variable while saving its value for the result.
5860 Module *Result = ParserResult;
5861 ParserResult = 0;
5862
5863 return Result;
5864}
5865
Reid Spencer61c83e02006-08-18 08:43:06 +00005866void llvm::GenerateError(const std::string &message, int LineNo) {
5867 if (LineNo == -1) LineNo = llvmAsmlineno;
5868 // TODO: column number in exception
5869 if (TheParseError)
5870 TheParseError->setError(CurFilename, message, LineNo);
5871 TriggerError = 1;
5872}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005873
5874int yyerror(const char *ErrorMsg) {
5875 std::string where
5876 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5877 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5878 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5879 if (yychar == YYEMPTY || yychar == 0)
5880 errMsg += "end-of-file.";
5881 else
5882 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005883 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005884 return 0;
5885}
Reid Spencer832254e2007-02-02 02:16:23 +00005886