blob: 9deb8cf256e2263e8ffc7cbc2ab84c311c4967dd [file] [log] [blame]
Reid Spencer38c91a92007-02-28 02:24:54 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencer38c91a92007-02-28 02:24:54 +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 Spencer38c91a92007-02-28 02:24:54 +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 Spencer38c91a92007-02-28 02:24:54 +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 Spencer38c91a92007-02-28 02:24:54 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Reid Spencer38c91a92007-02-28 02:24:54 +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 Spencer38c91a92007-02-28 02:24:54 +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 ESAPINTVAL = 260,
70 EUAPINTVAL = 261,
71 LOCALVAL_ID = 262,
72 GLOBALVAL_ID = 263,
73 FPVAL = 264,
74 VOID = 265,
75 INTTYPE = 266,
76 FLOAT = 267,
77 DOUBLE = 268,
78 LABEL = 269,
79 TYPE = 270,
80 LOCALVAR = 271,
81 GLOBALVAR = 272,
82 LABELSTR = 273,
83 STRINGCONSTANT = 274,
84 ATSTRINGCONSTANT = 275,
Reid Spencer3d6b71e2007-04-09 01:56:05 +000085 ZEROINITIALIZER = 276,
86 TRUETOK = 277,
87 FALSETOK = 278,
88 BEGINTOK = 279,
89 ENDTOK = 280,
90 DECLARE = 281,
91 DEFINE = 282,
92 GLOBAL = 283,
93 CONSTANT = 284,
94 SECTION = 285,
95 VOLATILE = 286,
96 TO = 287,
97 DOTDOTDOT = 288,
98 NULL_TOK = 289,
99 UNDEF = 290,
100 INTERNAL = 291,
101 LINKONCE = 292,
102 WEAK = 293,
103 APPENDING = 294,
104 DLLIMPORT = 295,
105 DLLEXPORT = 296,
106 EXTERN_WEAK = 297,
107 OPAQUE = 298,
108 EXTERNAL = 299,
109 TARGET = 300,
110 TRIPLE = 301,
111 ALIGN = 302,
112 DEPLIBS = 303,
113 CALL = 304,
114 TAIL = 305,
115 ASM_TOK = 306,
116 MODULE = 307,
117 SIDEEFFECT = 308,
118 CC_TOK = 309,
119 CCC_TOK = 310,
120 FASTCC_TOK = 311,
121 COLDCC_TOK = 312,
122 X86_STDCALLCC_TOK = 313,
123 X86_FASTCALLCC_TOK = 314,
124 DATALAYOUT = 315,
125 RET = 316,
126 BR = 317,
127 SWITCH = 318,
128 INVOKE = 319,
129 UNWIND = 320,
130 UNREACHABLE = 321,
131 ADD = 322,
132 SUB = 323,
133 MUL = 324,
134 UDIV = 325,
135 SDIV = 326,
136 FDIV = 327,
137 UREM = 328,
138 SREM = 329,
139 FREM = 330,
140 AND = 331,
141 OR = 332,
142 XOR = 333,
143 SHL = 334,
144 LSHR = 335,
145 ASHR = 336,
146 ICMP = 337,
147 FCMP = 338,
148 EQ = 339,
149 NE = 340,
150 SLT = 341,
151 SGT = 342,
152 SLE = 343,
153 SGE = 344,
154 ULT = 345,
155 UGT = 346,
156 ULE = 347,
157 UGE = 348,
158 OEQ = 349,
159 ONE = 350,
160 OLT = 351,
161 OGT = 352,
162 OLE = 353,
163 OGE = 354,
164 ORD = 355,
165 UNO = 356,
166 UEQ = 357,
167 UNE = 358,
168 MALLOC = 359,
169 ALLOCA = 360,
170 FREE = 361,
171 LOAD = 362,
172 STORE = 363,
173 GETELEMENTPTR = 364,
174 TRUNC = 365,
175 ZEXT = 366,
176 SEXT = 367,
177 FPTRUNC = 368,
178 FPEXT = 369,
179 BITCAST = 370,
180 UITOFP = 371,
181 SITOFP = 372,
182 FPTOUI = 373,
183 FPTOSI = 374,
184 INTTOPTR = 375,
185 PTRTOINT = 376,
186 PHI_TOK = 377,
187 SELECT = 378,
188 VAARG = 379,
189 EXTRACTELEMENT = 380,
190 INSERTELEMENT = 381,
191 SHUFFLEVECTOR = 382,
192 NORETURN = 383,
193 INREG = 384,
194 SRET = 385,
195 NOUNWIND = 386,
196 DEFAULT = 387,
197 HIDDEN = 388
Reid Spencer38c91a92007-02-28 02:24:54 +0000198 };
199#endif
200/* Tokens. */
201#define ESINT64VAL 258
202#define EUINT64VAL 259
203#define ESAPINTVAL 260
204#define EUAPINTVAL 261
205#define LOCALVAL_ID 262
206#define GLOBALVAL_ID 263
207#define FPVAL 264
208#define VOID 265
209#define INTTYPE 266
210#define FLOAT 267
211#define DOUBLE 268
212#define LABEL 269
213#define TYPE 270
214#define LOCALVAR 271
215#define GLOBALVAR 272
216#define LABELSTR 273
217#define STRINGCONSTANT 274
218#define ATSTRINGCONSTANT 275
Reid Spencer3d6b71e2007-04-09 01:56:05 +0000219#define ZEROINITIALIZER 276
220#define TRUETOK 277
221#define FALSETOK 278
222#define BEGINTOK 279
223#define ENDTOK 280
224#define DECLARE 281
225#define DEFINE 282
226#define GLOBAL 283
227#define CONSTANT 284
228#define SECTION 285
229#define VOLATILE 286
230#define TO 287
231#define DOTDOTDOT 288
232#define NULL_TOK 289
233#define UNDEF 290
234#define INTERNAL 291
235#define LINKONCE 292
236#define WEAK 293
237#define APPENDING 294
238#define DLLIMPORT 295
239#define DLLEXPORT 296
240#define EXTERN_WEAK 297
241#define OPAQUE 298
242#define EXTERNAL 299
243#define TARGET 300
244#define TRIPLE 301
245#define ALIGN 302
246#define DEPLIBS 303
247#define CALL 304
248#define TAIL 305
249#define ASM_TOK 306
250#define MODULE 307
251#define SIDEEFFECT 308
252#define CC_TOK 309
253#define CCC_TOK 310
254#define FASTCC_TOK 311
255#define COLDCC_TOK 312
256#define X86_STDCALLCC_TOK 313
257#define X86_FASTCALLCC_TOK 314
258#define DATALAYOUT 315
259#define RET 316
260#define BR 317
261#define SWITCH 318
262#define INVOKE 319
263#define UNWIND 320
264#define UNREACHABLE 321
265#define ADD 322
266#define SUB 323
267#define MUL 324
268#define UDIV 325
269#define SDIV 326
270#define FDIV 327
271#define UREM 328
272#define SREM 329
273#define FREM 330
274#define AND 331
275#define OR 332
276#define XOR 333
277#define SHL 334
278#define LSHR 335
279#define ASHR 336
280#define ICMP 337
281#define FCMP 338
282#define EQ 339
283#define NE 340
284#define SLT 341
285#define SGT 342
286#define SLE 343
287#define SGE 344
288#define ULT 345
289#define UGT 346
290#define ULE 347
291#define UGE 348
292#define OEQ 349
293#define ONE 350
294#define OLT 351
295#define OGT 352
296#define OLE 353
297#define OGE 354
298#define ORD 355
299#define UNO 356
300#define UEQ 357
301#define UNE 358
302#define MALLOC 359
303#define ALLOCA 360
304#define FREE 361
305#define LOAD 362
306#define STORE 363
307#define GETELEMENTPTR 364
308#define TRUNC 365
309#define ZEXT 366
310#define SEXT 367
311#define FPTRUNC 368
312#define FPEXT 369
313#define BITCAST 370
314#define UITOFP 371
315#define SITOFP 372
316#define FPTOUI 373
317#define FPTOSI 374
318#define INTTOPTR 375
319#define PTRTOINT 376
320#define PHI_TOK 377
321#define SELECT 378
322#define VAARG 379
323#define EXTRACTELEMENT 380
324#define INSERTELEMENT 381
325#define SHUFFLEVECTOR 382
326#define NORETURN 383
327#define INREG 384
328#define SRET 385
329#define NOUNWIND 386
330#define DEFAULT 387
331#define HIDDEN 388
Reid Spencer38c91a92007-02-28 02:24:54 +0000332
333
334
335
336/* Copy the first part of user declarations. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +0000337#line 14 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000338
339#include "ParserInternals.h"
340#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000341#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000342#include "llvm/Instructions.h"
343#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000344#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000345#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000346#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000347#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000348#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000349#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000350#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000351#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000352#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000353#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000354#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000355#ifndef NDEBUG
356#define YYDEBUG 1
357#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000358
Reid Spencere4f47592006-08-18 17:32:55 +0000359// The following is a gross hack. In order to rid the libAsmParser library of
360// exceptions, we have to have a way of getting the yyparse function to go into
361// an error situation. So, whenever we want an error to occur, the GenerateError
362// function (see bottom of file) sets TriggerError. Then, at the end of each
363// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
364// (a goto) to put YACC in error state. Furthermore, several calls to
365// GenerateError are made from inside productions and they must simulate the
366// previous exception behavior by exiting the production immediately. We have
367// replaced these with the GEN_ERROR macro which calls GeneratError and then
368// immediately invokes YYERROR. This would be so much cleaner if it was a
369// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000370static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000371#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000372#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
373
Reid Spencer68a24bd2005-08-27 18:50:39 +0000374int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
375int yylex(); // declaration" of xxx warnings.
376int yyparse();
377
378namespace llvm {
379 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000380#if YYDEBUG
381static cl::opt<bool>
382Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
383 cl::Hidden, cl::init(false));
384#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000385}
386using namespace llvm;
387
388static Module *ParserResult;
389
390// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
391// relating to upreferences in the input stream.
392//
393//#define DEBUG_UPREFS 1
394#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000395#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000396#else
397#define UR_OUT(X)
398#endif
399
400#define YYERROR_VERBOSE 1
401
Chris Lattnerb475c422005-11-12 18:22:38 +0000402static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000403
404
405// This contains info used when building the body of a function. It is
406// destroyed when the function is completed.
407//
408typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000409
Reid Spencer68a24bd2005-08-27 18:50:39 +0000410static void
Reid Spencer93c40032007-03-19 18:40:50 +0000411ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000412
413static struct PerModuleInfo {
414 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000415 ValueList Values; // Module level numbered definitions
416 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000417 std::vector<PATypeHolder> Types;
418 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000419
420 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000421 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000422 /// that we can resolve them later and print error messages as appropriate.
423 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
424
425 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
426 // references to global values. Global values may be referenced before they
427 // are defined, and if so, the temporary object that they represent is held
428 // here. This is used for forward references of GlobalValues.
429 //
430 typedef std::map<std::pair<const PointerType *,
431 ValID>, GlobalValue*> GlobalRefsType;
432 GlobalRefsType GlobalRefs;
433
434 void ModuleDone() {
435 // If we could not resolve some functions at function compilation time
436 // (calls to functions before they are defined), resolve them now... Types
437 // are resolved when the constant pool has been completely parsed.
438 //
439 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000440 if (TriggerError)
441 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000442
443 // Check to make sure that all global value forward references have been
444 // resolved!
445 //
446 if (!GlobalRefs.empty()) {
447 std::string UndefinedReferences = "Unresolved global references exist:\n";
448
449 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
450 I != E; ++I) {
451 UndefinedReferences += " " + I->first.first->getDescription() + " " +
452 I->first.second.getName() + "\n";
453 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000454 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000455 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000456 }
457
458 Values.clear(); // Clear out function local definitions
459 Types.clear();
460 CurrentModule = 0;
461 }
462
Reid Spencer68a24bd2005-08-27 18:50:39 +0000463 // GetForwardRefForGlobal - Check to see if there is a forward reference
464 // for this global. If so, remove it from the GlobalRefs map and return it.
465 // If not, just return null.
466 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
467 // Check to see if there is a forward reference to this global variable...
468 // if there is, eliminate it and patch the reference to use the new def'n.
469 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
470 GlobalValue *Ret = 0;
471 if (I != GlobalRefs.end()) {
472 Ret = I->second;
473 GlobalRefs.erase(I);
474 }
475 return Ret;
476 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000477
478 bool TypeIsUnresolved(PATypeHolder* PATy) {
479 // If it isn't abstract, its resolved
480 const Type* Ty = PATy->get();
481 if (!Ty->isAbstract())
482 return false;
483 // Traverse the type looking for abstract types. If it isn't abstract then
484 // we don't need to traverse that leg of the type.
485 std::vector<const Type*> WorkList, SeenList;
486 WorkList.push_back(Ty);
487 while (!WorkList.empty()) {
488 const Type* Ty = WorkList.back();
489 SeenList.push_back(Ty);
490 WorkList.pop_back();
491 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
492 // Check to see if this is an unresolved type
493 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
494 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
495 for ( ; I != E; ++I) {
496 if (I->second.get() == OpTy)
497 return true;
498 }
499 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
500 const Type* TheTy = SeqTy->getElementType();
501 if (TheTy->isAbstract() && TheTy != Ty) {
502 std::vector<const Type*>::iterator I = SeenList.begin(),
503 E = SeenList.end();
504 for ( ; I != E; ++I)
505 if (*I == TheTy)
506 break;
507 if (I == E)
508 WorkList.push_back(TheTy);
509 }
510 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
511 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
512 const Type* TheTy = StrTy->getElementType(i);
513 if (TheTy->isAbstract() && TheTy != Ty) {
514 std::vector<const Type*>::iterator I = SeenList.begin(),
515 E = SeenList.end();
516 for ( ; I != E; ++I)
517 if (*I == TheTy)
518 break;
519 if (I == E)
520 WorkList.push_back(TheTy);
521 }
522 }
523 }
524 }
525 return false;
526 }
527
528
Reid Spencer68a24bd2005-08-27 18:50:39 +0000529} CurModule;
530
531static struct PerFunctionInfo {
532 Function *CurrentFunction; // Pointer to current function being created
533
Reid Spencer93c40032007-03-19 18:40:50 +0000534 ValueList Values; // Keep track of #'d definitions
535 unsigned NextValNum;
536 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000537 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000538 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000539 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000540
541 /// BBForwardRefs - When we see forward references to basic blocks, keep
542 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000543 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000544
545 inline PerFunctionInfo() {
546 CurrentFunction = 0;
547 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000548 Linkage = GlobalValue::ExternalLinkage;
549 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000550 }
551
552 inline void FunctionStart(Function *M) {
553 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000554 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000555 }
556
557 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000558 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000559 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000560 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000561 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000562 return;
563 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000564
565 // Resolve all forward references now.
566 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
567
568 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000569 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000570 CurrentFunction = 0;
571 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000572 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000573 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000574 }
575} CurFun; // Info for the current function...
576
577static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
578
579
580//===----------------------------------------------------------------------===//
581// Code to handle definitions of all the types
582//===----------------------------------------------------------------------===//
583
Reid Spencer93c40032007-03-19 18:40:50 +0000584static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
585 // Things that have names or are void typed don't get slot numbers
586 if (V->hasName() || (V->getType() == Type::VoidTy))
587 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000588
Reid Spencer93c40032007-03-19 18:40:50 +0000589 // In the case of function values, we have to allow for the forward reference
590 // of basic blocks, which are included in the numbering. Consequently, we keep
591 // track of the next insertion location with NextValNum. When a BB gets
592 // inserted, it could change the size of the CurFun.Values vector.
593 if (&ValueTab == &CurFun.Values) {
594 if (ValueTab.size() <= CurFun.NextValNum)
595 ValueTab.resize(CurFun.NextValNum+1);
596 ValueTab[CurFun.NextValNum++] = V;
597 return;
598 }
599 // For all other lists, its okay to just tack it on the back of the vector.
600 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000601}
602
603static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
604 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000605 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000606 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000607 if (D.Num < CurModule.Types.size())
608 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000609 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000610 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000611 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
612 D.destroy(); // Free old strdup'd memory...
613 return N;
614 }
615 break;
616 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000617 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000618 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000619 }
620
621 // If we reached here, we referenced either a symbol that we don't know about
622 // or an id number that hasn't been read yet. We may be referencing something
623 // forward, so just create an entry to be resolved later and get to it...
624 //
625 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
626
627
628 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000629 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000630 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000631 return 0;
632 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000633 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000634 return 0;
635 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000636 }
637
Reid Spencer861d9d62006-11-28 07:29:44 +0000638 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000639 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000640 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000641
Reid Spencer861d9d62006-11-28 07:29:44 +0000642 Type *Typ = OpaqueType::get();
643 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
644 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000645 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000646
Reid Spencer93c40032007-03-19 18:40:50 +0000647// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000648// the provided ValID. If the value exists and has already been defined, return
649// it. Otherwise return null.
650//
Reid Spencer93c40032007-03-19 18:40:50 +0000651static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000652 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000653 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000654 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000655 return 0;
656 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000657
658 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000659 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000660 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000661 if (D.Num >= CurFun.Values.size())
662 return 0;
663 Value *Result = CurFun.Values[D.Num];
664 if (Ty != Result->getType()) {
665 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
666 Result->getType()->getDescription() + "' does not match "
667 "expected type, '" + Ty->getDescription() + "'");
668 return 0;
669 }
670 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000671 }
672 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000673 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000674 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000675 Value *Result = CurModule.Values[D.Num];
676 if (Ty != Result->getType()) {
677 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
678 Result->getType()->getDescription() + "' does not match "
679 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000680 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000681 }
682 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000683 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000684
685 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000686 if (!inFunctionScope())
687 return 0;
688 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
689 Value *N = SymTab.lookup(D.Name);
690 if (N == 0)
691 return 0;
692 if (N->getType() != Ty)
693 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000694
695 D.destroy(); // Free old strdup'd memory...
696 return N;
697 }
698 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000699 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
700 Value *N = SymTab.lookup(D.Name);
701 if (N == 0)
702 return 0;
703 if (N->getType() != Ty)
704 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000705
706 D.destroy(); // Free old strdup'd memory...
707 return N;
708 }
709
710 // Check to make sure that "Ty" is an integral type, and that our
711 // value will fit into the specified type...
712 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000713 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000714 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000715 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000716 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000717 return 0;
718 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000719 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000720
721 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000722 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
723 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000724 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000725 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000726 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000727 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000728 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000729 }
730 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000731 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000732 }
733
734 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000735 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000736 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000737 return 0;
738 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000739 return ConstantFP::get(Ty, D.ConstPoolFP);
740
741 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000742 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000743 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000744 return 0;
745 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000746 return ConstantPointerNull::get(cast<PointerType>(Ty));
747
748 case ValID::ConstUndefVal: // Is it an undef value?
749 return UndefValue::get(Ty);
750
Chris Lattner7aa61892005-12-21 17:53:23 +0000751 case ValID::ConstZeroVal: // Is it a zero value?
752 return Constant::getNullValue(Ty);
753
Reid Spencer68a24bd2005-08-27 18:50:39 +0000754 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000755 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000756 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000757 return 0;
758 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000759 return D.ConstantValue;
760
Chris Lattner0e9c3762006-01-25 22:27:16 +0000761 case ValID::InlineAsmVal: { // Inline asm expression
762 const PointerType *PTy = dyn_cast<PointerType>(Ty);
763 const FunctionType *FTy =
764 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000765 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000766 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 return 0;
768 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000769 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
770 D.IAD->HasSideEffects);
771 D.destroy(); // Free InlineAsmDescriptor.
772 return IA;
773 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000774 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000775 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000776 return 0;
777 } // End of switch
778
Reid Spencera9720f52007-02-05 17:04:00 +0000779 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000780 return 0;
781}
782
Reid Spencer93c40032007-03-19 18:40:50 +0000783// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000784// value is not already defined, it "improvises" by creating a placeholder var
785// that looks and acts just like the requested variable. When the value is
786// defined later, all uses of the placeholder variable are replaced with the
787// real thing.
788//
789static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000790 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000791 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000792 return 0;
793 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000794
795 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000796 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000797 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000798 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000799
Reid Spencer5b7e7532006-09-28 19:28:24 +0000800 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000801 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000802 return 0;
803 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000804
805 // If we reached here, we referenced either a symbol that we don't know about
806 // or an id number that hasn't been read yet. We may be referencing something
807 // forward, so just create an entry to be resolved later and get to it...
808 //
809 V = new Argument(Ty);
810
811 // Remember where this forward reference came from. FIXME, shouldn't we try
812 // to recycle these things??
813 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
814 llvmAsmlineno)));
815
816 if (inFunctionScope())
817 InsertValue(V, CurFun.LateResolveValues);
818 else
819 InsertValue(V, CurModule.LateResolveValues);
820 return V;
821}
822
Reid Spencer93c40032007-03-19 18:40:50 +0000823/// defineBBVal - This is a definition of a new basic block with the specified
824/// identifier which must be the same as CurFun.NextValNum, if its numeric.
825static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000826 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000827
Reid Spencer68a24bd2005-08-27 18:50:39 +0000828 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000829
Reid Spencer93c40032007-03-19 18:40:50 +0000830 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000831
Reid Spencer93c40032007-03-19 18:40:50 +0000832 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
833 if (BBI != CurFun.BBForwardRefs.end()) {
834 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000835 // The forward declaration could have been inserted anywhere in the
836 // function: insert it into the correct place now.
837 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
838 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000839
Reid Spencer66728ef2007-03-20 01:13:36 +0000840 // We're about to erase the entry, save the key so we can clean it up.
841 ValID Tmp = BBI->first;
842
Reid Spencer93c40032007-03-19 18:40:50 +0000843 // Erase the forward ref from the map as its no longer "forward"
844 CurFun.BBForwardRefs.erase(ID);
845
Reid Spencer66728ef2007-03-20 01:13:36 +0000846 // The key has been removed from the map but so we don't want to leave
847 // strdup'd memory around so destroy it too.
848 Tmp.destroy();
849
Reid Spencer93c40032007-03-19 18:40:50 +0000850 // If its a numbered definition, bump the number and set the BB value.
851 if (ID.Type == ValID::LocalID) {
852 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
853 InsertValue(BB);
854 }
855
856 ID.destroy();
857 return BB;
858 }
859
860 // We haven't seen this BB before and its first mention is a definition.
861 // Just create it and return it.
862 std::string Name (ID.Type == ValID::LocalName ? ID.Name : "");
863 BB = new BasicBlock(Name, CurFun.CurrentFunction);
864 if (ID.Type == ValID::LocalID) {
865 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
866 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000867 }
Reid Spencer93c40032007-03-19 18:40:50 +0000868
869 ID.destroy(); // Free strdup'd memory
870 return BB;
871}
872
873/// getBBVal - get an existing BB value or create a forward reference for it.
874///
875static BasicBlock *getBBVal(const ValID &ID) {
876 assert(inFunctionScope() && "Can't get basic block at global scope!");
877
878 BasicBlock *BB = 0;
879
880 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
881 if (BBI != CurFun.BBForwardRefs.end()) {
882 BB = BBI->second;
883 } if (ID.Type == ValID::LocalName) {
884 std::string Name = ID.Name;
885 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
886 if (N)
887 if (N->getType()->getTypeID() == Type::LabelTyID)
888 BB = cast<BasicBlock>(N);
889 else
890 GenerateError("Reference to label '" + Name + "' is actually of type '"+
891 N->getType()->getDescription() + "'");
892 } else if (ID.Type == ValID::LocalID) {
893 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
894 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
895 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
896 else
897 GenerateError("Reference to label '%" + utostr(ID.Num) +
898 "' is actually of type '"+
899 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
900 }
901 } else {
902 GenerateError("Illegal label reference " + ID.getName());
903 return 0;
904 }
905
906 // If its already been defined, return it now.
907 if (BB) {
908 ID.destroy(); // Free strdup'd memory.
909 return BB;
910 }
911
912 // Otherwise, this block has not been seen before, create it.
913 std::string Name;
914 if (ID.Type == ValID::LocalName)
915 Name = ID.Name;
916 BB = new BasicBlock(Name, CurFun.CurrentFunction);
917
918 // Insert it in the forward refs map.
919 CurFun.BBForwardRefs[ID] = BB;
920
Reid Spencer68a24bd2005-08-27 18:50:39 +0000921 return BB;
922}
923
924
925//===----------------------------------------------------------------------===//
926// Code to handle forward references in instructions
927//===----------------------------------------------------------------------===//
928//
929// This code handles the late binding needed with statements that reference
930// values not defined yet... for example, a forward branch, or the PHI node for
931// a loop body.
932//
933// This keeps a table (CurFun.LateResolveValues) of all such forward references
934// and back patchs after we are done.
935//
936
937// ResolveDefinitions - If we could not resolve some defs at parsing
938// time (forward branches, phi functions for loops, etc...) resolve the
939// defs now...
940//
941static void
Reid Spencer93c40032007-03-19 18:40:50 +0000942ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000943 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000944 while (!LateResolvers.empty()) {
945 Value *V = LateResolvers.back();
946 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000947
Reid Spencer93c40032007-03-19 18:40:50 +0000948 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
949 CurModule.PlaceHolderInfo.find(V);
950 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000951
Reid Spencer93c40032007-03-19 18:40:50 +0000952 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000953
Reid Spencer93c40032007-03-19 18:40:50 +0000954 Value *TheRealValue = getExistingVal(V->getType(), DID);
955 if (TriggerError)
956 return;
957 if (TheRealValue) {
958 V->replaceAllUsesWith(TheRealValue);
959 delete V;
960 CurModule.PlaceHolderInfo.erase(PHI);
961 } else if (FutureLateResolvers) {
962 // Functions have their unresolved items forwarded to the module late
963 // resolver table
964 InsertValue(V, *FutureLateResolvers);
965 } else {
966 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
967 GenerateError("Reference to an invalid definition: '" +DID.getName()+
968 "' of type '" + V->getType()->getDescription() + "'",
969 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000970 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000971 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000972 GenerateError("Reference to an invalid definition: #" +
973 itostr(DID.Num) + " of type '" +
974 V->getType()->getDescription() + "'",
975 PHI->second.second);
976 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000977 }
978 }
979 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000980 LateResolvers.clear();
981}
982
983// ResolveTypeTo - A brand new type was just declared. This means that (if
984// name is not null) things referencing Name can be resolved. Otherwise, things
985// refering to the number can be resolved. Do this now.
986//
987static void ResolveTypeTo(char *Name, const Type *ToTy) {
988 ValID D;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000989 if (Name) D = ValID::createLocalName(Name);
990 else D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000991
Reid Spencer861d9d62006-11-28 07:29:44 +0000992 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000993 CurModule.LateResolveTypes.find(D);
994 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000995 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000996 CurModule.LateResolveTypes.erase(I);
997 }
998}
999
1000// setValueName - Set the specified value to the name given. The name may be
1001// null potentially, in which case this is a noop. The string passed in is
1002// assumed to be a malloc'd string buffer, and is free'd by this function.
1003//
1004static void setValueName(Value *V, char *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001005 if (!NameStr) return;
1006 std::string Name(NameStr); // Copy string
1007 free(NameStr); // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001008
Reid Spencer41dff5e2007-01-26 08:05:27 +00001009 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001010 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001011 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001012 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001013
Reid Spencera9720f52007-02-05 17:04:00 +00001014 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001015 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1016 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001017 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001018 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001019 return;
1020 }
1021
1022 // Set the name.
1023 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001024}
1025
1026/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1027/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001028static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001029ParseGlobalVariable(char *NameStr,
1030 GlobalValue::LinkageTypes Linkage,
1031 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001032 bool isConstantGlobal, const Type *Ty,
1033 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001034 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001035 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001036 return 0;
1037 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001038
1039 const PointerType *PTy = PointerType::get(Ty);
1040
1041 std::string Name;
1042 if (NameStr) {
1043 Name = NameStr; // Copy string
1044 free(NameStr); // Free old string
1045 }
1046
1047 // See if this global value was forward referenced. If so, recycle the
1048 // object.
1049 ValID ID;
1050 if (!Name.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001051 ID = ValID::createGlobalName((char*)Name.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001052 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001053 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001054 }
1055
1056 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1057 // Move the global to the end of the list, from whereever it was
1058 // previously inserted.
1059 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1060 CurModule.CurrentModule->getGlobalList().remove(GV);
1061 CurModule.CurrentModule->getGlobalList().push_back(GV);
1062 GV->setInitializer(Initializer);
1063 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001064 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001065 GV->setConstant(isConstantGlobal);
1066 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001067 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001068 }
1069
Reid Spenceref9b9a72007-02-05 20:47:22 +00001070 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001071 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001072 // if the global we're parsing has an initializer (is a definition) and
1073 // has external linkage.
1074 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1075 // If there is already a global with external linkage with this name
1076 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1077 // If we allow this GVar to get created, it will be renamed in the
1078 // symbol table because it conflicts with an existing GVar. We can't
1079 // allow redefinition of GVars whose linking indicates that their name
1080 // must stay the same. Issue the error.
1081 GenerateError("Redefinition of global variable named '" + Name +
1082 "' of type '" + Ty->getDescription() + "'");
1083 return 0;
1084 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001085 }
1086
1087 // Otherwise there is no existing GV to use, create one now.
1088 GlobalVariable *GV =
1089 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1090 CurModule.CurrentModule);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001091 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001092 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001093 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001094}
1095
1096// setTypeName - Set the specified type to the name given. The name may be
1097// null potentially, in which case this is a noop. The string passed in is
1098// assumed to be a malloc'd string buffer, and is freed by this function.
1099//
1100// This function returns true if the type has already been defined, but is
1101// allowed to be redefined in the specified context. If the name is a new name
1102// for the type plane, it is inserted and false is returned.
1103static bool setTypeName(const Type *T, char *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001104 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001105 if (NameStr == 0) return false;
1106
1107 std::string Name(NameStr); // Copy string
1108 free(NameStr); // Free old string
1109
1110 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001111 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001112 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001113 return false;
1114 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001115
1116 // Set the type name, checking for conflicts as we do so.
1117 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1118
1119 if (AlreadyExists) { // Inserting a name that is already defined???
1120 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001121 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001122
1123 // There is only one case where this is allowed: when we are refining an
1124 // opaque type. In this case, Existing will be an opaque type.
1125 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1126 // We ARE replacing an opaque type!
1127 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1128 return true;
1129 }
1130
1131 // Otherwise, this is an attempt to redefine a type. That's okay if
1132 // the redefinition is identical to the original. This will be so if
1133 // Existing and T point to the same Type object. In this one case we
1134 // allow the equivalent redefinition.
1135 if (Existing == T) return true; // Yes, it's equal.
1136
1137 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001138 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001139 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001140 }
1141
1142 return false;
1143}
1144
1145//===----------------------------------------------------------------------===//
1146// Code for handling upreferences in type names...
1147//
1148
1149// TypeContains - Returns true if Ty directly contains E in it.
1150//
1151static bool TypeContains(const Type *Ty, const Type *E) {
1152 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1153 E) != Ty->subtype_end();
1154}
1155
1156namespace {
1157 struct UpRefRecord {
1158 // NestingLevel - The number of nesting levels that need to be popped before
1159 // this type is resolved.
1160 unsigned NestingLevel;
1161
1162 // LastContainedTy - This is the type at the current binding level for the
1163 // type. Every time we reduce the nesting level, this gets updated.
1164 const Type *LastContainedTy;
1165
1166 // UpRefTy - This is the actual opaque type that the upreference is
1167 // represented with.
1168 OpaqueType *UpRefTy;
1169
1170 UpRefRecord(unsigned NL, OpaqueType *URTy)
1171 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1172 };
1173}
1174
1175// UpRefs - A list of the outstanding upreferences that need to be resolved.
1176static std::vector<UpRefRecord> UpRefs;
1177
1178/// HandleUpRefs - Every time we finish a new layer of types, this function is
1179/// called. It loops through the UpRefs vector, which is a list of the
1180/// currently active types. For each type, if the up reference is contained in
1181/// the newly completed type, we decrement the level count. When the level
1182/// count reaches zero, the upreferenced type is the type that is passed in:
1183/// thus we can complete the cycle.
1184///
1185static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001186 // If Ty isn't abstract, or if there are no up-references in it, then there is
1187 // nothing to resolve here.
1188 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1189
Reid Spencer68a24bd2005-08-27 18:50:39 +00001190 PATypeHolder Ty(ty);
1191 UR_OUT("Type '" << Ty->getDescription() <<
1192 "' newly formed. Resolving upreferences.\n" <<
1193 UpRefs.size() << " upreferences active!\n");
1194
1195 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1196 // to zero), we resolve them all together before we resolve them to Ty. At
1197 // the end of the loop, if there is anything to resolve to Ty, it will be in
1198 // this variable.
1199 OpaqueType *TypeToResolve = 0;
1200
1201 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1202 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1203 << UpRefs[i].second->getDescription() << ") = "
1204 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1205 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1206 // Decrement level of upreference
1207 unsigned Level = --UpRefs[i].NestingLevel;
1208 UpRefs[i].LastContainedTy = Ty;
1209 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1210 if (Level == 0) { // Upreference should be resolved!
1211 if (!TypeToResolve) {
1212 TypeToResolve = UpRefs[i].UpRefTy;
1213 } else {
1214 UR_OUT(" * Resolving upreference for "
1215 << UpRefs[i].second->getDescription() << "\n";
1216 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1217 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1218 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1219 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1220 }
1221 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1222 --i; // Do not skip the next element...
1223 }
1224 }
1225 }
1226
1227 if (TypeToResolve) {
1228 UR_OUT(" * Resolving upreference for "
1229 << UpRefs[i].second->getDescription() << "\n";
1230 std::string OldName = TypeToResolve->getDescription());
1231 TypeToResolve->refineAbstractTypeTo(Ty);
1232 }
1233
1234 return Ty;
1235}
1236
Reid Spencer68a24bd2005-08-27 18:50:39 +00001237//===----------------------------------------------------------------------===//
1238// RunVMAsmParser - Define an interface to this parser
1239//===----------------------------------------------------------------------===//
1240//
Reid Spencer14310612006-12-31 05:40:51 +00001241static Module* RunParser(Module * M);
1242
Reid Spencer68a24bd2005-08-27 18:50:39 +00001243Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1244 set_scan_file(F);
1245
1246 CurFilename = Filename;
1247 return RunParser(new Module(CurFilename));
1248}
1249
1250Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1251 set_scan_string(AsmString);
1252
1253 CurFilename = "from_memory";
1254 if (M == NULL) {
1255 return RunParser(new Module (CurFilename));
1256 } else {
1257 return RunParser(M);
1258 }
1259}
1260
1261
Reid Spencer38c91a92007-02-28 02:24:54 +00001262
1263/* Enabling traces. */
1264#ifndef YYDEBUG
1265# define YYDEBUG 0
1266#endif
1267
1268/* Enabling verbose error messages. */
1269#ifdef YYERROR_VERBOSE
1270# undef YYERROR_VERBOSE
1271# define YYERROR_VERBOSE 1
1272#else
1273# define YYERROR_VERBOSE 0
1274#endif
1275
1276/* Enabling the token table. */
1277#ifndef YYTOKEN_TABLE
1278# define YYTOKEN_TABLE 0
1279#endif
1280
1281#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001282#line 939 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00001283typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001284 llvm::Module *ModuleVal;
1285 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001286 llvm::BasicBlock *BasicBlockVal;
1287 llvm::TerminatorInst *TermInstVal;
1288 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001289 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001290
Reid Spencera132e042006-12-03 05:46:11 +00001291 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001292 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001293 llvm::PATypeHolder *TypeVal;
1294 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001295 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001296 llvm::ArgListType *ArgList;
1297 llvm::TypeWithAttrs TypeWithAttrs;
1298 llvm::TypeWithAttrsList *TypeWithAttrsList;
1299 llvm::ValueRefList *ValueRefList;
1300
Reid Spencer68a24bd2005-08-27 18:50:39 +00001301 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001302 std::list<std::pair<llvm::Value*,
1303 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001304 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001305 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001306
1307 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001308 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer14310612006-12-31 05:40:51 +00001309 llvm::FunctionType::ParameterAttributes ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001310 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001311 int64_t SInt64Val;
1312 uint64_t UInt64Val;
1313 int SIntVal;
1314 unsigned UIntVal;
1315 double FPVal;
1316 bool BoolVal;
1317
1318 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001319 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001320
Reid Spencera132e042006-12-03 05:46:11 +00001321 llvm::Instruction::BinaryOps BinaryOpVal;
1322 llvm::Instruction::TermOps TermOpVal;
1323 llvm::Instruction::MemoryOps MemOpVal;
1324 llvm::Instruction::CastOps CastOpVal;
1325 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001326 llvm::ICmpInst::Predicate IPredicate;
1327 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner9d2fda62007-02-13 05:53:56 +00001328} YYSTYPE;
Reid Spencer38c91a92007-02-28 02:24:54 +00001329/* Line 196 of yacc.c. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001330#line 1331 "llvmAsmParser.tab.c"
Reid Spencer38c91a92007-02-28 02:24:54 +00001331# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1332# define YYSTYPE_IS_DECLARED 1
1333# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001334#endif
1335
Reid Spencer41dff5e2007-01-26 08:05:27 +00001336
Reid Spencer68a24bd2005-08-27 18:50:39 +00001337
Reid Spencer38c91a92007-02-28 02:24:54 +00001338/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001339
1340
Reid Spencer38c91a92007-02-28 02:24:54 +00001341/* Line 219 of yacc.c. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001342#line 1343 "llvmAsmParser.tab.c"
Reid Spencer41dff5e2007-01-26 08:05:27 +00001343
Reid Spencer38c91a92007-02-28 02:24:54 +00001344#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1345# define YYSIZE_T __SIZE_TYPE__
1346#endif
1347#if ! defined (YYSIZE_T) && defined (size_t)
1348# define YYSIZE_T size_t
1349#endif
1350#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1351# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1352# define YYSIZE_T size_t
1353#endif
1354#if ! defined (YYSIZE_T)
1355# define YYSIZE_T unsigned int
1356#endif
Chris Lattner9d2fda62007-02-13 05:53:56 +00001357
Reid Spencer38c91a92007-02-28 02:24:54 +00001358#ifndef YY_
1359# if YYENABLE_NLS
1360# if ENABLE_NLS
1361# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1362# define YY_(msgid) dgettext ("bison-runtime", msgid)
1363# endif
1364# endif
1365# ifndef YY_
1366# define YY_(msgid) msgid
1367# endif
1368#endif
1369
1370#if ! defined (yyoverflow) || YYERROR_VERBOSE
1371
1372/* The parser invokes alloca or malloc; define the necessary symbols. */
1373
1374# ifdef YYSTACK_USE_ALLOCA
1375# if YYSTACK_USE_ALLOCA
1376# ifdef __GNUC__
1377# define YYSTACK_ALLOC __builtin_alloca
1378# else
1379# define YYSTACK_ALLOC alloca
1380# if defined (__STDC__) || defined (__cplusplus)
1381# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1382# define YYINCLUDED_STDLIB_H
1383# endif
1384# endif
1385# endif
1386# endif
1387
1388# ifdef YYSTACK_ALLOC
1389 /* Pacify GCC's `empty if-body' warning. */
1390# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1391# ifndef YYSTACK_ALLOC_MAXIMUM
1392 /* The OS might guarantee only one guard page at the bottom of the stack,
1393 and a page size can be as small as 4096 bytes. So we cannot safely
1394 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1395 to allow for a few compiler-allocated temporary stack slots. */
1396# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1397# endif
1398# else
1399# define YYSTACK_ALLOC YYMALLOC
1400# define YYSTACK_FREE YYFREE
1401# ifndef YYSTACK_ALLOC_MAXIMUM
1402# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1403# endif
1404# ifdef __cplusplus
1405extern "C" {
1406# endif
1407# ifndef YYMALLOC
1408# define YYMALLOC malloc
1409# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1410 && (defined (__STDC__) || defined (__cplusplus)))
1411void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1412# endif
1413# endif
1414# ifndef YYFREE
1415# define YYFREE free
1416# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1417 && (defined (__STDC__) || defined (__cplusplus)))
1418void free (void *); /* INFRINGES ON USER NAME SPACE */
1419# endif
1420# endif
1421# ifdef __cplusplus
1422}
1423# endif
1424# endif
1425#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1426
1427
1428#if (! defined (yyoverflow) \
1429 && (! defined (__cplusplus) \
1430 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1431
1432/* A type that is properly aligned for any stack member. */
1433union yyalloc
1434{
1435 short int yyss;
1436 YYSTYPE yyvs;
1437 };
1438
1439/* The size of the maximum gap between one aligned stack and the next. */
1440# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1441
1442/* The size of an array large to enough to hold all stacks, each with
1443 N elements. */
1444# define YYSTACK_BYTES(N) \
1445 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1446 + YYSTACK_GAP_MAXIMUM)
1447
1448/* Copy COUNT objects from FROM to TO. The source and destination do
1449 not overlap. */
1450# ifndef YYCOPY
1451# if defined (__GNUC__) && 1 < __GNUC__
1452# define YYCOPY(To, From, Count) \
1453 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1454# else
1455# define YYCOPY(To, From, Count) \
1456 do \
1457 { \
1458 YYSIZE_T yyi; \
1459 for (yyi = 0; yyi < (Count); yyi++) \
1460 (To)[yyi] = (From)[yyi]; \
1461 } \
1462 while (0)
1463# endif
1464# endif
1465
1466/* Relocate STACK from its old location to the new one. The
1467 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1468 elements in the stack, and YYPTR gives the new location of the
1469 stack. Advance YYPTR to a properly aligned location for the next
1470 stack. */
1471# define YYSTACK_RELOCATE(Stack) \
1472 do \
1473 { \
1474 YYSIZE_T yynewbytes; \
1475 YYCOPY (&yyptr->Stack, Stack, yysize); \
1476 Stack = &yyptr->Stack; \
1477 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1478 yyptr += yynewbytes / sizeof (*yyptr); \
1479 } \
1480 while (0)
Chris Lattner9d2fda62007-02-13 05:53:56 +00001481
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001482#endif
1483
Reid Spencer38c91a92007-02-28 02:24:54 +00001484#if defined (__STDC__) || defined (__cplusplus)
1485 typedef signed char yysigned_char;
Reid Spencer5cbf9852007-01-30 20:08:39 +00001486#else
Reid Spencer38c91a92007-02-28 02:24:54 +00001487 typedef short int yysigned_char;
Reid Spencer5cbf9852007-01-30 20:08:39 +00001488#endif
1489
Reid Spencer38c91a92007-02-28 02:24:54 +00001490/* YYFINAL -- State number of the termination state. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001491#define YYFINAL 39
Reid Spencer38c91a92007-02-28 02:24:54 +00001492/* YYLAST -- Last index in YYTABLE. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001493#define YYLAST 1441
Reid Spencer38c91a92007-02-28 02:24:54 +00001494
1495/* YYNTOKENS -- Number of terminals. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001496#define YYNTOKENS 148
Reid Spencer38c91a92007-02-28 02:24:54 +00001497/* YYNNTS -- Number of nonterminals. */
1498#define YYNNTS 78
1499/* YYNRULES -- Number of rules. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001500#define YYNRULES 286
Reid Spencer38c91a92007-02-28 02:24:54 +00001501/* YYNRULES -- Number of states. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001502#define YYNSTATES 559
Reid Spencer38c91a92007-02-28 02:24:54 +00001503
1504/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1505#define YYUNDEFTOK 2
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001506#define YYMAXUTOK 388
Reid Spencer38c91a92007-02-28 02:24:54 +00001507
1508#define YYTRANSLATE(YYX) \
1509 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1510
1511/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1512static const unsigned char yytranslate[] =
1513{
1514 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1516 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001518 138, 139, 136, 2, 135, 2, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001520 143, 134, 144, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001521 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1522 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001523 2, 140, 137, 142, 2, 2, 2, 2, 2, 147,
Reid Spencer38c91a92007-02-28 02:24:54 +00001524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001526 141, 2, 2, 145, 2, 146, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001527 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1539 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1540 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1541 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1542 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1543 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1544 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1545 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1546 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1547 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1548 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1549 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1550 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1551 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001552 125, 126, 127, 128, 129, 130, 131, 132, 133
Reid Spencer38c91a92007-02-28 02:24:54 +00001553};
1554
1555#if YYDEBUG
1556/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1557 YYRHS. */
1558static const unsigned short int yyprhs[] =
1559{
1560 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1561 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1562 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1563 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1564 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1565 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1566 119, 121, 122, 125, 126, 128, 130, 133, 134, 136,
1567 138, 140, 142, 144, 146, 148, 150, 151, 153, 154,
1568 156, 158, 159, 161, 163, 165, 167, 168, 170, 172,
1569 174, 176, 178, 181, 183, 185, 187, 189, 190, 193,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001570 195, 197, 199, 200, 203, 204, 207, 208, 212, 215,
1571 216, 218, 219, 223, 225, 228, 230, 232, 234, 236,
1572 238, 240, 243, 245, 248, 254, 260, 266, 272, 276,
1573 279, 285, 290, 293, 295, 297, 299, 303, 305, 309,
1574 311, 312, 314, 318, 323, 327, 331, 336, 341, 345,
1575 352, 358, 361, 364, 367, 370, 373, 376, 379, 382,
1576 385, 388, 391, 394, 401, 407, 416, 423, 430, 438,
1577 446, 453, 462, 471, 475, 477, 479, 481, 483, 484,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001578 486, 489, 490, 494, 495, 499, 503, 507, 511, 512,
1579 519, 520, 528, 529, 537, 540, 544, 546, 550, 554,
1580 558, 562, 564, 565, 571, 575, 577, 581, 583, 584,
1581 594, 596, 598, 603, 605, 607, 610, 614, 615, 617,
1582 619, 621, 623, 625, 627, 629, 631, 633, 637, 639,
1583 645, 647, 649, 651, 653, 655, 657, 660, 663, 666,
1584 670, 673, 674, 676, 679, 682, 686, 696, 706, 715,
1585 730, 732, 734, 741, 747, 750, 757, 765, 769, 775,
1586 776, 777, 781, 784, 786, 792, 798, 805, 812, 817,
1587 824, 829, 834, 841, 848, 851, 860, 862, 864, 865,
1588 869, 876, 880, 887, 890, 895, 902
Reid Spencer38c91a92007-02-28 02:24:54 +00001589};
1590
1591/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1592static const short int yyrhs[] =
1593{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001594 188, 0, -1, 67, -1, 68, -1, 69, -1, 70,
1595 -1, 71, -1, 72, -1, 73, -1, 74, -1, 75,
1596 -1, 79, -1, 80, -1, 81, -1, 76, -1, 77,
1597 -1, 78, -1, 110, -1, 111, -1, 112, -1, 113,
1598 -1, 114, -1, 115, -1, 116, -1, 117, -1, 118,
1599 -1, 119, -1, 120, -1, 121, -1, 84, -1, 85,
1600 -1, 86, -1, 87, -1, 88, -1, 89, -1, 90,
1601 -1, 91, -1, 92, -1, 93, -1, 94, -1, 95,
1602 -1, 96, -1, 97, -1, 98, -1, 99, -1, 100,
1603 -1, 101, -1, 102, -1, 103, -1, 90, -1, 91,
1604 -1, 92, -1, 93, -1, 22, -1, 23, -1, 11,
1605 -1, 12, -1, 13, -1, 16, -1, 19, -1, 156,
1606 -1, -1, 156, 134, -1, -1, 17, -1, 20, -1,
1607 159, 134, -1, -1, 36, -1, 38, -1, 37, -1,
1608 39, -1, 41, -1, 40, -1, 42, -1, 44, -1,
1609 -1, 133, -1, -1, 40, -1, 42, -1, -1, 36,
1610 -1, 37, -1, 38, -1, 41, -1, -1, 55, -1,
1611 56, -1, 57, -1, 58, -1, 59, -1, 54, 4,
1612 -1, 111, -1, 112, -1, 129, -1, 130, -1, -1,
1613 168, 167, -1, 128, -1, 131, -1, 167, -1, -1,
1614 170, 169, -1, -1, 47, 4, -1, -1, 135, 47,
1615 4, -1, 30, 19, -1, -1, 173, -1, -1, 135,
1616 176, 175, -1, 173, -1, 47, 4, -1, 11, -1,
1617 12, -1, 13, -1, 14, -1, 43, -1, 177, -1,
1618 178, 136, -1, 210, -1, 137, 4, -1, 178, 138,
1619 182, 139, 170, -1, 10, 138, 182, 139, 170, -1,
1620 140, 4, 141, 178, 142, -1, 143, 4, 141, 178,
1621 144, -1, 145, 183, 146, -1, 145, 146, -1, 143,
1622 145, 183, 146, 144, -1, 143, 145, 146, 144, -1,
1623 178, 168, -1, 178, -1, 10, -1, 179, -1, 181,
1624 135, 179, -1, 181, -1, 181, 135, 33, -1, 33,
1625 -1, -1, 178, -1, 183, 135, 178, -1, 178, 140,
1626 186, 142, -1, 178, 140, 142, -1, 178, 147, 19,
1627 -1, 178, 143, 186, 144, -1, 178, 145, 186, 146,
1628 -1, 178, 145, 146, -1, 178, 143, 145, 186, 146,
1629 144, -1, 178, 143, 145, 146, 144, -1, 178, 34,
1630 -1, 178, 35, -1, 178, 210, -1, 178, 185, -1,
1631 178, 21, -1, 154, 3, -1, 154, 5, -1, 154,
1632 4, -1, 154, 6, -1, 11, 22, -1, 11, 23,
1633 -1, 155, 9, -1, 151, 138, 184, 32, 178, 139,
1634 -1, 109, 138, 184, 221, 139, -1, 123, 138, 184,
1635 135, 184, 135, 184, 139, -1, 149, 138, 184, 135,
1636 184, 139, -1, 150, 138, 184, 135, 184, 139, -1,
1637 82, 152, 138, 184, 135, 184, 139, -1, 83, 153,
1638 138, 184, 135, 184, 139, -1, 125, 138, 184, 135,
1639 184, 139, -1, 126, 138, 184, 135, 184, 135, 184,
1640 139, -1, 127, 138, 184, 135, 184, 135, 184, 139,
1641 -1, 186, 135, 184, -1, 184, -1, 28, -1, 29,
1642 -1, 189, -1, -1, 190, -1, 189, 190, -1, -1,
1643 27, 191, 206, -1, -1, 26, 192, 207, -1, 52,
1644 51, 196, -1, 158, 15, 178, -1, 158, 15, 10,
1645 -1, -1, 160, 163, 187, 184, 193, 175, -1, -1,
1646 160, 161, 163, 187, 184, 194, 175, -1, -1, 160,
1647 162, 163, 187, 178, 195, 175, -1, 45, 197, -1,
1648 48, 134, 198, -1, 19, -1, 46, 134, 19, -1,
1649 60, 134, 19, -1, 140, 199, 142, -1, 199, 135,
1650 19, -1, 19, -1, -1, 200, 135, 178, 168, 157,
1651 -1, 178, 168, 157, -1, 200, -1, 200, 135, 33,
1652 -1, 33, -1, -1, 166, 180, 159, 138, 201, 139,
1653 170, 174, 171, -1, 24, -1, 145, -1, 165, 163,
1654 202, 203, -1, 25, -1, 146, -1, 213, 205, -1,
1655 164, 163, 202, -1, -1, 53, -1, 3, -1, 4,
1656 -1, 9, -1, 22, -1, 23, -1, 34, -1, 35,
1657 -1, 21, -1, 143, 186, 144, -1, 185, -1, 51,
1658 208, 19, 135, 19, -1, 7, -1, 8, -1, 156,
1659 -1, 159, -1, 210, -1, 209, -1, 178, 211, -1,
1660 213, 214, -1, 204, 214, -1, 215, 158, 216, -1,
1661 215, 218, -1, -1, 18, -1, 61, 212, -1, 61,
1662 10, -1, 62, 14, 211, -1, 62, 11, 211, 135,
1663 14, 211, 135, 14, 211, -1, 63, 154, 211, 135,
1664 14, 211, 140, 217, 142, -1, 63, 154, 211, 135,
1665 14, 211, 140, 142, -1, 64, 166, 180, 211, 138,
1666 220, 139, 170, 32, 14, 211, 65, 14, 211, -1,
1667 65, -1, 66, -1, 217, 154, 209, 135, 14, 211,
1668 -1, 154, 209, 135, 14, 211, -1, 158, 223, -1,
1669 178, 140, 211, 135, 211, 142, -1, 219, 135, 140,
1670 211, 135, 211, 142, -1, 178, 211, 168, -1, 220,
1671 135, 178, 211, 168, -1, -1, -1, 221, 135, 212,
1672 -1, 50, 49, -1, 49, -1, 149, 178, 211, 135,
1673 211, -1, 150, 178, 211, 135, 211, -1, 82, 152,
1674 178, 211, 135, 211, -1, 83, 153, 178, 211, 135,
1675 211, -1, 151, 212, 32, 178, -1, 123, 212, 135,
1676 212, 135, 212, -1, 124, 212, 135, 178, -1, 125,
1677 212, 135, 212, -1, 126, 212, 135, 212, 135, 212,
1678 -1, 127, 212, 135, 212, 135, 212, -1, 122, 219,
1679 -1, 222, 166, 180, 211, 138, 220, 139, 170, -1,
1680 225, -1, 31, -1, -1, 104, 178, 172, -1, 104,
1681 178, 135, 11, 211, 172, -1, 105, 178, 172, -1,
1682 105, 178, 135, 11, 211, 172, -1, 106, 212, -1,
1683 224, 107, 178, 211, -1, 224, 108, 212, 135, 178,
1684 211, -1, 109, 178, 211, 221, -1
Reid Spencer38c91a92007-02-28 02:24:54 +00001685};
1686
1687/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1688static const unsigned short int yyrline[] =
1689{
Reid Spencer66728ef2007-03-20 01:13:36 +00001690 0, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093,
1691 1093, 1094, 1094, 1094, 1094, 1094, 1094, 1095, 1095, 1095,
1692 1095, 1095, 1095, 1096, 1096, 1096, 1096, 1096, 1096, 1099,
1693 1099, 1100, 1100, 1101, 1101, 1102, 1102, 1103, 1103, 1107,
1694 1107, 1108, 1108, 1109, 1109, 1110, 1110, 1111, 1111, 1112,
1695 1112, 1113, 1113, 1114, 1115, 1120, 1121, 1121, 1123, 1123,
1696 1124, 1124, 1128, 1132, 1137, 1137, 1139, 1143, 1149, 1150,
1697 1151, 1152, 1153, 1157, 1158, 1159, 1163, 1164, 1168, 1169,
1698 1170, 1174, 1175, 1176, 1177, 1178, 1181, 1182, 1183, 1184,
1699 1185, 1186, 1187, 1194, 1195, 1196, 1197, 1200, 1201, 1206,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001700 1207, 1208, 1211, 1212, 1219, 1220, 1226, 1227, 1235, 1243,
1701 1244, 1249, 1250, 1251, 1256, 1269, 1269, 1269, 1269, 1272,
1702 1276, 1280, 1287, 1292, 1300, 1319, 1338, 1343, 1355, 1365,
1703 1369, 1379, 1386, 1393, 1400, 1405, 1410, 1417, 1418, 1425,
1704 1432, 1440, 1446, 1458, 1486, 1502, 1531, 1559, 1584, 1603,
1705 1629, 1649, 1661, 1668, 1734, 1744, 1754, 1760, 1770, 1776,
1706 1786, 1791, 1796, 1804, 1816, 1838, 1846, 1852, 1863, 1868,
1707 1873, 1879, 1885, 1894, 1898, 1906, 1906, 1917, 1922, 1930,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001708 1931, 1935, 1935, 1939, 1939, 1942, 1945, 1969, 1980, 1980,
1709 1990, 1990, 1998, 1998, 2008, 2011, 2017, 2030, 2034, 2039,
1710 2041, 2046, 2051, 2060, 2070, 2081, 2085, 2094, 2103, 2108,
1711 2220, 2220, 2222, 2231, 2231, 2233, 2238, 2250, 2254, 2259,
1712 2263, 2267, 2271, 2275, 2279, 2283, 2287, 2291, 2316, 2320,
1713 2334, 2338, 2342, 2346, 2352, 2352, 2358, 2367, 2371, 2380,
1714 2389, 2398, 2402, 2407, 2411, 2415, 2420, 2430, 2449, 2458,
1715 2527, 2531, 2538, 2549, 2562, 2572, 2583, 2593, 2602, 2611,
1716 2614, 2615, 2622, 2626, 2631, 2652, 2669, 2683, 2697, 2709,
1717 2717, 2724, 2730, 2736, 2742, 2757, 2821, 2826, 2830, 2837,
1718 2844, 2852, 2859, 2867, 2875, 2889, 2906
Reid Spencer38c91a92007-02-28 02:24:54 +00001719};
1720#endif
1721
1722#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1723/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1724 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1725static const char *const yytname[] =
1726{
1727 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1728 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1729 "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001730 "STRINGCONSTANT", "ATSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1731 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1732 "CONSTANT", "SECTION", "VOLATILE", "TO", "DOTDOTDOT", "NULL_TOK",
1733 "UNDEF", "INTERNAL", "LINKONCE", "WEAK", "APPENDING", "DLLIMPORT",
1734 "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", "EXTERNAL", "TARGET", "TRIPLE",
1735 "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT",
1736 "CC_TOK", "CCC_TOK", "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK",
1737 "X86_FASTCALLCC_TOK", "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE",
1738 "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV",
1739 "UREM", "SREM", "FREM", "AND", "OR", "XOR", "SHL", "LSHR", "ASHR",
1740 "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT",
1741 "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO",
1742 "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE",
1743 "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST",
1744 "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT",
1745 "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT",
1746 "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET", "NOUNWIND", "DEFAULT",
1747 "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'",
1748 "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps",
1749 "LogicalOps", "CastOps", "IPredicates", "FPredicates", "IntType",
1750 "FPType", "LocalName", "OptLocalName", "OptLocalAssign", "GlobalName",
1751 "OptGlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1752 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1753 "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr",
1754 "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString", "OptSection",
1755 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1756 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
1757 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "Module",
1758 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1759 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1760 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1761 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
Reid Spencer38c91a92007-02-28 02:24:54 +00001762 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1763 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1764 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1765 "OptVolatile", "MemoryInst", 0
1766};
1767#endif
1768
1769# ifdef YYPRINT
1770/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1771 token YYLEX-NUM. */
1772static const unsigned short int yytoknum[] =
1773{
1774 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1775 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1776 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1777 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1778 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1779 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1780 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1781 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1782 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1783 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1784 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1785 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1786 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001787 385, 386, 387, 388, 61, 44, 42, 92, 40, 41,
1788 91, 120, 93, 60, 62, 123, 125, 99
Reid Spencer38c91a92007-02-28 02:24:54 +00001789};
1790# endif
1791
1792/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1793static const unsigned char yyr1[] =
1794{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001795 0, 148, 149, 149, 149, 149, 149, 149, 149, 149,
1796 149, 150, 150, 150, 150, 150, 150, 151, 151, 151,
1797 151, 151, 151, 151, 151, 151, 151, 151, 151, 152,
Reid Spencer38c91a92007-02-28 02:24:54 +00001798 152, 152, 152, 152, 152, 152, 152, 152, 152, 153,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001799 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
1800 153, 153, 153, 153, 153, 154, 155, 155, 156, 156,
1801 157, 157, 158, 158, 159, 159, 160, 160, 161, 161,
1802 161, 161, 161, 162, 162, 162, 163, 163, 164, 164,
1803 164, 165, 165, 165, 165, 165, 166, 166, 166, 166,
1804 166, 166, 166, 167, 167, 167, 167, 168, 168, 169,
1805 169, 169, 170, 170, 171, 171, 172, 172, 173, 174,
1806 174, 175, 175, 176, 176, 177, 177, 177, 177, 178,
1807 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
1808 178, 178, 179, 180, 180, 181, 181, 182, 182, 182,
1809 182, 183, 183, 184, 184, 184, 184, 184, 184, 184,
1810 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
1811 184, 184, 184, 185, 185, 185, 185, 185, 185, 185,
1812 185, 185, 185, 186, 186, 187, 187, 188, 188, 189,
1813 189, 191, 190, 192, 190, 190, 190, 190, 193, 190,
1814 194, 190, 195, 190, 190, 190, 196, 197, 197, 198,
1815 199, 199, 199, 200, 200, 201, 201, 201, 201, 202,
1816 203, 203, 204, 205, 205, 206, 207, 208, 208, 209,
1817 209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
1818 210, 210, 210, 210, 211, 211, 212, 213, 213, 214,
1819 215, 215, 215, 216, 216, 216, 216, 216, 216, 216,
1820 216, 216, 217, 217, 218, 219, 219, 220, 220, 220,
1821 221, 221, 222, 222, 223, 223, 223, 223, 223, 223,
1822 223, 223, 223, 223, 223, 223, 223, 224, 224, 225,
1823 225, 225, 225, 225, 225, 225, 225
Reid Spencer38c91a92007-02-28 02:24:54 +00001824};
1825
1826/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1827static const unsigned char yyr2[] =
1828{
1829 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1830 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1831 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1832 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1833 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1834 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1835 1, 0, 2, 0, 1, 1, 2, 0, 1, 1,
1836 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
1837 1, 0, 1, 1, 1, 1, 0, 1, 1, 1,
1838 1, 1, 2, 1, 1, 1, 1, 0, 2, 1,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001839 1, 1, 0, 2, 0, 2, 0, 3, 2, 0,
1840 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1841 1, 2, 1, 2, 5, 5, 5, 5, 3, 2,
1842 5, 4, 2, 1, 1, 1, 3, 1, 3, 1,
1843 0, 1, 3, 4, 3, 3, 4, 4, 3, 6,
1844 5, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1845 2, 2, 2, 6, 5, 8, 6, 6, 7, 7,
1846 6, 8, 8, 3, 1, 1, 1, 1, 0, 1,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001847 2, 0, 3, 0, 3, 3, 3, 3, 0, 6,
1848 0, 7, 0, 7, 2, 3, 1, 3, 3, 3,
1849 3, 1, 0, 5, 3, 1, 3, 1, 0, 9,
1850 1, 1, 4, 1, 1, 2, 3, 0, 1, 1,
1851 1, 1, 1, 1, 1, 1, 1, 3, 1, 5,
1852 1, 1, 1, 1, 1, 1, 2, 2, 2, 3,
1853 2, 0, 1, 2, 2, 3, 9, 9, 8, 14,
1854 1, 1, 6, 5, 2, 6, 7, 3, 5, 0,
1855 0, 3, 2, 1, 5, 5, 6, 6, 4, 6,
1856 4, 4, 6, 6, 2, 8, 1, 1, 0, 3,
1857 6, 3, 6, 2, 4, 6, 4
Reid Spencer38c91a92007-02-28 02:24:54 +00001858};
1859
1860/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1861 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1862 means the default is an error. */
1863static const unsigned short int yydefact[] =
1864{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001865 67, 58, 64, 59, 65, 183, 181, 0, 0, 0,
1866 0, 0, 0, 76, 0, 67, 179, 78, 81, 0,
1867 0, 194, 0, 0, 62, 0, 66, 68, 70, 69,
1868 71, 73, 72, 74, 75, 77, 76, 76, 0, 1,
1869 180, 79, 80, 76, 184, 82, 83, 84, 85, 76,
1870 241, 182, 241, 0, 0, 202, 195, 196, 185, 230,
1871 231, 187, 115, 116, 117, 118, 119, 0, 0, 0,
1872 0, 232, 233, 120, 186, 122, 0, 0, 175, 176,
1873 0, 86, 86, 242, 238, 63, 213, 214, 215, 237,
1874 197, 198, 201, 0, 140, 123, 0, 0, 0, 0,
1875 129, 141, 0, 121, 140, 0, 0, 115, 116, 117,
1876 0, 0, 0, 188, 0, 87, 88, 89, 90, 91,
1877 0, 216, 0, 278, 240, 0, 199, 139, 97, 135,
1878 137, 0, 0, 0, 0, 0, 0, 128, 0, 190,
1879 192, 160, 161, 156, 158, 157, 159, 162, 155, 151,
1880 152, 2, 3, 4, 5, 6, 7, 8, 9, 10,
1881 14, 15, 16, 11, 12, 13, 0, 0, 0, 17,
1882 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1883 28, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1884 0, 0, 154, 153, 111, 92, 134, 133, 0, 210,
1885 211, 212, 277, 263, 0, 0, 0, 0, 86, 250,
1886 251, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1887 0, 0, 0, 0, 0, 0, 239, 86, 254, 0,
1888 276, 200, 132, 0, 102, 0, 0, 131, 0, 142,
1889 102, 111, 111, 29, 30, 31, 32, 33, 34, 35,
1890 36, 37, 38, 0, 53, 54, 49, 50, 51, 52,
1891 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
1892 0, 0, 0, 0, 0, 0, 144, 174, 0, 0,
1893 0, 148, 0, 145, 0, 0, 0, 0, 189, 0,
1894 262, 244, 0, 243, 0, 0, 55, 0, 0, 0,
1895 0, 106, 106, 283, 0, 0, 274, 0, 0, 0,
1896 0, 0, 0, 0, 0, 0, 0, 0, 93, 94,
1897 95, 96, 98, 138, 136, 125, 126, 127, 130, 124,
1898 191, 193, 0, 0, 260, 0, 0, 0, 0, 0,
1899 143, 129, 141, 0, 146, 147, 0, 0, 0, 0,
1900 0, 113, 111, 208, 219, 220, 221, 226, 222, 223,
1901 224, 225, 217, 0, 228, 235, 234, 236, 0, 245,
1902 0, 0, 0, 0, 0, 279, 0, 281, 260, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00001903 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001904 0, 0, 99, 100, 101, 103, 0, 0, 0, 0,
1905 0, 0, 0, 173, 150, 0, 0, 0, 0, 108,
1906 114, 112, 207, 97, 205, 0, 218, 0, 0, 0,
1907 0, 0, 0, 0, 0, 0, 0, 286, 0, 0,
1908 0, 270, 271, 0, 0, 0, 0, 268, 0, 284,
1909 0, 0, 0, 0, 164, 0, 0, 0, 0, 149,
1910 0, 0, 0, 61, 0, 102, 0, 227, 0, 0,
1911 259, 0, 0, 106, 107, 106, 0, 0, 0, 0,
1912 0, 264, 265, 259, 0, 0, 0, 261, 0, 170,
1913 0, 0, 166, 167, 163, 60, 204, 206, 97, 109,
1914 0, 0, 0, 0, 0, 266, 267, 0, 280, 282,
1915 0, 0, 269, 272, 273, 0, 285, 168, 169, 0,
1916 0, 0, 61, 110, 104, 229, 0, 0, 97, 0,
1917 102, 255, 0, 102, 165, 171, 172, 203, 0, 209,
1918 0, 248, 0, 0, 257, 0, 0, 256, 275, 105,
1919 246, 0, 247, 0, 97, 0, 0, 0, 258, 0,
1920 0, 0, 0, 253, 0, 0, 252, 0, 249
Reid Spencer38c91a92007-02-28 02:24:54 +00001921};
1922
1923/* YYDEFGOTO[NTERM-NUM]. */
1924static const short int yydefgoto[] =
1925{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001926 -1, 189, 190, 191, 253, 270, 110, 111, 71, 486,
1927 11, 72, 13, 36, 37, 38, 43, 49, 120, 322,
1928 232, 395, 325, 529, 375, 351, 514, 288, 352, 73,
1929 112, 129, 198, 130, 131, 102, 277, 364, 278, 80,
1930 14, 15, 16, 18, 17, 194, 241, 242, 58, 21,
1931 56, 93, 414, 415, 121, 201, 50, 88, 51, 44,
1932 417, 365, 75, 367, 293, 52, 84, 85, 226, 533,
1933 124, 306, 494, 398, 227, 228, 229, 230
Reid Spencer38c91a92007-02-28 02:24:54 +00001934};
1935
1936/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1937 STATE-NUM. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001938#define YYPACT_NINF -428
Reid Spencer38c91a92007-02-28 02:24:54 +00001939static const short int yypact[] =
1940{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001941 262, -428, -428, -428, -428, -428, -428, -26, -85, 60,
1942 5, 50, 9, 282, 135, 406, -428, 203, 191, 32,
1943 74, -428, 73, 134, -428, 1106, -428, -428, -428, -428,
1944 -428, -428, -428, -428, -428, -428, 87, 87, 150, -428,
1945 -428, -428, -428, 87, -428, -428, -428, -428, -428, 87,
1946 208, -428, 1, 228, 234, 248, -428, -428, -428, -428,
1947 -428, 130, -428, -428, -428, -428, -428, 276, 280, 4,
1948 111, -428, -428, -428, -57, -428, 150, 150, -428, -428,
1949 1143, 311, 311, -428, -428, 118, -428, -428, -428, -428,
1950 -428, -428, -428, -6, 40, -428, 144, 146, 908, 130,
1951 -428, -57, -68, -428, 40, 1143, 1157, 39, 281, 285,
1952 232, 286, 738, -428, 292, -428, -428, -428, -428, -428,
1953 1191, -428, -7, 1314, -428, 278, -428, -428, -57, -428,
1954 166, 163, 1157, 1157, 159, -36, 1157, -428, 165, -428,
1955 -57, -428, -428, -428, -428, -428, -428, -428, -428, -428,
1956 -428, -428, -428, -428, -428, -428, -428, -428, -428, -428,
1957 -428, -428, -428, -428, -428, -428, 255, 594, 167, -428,
1958 -428, -428, -428, -428, -428, -428, -428, -428, -428, -428,
1959 -428, 170, 171, 173, 175, 497, 1207, 945, 296, 187,
1960 196, 197, -428, -428, 192, -428, 130, -57, 213, -428,
1961 -428, -428, -428, -428, 287, 1228, 247, 338, 311, -428,
1962 -428, 255, 594, 1157, 1157, 1157, 1157, 1157, 1157, 1157,
1963 1157, 1157, 1157, 1157, 1157, 1157, -428, 311, -428, 152,
1964 -428, -428, -43, 1003, -428, -41, -103, -428, 206, -57,
1965 -428, 192, 192, -428, -428, -428, -428, -428, -428, -428,
1966 -428, -428, -428, 214, -428, -428, -428, -428, -428, -428,
1967 -428, -428, -428, -428, -428, -428, -428, -428, -428, -428,
1968 216, 1143, 1143, 1143, 1143, 1143, -428, -428, 17, 987,
1969 -18, -428, -33, -428, 1143, 1143, 1143, 8, -428, 217,
1970 -428, 130, 592, -428, 717, 717, -428, 717, 1191, 1157,
1971 1157, 106, 114, -428, 592, 31, 236, 239, 240, 241,
1972 242, 243, 592, 592, 347, 1191, 1157, 1157, -428, -428,
1973 -428, -428, -428, -428, -428, -40, -428, -428, -428, -40,
1974 -428, -428, 1143, 1143, -428, 245, 246, 252, 256, 1143,
1975 -428, 238, 738, -31, -428, -428, 257, 259, 351, 371,
1976 393, -428, 192, 1050, -428, -428, -428, -428, -428, -428,
1977 -428, -428, 346, 1143, -428, -428, -428, -428, 265, -428,
1978 267, 717, 592, 592, 16, -428, 19, -428, -428, 717,
1979 263, 1157, 1157, 1157, 1157, 1157, 269, 272, 1157, 717,
1980 592, 273, -428, -428, -428, -428, 275, 283, -32, 1143,
1981 1143, 1143, 1143, -428, -428, 290, 1143, 1143, 1157, -428,
1982 -428, -428, -428, -57, 289, 288, -428, 398, 13, 415,
1983 417, 297, 302, 303, 717, 435, 717, 305, 306, 717,
1984 307, -57, -428, 308, 312, 717, 717, -57, 310, -428,
1985 1157, 1143, 1143, 1157, -428, 315, 313, 320, 321, -428,
1986 322, 324, 22, 21, 1088, -428, 325, -428, 717, 717,
1987 1157, 717, 717, 329, -428, 329, 717, 330, 1157, 1157,
1988 1157, -428, -428, 1157, 592, 327, 328, -428, 1143, -428,
1989 1143, 1143, -428, -428, -428, -428, -428, -428, -57, 34,
1990 440, 333, 331, 592, 72, -428, -428, 422, -428, -428,
1991 336, 717, -428, -428, -428, 75, -428, -428, -428, 340,
1992 343, 344, 21, -428, 423, -428, 461, -1, -428, 1157,
1993 -428, -428, 345, -428, -428, -428, -428, -428, 481, -428,
1994 717, -428, 866, 2, -43, 592, 44, -428, -40, -428,
1995 -428, 353, -428, 866, -428, 472, 475, 357, -43, 717,
1996 717, 479, 429, -428, 717, 482, -428, 717, -428
Reid Spencer38c91a92007-02-28 02:24:54 +00001997};
1998
1999/* YYPGOTO[NTERM-NUM]. */
2000static const short int yypgoto[] =
2001{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002002 -428, 374, 375, 376, 291, 294, -205, -428, 0, -12,
2003 416, 14, -428, -428, -428, 57, -428, -428, -150, -313,
2004 -404, -428, -237, -428, -295, 26, -428, -210, -428, -428,
2005 -24, 270, -223, -428, 414, 421, -69, -108, -181, 189,
2006 -428, -428, 505, -428, -428, -428, -428, -428, -428, -428,
2007 -428, -428, -428, -428, 439, -428, -428, -428, -428, -428,
2008 -428, -427, -73, 101, -197, -428, 470, -428, -428, -428,
2009 -428, -428, 51, 145, -428, -428, -428, -428
Reid Spencer38c91a92007-02-28 02:24:54 +00002010};
2011
2012/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2013 positive, shift that token. If negative, reduce the rule which
2014 number is the opposite. If zero, do what YYDEFACT says.
2015 If YYTABLE_NINF, syntax error. */
Reid Spencer67d8ed92007-03-22 02:14:08 +00002016#define YYTABLE_NINF -179
Reid Spencer38c91a92007-02-28 02:24:54 +00002017static const short int yytable[] =
2018{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002019 10, 74, 297, 329, 192, 280, 282, 377, 97, 453,
2020 296, 113, 394, 296, 12, 10, 394, 199, 303, 83,
2021 19, 307, 308, 309, 310, 311, 86, 424, 314, 12,
2022 426, 330, 331, 103, 20, 104, 139, 1, 349, 193,
2023 3, 327, -55, -55, -55, -55, 101, 59, 60, 22,
2024 99, 62, 63, 64, 65, 350, 1, 2, 298, 3,
2025 4, 141, 142, 425, 349, 25, 425, 136, 318, 319,
2026 128, 318, 319, 127, 101, 371, 545, 315, 137, 103,
2027 128, 104, 140, 66, 512, 10, 320, 321, 392, 320,
2028 321, 393, 389, 76, 77, 103, 197, 104, 343, 136,
2029 81, 326, 339, 443, 339, 541, 82, 444, 235, 236,
2030 238, 23, 239, 345, 534, 405, 547, 339, 59, 60,
2031 391, 99, 62, 63, 64, 65, 344, 1, 2, 125,
2032 3, 4, 318, 319, 1, 39, 126, 3, 200, 24,
2033 548, 531, 411, 26, 542, 318, 319, 87, 339, 98,
2034 320, 321, 339, 57, 66, 318, 319, 457, 103, 340,
2035 104, 484, 392, 320, 321, 393, 53, 103, 498, 104,
2036 499, 379, 392, 320, 321, 393, 394, 67, 78, 79,
2037 68, 292, 418, 69, 430, 70, 432, 433, 434, 301,
2038 302, 292, 304, 305, 292, 292, 292, 292, 292, 312,
2039 313, 292, 334, 335, 336, 337, 338, 519, 54, 128,
2040 519, 520, 289, 55, 523, 346, 347, 348, 489, 366,
2041 35, 366, 366, 394, 366, 394, 83, 45, 46, 47,
2042 2, 366, 48, 4, 192, 143, 144, 145, 146, 366,
2043 366, 374, 103, 41, 104, 42, 477, 90, 67, 376,
2044 103, 68, 104, 91, 69, 342, 70, 100, 294, 316,
2045 317, 295, -178, 396, 397, 105, 106, 92, 94, 193,
2046 403, 502, 503, 504, 197, 372, 373, -63, 1, 2,
2047 95, 3, 4, 536, 96, 132, 538, 133, 5, 6,
2048 -56, 197, 390, 292, -57, 147, 195, 231, 366, 366,
2049 366, 233, 234, 237, 240, 271, 366, 7, 272, 273,
2050 8, 274, 532, 275, 9, 283, 366, 366, 27, 28,
2051 29, 30, 31, 32, 33, 284, 34, 287, 543, 413,
2052 445, 446, 447, 448, 285, 286, 290, 450, 451, 243,
2053 244, 245, 246, 247, 248, 249, 250, 251, 252, 296,
2054 328, 366, 332, 366, 333, 353, 366, 292, 431, 292,
2055 292, 292, 366, 366, 437, 114, 115, 116, 117, 118,
2056 119, 380, 475, 476, 381, 382, 383, 384, 385, 388,
2057 399, 400, 404, 408, 452, 366, 366, 401, 366, 366,
2058 409, 402, 406, 366, 407, 368, 369, 410, 370, 416,
2059 419, 366, 420, 429, 435, 378, -177, 436, 440, 509,
2060 441, 510, 511, 386, 387, 35, 474, 456, 442, 292,
2061 366, -63, 1, 2, 454, 3, 4, 455, 366, 458,
2062 488, 459, 5, 6, 449, 460, 493, 461, 462, 464,
2063 443, 466, 468, 469, 292, 292, 292, 470, 473, 493,
2064 478, 7, 479, 485, 8, 480, 481, 366, 9, 515,
2065 490, 482, 366, 483, 497, 501, 507, 508, 516, 425,
2066 528, 517, 421, 422, 423, 530, 366, 366, 521, 524,
2067 428, 366, 525, 526, 366, 539, 549, 537, 546, 550,
2068 438, 439, 551, 554, 555, 535, 557, 223, 224, 225,
2069 527, 123, 299, 324, 59, 60, 300, 99, 107, 108,
2070 109, 65, 485, 1, 2, 513, 3, 4, 138, 135,
2071 40, 122, 89, 427, 505, 463, 0, 465, 0, 0,
2072 467, 0, 0, 0, 0, 0, 471, 472, 0, 0,
2073 66, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2074 0, 0, 0, 0, 0, 0, 0, 0, 0, 491,
2075 492, 0, 495, 496, 0, 0, 0, 500, 0, 0,
2076 0, 0, 0, 0, 0, 506, 0, 0, 0, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00002077 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002078 0, 0, 0, 0, 518, 354, 355, 0, 0, 59,
2079 60, 356, 522, 0, 0, 0, 0, 0, 1, 2,
2080 0, 3, 4, 357, 358, 359, 254, 255, 0, 0,
2081 0, 0, 0, 0, 0, 0, 360, 361, 0, 0,
2082 0, 540, 0, 0, 67, 0, 544, 68, 0, 276,
2083 69, 0, 70, 362, 0, 0, 0, 0, 0, 0,
2084 552, 553, 0, 0, 0, 556, 0, 0, 558, 151,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002085 152, 153, 154, 155, 156, 157, 158, 159, 160, 161,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002086 162, 163, 164, 165, 166, 167, 0, 0, 0, 0,
2087 0, 0, 0, 0, 256, 257, 258, 259, 260, 261,
2088 262, 263, 264, 265, 266, 267, 268, 269, 0, 0,
2089 0, 168, 169, 170, 171, 172, 173, 174, 175, 176,
2090 177, 178, 179, 180, 0, 181, 0, 182, 183, 184,
2091 354, 355, 0, 0, 59, 60, 356, 0, 103, 0,
2092 104, 0, 0, 1, 2, 363, 3, 4, 357, 358,
2093 359, 0, 0, 0, 0, 59, 60, 0, 0, 0,
2094 0, 360, 361, 0, 1, 2, 0, 3, 4, 148,
2095 0, 0, 0, 0, 0, 0, 0, 0, 362, 0,
2096 0, 0, 149, 150, 0, 0, 0, 0, 0, 0,
2097 0, 0, 0, 0, 151, 152, 153, 154, 155, 156,
2098 157, 158, 159, 160, 161, 162, 163, 164, 165, 166,
2099 167, 0, 0, 0, 0, 151, 152, 153, 154, 155,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002100 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002101 166, 167, 0, 0, 0, 0, 168, 169, 170, 171,
2102 172, 173, 174, 175, 176, 177, 178, 179, 180, 0,
2103 181, 0, 182, 183, 184, 0, 0, 168, 169, 170,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002104 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002105 363, 181, 0, 182, 183, 184, 0, 0, 0, 354,
2106 355, 0, 0, 0, 103, 356, 104, 0, 185, 0,
2107 0, 186, 0, 187, 0, 188, 0, 357, 358, 359,
2108 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2109 360, 361, 0, 0, 0, 0, 0, 0, 0, 0,
2110 0, 0, 0, 0, 0, 59, 60, 362, 99, 62,
2111 63, 64, 65, 0, 1, 2, 0, 3, 4, 0,
2112 0, 0, 0, 151, 152, 153, 154, 155, 156, 157,
Reid Spencer38c91a92007-02-28 02:24:54 +00002113 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002114 0, 66, 59, 60, 0, 99, 107, 108, 109, 65,
2115 0, 1, 2, 0, 3, 4, 0, 0, 0, 0,
2116 0, 0, 0, 0, 0, 168, 169, 170, 171, 172,
2117 173, 174, 175, 176, 177, 178, 179, 180, 66, 181,
2118 0, 182, 183, 184, 59, 60, 0, 99, 107, 108,
2119 109, 65, 0, 1, 2, 0, 3, 4, 0, 363,
2120 59, 60, 0, 99, 62, 63, 64, 65, 0, 1,
2121 2, 0, 3, 4, 0, 0, 0, 0, 0, 0,
2122 66, 0, 0, 0, 0, 0, 323, 0, 0, 0,
2123 0, 0, 0, 0, 0, 67, 66, 0, 68, 0,
2124 0, 69, 0, 70, 134, 0, 0, 59, 60, 0,
2125 99, 62, 63, 64, 65, 0, 1, 2, 0, 3,
2126 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2127 0, 0, 67, 412, 0, 68, 0, 0, 69, 0,
2128 70, 281, 0, 66, 0, 59, 60, 0, 99, 62,
2129 63, 64, 65, 0, 1, 2, 0, 3, 4, 0,
2130 0, 0, 0, 59, 60, 0, 61, 62, 63, 64,
2131 65, 487, 1, 2, 67, 3, 4, 68, 0, 0,
2132 69, 66, 70, 341, 0, 0, 0, 0, 0, 0,
2133 67, 0, 0, 68, 0, 0, 69, 0, 70, 66,
2134 59, 60, 0, 99, 107, 108, 109, 65, 0, 1,
2135 2, 0, 3, 4, 59, 60, 0, 99, 62, 63,
2136 64, 65, 0, 1, 2, 0, 3, 4, 0, 0,
2137 0, 0, 0, 0, 0, 0, 66, 67, 0, 0,
2138 68, 0, 0, 69, 0, 70, 0, 0, 59, 60,
2139 66, 196, 62, 63, 64, 65, 0, 1, 2, 0,
2140 3, 4, 0, 0, 59, 60, 0, 99, 107, 108,
2141 109, 65, 0, 1, 2, 67, 3, 4, 68, 0,
2142 0, 69, 0, 70, 66, 59, 60, 0, 291, 62,
2143 63, 64, 65, 67, 1, 2, 68, 3, 4, 69,
2144 66, 70, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002145 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002146 0, 66, 0, 0, 0, 0, 0, 0, 0, 0,
2147 67, 0, 0, 68, 0, 0, 69, 0, 70, 0,
2148 0, 0, 0, 0, 67, 0, 0, 68, 0, 0,
2149 69, 0, 70, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002150 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002151 0, 0, 0, 0, 0, 0, 0, 0, 67, 0,
2152 0, 68, 0, 0, 69, 0, 70, 0, 0, 0,
2153 0, 0, 0, 0, 67, 202, 0, 68, 0, 0,
2154 69, 0, 279, 0, 0, 0, 0, 0, 0, 0,
2155 0, 0, 0, 203, 204, 67, 0, 0, 68, 0,
2156 0, 69, 0, 70, 0, 205, 206, 207, 208, 209,
2157 210, 151, 152, 153, 154, 155, 156, 157, 158, 159,
2158 160, 161, 162, 163, 164, 165, 211, 212, 0, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00002159 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002160 0, 0, 0, 0, 0, 0, 0, 0, 213, 214,
2161 215, 0, 0, 216, 169, 170, 171, 172, 173, 174,
2162 175, 176, 177, 178, 179, 180, 217, 218, 219, 220,
2163 221, 222
Reid Spencer38c91a92007-02-28 02:24:54 +00002164};
2165
2166static const short int yycheck[] =
2167{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002168 0, 25, 207, 240, 112, 186, 187, 302, 4, 413,
2169 11, 80, 325, 11, 0, 15, 329, 24, 215, 18,
2170 46, 218, 219, 220, 221, 222, 25, 11, 225, 15,
2171 11, 241, 242, 136, 60, 138, 105, 16, 30, 112,
2172 19, 144, 3, 4, 5, 6, 70, 7, 8, 134,
2173 10, 11, 12, 13, 14, 47, 16, 17, 208, 19,
2174 20, 22, 23, 47, 30, 15, 47, 135, 111, 112,
2175 94, 111, 112, 33, 98, 298, 32, 227, 146, 136,
2176 104, 138, 106, 43, 488, 85, 129, 130, 128, 129,
2177 130, 131, 315, 36, 37, 136, 120, 138, 279, 135,
2178 43, 142, 135, 135, 135, 532, 49, 139, 132, 133,
2179 146, 51, 136, 146, 518, 146, 543, 135, 7, 8,
2180 317, 10, 11, 12, 13, 14, 144, 16, 17, 135,
2181 19, 20, 111, 112, 16, 0, 142, 19, 145, 134,
2182 544, 142, 352, 134, 142, 111, 112, 146, 135, 145,
2183 129, 130, 135, 19, 43, 111, 112, 144, 136, 142,
2184 138, 139, 128, 129, 130, 131, 134, 136, 463, 138,
2185 465, 140, 128, 129, 130, 131, 489, 137, 28, 29,
2186 140, 205, 363, 143, 381, 145, 383, 384, 385, 213,
2187 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
2188 224, 225, 271, 272, 273, 274, 275, 135, 134, 233,
2189 135, 139, 198, 140, 139, 284, 285, 286, 455, 292,
2190 133, 294, 295, 536, 297, 538, 18, 36, 37, 38,
2191 17, 304, 41, 20, 342, 3, 4, 5, 6, 312,
2192 313, 135, 136, 40, 138, 42, 443, 19, 137, 135,
2193 136, 140, 138, 19, 143, 279, 145, 146, 11, 107,
2194 108, 14, 0, 332, 333, 76, 77, 19, 138, 342,
2195 339, 468, 469, 470, 298, 299, 300, 15, 16, 17,
2196 4, 19, 20, 520, 4, 141, 523, 141, 26, 27,
2197 9, 315, 316, 317, 9, 9, 4, 19, 371, 372,
2198 373, 135, 139, 144, 139, 138, 379, 45, 138, 138,
2199 48, 138, 517, 138, 52, 19, 389, 390, 36, 37,
2200 38, 39, 40, 41, 42, 138, 44, 135, 533, 353,
2201 399, 400, 401, 402, 138, 138, 49, 406, 407, 84,
2202 85, 86, 87, 88, 89, 90, 91, 92, 93, 11,
2203 144, 424, 138, 426, 138, 138, 429, 381, 382, 383,
2204 384, 385, 435, 436, 388, 54, 55, 56, 57, 58,
2205 59, 135, 441, 442, 135, 135, 135, 135, 135, 32,
2206 135, 135, 144, 32, 408, 458, 459, 135, 461, 462,
2207 19, 135, 135, 466, 135, 294, 295, 4, 297, 53,
2208 135, 474, 135, 140, 135, 304, 0, 135, 135, 478,
2209 135, 480, 481, 312, 313, 133, 440, 19, 135, 443,
2210 493, 15, 16, 17, 135, 19, 20, 139, 501, 14,
2211 454, 14, 26, 27, 144, 138, 460, 135, 135, 4,
2212 135, 135, 135, 135, 468, 469, 470, 135, 138, 473,
2213 135, 45, 139, 453, 48, 135, 135, 530, 52, 19,
2214 135, 139, 535, 139, 135, 135, 139, 139, 135, 47,
2215 47, 140, 371, 372, 373, 14, 549, 550, 142, 139,
2216 379, 554, 139, 139, 557, 4, 14, 142, 135, 14,
2217 389, 390, 135, 14, 65, 519, 14, 123, 123, 123,
2218 512, 85, 211, 233, 7, 8, 212, 10, 11, 12,
2219 13, 14, 512, 16, 17, 489, 19, 20, 104, 98,
2220 15, 82, 52, 378, 473, 424, -1, 426, -1, -1,
2221 429, -1, -1, -1, -1, -1, 435, 436, -1, -1,
2222 43, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2223 -1, -1, -1, -1, -1, -1, -1, -1, -1, 458,
2224 459, -1, 461, 462, -1, -1, -1, 466, -1, -1,
2225 -1, -1, -1, -1, -1, 474, -1, -1, -1, -1,
Reid Spencer38c91a92007-02-28 02:24:54 +00002226 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002227 -1, -1, -1, -1, 493, 3, 4, -1, -1, 7,
2228 8, 9, 501, -1, -1, -1, -1, -1, 16, 17,
2229 -1, 19, 20, 21, 22, 23, 22, 23, -1, -1,
2230 -1, -1, -1, -1, -1, -1, 34, 35, -1, -1,
2231 -1, 530, -1, -1, 137, -1, 535, 140, -1, 142,
2232 143, -1, 145, 51, -1, -1, -1, -1, -1, -1,
2233 549, 550, -1, -1, -1, 554, -1, -1, 557, 67,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002234 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002235 78, 79, 80, 81, 82, 83, -1, -1, -1, -1,
2236 -1, -1, -1, -1, 90, 91, 92, 93, 94, 95,
2237 96, 97, 98, 99, 100, 101, 102, 103, -1, -1,
2238 -1, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2239 118, 119, 120, 121, -1, 123, -1, 125, 126, 127,
2240 3, 4, -1, -1, 7, 8, 9, -1, 136, -1,
2241 138, -1, -1, 16, 17, 143, 19, 20, 21, 22,
2242 23, -1, -1, -1, -1, 7, 8, -1, -1, -1,
2243 -1, 34, 35, -1, 16, 17, -1, 19, 20, 21,
2244 -1, -1, -1, -1, -1, -1, -1, -1, 51, -1,
2245 -1, -1, 34, 35, -1, -1, -1, -1, -1, -1,
2246 -1, -1, -1, -1, 67, 68, 69, 70, 71, 72,
2247 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2248 83, -1, -1, -1, -1, 67, 68, 69, 70, 71,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002249 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002250 82, 83, -1, -1, -1, -1, 109, 110, 111, 112,
2251 113, 114, 115, 116, 117, 118, 119, 120, 121, -1,
2252 123, -1, 125, 126, 127, -1, -1, 109, 110, 111,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002253 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002254 143, 123, -1, 125, 126, 127, -1, -1, -1, 3,
2255 4, -1, -1, -1, 136, 9, 138, -1, 140, -1,
2256 -1, 143, -1, 145, -1, 147, -1, 21, 22, 23,
2257 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2258 34, 35, -1, -1, -1, -1, -1, -1, -1, -1,
2259 -1, -1, -1, -1, -1, 7, 8, 51, 10, 11,
2260 12, 13, 14, -1, 16, 17, -1, 19, 20, -1,
2261 -1, -1, -1, 67, 68, 69, 70, 71, 72, 73,
Reid Spencer38c91a92007-02-28 02:24:54 +00002262 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002263 -1, 43, 7, 8, -1, 10, 11, 12, 13, 14,
2264 -1, 16, 17, -1, 19, 20, -1, -1, -1, -1,
2265 -1, -1, -1, -1, -1, 109, 110, 111, 112, 113,
2266 114, 115, 116, 117, 118, 119, 120, 121, 43, 123,
2267 -1, 125, 126, 127, 7, 8, -1, 10, 11, 12,
2268 13, 14, -1, 16, 17, -1, 19, 20, -1, 143,
2269 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
2270 17, -1, 19, 20, -1, -1, -1, -1, -1, -1,
2271 43, -1, -1, -1, -1, -1, 33, -1, -1, -1,
2272 -1, -1, -1, -1, -1, 137, 43, -1, 140, -1,
2273 -1, 143, -1, 145, 146, -1, -1, 7, 8, -1,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002274 10, 11, 12, 13, 14, -1, 16, 17, -1, 19,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002275 20, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2276 -1, -1, 137, 33, -1, 140, -1, -1, 143, -1,
2277 145, 146, -1, 43, -1, 7, 8, -1, 10, 11,
2278 12, 13, 14, -1, 16, 17, -1, 19, 20, -1,
2279 -1, -1, -1, 7, 8, -1, 10, 11, 12, 13,
2280 14, 33, 16, 17, 137, 19, 20, 140, -1, -1,
2281 143, 43, 145, 146, -1, -1, -1, -1, -1, -1,
2282 137, -1, -1, 140, -1, -1, 143, -1, 145, 43,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002283 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
Reid Spencer38c91a92007-02-28 02:24:54 +00002284 17, -1, 19, 20, 7, 8, -1, 10, 11, 12,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002285 13, 14, -1, 16, 17, -1, 19, 20, -1, -1,
2286 -1, -1, -1, -1, -1, -1, 43, 137, -1, -1,
2287 140, -1, -1, 143, -1, 145, -1, -1, 7, 8,
2288 43, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2289 19, 20, -1, -1, 7, 8, -1, 10, 11, 12,
2290 13, 14, -1, 16, 17, 137, 19, 20, 140, -1,
2291 -1, 143, -1, 145, 43, 7, 8, -1, 10, 11,
2292 12, 13, 14, 137, 16, 17, 140, 19, 20, 143,
2293 43, 145, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer38c91a92007-02-28 02:24:54 +00002294 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002295 -1, 43, -1, -1, -1, -1, -1, -1, -1, -1,
2296 137, -1, -1, 140, -1, -1, 143, -1, 145, -1,
2297 -1, -1, -1, -1, 137, -1, -1, 140, -1, -1,
2298 143, -1, 145, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer38c91a92007-02-28 02:24:54 +00002299 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002300 -1, -1, -1, -1, -1, -1, -1, -1, 137, -1,
2301 -1, 140, -1, -1, 143, -1, 145, -1, -1, -1,
2302 -1, -1, -1, -1, 137, 31, -1, 140, -1, -1,
2303 143, -1, 145, -1, -1, -1, -1, -1, -1, -1,
2304 -1, -1, -1, 49, 50, 137, -1, -1, 140, -1,
2305 -1, 143, -1, 145, -1, 61, 62, 63, 64, 65,
2306 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
2307 76, 77, 78, 79, 80, 81, 82, 83, -1, -1,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002308 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002309 -1, -1, -1, -1, -1, -1, -1, -1, 104, 105,
2310 106, -1, -1, 109, 110, 111, 112, 113, 114, 115,
2311 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
2312 126, 127
Reid Spencer38c91a92007-02-28 02:24:54 +00002313};
2314
2315/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2316 symbol of state STATE-NUM. */
2317static const unsigned char yystos[] =
2318{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002319 0, 16, 17, 19, 20, 26, 27, 45, 48, 52,
2320 156, 158, 159, 160, 188, 189, 190, 192, 191, 46,
2321 60, 197, 134, 51, 134, 15, 134, 36, 37, 38,
2322 39, 40, 41, 42, 44, 133, 161, 162, 163, 0,
2323 190, 40, 42, 164, 207, 36, 37, 38, 41, 165,
2324 204, 206, 213, 134, 134, 140, 198, 19, 196, 7,
2325 8, 10, 11, 12, 13, 14, 43, 137, 140, 143,
2326 145, 156, 159, 177, 178, 210, 163, 163, 28, 29,
2327 187, 163, 163, 18, 214, 215, 25, 146, 205, 214,
2328 19, 19, 19, 199, 138, 4, 4, 4, 145, 10,
2329 146, 178, 183, 136, 138, 187, 187, 11, 12, 13,
2330 154, 155, 178, 184, 54, 55, 56, 57, 58, 59,
2331 166, 202, 202, 158, 218, 135, 142, 33, 178, 179,
2332 181, 182, 141, 141, 146, 183, 135, 146, 182, 184,
2333 178, 22, 23, 3, 4, 5, 6, 9, 21, 34,
2334 35, 67, 68, 69, 70, 71, 72, 73, 74, 75,
2335 76, 77, 78, 79, 80, 81, 82, 83, 109, 110,
Reid Spencer38c91a92007-02-28 02:24:54 +00002336 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002337 121, 123, 125, 126, 127, 140, 143, 145, 147, 149,
2338 150, 151, 185, 210, 193, 4, 10, 178, 180, 24,
2339 145, 203, 31, 49, 50, 61, 62, 63, 64, 65,
2340 66, 82, 83, 104, 105, 106, 109, 122, 123, 124,
2341 125, 126, 127, 149, 150, 151, 216, 222, 223, 224,
2342 225, 19, 168, 135, 139, 178, 178, 144, 146, 178,
2343 139, 194, 195, 84, 85, 86, 87, 88, 89, 90,
2344 91, 92, 93, 152, 22, 23, 90, 91, 92, 93,
Reid Spencer38c91a92007-02-28 02:24:54 +00002345 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002346 153, 138, 138, 138, 138, 138, 142, 184, 186, 145,
2347 186, 146, 186, 19, 138, 138, 138, 135, 175, 159,
2348 49, 10, 178, 212, 11, 14, 11, 154, 166, 152,
2349 153, 178, 178, 212, 178, 178, 219, 212, 212, 212,
2350 212, 212, 178, 178, 212, 166, 107, 108, 111, 112,
2351 129, 130, 167, 33, 179, 170, 142, 144, 144, 170,
2352 175, 175, 138, 138, 184, 184, 184, 184, 184, 135,
2353 142, 146, 178, 186, 144, 146, 184, 184, 184, 30,
2354 47, 173, 176, 138, 3, 4, 9, 21, 22, 23,
2355 34, 35, 51, 143, 185, 209, 210, 211, 211, 211,
2356 211, 180, 178, 178, 135, 172, 135, 172, 211, 140,
2357 135, 135, 135, 135, 135, 135, 211, 211, 32, 180,
2358 178, 212, 128, 131, 167, 169, 184, 184, 221, 135,
2359 135, 135, 135, 184, 144, 146, 135, 135, 32, 19,
2360 4, 175, 33, 178, 200, 201, 53, 208, 186, 135,
2361 135, 211, 211, 211, 11, 47, 11, 221, 211, 140,
2362 212, 178, 212, 212, 212, 135, 135, 178, 211, 211,
2363 135, 135, 135, 135, 139, 184, 184, 184, 184, 144,
2364 184, 184, 178, 168, 135, 139, 19, 144, 14, 14,
2365 138, 135, 135, 211, 4, 211, 135, 211, 135, 135,
2366 135, 211, 211, 138, 178, 184, 184, 212, 135, 139,
2367 135, 135, 139, 139, 139, 156, 157, 33, 178, 170,
2368 135, 211, 211, 178, 220, 211, 211, 135, 172, 172,
2369 211, 135, 212, 212, 212, 220, 211, 139, 139, 184,
2370 184, 184, 168, 173, 174, 19, 135, 140, 211, 135,
2371 139, 142, 211, 139, 139, 139, 139, 157, 47, 171,
2372 14, 142, 154, 217, 168, 178, 170, 142, 170, 4,
2373 211, 209, 142, 154, 211, 32, 135, 209, 168, 14,
2374 14, 135, 211, 211, 14, 65, 211, 14, 211
Reid Spencer38c91a92007-02-28 02:24:54 +00002375};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002376
2377#define yyerrok (yyerrstatus = 0)
2378#define yyclearin (yychar = YYEMPTY)
Reid Spencer38c91a92007-02-28 02:24:54 +00002379#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002380#define YYEOF 0
Reid Spencer38c91a92007-02-28 02:24:54 +00002381
Reid Spencer68a24bd2005-08-27 18:50:39 +00002382#define YYACCEPT goto yyacceptlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002383#define YYABORT goto yyabortlab
2384#define YYERROR goto yyerrorlab
2385
2386
2387/* Like YYERROR except do call yyerror. This remains here temporarily
2388 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002389 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002390
Reid Spencer68a24bd2005-08-27 18:50:39 +00002391#define YYFAIL goto yyerrlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002392
Reid Spencer68a24bd2005-08-27 18:50:39 +00002393#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002394
2395#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002396do \
2397 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer38c91a92007-02-28 02:24:54 +00002398 { \
2399 yychar = (Token); \
2400 yylval = (Value); \
2401 yytoken = YYTRANSLATE (yychar); \
Chris Lattner9d2fda62007-02-13 05:53:56 +00002402 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002403 goto yybackup; \
2404 } \
2405 else \
Reid Spencer38c91a92007-02-28 02:24:54 +00002406 { \
2407 yyerror (YY_("syntax error: cannot back up")); \
2408 YYERROR; \
2409 } \
Chris Lattner9d2fda62007-02-13 05:53:56 +00002410while (0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002411
Reid Spencer38c91a92007-02-28 02:24:54 +00002412
Reid Spencer68a24bd2005-08-27 18:50:39 +00002413#define YYTERROR 1
2414#define YYERRCODE 256
2415
Reid Spencer38c91a92007-02-28 02:24:54 +00002416
2417/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2418 If N is 0, then set CURRENT to the empty location which ends
2419 the previous symbol: RHS[0] (always defined). */
2420
2421#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2422#ifndef YYLLOC_DEFAULT
2423# define YYLLOC_DEFAULT(Current, Rhs, N) \
2424 do \
2425 if (N) \
2426 { \
2427 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2428 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2429 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2430 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2431 } \
2432 else \
2433 { \
2434 (Current).first_line = (Current).last_line = \
2435 YYRHSLOC (Rhs, 0).last_line; \
2436 (Current).first_column = (Current).last_column = \
2437 YYRHSLOC (Rhs, 0).last_column; \
2438 } \
2439 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002440#endif
2441
Reid Spencer38c91a92007-02-28 02:24:54 +00002442
2443/* YY_LOCATION_PRINT -- Print the location on the stream.
2444 This macro was not mandated originally: define only if we know
2445 we won't break user code: when these are the locations we know. */
2446
2447#ifndef YY_LOCATION_PRINT
2448# if YYLTYPE_IS_TRIVIAL
2449# define YY_LOCATION_PRINT(File, Loc) \
2450 fprintf (File, "%d.%d-%d.%d", \
2451 (Loc).first_line, (Loc).first_column, \
2452 (Loc).last_line, (Loc).last_column)
2453# else
2454# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2455# endif
2456#endif
2457
2458
2459/* YYLEX -- calling `yylex' with the right arguments. */
2460
Reid Spencer41dff5e2007-01-26 08:05:27 +00002461#ifdef YYLEX_PARAM
Reid Spencer38c91a92007-02-28 02:24:54 +00002462# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer41dff5e2007-01-26 08:05:27 +00002463#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002464# define YYLEX yylex ()
Chris Lattner32980692007-02-19 07:44:24 +00002465#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002466
2467/* Enable debugging if requested. */
2468#if YYDEBUG
2469
2470# ifndef YYFPRINTF
2471# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2472# define YYFPRINTF fprintf
2473# endif
2474
2475# define YYDPRINTF(Args) \
2476do { \
2477 if (yydebug) \
2478 YYFPRINTF Args; \
2479} while (0)
2480
2481# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2482do { \
2483 if (yydebug) \
2484 { \
2485 YYFPRINTF (stderr, "%s ", Title); \
2486 yysymprint (stderr, \
2487 Type, Value); \
2488 YYFPRINTF (stderr, "\n"); \
2489 } \
2490} while (0)
2491
2492/*------------------------------------------------------------------.
2493| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2494| TOP (included). |
2495`------------------------------------------------------------------*/
2496
2497#if defined (__STDC__) || defined (__cplusplus)
2498static void
2499yy_stack_print (short int *bottom, short int *top)
Chris Lattner32980692007-02-19 07:44:24 +00002500#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002501static void
2502yy_stack_print (bottom, top)
2503 short int *bottom;
2504 short int *top;
Chris Lattner32980692007-02-19 07:44:24 +00002505#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002506{
2507 YYFPRINTF (stderr, "Stack now");
2508 for (/* Nothing. */; bottom <= top; ++bottom)
2509 YYFPRINTF (stderr, " %d", *bottom);
2510 YYFPRINTF (stderr, "\n");
2511}
2512
2513# define YY_STACK_PRINT(Bottom, Top) \
2514do { \
2515 if (yydebug) \
2516 yy_stack_print ((Bottom), (Top)); \
2517} while (0)
2518
2519
2520/*------------------------------------------------.
2521| Report that the YYRULE is going to be reduced. |
2522`------------------------------------------------*/
2523
2524#if defined (__STDC__) || defined (__cplusplus)
2525static void
2526yy_reduce_print (int yyrule)
2527#else
2528static void
2529yy_reduce_print (yyrule)
2530 int yyrule;
Chris Lattner9d2fda62007-02-13 05:53:56 +00002531#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002532{
2533 int yyi;
2534 unsigned long int yylno = yyrline[yyrule];
2535 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2536 yyrule - 1, yylno);
2537 /* Print the symbols being reduced, and their result. */
2538 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2539 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2540 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2541}
Reid Spencer9d6565a2007-02-15 02:26:10 +00002542
Reid Spencer38c91a92007-02-28 02:24:54 +00002543# define YY_REDUCE_PRINT(Rule) \
2544do { \
2545 if (yydebug) \
2546 yy_reduce_print (Rule); \
2547} while (0)
Reid Spencer9d6565a2007-02-15 02:26:10 +00002548
Reid Spencer38c91a92007-02-28 02:24:54 +00002549/* Nonzero means print parse trace. It is left uninitialized so that
2550 multiple parsers can coexist. */
2551int yydebug;
2552#else /* !YYDEBUG */
2553# define YYDPRINTF(Args)
2554# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2555# define YY_STACK_PRINT(Bottom, Top)
2556# define YY_REDUCE_PRINT(Rule)
2557#endif /* !YYDEBUG */
Reid Spencer9d6565a2007-02-15 02:26:10 +00002558
Reid Spencer9d6565a2007-02-15 02:26:10 +00002559
Reid Spencer38c91a92007-02-28 02:24:54 +00002560/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002561#ifndef YYINITDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002562# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002563#endif
2564
Reid Spencer38c91a92007-02-28 02:24:54 +00002565/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2566 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002567
Reid Spencer38c91a92007-02-28 02:24:54 +00002568 Do not make this value too large; the results are undefined if
2569 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2570 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002571
2572#ifndef YYMAXDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002573# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002574#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002575
Reid Spencer68a24bd2005-08-27 18:50:39 +00002576
2577
Reid Spencer38c91a92007-02-28 02:24:54 +00002578#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002579
Reid Spencer38c91a92007-02-28 02:24:54 +00002580# ifndef yystrlen
2581# if defined (__GLIBC__) && defined (_STRING_H)
2582# define yystrlen strlen
2583# else
2584/* Return the length of YYSTR. */
2585static YYSIZE_T
2586# if defined (__STDC__) || defined (__cplusplus)
2587yystrlen (const char *yystr)
2588# else
2589yystrlen (yystr)
2590 const char *yystr;
2591# endif
Chris Lattner32980692007-02-19 07:44:24 +00002592{
Reid Spencer38c91a92007-02-28 02:24:54 +00002593 const char *yys = yystr;
Chris Lattner32980692007-02-19 07:44:24 +00002594
Reid Spencer38c91a92007-02-28 02:24:54 +00002595 while (*yys++ != '\0')
2596 continue;
2597
2598 return yys - yystr - 1;
Chris Lattner32980692007-02-19 07:44:24 +00002599}
Reid Spencer38c91a92007-02-28 02:24:54 +00002600# endif
2601# endif
Chris Lattner32980692007-02-19 07:44:24 +00002602
Reid Spencer38c91a92007-02-28 02:24:54 +00002603# ifndef yystpcpy
2604# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2605# define yystpcpy stpcpy
2606# else
2607/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2608 YYDEST. */
2609static char *
2610# if defined (__STDC__) || defined (__cplusplus)
2611yystpcpy (char *yydest, const char *yysrc)
2612# else
2613yystpcpy (yydest, yysrc)
2614 char *yydest;
2615 const char *yysrc;
2616# endif
Chris Lattner32980692007-02-19 07:44:24 +00002617{
Reid Spencer38c91a92007-02-28 02:24:54 +00002618 char *yyd = yydest;
2619 const char *yys = yysrc;
Chris Lattner32980692007-02-19 07:44:24 +00002620
Reid Spencer38c91a92007-02-28 02:24:54 +00002621 while ((*yyd++ = *yys++) != '\0')
2622 continue;
2623
2624 return yyd - 1;
Chris Lattner32980692007-02-19 07:44:24 +00002625}
Reid Spencer38c91a92007-02-28 02:24:54 +00002626# endif
2627# endif
Chris Lattner32980692007-02-19 07:44:24 +00002628
Reid Spencer38c91a92007-02-28 02:24:54 +00002629# ifndef yytnamerr
2630/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2631 quotes and backslashes, so that it's suitable for yyerror. The
2632 heuristic is that double-quoting is unnecessary unless the string
2633 contains an apostrophe, a comma, or backslash (other than
2634 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2635 null, do not copy; instead, return the length of what the result
2636 would have been. */
2637static YYSIZE_T
2638yytnamerr (char *yyres, const char *yystr)
2639{
2640 if (*yystr == '"')
2641 {
2642 size_t yyn = 0;
2643 char const *yyp = yystr;
2644
2645 for (;;)
2646 switch (*++yyp)
2647 {
2648 case '\'':
2649 case ',':
2650 goto do_not_strip_quotes;
2651
2652 case '\\':
2653 if (*++yyp != '\\')
2654 goto do_not_strip_quotes;
2655 /* Fall through. */
2656 default:
2657 if (yyres)
2658 yyres[yyn] = *yyp;
2659 yyn++;
2660 break;
2661
2662 case '"':
2663 if (yyres)
2664 yyres[yyn] = '\0';
2665 return yyn;
2666 }
2667 do_not_strip_quotes: ;
2668 }
2669
2670 if (! yyres)
2671 return yystrlen (yystr);
2672
2673 return yystpcpy (yyres, yystr) - yyres;
2674}
2675# endif
2676
2677#endif /* YYERROR_VERBOSE */
2678
Reid Spencer9d6565a2007-02-15 02:26:10 +00002679
2680
Reid Spencer38c91a92007-02-28 02:24:54 +00002681#if YYDEBUG
2682/*--------------------------------.
2683| Print this symbol on YYOUTPUT. |
2684`--------------------------------*/
Reid Spencer9d6565a2007-02-15 02:26:10 +00002685
Reid Spencer38c91a92007-02-28 02:24:54 +00002686#if defined (__STDC__) || defined (__cplusplus)
2687static void
2688yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner32980692007-02-19 07:44:24 +00002689#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002690static void
2691yysymprint (yyoutput, yytype, yyvaluep)
2692 FILE *yyoutput;
2693 int yytype;
2694 YYSTYPE *yyvaluep;
2695#endif
2696{
2697 /* Pacify ``unused variable'' warnings. */
2698 (void) yyvaluep;
2699
2700 if (yytype < YYNTOKENS)
2701 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2702 else
2703 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2704
2705
2706# ifdef YYPRINT
2707 if (yytype < YYNTOKENS)
2708 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2709# endif
2710 switch (yytype)
2711 {
2712 default:
2713 break;
2714 }
2715 YYFPRINTF (yyoutput, ")");
2716}
2717
2718#endif /* ! YYDEBUG */
2719/*-----------------------------------------------.
2720| Release the memory associated to this symbol. |
2721`-----------------------------------------------*/
2722
2723#if defined (__STDC__) || defined (__cplusplus)
2724static void
2725yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2726#else
2727static void
2728yydestruct (yymsg, yytype, yyvaluep)
2729 const char *yymsg;
2730 int yytype;
2731 YYSTYPE *yyvaluep;
2732#endif
2733{
2734 /* Pacify ``unused variable'' warnings. */
2735 (void) yyvaluep;
2736
2737 if (!yymsg)
2738 yymsg = "Deleting";
2739 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2740
2741 switch (yytype)
2742 {
2743
2744 default:
2745 break;
2746 }
2747}
2748
2749
2750/* Prevent warnings from -Wmissing-prototypes. */
2751
2752#ifdef YYPARSE_PARAM
2753# if defined (__STDC__) || defined (__cplusplus)
2754int yyparse (void *YYPARSE_PARAM);
2755# else
2756int yyparse ();
2757# endif
2758#else /* ! YYPARSE_PARAM */
2759#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002760int yyparse (void);
Chris Lattner32980692007-02-19 07:44:24 +00002761#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002762int yyparse ();
2763#endif
2764#endif /* ! YYPARSE_PARAM */
2765
2766
2767
2768/* The look-ahead symbol. */
2769int yychar;
2770
2771/* The semantic value of the look-ahead symbol. */
2772YYSTYPE yylval;
2773
2774/* Number of syntax errors so far. */
2775int yynerrs;
2776
2777
2778
2779/*----------.
2780| yyparse. |
2781`----------*/
2782
2783#ifdef YYPARSE_PARAM
2784# if defined (__STDC__) || defined (__cplusplus)
2785int yyparse (void *YYPARSE_PARAM)
2786# else
2787int yyparse (YYPARSE_PARAM)
2788 void *YYPARSE_PARAM;
2789# endif
2790#else /* ! YYPARSE_PARAM */
2791#if defined (__STDC__) || defined (__cplusplus)
2792int
2793yyparse (void)
2794#else
2795int
2796yyparse ()
2797
2798#endif
2799#endif
2800{
2801
2802 int yystate;
2803 int yyn;
2804 int yyresult;
2805 /* Number of tokens to shift before error messages enabled. */
2806 int yyerrstatus;
2807 /* Look-ahead token as an internal (translated) token number. */
2808 int yytoken = 0;
2809
2810 /* Three stacks and their tools:
2811 `yyss': related to states,
2812 `yyvs': related to semantic values,
2813 `yyls': related to locations.
2814
2815 Refer to the stacks thru separate pointers, to allow yyoverflow
2816 to reallocate them elsewhere. */
2817
2818 /* The state stack. */
2819 short int yyssa[YYINITDEPTH];
2820 short int *yyss = yyssa;
2821 short int *yyssp;
2822
2823 /* The semantic value stack. */
2824 YYSTYPE yyvsa[YYINITDEPTH];
2825 YYSTYPE *yyvs = yyvsa;
2826 YYSTYPE *yyvsp;
2827
2828
2829
Chris Lattner9d2fda62007-02-13 05:53:56 +00002830#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002831
Reid Spencer38c91a92007-02-28 02:24:54 +00002832 YYSIZE_T yystacksize = YYINITDEPTH;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002833
Reid Spencer38c91a92007-02-28 02:24:54 +00002834 /* The variables used to return semantic value and location from the
2835 action routines. */
2836 YYSTYPE yyval;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002837
Chris Lattner7d9801d2007-02-13 00:58:01 +00002838
Reid Spencer38c91a92007-02-28 02:24:54 +00002839 /* When reducing, the number of symbols on the RHS of the reduced
2840 rule. */
Chris Lattner9d2fda62007-02-13 05:53:56 +00002841 int yylen;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002842
Reid Spencer38c91a92007-02-28 02:24:54 +00002843 YYDPRINTF ((stderr, "Starting parse\n"));
Chris Lattner7d9801d2007-02-13 00:58:01 +00002844
Reid Spencer68a24bd2005-08-27 18:50:39 +00002845 yystate = 0;
2846 yyerrstatus = 0;
2847 yynerrs = 0;
2848 yychar = YYEMPTY; /* Cause a token to be read. */
2849
2850 /* Initialize stack pointers.
2851 Waste one element of value and location stack
2852 so that they stay on the same level as the state stack.
2853 The wasted elements are never initialized. */
2854
Reid Spencer38c91a92007-02-28 02:24:54 +00002855 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002856 yyvsp = yyvs;
2857
Reid Spencer38c91a92007-02-28 02:24:54 +00002858 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002859
Reid Spencer38c91a92007-02-28 02:24:54 +00002860/*------------------------------------------------------------.
2861| yynewstate -- Push a new state, which is found in yystate. |
2862`------------------------------------------------------------*/
2863 yynewstate:
2864 /* In all cases, when you get here, the value and location stacks
2865 have just been pushed. so pushing a state here evens the stacks.
2866 */
2867 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002868
Reid Spencer38c91a92007-02-28 02:24:54 +00002869 yysetstate:
2870 *yyssp = yystate;
2871
2872 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002873 {
2874 /* Get the current used size of the three stacks, in elements. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002875 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002876
2877#ifdef yyoverflow
Reid Spencer38c91a92007-02-28 02:24:54 +00002878 {
2879 /* Give user a chance to reallocate the stack. Use copies of
2880 these so that the &'s don't force the real ones into
2881 memory. */
2882 YYSTYPE *yyvs1 = yyvs;
2883 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002884
Reid Spencer38c91a92007-02-28 02:24:54 +00002885
2886 /* Each stack pointer address is followed by the size of the
2887 data in use in that stack, in bytes. This used to be a
2888 conditional around just the two extra args, but that might
2889 be undefined if yyoverflow is a macro. */
2890 yyoverflow (YY_("memory exhausted"),
2891 &yyss1, yysize * sizeof (*yyssp),
2892 &yyvs1, yysize * sizeof (*yyvsp),
2893
2894 &yystacksize);
2895
2896 yyss = yyss1;
2897 yyvs = yyvs1;
2898 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002899#else /* no yyoverflow */
Reid Spencer38c91a92007-02-28 02:24:54 +00002900# ifndef YYSTACK_RELOCATE
2901 goto yyexhaustedlab;
2902# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002903 /* Extend the stack our own way. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002904 if (YYMAXDEPTH <= yystacksize)
2905 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002906 yystacksize *= 2;
Reid Spencer38c91a92007-02-28 02:24:54 +00002907 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002908 yystacksize = YYMAXDEPTH;
Reid Spencer38c91a92007-02-28 02:24:54 +00002909
2910 {
2911 short int *yyss1 = yyss;
2912 union yyalloc *yyptr =
2913 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2914 if (! yyptr)
2915 goto yyexhaustedlab;
2916 YYSTACK_RELOCATE (yyss);
2917 YYSTACK_RELOCATE (yyvs);
2918
2919# undef YYSTACK_RELOCATE
2920 if (yyss1 != yyssa)
2921 YYSTACK_FREE (yyss1);
2922 }
2923# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002924#endif /* no yyoverflow */
2925
Reid Spencer38c91a92007-02-28 02:24:54 +00002926 yyssp = yyss + yysize - 1;
2927 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002928
2929
Reid Spencer38c91a92007-02-28 02:24:54 +00002930 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2931 (unsigned long int) yystacksize));
2932
2933 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002934 YYABORT;
2935 }
2936
Reid Spencer38c91a92007-02-28 02:24:54 +00002937 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002938
2939 goto yybackup;
Reid Spencer38c91a92007-02-28 02:24:54 +00002940
2941/*-----------.
2942| yybackup. |
2943`-----------*/
2944yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002945
Chris Lattner9d2fda62007-02-13 05:53:56 +00002946/* Do appropriate processing given the current state. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002947/* Read a look-ahead token if we need one and don't already have one. */
Chris Lattner9d2fda62007-02-13 05:53:56 +00002948/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002949
Reid Spencer38c91a92007-02-28 02:24:54 +00002950 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer5cbf9852007-01-30 20:08:39 +00002951
Reid Spencer68a24bd2005-08-27 18:50:39 +00002952 yyn = yypact[yystate];
Reid Spencer38c91a92007-02-28 02:24:54 +00002953 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002954 goto yydefault;
2955
Reid Spencer38c91a92007-02-28 02:24:54 +00002956 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002957
Reid Spencer38c91a92007-02-28 02:24:54 +00002958 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002959 if (yychar == YYEMPTY)
2960 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002961 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002962 yychar = YYLEX;
2963 }
2964
Reid Spencer38c91a92007-02-28 02:24:54 +00002965 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002966 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002967 yychar = yytoken = YYEOF;
2968 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002969 }
2970 else
2971 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002972 yytoken = YYTRANSLATE (yychar);
2973 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002974 }
2975
Reid Spencer38c91a92007-02-28 02:24:54 +00002976 /* If the proper action on seeing token YYTOKEN is to reduce or to
2977 detect an error, take that action. */
2978 yyn += yytoken;
2979 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002980 goto yydefault;
2981 yyn = yytable[yyn];
Reid Spencer38c91a92007-02-28 02:24:54 +00002982 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002983 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002984 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002985 goto yyerrlab;
2986 yyn = -yyn;
2987 goto yyreduce;
2988 }
2989
2990 if (yyn == YYFINAL)
2991 YYACCEPT;
2992
Reid Spencer38c91a92007-02-28 02:24:54 +00002993 /* Shift the look-ahead token. */
2994 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer5cbf9852007-01-30 20:08:39 +00002995
Chris Lattner9d2fda62007-02-13 05:53:56 +00002996 /* Discard the token being shifted unless it is eof. */
Reid Spencer5cbf9852007-01-30 20:08:39 +00002997 if (yychar != YYEOF)
2998 yychar = YYEMPTY;
2999
Chris Lattner7d9801d2007-02-13 00:58:01 +00003000 *++yyvsp = yylval;
3001
Reid Spencer38c91a92007-02-28 02:24:54 +00003002
3003 /* Count tokens shifted since error; after three, turn off error
3004 status. */
3005 if (yyerrstatus)
3006 yyerrstatus--;
Chris Lattner9d2fda62007-02-13 05:53:56 +00003007
3008 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003009 goto yynewstate;
3010
Chris Lattner32980692007-02-19 07:44:24 +00003011
Reid Spencer38c91a92007-02-28 02:24:54 +00003012/*-----------------------------------------------------------.
3013| yydefault -- do the default action for the current state. |
3014`-----------------------------------------------------------*/
3015yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003016 yyn = yydefact[yystate];
3017 if (yyn == 0)
3018 goto yyerrlab;
Reid Spencer38c91a92007-02-28 02:24:54 +00003019 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003020
Reid Spencer38c91a92007-02-28 02:24:54 +00003021
3022/*-----------------------------.
3023| yyreduce -- Do a reduction. |
3024`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003025yyreduce:
Reid Spencer38c91a92007-02-28 02:24:54 +00003026 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003027 yylen = yyr2[yyn];
3028
Reid Spencer38c91a92007-02-28 02:24:54 +00003029 /* If YYLEN is nonzero, implement the default value of the action:
3030 `$$ = $1'.
3031
3032 Otherwise, the following line sets YYVAL to garbage.
3033 This behavior is undocumented and Bison
3034 users should not rely upon it. Assigning to YYVAL
3035 unconditionally makes the parser a bit smaller, and it avoids a
3036 GCC warning that YYVAL may be used uninitialized. */
3037 yyval = yyvsp[1-yylen];
3038
3039
3040 YY_REDUCE_PRINT (yyn);
3041 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003042 {
Reid Spencer38c91a92007-02-28 02:24:54 +00003043 case 29:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003044#line 1099 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003045 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3046 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003047
Reid Spencer38c91a92007-02-28 02:24:54 +00003048 case 30:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003049#line 1099 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003050 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3051 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003052
Reid Spencer38c91a92007-02-28 02:24:54 +00003053 case 31:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003054#line 1100 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003055 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3056 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003057
Reid Spencer38c91a92007-02-28 02:24:54 +00003058 case 32:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003059#line 1100 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003060 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3061 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003062
Reid Spencer38c91a92007-02-28 02:24:54 +00003063 case 33:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003064#line 1101 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003065 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3066 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003067
Reid Spencer38c91a92007-02-28 02:24:54 +00003068 case 34:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003069#line 1101 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003070 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3071 break;
3072
3073 case 35:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003074#line 1102 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003075 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3076 break;
3077
3078 case 36:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003079#line 1102 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003080 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3081 break;
3082
3083 case 37:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003084#line 1103 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003085 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3086 break;
3087
3088 case 38:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003089#line 1103 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003090 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3091 break;
3092
3093 case 39:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003094#line 1107 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003095 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3096 break;
3097
3098 case 40:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003099#line 1107 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003100 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3101 break;
3102
3103 case 41:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003104#line 1108 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003105 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3106 break;
3107
3108 case 42:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003109#line 1108 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003110 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3111 break;
3112
3113 case 43:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003114#line 1109 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003115 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3116 break;
3117
3118 case 44:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003119#line 1109 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003120 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3121 break;
3122
3123 case 45:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003124#line 1110 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003125 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3126 break;
3127
3128 case 46:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003129#line 1110 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003130 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3131 break;
3132
3133 case 47:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003134#line 1111 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003135 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3136 break;
3137
3138 case 48:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003139#line 1111 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003140 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3141 break;
3142
3143 case 49:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003144#line 1112 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003145 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3146 break;
3147
3148 case 50:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003149#line 1112 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003150 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3151 break;
3152
3153 case 51:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003154#line 1113 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003155 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3156 break;
3157
3158 case 52:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003159#line 1113 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003160 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3161 break;
3162
3163 case 53:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003164#line 1114 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003165 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3166 break;
3167
3168 case 54:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003169#line 1115 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003170 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3171 break;
3172
3173 case 61:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003174#line 1124 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003175 { (yyval.StrVal) = 0; ;}
3176 break;
3177
3178 case 62:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003179#line 1128 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003180 {
3181 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003182 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003183 ;}
3184 break;
3185
3186 case 63:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003187#line 1132 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003188 {
3189 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003190 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003191 ;}
3192 break;
3193
3194 case 66:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003195#line 1139 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003196 {
3197 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003198 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003199 ;}
3200 break;
3201
3202 case 67:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003203#line 1143 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003204 {
3205 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003206 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003207 ;}
3208 break;
3209
3210 case 68:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003211#line 1149 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003212 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3213 break;
3214
3215 case 69:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003216#line 1150 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003217 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3218 break;
3219
3220 case 70:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003221#line 1151 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003222 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3223 break;
3224
3225 case 71:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003226#line 1152 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003227 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3228 break;
3229
3230 case 72:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003231#line 1153 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003232 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3233 break;
3234
3235 case 73:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003236#line 1157 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003237 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3238 break;
3239
3240 case 74:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003241#line 1158 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003242 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3243 break;
3244
3245 case 75:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003246#line 1159 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003247 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3248 break;
3249
3250 case 76:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003251#line 1163 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003252 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3253 break;
3254
3255 case 77:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003256#line 1164 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003257 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3258 break;
3259
3260 case 78:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003261#line 1168 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003262 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3263 break;
3264
3265 case 79:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003266#line 1169 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003267 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3268 break;
3269
3270 case 80:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003271#line 1170 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003272 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3273 break;
3274
3275 case 81:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003276#line 1174 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003277 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3278 break;
3279
3280 case 82:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003281#line 1175 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003282 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3283 break;
3284
3285 case 83:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003286#line 1176 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003287 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3288 break;
3289
3290 case 84:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003291#line 1177 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003292 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3293 break;
3294
3295 case 85:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003296#line 1178 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003297 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3298 break;
3299
3300 case 86:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003301#line 1181 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003302 { (yyval.UIntVal) = CallingConv::C; ;}
3303 break;
3304
3305 case 87:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003306#line 1182 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003307 { (yyval.UIntVal) = CallingConv::C; ;}
3308 break;
3309
3310 case 88:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003311#line 1183 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003312 { (yyval.UIntVal) = CallingConv::Fast; ;}
3313 break;
3314
3315 case 89:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003316#line 1184 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003317 { (yyval.UIntVal) = CallingConv::Cold; ;}
3318 break;
3319
3320 case 90:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003321#line 1185 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003322 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3323 break;
3324
3325 case 91:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003326#line 1186 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003327 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3328 break;
3329
3330 case 92:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003331#line 1187 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003332 {
3333 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencerb5334b02007-02-05 10:18:06 +00003334 GEN_ERROR("Calling conv too large");
Reid Spencer38c91a92007-02-28 02:24:54 +00003335 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003336 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003337 ;}
3338 break;
3339
3340 case 93:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003341#line 1194 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003342 { (yyval.ParamAttrs) = FunctionType::ZExtAttribute; ;}
3343 break;
3344
3345 case 94:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003346#line 1195 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003347 { (yyval.ParamAttrs) = FunctionType::SExtAttribute; ;}
3348 break;
3349
3350 case 95:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003351#line 1196 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003352 { (yyval.ParamAttrs) = FunctionType::InRegAttribute; ;}
3353 break;
3354
3355 case 96:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003356#line 1197 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003357 { (yyval.ParamAttrs) = FunctionType::StructRetAttribute; ;}
3358 break;
3359
3360 case 97:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003361#line 1200 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003362 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3363 break;
3364
3365 case 98:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003366#line 1201 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003367 {
3368 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
3369 ;}
3370 break;
3371
3372 case 99:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003373#line 1206 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003374 { (yyval.ParamAttrs) = FunctionType::NoReturnAttribute; ;}
3375 break;
3376
Reid Spencer67d8ed92007-03-22 02:14:08 +00003377 case 100:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003378#line 1207 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003379 { (yyval.ParamAttrs) = FunctionType::NoUnwindAttribute; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003380 break;
3381
3382 case 102:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003383#line 1211 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003384 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3385 break;
3386
3387 case 103:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003388#line 1212 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003389 {
3390 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
3391 ;}
3392 break;
3393
Reid Spencer67d8ed92007-03-22 02:14:08 +00003394 case 104:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003395#line 1219 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003396 { (yyval.UIntVal) = 0; ;}
3397 break;
3398
Reid Spencer67d8ed92007-03-22 02:14:08 +00003399 case 105:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003400#line 1220 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003401 {
3402 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3403 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003404 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003405 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003406;}
3407 break;
3408
Reid Spencer66728ef2007-03-20 01:13:36 +00003409 case 106:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003410#line 1226 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003411 { (yyval.UIntVal) = 0; ;}
3412 break;
3413
3414 case 107:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003415#line 1227 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer66728ef2007-03-20 01:13:36 +00003416 {
3417 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3418 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3419 GEN_ERROR("Alignment must be a power of two");
3420 CHECK_FOR_ERROR
3421;}
3422 break;
3423
Reid Spencer67d8ed92007-03-22 02:14:08 +00003424 case 108:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003425#line 1235 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003426 {
3427 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3428 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencerb5334b02007-02-05 10:18:06 +00003429 GEN_ERROR("Invalid character in section name");
Reid Spencer38c91a92007-02-28 02:24:54 +00003430 (yyval.StrVal) = (yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003431 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003432;}
3433 break;
3434
Reid Spencer67d8ed92007-03-22 02:14:08 +00003435 case 109:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003436#line 1243 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003437 { (yyval.StrVal) = 0; ;}
3438 break;
3439
Reid Spencer38c91a92007-02-28 02:24:54 +00003440 case 110:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003441#line 1244 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003442 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003443 break;
3444
3445 case 111:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003446#line 1249 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003447 {;}
3448 break;
3449
3450 case 112:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003451#line 1250 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003452 {;}
3453 break;
3454
3455 case 113:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003456#line 1251 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003457 {
3458 CurGV->setSection((yyvsp[0].StrVal));
3459 free((yyvsp[0].StrVal));
Reid Spencer6f407902007-01-13 05:00:46 +00003460 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003461 ;}
3462 break;
3463
Reid Spencer67d8ed92007-03-22 02:14:08 +00003464 case 114:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003465#line 1256 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003466 {
3467 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003468 GEN_ERROR("Alignment must be a power of two");
Reid Spencer38c91a92007-02-28 02:24:54 +00003469 CurGV->setAlignment((yyvsp[0].UInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003470 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003471 ;}
3472 break;
3473
Reid Spencer67d8ed92007-03-22 02:14:08 +00003474 case 119:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003475#line 1272 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003476 {
3477 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003478 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003479 ;}
3480 break;
3481
Reid Spencer67d8ed92007-03-22 02:14:08 +00003482 case 120:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003483#line 1276 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003484 {
3485 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003486 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003487 ;}
3488 break;
3489
Reid Spencer67d8ed92007-03-22 02:14:08 +00003490 case 121:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003491#line 1280 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003492 { // Pointer type?
3493 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003494 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencer38c91a92007-02-28 02:24:54 +00003495 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3496 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003497 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003498 ;}
3499 break;
3500
Reid Spencer67d8ed92007-03-22 02:14:08 +00003501 case 122:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003502#line 1287 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003503 { // Named types are also simple types...
3504 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003505 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003506 (yyval.TypeVal) = new PATypeHolder(tmp);
3507 ;}
3508 break;
3509
Reid Spencer67d8ed92007-03-22 02:14:08 +00003510 case 123:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003511#line 1292 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003512 { // Type UpReference
3513 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003514 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer38c91a92007-02-28 02:24:54 +00003515 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3516 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003517 UR_OUT("New Upreference!\n");
3518 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003519 ;}
3520 break;
3521
Reid Spencer67d8ed92007-03-22 02:14:08 +00003522 case 124:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003523#line 1300 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003524 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003525 std::vector<const Type*> Params;
3526 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00003527 Attrs.push_back((yyvsp[0].ParamAttrs));
3528 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003529 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003530 Params.push_back(Ty);
3531 if (Ty != Type::VoidTy)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003532 Attrs.push_back(I->Attrs);
3533 }
3534 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3535 if (isVarArg) Params.pop_back();
3536
Reid Spencer38c91a92007-02-28 02:24:54 +00003537 FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, Attrs);
3538 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3539 delete (yyvsp[-4].TypeVal); // Delete the return type handle
3540 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003541 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003542 ;}
3543 break;
3544
Reid Spencer67d8ed92007-03-22 02:14:08 +00003545 case 125:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003546#line 1319 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003547 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003548 std::vector<const Type*> Params;
3549 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00003550 Attrs.push_back((yyvsp[0].ParamAttrs));
3551 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003552 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003553 Params.push_back(Ty);
3554 if (Ty != Type::VoidTy)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003555 Attrs.push_back(I->Attrs);
3556 }
3557 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3558 if (isVarArg) Params.pop_back();
3559
Reid Spencer38c91a92007-02-28 02:24:54 +00003560 FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, Attrs);
3561 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3562 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003563 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003564 ;}
3565 break;
3566
Reid Spencer67d8ed92007-03-22 02:14:08 +00003567 case 126:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003568#line 1338 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003569 { // Sized array type?
3570 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3571 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003572 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003573 ;}
3574 break;
3575
Reid Spencer67d8ed92007-03-22 02:14:08 +00003576 case 127:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003577#line 1343 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003578 { // Vector type?
3579 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3580 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003581 GEN_ERROR("Unsigned result not equal to signed result");
3582 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
Reid Spencer9d6565a2007-02-15 02:26:10 +00003583 GEN_ERROR("Element type of a VectorType must be primitive");
Reid Spencer38c91a92007-02-28 02:24:54 +00003584 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003585 GEN_ERROR("Vector length should be a power of 2");
Reid Spencer38c91a92007-02-28 02:24:54 +00003586 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3587 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003588 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003589 ;}
3590 break;
3591
Reid Spencer67d8ed92007-03-22 02:14:08 +00003592 case 128:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003593#line 1355 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003594 { // Structure type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003595 std::vector<const Type*> Elements;
Reid Spencer38c91a92007-02-28 02:24:54 +00003596 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3597 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003598 Elements.push_back(*I);
3599
Reid Spencer38c91a92007-02-28 02:24:54 +00003600 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3601 delete (yyvsp[-1].TypeList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003602 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003603 ;}
3604 break;
3605
Reid Spencer67d8ed92007-03-22 02:14:08 +00003606 case 129:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003607#line 1365 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003608 { // Empty structure type?
3609 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003610 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003611 ;}
3612 break;
3613
Reid Spencer67d8ed92007-03-22 02:14:08 +00003614 case 130:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003615#line 1369 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003616 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003617 std::vector<const Type*> Elements;
Reid Spencer38c91a92007-02-28 02:24:54 +00003618 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3619 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003620 Elements.push_back(*I);
3621
Reid Spencer38c91a92007-02-28 02:24:54 +00003622 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3623 delete (yyvsp[-2].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003624 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003625 ;}
3626 break;
3627
Reid Spencer67d8ed92007-03-22 02:14:08 +00003628 case 131:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003629#line 1379 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003630 { // Empty structure type?
3631 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003632 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003633 ;}
3634 break;
3635
Reid Spencer67d8ed92007-03-22 02:14:08 +00003636 case 132:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003637#line 1386 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003638 {
3639 (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal);
3640 (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs);
3641 ;}
3642 break;
3643
Reid Spencer67d8ed92007-03-22 02:14:08 +00003644 case 133:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003645#line 1393 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003646 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003647 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003648 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3649 if (!(*(yyvsp[0].TypeVal))->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00003650 GEN_ERROR("LLVM functions cannot return aggregate types");
Reid Spencer38c91a92007-02-28 02:24:54 +00003651 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3652 ;}
3653 break;
3654
Reid Spencer67d8ed92007-03-22 02:14:08 +00003655 case 134:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003656#line 1400 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003657 {
3658 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3659 ;}
3660 break;
3661
Reid Spencer67d8ed92007-03-22 02:14:08 +00003662 case 135:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003663#line 1405 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003664 {
3665 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3666 (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer6f407902007-01-13 05:00:46 +00003667 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003668 ;}
3669 break;
3670
Reid Spencer67d8ed92007-03-22 02:14:08 +00003671 case 136:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003672#line 1410 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003673 {
3674 ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00003675 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003676 ;}
3677 break;
3678
Reid Spencer67d8ed92007-03-22 02:14:08 +00003679 case 138:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003680#line 1418 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003681 {
3682 (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003683 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3684 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003685 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003686 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003687 ;}
3688 break;
3689
Reid Spencer67d8ed92007-03-22 02:14:08 +00003690 case 139:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003691#line 1425 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003692 {
3693 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003694 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3695 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003696 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003697 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003698 ;}
3699 break;
3700
Reid Spencer67d8ed92007-03-22 02:14:08 +00003701 case 140:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003702#line 1432 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003703 {
3704 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003705 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003706 ;}
3707 break;
3708
Reid Spencer67d8ed92007-03-22 02:14:08 +00003709 case 141:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003710#line 1440 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003711 {
3712 (yyval.TypeList) = new std::list<PATypeHolder>();
Reid Spencer66728ef2007-03-20 01:13:36 +00003713 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal));
3714 delete (yyvsp[0].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003715 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003716 ;}
3717 break;
3718
Reid Spencer67d8ed92007-03-22 02:14:08 +00003719 case 142:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003720#line 1446 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003721 {
Reid Spencer66728ef2007-03-20 01:13:36 +00003722 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal));
3723 delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003724 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003725 ;}
3726 break;
3727
Reid Spencer67d8ed92007-03-22 02:14:08 +00003728 case 143:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003729#line 1458 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003730 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003731 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003732 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3733 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003734 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003735 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003736 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003737 const Type *ETy = ATy->getElementType();
3738 int NumElements = ATy->getNumElements();
3739
3740 // Verify that we have the correct size...
Reid Spencer38c91a92007-02-28 02:24:54 +00003741 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003742 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003743 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003744 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003745
3746 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00003747 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3748 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003749 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3750 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer38c91a92007-02-28 02:24:54 +00003751 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003752 }
3753
Reid Spencer38c91a92007-02-28 02:24:54 +00003754 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3755 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003756 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003757 ;}
3758 break;
3759
Reid Spencer67d8ed92007-03-22 02:14:08 +00003760 case 144:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003761#line 1486 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003762 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003763 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003764 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3765 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003766 if (ATy == 0)
3767 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003768 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003769
Andrew Lenharth6353e052006-12-08 18:07:09 +00003770 int NumElements = ATy->getNumElements();
3771 if (NumElements != -1 && NumElements != 0)
3772 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003773 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencer38c91a92007-02-28 02:24:54 +00003774 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3775 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003776 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003777 ;}
3778 break;
3779
Reid Spencer67d8ed92007-03-22 02:14:08 +00003780 case 145:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003781#line 1502 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003782 {
Reid Spencer14310612006-12-31 05:40:51 +00003783 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003784 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3785 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003786 if (ATy == 0)
3787 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003788 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer61c83e02006-08-18 08:43:06 +00003789
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003790 int NumElements = ATy->getNumElements();
3791 const Type *ETy = ATy->getElementType();
Reid Spencer38c91a92007-02-28 02:24:54 +00003792 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3793 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003794 GEN_ERROR("Can't build string constant of size " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003795 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003796 " when array has size " + itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003797 std::vector<Constant*> Vals;
3798 if (ETy == Type::Int8Ty) {
Reid Spencer38c91a92007-02-28 02:24:54 +00003799 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003800 C != (unsigned char*)EndStr; ++C)
3801 Vals.push_back(ConstantInt::get(ETy, *C));
3802 } else {
Reid Spencer38c91a92007-02-28 02:24:54 +00003803 free((yyvsp[0].StrVal));
Reid Spencerb5334b02007-02-05 10:18:06 +00003804 GEN_ERROR("Cannot build string arrays of non byte sized elements");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003805 }
Reid Spencer38c91a92007-02-28 02:24:54 +00003806 free((yyvsp[0].StrVal));
3807 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3808 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003809 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003810 ;}
3811 break;
3812
Reid Spencer67d8ed92007-03-22 02:14:08 +00003813 case 146:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003814#line 1531 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003815 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003816 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003817 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3818 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003819 if (PTy == 0)
3820 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003821 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003822 const Type *ETy = PTy->getElementType();
3823 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003824
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003825 // Verify that we have the correct size...
Reid Spencer38c91a92007-02-28 02:24:54 +00003826 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003827 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003828 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003829 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003830
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003831 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00003832 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3833 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003834 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3835 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer38c91a92007-02-28 02:24:54 +00003836 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003837 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003838
Reid Spencer38c91a92007-02-28 02:24:54 +00003839 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[-1].ConstVector));
3840 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003841 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003842 ;}
3843 break;
3844
Reid Spencer67d8ed92007-03-22 02:14:08 +00003845 case 147:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003846#line 1559 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003847 {
3848 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003849 if (STy == 0)
3850 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003851 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003852
Reid Spencer38c91a92007-02-28 02:24:54 +00003853 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003854 GEN_ERROR("Illegal number of initializers for structure type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003855
3856 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer38c91a92007-02-28 02:24:54 +00003857 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3858 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003859 GEN_ERROR("Expected type '" +
3860 STy->getElementType(i)->getDescription() +
3861 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003862 " of structure initializer");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003863
3864 // Check to ensure that Type is not packed
3865 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003866 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003867
Reid Spencer38c91a92007-02-28 02:24:54 +00003868 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3869 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003870 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003871 ;}
3872 break;
3873
Reid Spencer67d8ed92007-03-22 02:14:08 +00003874 case 148:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003875#line 1584 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003876 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003877 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003878 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3879 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003880 if (STy == 0)
3881 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003882 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003883
3884 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003885 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003886
3887 // Check to ensure that Type is not packed
3888 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003889 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003890
Reid Spencer38c91a92007-02-28 02:24:54 +00003891 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3892 delete (yyvsp[-2].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003893 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003894 ;}
3895 break;
3896
Reid Spencer67d8ed92007-03-22 02:14:08 +00003897 case 149:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003898#line 1603 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003899 {
3900 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003901 if (STy == 0)
3902 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003903 (*(yyvsp[-5].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003904
Reid Spencer38c91a92007-02-28 02:24:54 +00003905 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003906 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003907
3908 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer38c91a92007-02-28 02:24:54 +00003909 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i)
3910 if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003911 GEN_ERROR("Expected type '" +
3912 STy->getElementType(i)->getDescription() +
3913 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003914 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003915
3916 // Check to ensure that Type is packed
3917 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003918 GEN_ERROR("Vector initializer to non-vector type '" +
3919 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003920
Reid Spencer38c91a92007-02-28 02:24:54 +00003921 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector));
3922 delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003923 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003924 ;}
3925 break;
3926
Reid Spencer67d8ed92007-03-22 02:14:08 +00003927 case 150:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003928#line 1629 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003929 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003930 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003931 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
3932 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003933 if (STy == 0)
3934 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003935 (*(yyvsp[-4].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003936
3937 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003938 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003939
3940 // Check to ensure that Type is packed
3941 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003942 GEN_ERROR("Vector initializer to non-vector type '" +
3943 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003944
Reid Spencer38c91a92007-02-28 02:24:54 +00003945 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3946 delete (yyvsp[-4].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003947 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003948 ;}
3949 break;
3950
Reid Spencer67d8ed92007-03-22 02:14:08 +00003951 case 151:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003952#line 1649 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003953 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003954 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003955 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3956 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003957 if (PTy == 0)
3958 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003959 (*(yyvsp[-1].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003960
Reid Spencer38c91a92007-02-28 02:24:54 +00003961 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3962 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003963 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003964 ;}
3965 break;
3966
Reid Spencer67d8ed92007-03-22 02:14:08 +00003967 case 152:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003968#line 1661 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003969 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003970 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003971 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3972 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3973 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003974 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003975 ;}
3976 break;
3977
Reid Spencer67d8ed92007-03-22 02:14:08 +00003978 case 153:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00003979#line 1668 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003980 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003981 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003982 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3983 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003984 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003985 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003986
3987 // ConstExprs can exist in the body of a function, thus creating
3988 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00003989 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00003990 // symbol table instead of the module symbol table for the global symbol,
3991 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00003992 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00003993 //
3994 Function *SavedCurFn = CurFun.CurrentFunction;
3995 CurFun.CurrentFunction = 0;
3996
Reid Spencer93c40032007-03-19 18:40:50 +00003997 Value *V = getExistingVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003998 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003999
4000 CurFun.CurrentFunction = SavedCurFn;
4001
4002 // If this is an initializer for a constant pointer, which is referencing a
4003 // (currently) undefined variable, create a stub now that shall be replaced
4004 // in the future with the right type of variable.
4005 //
4006 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004007 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004008 const PointerType *PT = cast<PointerType>(Ty);
4009
4010 // First check to see if the forward references value is already created!
4011 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer38c91a92007-02-28 02:24:54 +00004012 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004013
4014 if (I != CurModule.GlobalRefs.end()) {
4015 V = I->second; // Placeholder already exists, use it...
Reid Spencer38c91a92007-02-28 02:24:54 +00004016 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004017 } else {
4018 std::string Name;
Reid Spencer38c91a92007-02-28 02:24:54 +00004019 if ((yyvsp[0].ValIDVal).Type == ValID::GlobalName)
4020 Name = (yyvsp[0].ValIDVal).Name;
4021 else if ((yyvsp[0].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004022 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004023
4024 // Create the forward referenced global.
4025 GlobalValue *GV;
4026 if (const FunctionType *FTy =
4027 dyn_cast<FunctionType>(PT->getElementType())) {
4028 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4029 CurModule.CurrentModule);
4030 } else {
4031 GV = new GlobalVariable(PT->getElementType(), false,
4032 GlobalValue::ExternalLinkage, 0,
4033 Name, CurModule.CurrentModule);
4034 }
4035
4036 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer38c91a92007-02-28 02:24:54 +00004037 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004038 V = GV;
4039 }
4040 }
4041
Reid Spencer38c91a92007-02-28 02:24:54 +00004042 (yyval.ConstVal) = cast<GlobalValue>(V);
4043 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004044 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004045 ;}
4046 break;
4047
Reid Spencer67d8ed92007-03-22 02:14:08 +00004048 case 154:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004049#line 1734 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004050 {
Reid Spencer14310612006-12-31 05:40:51 +00004051 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004052 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4053 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004054 GEN_ERROR("Mismatched types for constant expression: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00004055 (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription());
4056 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4057 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004058 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004059 ;}
4060 break;
4061
Reid Spencer67d8ed92007-03-22 02:14:08 +00004062 case 155:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004063#line 1744 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004064 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004065 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004066 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4067 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004068 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencerb5334b02007-02-05 10:18:06 +00004069 GEN_ERROR("Cannot create a null initialized value of this type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004070 (yyval.ConstVal) = Constant::getNullValue(Ty);
4071 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004072 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004073 ;}
4074 break;
4075
Reid Spencer67d8ed92007-03-22 02:14:08 +00004076 case 156:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004077#line 1754 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004078 { // integral constants
4079 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004080 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer49d273e2007-03-19 20:40:51 +00004081 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val), true);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004082 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004083 ;}
4084 break;
4085
Reid Spencer67d8ed92007-03-22 02:14:08 +00004086 case 157:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004087#line 1760 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004088 { // arbitrary precision integer constants
4089 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4090 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
4091 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004092 }
4093 (yyvsp[0].APIntVal)->sextOrTrunc(BitWidth);
4094 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004095 delete (yyvsp[0].APIntVal);
4096 CHECK_FOR_ERROR
4097 ;}
4098 break;
4099
Reid Spencer67d8ed92007-03-22 02:14:08 +00004100 case 158:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004101#line 1770 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004102 { // integral constants
4103 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004104 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer49d273e2007-03-19 20:40:51 +00004105 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004106 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004107 ;}
4108 break;
4109
Reid Spencer67d8ed92007-03-22 02:14:08 +00004110 case 159:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004111#line 1776 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004112 { // arbitrary precision integer constants
4113 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4114 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
4115 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004116 }
4117 (yyvsp[0].APIntVal)->zextOrTrunc(BitWidth);
4118 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004119 delete (yyvsp[0].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004120 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004121 ;}
4122 break;
4123
Reid Spencer67d8ed92007-03-22 02:14:08 +00004124 case 160:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004125#line 1786 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004126 { // Boolean constants
4127 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4128 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004129 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004130 ;}
4131 break;
4132
Reid Spencer67d8ed92007-03-22 02:14:08 +00004133 case 161:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004134#line 1791 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004135 { // Boolean constants
4136 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4137 (yyval.ConstVal) = ConstantInt::getFalse();
4138 CHECK_FOR_ERROR
4139 ;}
4140 break;
4141
Reid Spencer67d8ed92007-03-22 02:14:08 +00004142 case 162:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004143#line 1796 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004144 { // Float & Double constants
4145 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004146 GEN_ERROR("Floating point constant invalid for type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004147 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004148 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004149 ;}
4150 break;
4151
Reid Spencer67d8ed92007-03-22 02:14:08 +00004152 case 163:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004153#line 1804 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004154 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004155 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004156 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4157 Constant *Val = (yyvsp[-3].ConstVal);
4158 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4159 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004160 GEN_ERROR("invalid cast opcode for cast from '" +
4161 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004162 DestTy->getDescription() + "'");
Reid Spencer38c91a92007-02-28 02:24:54 +00004163 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
4164 delete (yyvsp[-1].TypeVal);
4165 ;}
4166 break;
4167
Reid Spencer67d8ed92007-03-22 02:14:08 +00004168 case 164:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004169#line 1816 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004170 {
4171 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004172 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004173
4174 const Type *IdxTy =
Reid Spencer38c91a92007-02-28 02:24:54 +00004175 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), &(*(yyvsp[-1].ValueList))[0], (yyvsp[-1].ValueList)->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004176 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004177 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004178 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004179
Chris Lattnerf7469af2007-01-31 04:44:08 +00004180 SmallVector<Constant*, 8> IdxVec;
Reid Spencer38c91a92007-02-28 02:24:54 +00004181 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
4182 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004183 IdxVec.push_back(C);
4184 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004185 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004186
Reid Spencer38c91a92007-02-28 02:24:54 +00004187 delete (yyvsp[-1].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004188
Reid Spencer38c91a92007-02-28 02:24:54 +00004189 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004190 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004191 ;}
4192 break;
4193
Reid Spencer67d8ed92007-03-22 02:14:08 +00004194 case 165:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004195#line 1838 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004196 {
4197 if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00004198 GEN_ERROR("Select condition must be of boolean type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004199 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004200 GEN_ERROR("Select operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004201 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004202 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004203 ;}
4204 break;
4205
Reid Spencer67d8ed92007-03-22 02:14:08 +00004206 case 166:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004207#line 1846 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004208 {
4209 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004210 GEN_ERROR("Binary operator types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004211 CHECK_FOR_ERROR;
Reid Spencer38c91a92007-02-28 02:24:54 +00004212 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4213 ;}
4214 break;
4215
Reid Spencer67d8ed92007-03-22 02:14:08 +00004216 case 167:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004217#line 1852 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004218 {
4219 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004220 GEN_ERROR("Logical operator types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004221 if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) {
4222 if (Instruction::isShift((yyvsp[-5].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].ConstVal)->getType()) ||
4223 !cast<VectorType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00004224 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004225 }
Reid Spencer38c91a92007-02-28 02:24:54 +00004226 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004227 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004228 ;}
4229 break;
4230
Reid Spencer67d8ed92007-03-22 02:14:08 +00004231 case 168:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004232#line 1863 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004233 {
4234 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004235 GEN_ERROR("icmp operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004236 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4237 ;}
4238 break;
4239
Reid Spencer67d8ed92007-03-22 02:14:08 +00004240 case 169:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004241#line 1868 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004242 {
4243 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004244 GEN_ERROR("fcmp operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004245 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4246 ;}
4247 break;
4248
Reid Spencer67d8ed92007-03-22 02:14:08 +00004249 case 170:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004250#line 1873 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004251 {
4252 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004253 GEN_ERROR("Invalid extractelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004254 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004255 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004256 ;}
4257 break;
4258
Reid Spencer67d8ed92007-03-22 02:14:08 +00004259 case 171:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004260#line 1879 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004261 {
4262 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004263 GEN_ERROR("Invalid insertelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004264 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004265 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004266 ;}
4267 break;
4268
Reid Spencer67d8ed92007-03-22 02:14:08 +00004269 case 172:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004270#line 1885 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004271 {
4272 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004273 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004274 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004275 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004276 ;}
4277 break;
4278
Reid Spencer67d8ed92007-03-22 02:14:08 +00004279 case 173:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004280#line 1894 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004281 {
4282 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004283 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004284 ;}
4285 break;
4286
Reid Spencer67d8ed92007-03-22 02:14:08 +00004287 case 174:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004288#line 1898 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004289 {
4290 (yyval.ConstVector) = new std::vector<Constant*>();
4291 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004292 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004293 ;}
4294 break;
4295
Reid Spencer67d8ed92007-03-22 02:14:08 +00004296 case 175:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004297#line 1906 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004298 { (yyval.BoolVal) = false; ;}
4299 break;
4300
Reid Spencer67d8ed92007-03-22 02:14:08 +00004301 case 176:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004302#line 1906 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004303 { (yyval.BoolVal) = true; ;}
4304 break;
4305
Reid Spencer38c91a92007-02-28 02:24:54 +00004306 case 177:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004307#line 1917 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004308 {
4309 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004310 CurModule.ModuleDone();
4311 CHECK_FOR_ERROR;
Reid Spencer38c91a92007-02-28 02:24:54 +00004312 ;}
4313 break;
4314
Reid Spencer67d8ed92007-03-22 02:14:08 +00004315 case 178:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004316#line 1922 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00004317 {
4318 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4319 CurModule.ModuleDone();
4320 CHECK_FOR_ERROR;
4321 ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00004322 break;
4323
4324 case 181:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004325#line 1935 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00004326 { CurFun.isDeclare = false; ;}
4327 break;
4328
4329 case 182:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004330#line 1935 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004331 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004332 CurFun.FunctionDone();
4333 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004334 ;}
4335 break;
4336
Reid Spencer67d8ed92007-03-22 02:14:08 +00004337 case 183:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004338#line 1939 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004339 { CurFun.isDeclare = true; ;}
4340 break;
4341
Reid Spencer38c91a92007-02-28 02:24:54 +00004342 case 184:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004343#line 1939 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004344 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004345 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004346 ;}
4347 break;
4348
4349 case 185:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004350#line 1942 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00004351 {
4352 CHECK_FOR_ERROR
4353 ;}
4354 break;
4355
4356 case 186:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004357#line 1945 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004358 {
Reid Spencer14310612006-12-31 05:40:51 +00004359 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004360 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004361 // Eagerly resolve types. This is not an optimization, this is a
4362 // requirement that is due to the fact that we could have this:
4363 //
4364 // %list = type { %list * }
4365 // %list = type { %list * } ; repeated type decl
4366 //
4367 // If types are not resolved eagerly, then the two types will not be
4368 // determined to be the same type!
4369 //
Reid Spencer38c91a92007-02-28 02:24:54 +00004370 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004371
Reid Spencer38c91a92007-02-28 02:24:54 +00004372 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004373 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004374 // If this is a named type that is not a redefinition, add it to the slot
4375 // table.
Reid Spencer38c91a92007-02-28 02:24:54 +00004376 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004377 }
Reid Spencera132e042006-12-03 05:46:11 +00004378
Reid Spencer38c91a92007-02-28 02:24:54 +00004379 delete (yyvsp[0].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004380 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004381 ;}
4382 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004383
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004384 case 187:
4385#line 1969 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004386 {
4387 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType));
4388
4389 if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004390 CHECK_FOR_ERROR
4391 // If this is a named type that is not a redefinition, add it to the slot
4392 // table.
Reid Spencer38c91a92007-02-28 02:24:54 +00004393 CurModule.Types.push_back((yyvsp[0].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004394 }
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004395 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004396 ;}
4397 break;
4398
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004399 case 188:
4400#line 1980 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004401 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004402 /* "Externally Visible" Linkage */
Reid Spencer38c91a92007-02-28 02:24:54 +00004403 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004404 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer38c91a92007-02-28 02:24:54 +00004405 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage,
4406 (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004407 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004408 ;}
4409 break;
4410
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004411 case 189:
4412#line 1987 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004413 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004414 CurGV = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00004415 ;}
4416 break;
4417
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004418 case 190:
4419#line 1990 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004420 {
4421 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004422 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer38c91a92007-02-28 02:24:54 +00004423 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 +00004424 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004425 ;}
4426 break;
4427
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004428 case 191:
4429#line 1995 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004430 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004431 CurGV = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00004432 ;}
4433 break;
4434
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004435 case 192:
4436#line 1998 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004437 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004438 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004439 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
4440 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 +00004441 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004442 delete (yyvsp[0].TypeVal);
4443 ;}
4444 break;
4445
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004446 case 193:
4447#line 2004 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004448 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004449 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004450 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004451 ;}
4452 break;
4453
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004454 case 194:
4455#line 2008 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004456 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004457 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004458 ;}
4459 break;
4460
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004461 case 195:
4462#line 2011 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004463 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004464 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004465 ;}
4466 break;
4467
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004468 case 196:
4469#line 2017 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004470 {
Chris Lattner66316012006-01-24 04:14:29 +00004471 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer38c91a92007-02-28 02:24:54 +00004472 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4473 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4474 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004475
4476 if (AsmSoFar.empty())
4477 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4478 else
4479 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004480 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004481;}
4482 break;
4483
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004484 case 197:
4485#line 2030 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004486 {
4487 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4488 free((yyvsp[0].StrVal));
4489 ;}
4490 break;
4491
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004492 case 198:
4493#line 2034 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004494 {
4495 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4496 free((yyvsp[0].StrVal));
4497 ;}
4498 break;
4499
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004500 case 200:
4501#line 2041 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4502 {
4503 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4504 free((yyvsp[0].StrVal));
4505 CHECK_FOR_ERROR
4506 ;}
4507 break;
4508
Reid Spencer38c91a92007-02-28 02:24:54 +00004509 case 201:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004510#line 2046 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004511 {
4512 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4513 free((yyvsp[0].StrVal));
Reid Spencera54b7cb2007-01-12 07:05:14 +00004514 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004515 ;}
4516 break;
4517
4518 case 202:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004519#line 2051 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004520 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004521 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004522 ;}
4523 break;
4524
4525 case 203:
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004526#line 2060 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004527 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004528 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004529 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4530 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004531 GEN_ERROR("void typed arguments are invalid");
Reid Spencer38c91a92007-02-28 02:24:54 +00004532 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4533 (yyval.ArgList) = (yyvsp[-4].ArgList);
4534 (yyvsp[-4].ArgList)->push_back(E);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004535 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004536 ;}
4537 break;
4538
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004539 case 204:
4540#line 2070 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004541 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004542 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004543 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4544 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004545 GEN_ERROR("void typed arguments are invalid");
Reid Spencer38c91a92007-02-28 02:24:54 +00004546 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4547 (yyval.ArgList) = new ArgListType;
4548 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004549 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004550 ;}
4551 break;
4552
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004553 case 205:
4554#line 2081 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004555 {
4556 (yyval.ArgList) = (yyvsp[0].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004557 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004558 ;}
4559 break;
4560
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004561 case 206:
4562#line 2085 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004563 {
4564 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004565 struct ArgListEntry E;
4566 E.Ty = new PATypeHolder(Type::VoidTy);
4567 E.Name = 0;
4568 E.Attrs = FunctionType::NoAttributeSet;
Reid Spencer38c91a92007-02-28 02:24:54 +00004569 (yyval.ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004570 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004571 ;}
4572 break;
4573
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004574 case 207:
4575#line 2094 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004576 {
4577 (yyval.ArgList) = new ArgListType;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004578 struct ArgListEntry E;
4579 E.Ty = new PATypeHolder(Type::VoidTy);
4580 E.Name = 0;
4581 E.Attrs = FunctionType::NoAttributeSet;
Reid Spencer38c91a92007-02-28 02:24:54 +00004582 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004583 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004584 ;}
4585 break;
4586
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004587 case 208:
4588#line 2103 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004589 {
4590 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004591 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004592 ;}
4593 break;
4594
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004595 case 209:
4596#line 2109 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004597 {
4598 UnEscapeLexed((yyvsp[-6].StrVal));
4599 std::string FunctionName((yyvsp[-6].StrVal));
4600 free((yyvsp[-6].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004601
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004602 // Check the function result for abstractness if this is a define. We should
4603 // have no abstract types at this point
Reid Spencer38c91a92007-02-28 02:24:54 +00004604 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal)))
4605 GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004606
Reid Spencer68a24bd2005-08-27 18:50:39 +00004607 std::vector<const Type*> ParamTypeList;
Reid Spencer14310612006-12-31 05:40:51 +00004608 std::vector<FunctionType::ParameterAttributes> ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00004609 ParamAttrs.push_back((yyvsp[-2].ParamAttrs));
4610 if ((yyvsp[-4].ArgList)) { // If there are arguments...
4611 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004612 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004613 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4614 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004615 ParamTypeList.push_back(Ty);
4616 if (Ty != Type::VoidTy)
4617 ParamAttrs.push_back(I->Attrs);
4618 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004619 }
4620
4621 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4622 if (isVarArg) ParamTypeList.pop_back();
4623
Reid Spencer38c91a92007-02-28 02:24:54 +00004624 FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg,
Reid Spencer14310612006-12-31 05:40:51 +00004625 ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004626 const PointerType *PFT = PointerType::get(FT);
Reid Spencer38c91a92007-02-28 02:24:54 +00004627 delete (yyvsp[-7].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004628
4629 ValID ID;
4630 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004631 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004632 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004633 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004634 }
4635
4636 Function *Fn = 0;
4637 // See if this function was forward referenced. If so, recycle the object.
4638 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4639 // Move the function to the end of the list, from whereever it was
4640 // previously inserted.
4641 Fn = cast<Function>(FWRef);
4642 CurModule.CurrentModule->getFunctionList().remove(Fn);
4643 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4644 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004645 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
4646 if (Fn->getFunctionType() != FT ) {
4647 // The existing function doesn't have the same type. This is an overload
4648 // error.
4649 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4650 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
4651 // Neither the existing or the current function is a declaration and they
4652 // have the same name and same type. Clearly this is a redefinition.
Reid Spencerb5334b02007-02-05 10:18:06 +00004653 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004654 } if (Fn->isDeclaration()) {
4655 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004656 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4657 AI != AE; ++AI)
4658 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004659 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004660 } else { // Not already defined?
4661 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4662 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004663
Reid Spencer68a24bd2005-08-27 18:50:39 +00004664 InsertValue(Fn, CurModule.Values);
4665 }
4666
4667 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004668
4669 if (CurFun.isDeclare) {
4670 // If we have declaration, always overwrite linkage. This will allow us to
4671 // correctly handle cases, when pointer to function is passed as argument to
4672 // another function.
4673 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004674 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004675 }
Reid Spencer38c91a92007-02-28 02:24:54 +00004676 Fn->setCallingConv((yyvsp[-8].UIntVal));
4677 Fn->setAlignment((yyvsp[0].UIntVal));
4678 if ((yyvsp[-1].StrVal)) {
4679 Fn->setSection((yyvsp[-1].StrVal));
4680 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004681 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004682
4683 // Add all of the arguments we parsed to the function...
Reid Spencer38c91a92007-02-28 02:24:54 +00004684 if ((yyvsp[-4].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004685 if (isVarArg) { // Nuke the last entry
Reid Spencer38c91a92007-02-28 02:24:54 +00004686 assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004687 "Not a varargs marker!");
Reid Spencer38c91a92007-02-28 02:24:54 +00004688 delete (yyvsp[-4].ArgList)->back().Ty;
4689 (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004690 }
4691 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004692 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004693 unsigned Idx = 1;
Reid Spencer38c91a92007-02-28 02:24:54 +00004694 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin();
4695 I != (yyvsp[-4].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004696 delete I->Ty; // Delete the typeholder...
Reid Spenceref9b9a72007-02-05 20:47:22 +00004697 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004698 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004699 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004700 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004701 }
Reid Spencera132e042006-12-03 05:46:11 +00004702
Reid Spencer38c91a92007-02-28 02:24:54 +00004703 delete (yyvsp[-4].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004704 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004705 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004706;}
4707 break;
4708
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004709 case 212:
4710#line 2222 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004711 {
4712 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004713
4714 // Make sure that we keep track of the linkage type even if there was a
4715 // previous "declare".
Reid Spencer38c91a92007-02-28 02:24:54 +00004716 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
4717 (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility));
4718;}
4719 break;
4720
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004721 case 215:
4722#line 2233 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004723 {
4724 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004725 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004726;}
4727 break;
4728
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004729 case 216:
4730#line 2238 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004731 {
4732 CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage));
4733 CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility));
4734 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004735 CurFun.FunctionDone();
4736 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004737 ;}
4738 break;
4739
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004740 case 217:
4741#line 2250 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004742 {
4743 (yyval.BoolVal) = false;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004744 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004745 ;}
4746 break;
4747
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004748 case 218:
4749#line 2254 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004750 {
4751 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004752 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004753 ;}
4754 break;
4755
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004756 case 219:
4757#line 2259 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004758 { // A reference to a direct constant
4759 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004760 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004761 ;}
4762 break;
4763
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004764 case 220:
4765#line 2263 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004766 {
4767 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Reid Spencer6f407902007-01-13 05:00:46 +00004768 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004769 ;}
4770 break;
4771
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004772 case 221:
4773#line 2267 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004774 { // Perhaps it's an FP constant?
4775 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004776 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004777 ;}
4778 break;
4779
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004780 case 222:
4781#line 2271 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004782 {
4783 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004784 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004785 ;}
4786 break;
4787
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004788 case 223:
4789#line 2275 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004790 {
4791 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004792 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004793 ;}
4794 break;
4795
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004796 case 224:
4797#line 2279 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004798 {
4799 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004800 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004801 ;}
4802 break;
4803
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004804 case 225:
4805#line 2283 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004806 {
4807 (yyval.ValIDVal) = ValID::createUndef();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004808 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004809 ;}
4810 break;
4811
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004812 case 226:
4813#line 2287 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004814 { // A vector zero constant.
4815 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00004816 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004817 ;}
4818 break;
4819
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004820 case 227:
4821#line 2291 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004822 { // Nonempty unsized packed vector
4823 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4824 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004825
Reid Spencer9d6565a2007-02-15 02:26:10 +00004826 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004827 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004828 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004829 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004830 ETy,
4831 NumElements)
4832 )
4833 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004834
4835 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00004836 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4837 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004838 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004839 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00004840 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004841 }
4842
Reid Spencer38c91a92007-02-28 02:24:54 +00004843 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[-1].ConstVector)));
4844 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004845 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004846 ;}
4847 break;
4848
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004849 case 228:
4850#line 2316 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004851 {
4852 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004853 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004854 ;}
4855 break;
4856
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004857 case 229:
4858#line 2320 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004859 {
4860 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4861 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4862 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4863 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4864 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4865 free((yyvsp[-2].StrVal));
4866 free((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004867 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004868 ;}
4869 break;
4870
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004871 case 230:
4872#line 2334 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004873 { // Is it an integer reference...?
4874 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004875 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004876 ;}
4877 break;
4878
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004879 case 231:
4880#line 2338 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004881 {
4882 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004883 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004884 ;}
4885 break;
4886
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004887 case 232:
4888#line 2342 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004889 { // Is it a named reference...?
4890 (yyval.ValIDVal) = ValID::createLocalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004891 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004892 ;}
4893 break;
4894
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004895 case 233:
4896#line 2346 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004897 { // Is it a named reference...?
4898 (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004899 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004900 ;}
4901 break;
4902
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004903 case 236:
4904#line 2358 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004905 {
Reid Spencer832254e2007-02-02 02:16:23 +00004906 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004907 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4908 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
4909 delete (yyvsp[-1].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004910 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004911 ;}
4912 break;
4913
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004914 case 237:
4915#line 2367 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004916 {
4917 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004918 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004919 ;}
4920 break;
4921
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004922 case 238:
4923#line 2371 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004924 { // Do not allow functions with 0 basic blocks
4925 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004926 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004927 ;}
4928 break;
4929
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004930 case 239:
4931#line 2380 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004932 {
4933 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004934 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004935 InsertValue((yyvsp[0].TermInstVal));
4936 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004937 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004938 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004939 ;}
4940 break;
4941
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004942 case 240:
4943#line 2389 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004944 {
4945 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004946 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4947 if (CI2->getParent() == 0)
Reid Spencer38c91a92007-02-28 02:24:54 +00004948 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
4949 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4950 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004951 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004952 ;}
4953 break;
4954
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004955 case 241:
4956#line 2398 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004957 { // Empty space between instruction lists
4958 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004959 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004960 ;}
4961 break;
4962
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004963 case 242:
4964#line 2402 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004965 { // Labelled (named) basic block
4966 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName((yyvsp[0].StrVal)));
Reid Spencer3822ff52006-11-08 06:47:33 +00004967 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004968 ;}
4969 break;
Reid Spencer3822ff52006-11-08 06:47:33 +00004970
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004971 case 243:
4972#line 2407 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004973 { // Return with a result...
4974 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
4975 CHECK_FOR_ERROR
4976 ;}
4977 break;
4978
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004979 case 244:
4980#line 2411 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004981 { // Return with no result...
Reid Spencer38c91a92007-02-28 02:24:54 +00004982 (yyval.TermInstVal) = new ReturnInst();
4983 CHECK_FOR_ERROR
4984 ;}
4985 break;
4986
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004987 case 245:
4988#line 2415 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004989 { // Unconditional Branch...
Reid Spencer38c91a92007-02-28 02:24:54 +00004990 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
4991 CHECK_FOR_ERROR
4992 (yyval.TermInstVal) = new BranchInst(tmpBB);
4993 ;}
4994 break;
4995
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004996 case 246:
4997#line 2420 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004998 {
4999 assert(cast<IntegerType>((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?");
5000 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5001 CHECK_FOR_ERROR
5002 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5003 CHECK_FOR_ERROR
5004 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
5005 CHECK_FOR_ERROR
5006 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5007 ;}
5008 break;
5009
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005010 case 247:
5011#line 2430 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005012 {
5013 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
5014 CHECK_FOR_ERROR
5015 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5016 CHECK_FOR_ERROR
5017 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
5018 (yyval.TermInstVal) = S;
5019
5020 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5021 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005022 for (; I != E; ++I) {
5023 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5024 S->addCase(CI, I->second);
5025 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005026 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005027 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005028 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005029 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005030 ;}
5031 break;
5032
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005033 case 248:
5034#line 2449 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005035 {
5036 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005037 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005038 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005039 CHECK_FOR_ERROR
5040 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencer38c91a92007-02-28 02:24:54 +00005041 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00005042 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005043 ;}
5044 break;
5045
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005046 case 249:
5047#line 2459 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005048 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005049
Reid Spencer14310612006-12-31 05:40:51 +00005050 // Handle the short syntax
5051 const PointerType *PFTy = 0;
5052 const FunctionType *Ty = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00005053 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005054 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5055 // Pull out the types of all of the arguments...
5056 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005057 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00005058 ParamAttrs.push_back((yyvsp[-6].ParamAttrs));
5059 for (ValueRefList::iterator I = (yyvsp[-8].ValueRefList)->begin(), E = (yyvsp[-8].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005060 const Type *Ty = I->Val->getType();
5061 if (Ty == Type::VoidTy)
5062 GEN_ERROR("Short call syntax cannot be used with varargs");
5063 ParamTypes.push_back(Ty);
5064 ParamAttrs.push_back(I->Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005065 }
5066
Reid Spencer38c91a92007-02-28 02:24:54 +00005067 Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005068 PFTy = PointerType::get(Ty);
5069 }
5070
Reid Spencer66728ef2007-03-20 01:13:36 +00005071 delete (yyvsp[-11].TypeVal);
5072
Reid Spencer38c91a92007-02-28 02:24:54 +00005073 Value *V = getVal(PFTy, (yyvsp[-10].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005074 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005075 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005076 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005077 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005078 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005079
Reid Spencer14310612006-12-31 05:40:51 +00005080 // Check the arguments
5081 ValueList Args;
Reid Spencer38c91a92007-02-28 02:24:54 +00005082 if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005083 // Make sure no arguments is a good thing!
5084 if (Ty->getNumParams() != 0)
5085 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005086 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005087 } else { // Has arguments?
5088 // Loop through FunctionType's arguments and ensure they are specified
5089 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005090 FunctionType::param_iterator I = Ty->param_begin();
5091 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer38c91a92007-02-28 02:24:54 +00005092 ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005093
Reid Spencer14310612006-12-31 05:40:51 +00005094 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5095 if (ArgI->Val->getType() != *I)
5096 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005097 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005098 Args.push_back(ArgI->Val);
5099 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005100
Reid Spencer14310612006-12-31 05:40:51 +00005101 if (Ty->isVarArg()) {
5102 if (I == E)
5103 for (; ArgI != ArgE; ++ArgI)
5104 Args.push_back(ArgI->Val); // push the remaining varargs
5105 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005106 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005107 }
Reid Spencer14310612006-12-31 05:40:51 +00005108
5109 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005110 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencer38c91a92007-02-28 02:24:54 +00005111 II->setCallingConv((yyvsp[-12].UIntVal));
5112 (yyval.TermInstVal) = II;
5113 delete (yyvsp[-8].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005114 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005115 ;}
5116 break;
5117
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005118 case 250:
5119#line 2527 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005120 {
5121 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005122 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005123 ;}
5124 break;
5125
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005126 case 251:
5127#line 2531 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005128 {
5129 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005130 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005131 ;}
5132 break;
5133
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005134 case 252:
5135#line 2538 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005136 {
5137 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
Reid Spencer93c40032007-03-19 18:40:50 +00005138 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005139 CHECK_FOR_ERROR
5140 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005141 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005142
Reid Spencer38c91a92007-02-28 02:24:54 +00005143 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005144 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005145 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5146 ;}
5147 break;
5148
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005149 case 253:
5150#line 2549 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005151 {
5152 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencer93c40032007-03-19 18:40:50 +00005153 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005154 CHECK_FOR_ERROR
5155
5156 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005157 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005158
Reid Spencer38c91a92007-02-28 02:24:54 +00005159 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005160 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005161 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5162 ;}
5163 break;
5164
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005165 case 254:
5166#line 2562 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005167 {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005168 // Is this definition named?? if so, assign the name...
Reid Spencer38c91a92007-02-28 02:24:54 +00005169 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Reid Spenceref9b9a72007-02-05 20:47:22 +00005170 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005171 InsertValue((yyvsp[0].InstVal));
5172 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005173 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005174 ;}
5175 break;
5176
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005177 case 255:
5178#line 2572 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005179 { // Used for PHI nodes
Reid Spencer14310612006-12-31 05:40:51 +00005180 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005181 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription());
5182 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5183 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005184 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005185 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005186 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005187 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5188 delete (yyvsp[-5].TypeVal);
5189 ;}
5190 break;
5191
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005192 case 256:
5193#line 2583 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005194 {
5195 (yyval.PHIList) = (yyvsp[-6].PHIList);
5196 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005197 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005198 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005199 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005200 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5201 ;}
5202 break;
5203
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005204 case 257:
5205#line 2593 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005206 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005207 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005208 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005209 // Used for call and invoke instructions
Reid Spencer38c91a92007-02-28 02:24:54 +00005210 (yyval.ValueRefList) = new ValueRefList();
5211 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5212 (yyval.ValueRefList)->push_back(E);
Reid Spencer66728ef2007-03-20 01:13:36 +00005213 delete (yyvsp[-2].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005214 ;}
5215 break;
5216
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005217 case 258:
5218#line 2602 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005219 {
Reid Spencer14310612006-12-31 05:40:51 +00005220 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005221 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5222 (yyval.ValueRefList) = (yyvsp[-4].ValueRefList);
5223 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5224 (yyval.ValueRefList)->push_back(E);
Reid Spencer66728ef2007-03-20 01:13:36 +00005225 delete (yyvsp[-2].TypeVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005226 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005227 ;}
5228 break;
5229
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005230 case 259:
5231#line 2611 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00005232 { (yyval.ValueRefList) = new ValueRefList(); ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00005233 break;
5234
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005235 case 260:
5236#line 2614 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00005237 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5238 break;
5239
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005240 case 261:
5241#line 2615 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005242 {
5243 (yyval.ValueList) = (yyvsp[-2].ValueList);
5244 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer14310612006-12-31 05:40:51 +00005245 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005246 ;}
5247 break;
5248
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005249 case 262:
5250#line 2622 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005251 {
5252 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005253 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005254 ;}
5255 break;
5256
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005257 case 263:
5258#line 2626 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005259 {
5260 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005261 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005262 ;}
5263 break;
5264
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005265 case 264:
5266#line 2631 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005267 {
Reid Spencer14310612006-12-31 05:40:51 +00005268 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005269 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5270 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
5271 !isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005272 GEN_ERROR(
Reid Spencerb5334b02007-02-05 10:18:06 +00005273 "Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005274 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()) &&
5275 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
5276 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
5277 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
Chris Lattner32980692007-02-19 07:44:24 +00005278 GEN_ERROR("Remainder not supported on vector types");
Reid Spencer38c91a92007-02-28 02:24:54 +00005279 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005280 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005281 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005282 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005283 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
5284 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005285 GEN_ERROR("binary operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005286 delete (yyvsp[-3].TypeVal);
5287 ;}
5288 break;
5289
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005290 case 265:
5291#line 2652 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005292 {
Reid Spencer14310612006-12-31 05:40:51 +00005293 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005294 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5295 if (!(*(yyvsp[-3].TypeVal))->isInteger()) {
5296 if (Instruction::isShift((yyvsp[-4].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].TypeVal)->get()) ||
5297 !cast<VectorType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00005298 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005299 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005300 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005301 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005302 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005303 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005304 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
5305 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005306 GEN_ERROR("binary operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005307 delete (yyvsp[-3].TypeVal);
5308 ;}
5309 break;
5310
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005311 case 266:
5312#line 2669 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005313 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005314 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005315 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5316 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Chris Lattner32980692007-02-19 07:44:24 +00005317 GEN_ERROR("Vector types not supported by icmp instruction");
Reid Spencer38c91a92007-02-28 02:24:54 +00005318 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005319 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005320 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005321 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005322 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5323 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005324 GEN_ERROR("icmp operator returned null");
Reid Spencer66728ef2007-03-20 01:13:36 +00005325 delete (yyvsp[-3].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005326 ;}
5327 break;
5328
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005329 case 267:
5330#line 2683 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005331 {
Reid Spencer14310612006-12-31 05:40:51 +00005332 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005333 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5334 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Chris Lattner32980692007-02-19 07:44:24 +00005335 GEN_ERROR("Vector types not supported by fcmp instruction");
Reid Spencer38c91a92007-02-28 02:24:54 +00005336 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005337 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005338 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005339 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005340 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5341 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005342 GEN_ERROR("fcmp operator returned null");
Reid Spencer66728ef2007-03-20 01:13:36 +00005343 delete (yyvsp[-3].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005344 ;}
5345 break;
5346
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005347 case 268:
5348#line 2697 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005349 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005350 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005351 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5352 Value* Val = (yyvsp[-2].ValueVal);
5353 const Type* DestTy = (yyvsp[0].TypeVal)->get();
5354 if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005355 GEN_ERROR("invalid cast opcode for cast from '" +
5356 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005357 DestTy->getDescription() + "'");
Reid Spencer38c91a92007-02-28 02:24:54 +00005358 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy);
5359 delete (yyvsp[0].TypeVal);
5360 ;}
5361 break;
5362
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005363 case 269:
5364#line 2709 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005365 {
5366 if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00005367 GEN_ERROR("select condition must be boolean");
Reid Spencer38c91a92007-02-28 02:24:54 +00005368 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00005369 GEN_ERROR("select value types should match");
Reid Spencer38c91a92007-02-28 02:24:54 +00005370 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005371 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005372 ;}
5373 break;
5374
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005375 case 270:
5376#line 2717 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005377 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005378 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005379 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5380 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5381 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005382 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005383 ;}
5384 break;
5385
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005386 case 271:
5387#line 2724 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005388 {
5389 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005390 GEN_ERROR("Invalid extractelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005391 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005392 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005393 ;}
5394 break;
5395
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005396 case 272:
5397#line 2730 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005398 {
5399 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005400 GEN_ERROR("Invalid insertelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005401 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005402 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005403 ;}
5404 break;
5405
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005406 case 273:
5407#line 2736 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005408 {
5409 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005410 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005411 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005412 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005413 ;}
5414 break;
5415
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005416 case 274:
5417#line 2742 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005418 {
5419 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005420 if (!Ty->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00005421 GEN_ERROR("PHI node operands must be of first class type");
Reid Spencer38c91a92007-02-28 02:24:54 +00005422 (yyval.InstVal) = new PHINode(Ty);
5423 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5424 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5425 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00005426 GEN_ERROR("All elements of a PHI node must be of the same type");
Reid Spencer38c91a92007-02-28 02:24:54 +00005427 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5428 (yyvsp[0].PHIList)->pop_front();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005429 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005430 delete (yyvsp[0].PHIList); // Free the list...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005431 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005432 ;}
5433 break;
5434
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005435 case 275:
5436#line 2758 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005437 {
Reid Spencer14310612006-12-31 05:40:51 +00005438
5439 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005440 const PointerType *PFTy = 0;
5441 const FunctionType *Ty = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00005442 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005443 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5444 // Pull out the types of all of the arguments...
5445 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005446 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00005447 ParamAttrs.push_back((yyvsp[0].ParamAttrs));
5448 for (ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005449 const Type *Ty = I->Val->getType();
5450 if (Ty == Type::VoidTy)
5451 GEN_ERROR("Short call syntax cannot be used with varargs");
5452 ParamTypes.push_back(Ty);
5453 ParamAttrs.push_back(I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005454 }
5455
Reid Spencer38c91a92007-02-28 02:24:54 +00005456 Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005457 PFTy = PointerType::get(Ty);
5458 }
5459
Reid Spencer38c91a92007-02-28 02:24:54 +00005460 Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005461 CHECK_FOR_ERROR
5462
Reid Spencer14310612006-12-31 05:40:51 +00005463 // Check the arguments
5464 ValueList Args;
Reid Spencer38c91a92007-02-28 02:24:54 +00005465 if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005466 // Make sure no arguments is a good thing!
5467 if (Ty->getNumParams() != 0)
5468 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005469 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005470 } else { // Has arguments?
5471 // Loop through FunctionType's arguments and ensure they are specified
5472 // correctly!
5473 //
5474 FunctionType::param_iterator I = Ty->param_begin();
5475 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer38c91a92007-02-28 02:24:54 +00005476 ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005477
Reid Spencer14310612006-12-31 05:40:51 +00005478 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5479 if (ArgI->Val->getType() != *I)
5480 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005481 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005482 Args.push_back(ArgI->Val);
5483 }
5484 if (Ty->isVarArg()) {
5485 if (I == E)
5486 for (; ArgI != ArgE; ++ArgI)
5487 Args.push_back(ArgI->Val); // push the remaining varargs
5488 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005489 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005490 }
Reid Spencer14310612006-12-31 05:40:51 +00005491 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00005492 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencer38c91a92007-02-28 02:24:54 +00005493 CI->setTailCall((yyvsp[-7].BoolVal));
5494 CI->setCallingConv((yyvsp[-6].UIntVal));
5495 (yyval.InstVal) = CI;
5496 delete (yyvsp[-2].ValueRefList);
5497 delete (yyvsp[-5].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005498 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005499 ;}
5500 break;
5501
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005502 case 276:
5503#line 2821 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005504 {
5505 (yyval.InstVal) = (yyvsp[0].InstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005506 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005507 ;}
5508 break;
5509
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005510 case 277:
5511#line 2826 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005512 {
5513 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005514 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005515 ;}
5516 break;
5517
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005518 case 278:
5519#line 2830 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005520 {
5521 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005522 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005523 ;}
5524 break;
5525
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005526 case 279:
5527#line 2837 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005528 {
Reid Spencer6f407902007-01-13 05:00:46 +00005529 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005530 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5531 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5532 delete (yyvsp[-1].TypeVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005533 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005534 ;}
5535 break;
5536
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005537 case 280:
5538#line 2844 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005539 {
Reid Spencer14310612006-12-31 05:40:51 +00005540 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005541 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5542 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005543 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005544 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5545 delete (yyvsp[-4].TypeVal);
5546 ;}
5547 break;
5548
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005549 case 281:
5550#line 2852 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005551 {
Reid Spencer14310612006-12-31 05:40:51 +00005552 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005553 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5554 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5555 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005556 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005557 ;}
5558 break;
5559
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005560 case 282:
5561#line 2859 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005562 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005563 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005564 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5565 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005566 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005567 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5568 delete (yyvsp[-4].TypeVal);
5569 ;}
5570 break;
5571
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005572 case 283:
5573#line 2867 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005574 {
5575 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005576 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005577 (yyvsp[0].ValueVal)->getType()->getDescription() + "");
5578 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005579 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005580 ;}
5581 break;
5582
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005583 case 284:
5584#line 2875 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005585 {
Reid Spencer14310612006-12-31 05:40:51 +00005586 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005587 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5588 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005589 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005590 (*(yyvsp[-1].TypeVal))->getDescription());
5591 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005592 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005593 (*(yyvsp[-1].TypeVal))->getDescription());
5594 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005595 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005596 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5597 delete (yyvsp[-1].TypeVal);
5598 ;}
5599 break;
5600
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005601 case 285:
5602#line 2889 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005603 {
Reid Spencer14310612006-12-31 05:40:51 +00005604 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005605 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5606 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005607 if (!PT)
5608 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005609 (*(yyvsp[-1].TypeVal))->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005610 const Type *ElTy = PT->getElementType();
Reid Spencer38c91a92007-02-28 02:24:54 +00005611 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5612 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencerb5334b02007-02-05 10:18:06 +00005613 "' into space of type '" + ElTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005614
Reid Spencer38c91a92007-02-28 02:24:54 +00005615 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005616 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005617 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5618 delete (yyvsp[-1].TypeVal);
5619 ;}
5620 break;
5621
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005622 case 286:
5623#line 2906 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005624 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005625 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005626 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5627 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005628 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005629
Reid Spencer38c91a92007-02-28 02:24:54 +00005630 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005631 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00005632 (*(yyvsp[-2].TypeVal))->getDescription()+ "'");
5633 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005634 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005635 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size());
5636 delete (yyvsp[-2].TypeVal);
5637 delete (yyvsp[0].ValueList);
5638 ;}
5639 break;
5640
5641
5642 default: break;
5643 }
5644
5645/* Line 1126 of yacc.c. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005646#line 5647 "llvmAsmParser.tab.c"
Chris Lattner9d2fda62007-02-13 05:53:56 +00005647
5648 yyvsp -= yylen;
5649 yyssp -= yylen;
Reid Spencer5cbf9852007-01-30 20:08:39 +00005650
Reid Spencer38c91a92007-02-28 02:24:54 +00005651
5652 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005653
5654 *++yyvsp = yyval;
5655
5656
Reid Spencer38c91a92007-02-28 02:24:54 +00005657 /* Now `shift' the result of the reduction. Determine what state
5658 that goes to, based on the state we popped back to and the rule
5659 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005660
5661 yyn = yyr1[yyn];
5662
Reid Spencer38c91a92007-02-28 02:24:54 +00005663 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5664 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005665 yystate = yytable[yystate];
5666 else
Reid Spencer38c91a92007-02-28 02:24:54 +00005667 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005668
5669 goto yynewstate;
5670
5671
Reid Spencer38c91a92007-02-28 02:24:54 +00005672/*------------------------------------.
5673| yyerrlab -- here on detecting error |
5674`------------------------------------*/
5675yyerrlab:
5676 /* If not already recovering from an error, report this error. */
5677 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005678 {
5679 ++yynerrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00005680#if YYERROR_VERBOSE
Chris Lattner9d2fda62007-02-13 05:53:56 +00005681 yyn = yypact[yystate];
5682
Reid Spencer38c91a92007-02-28 02:24:54 +00005683 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattner9d2fda62007-02-13 05:53:56 +00005684 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005685 int yytype = YYTRANSLATE (yychar);
5686 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5687 YYSIZE_T yysize = yysize0;
5688 YYSIZE_T yysize1;
5689 int yysize_overflow = 0;
5690 char *yymsg = 0;
5691# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5692 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5693 int yyx;
Chris Lattner9d2fda62007-02-13 05:53:56 +00005694
Reid Spencer38c91a92007-02-28 02:24:54 +00005695#if 0
5696 /* This is so xgettext sees the translatable formats that are
5697 constructed on the fly. */
5698 YY_("syntax error, unexpected %s");
5699 YY_("syntax error, unexpected %s, expecting %s");
5700 YY_("syntax error, unexpected %s, expecting %s or %s");
5701 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5702 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5703#endif
5704 char *yyfmt;
5705 char const *yyf;
5706 static char const yyunexpected[] = "syntax error, unexpected %s";
5707 static char const yyexpecting[] = ", expecting %s";
5708 static char const yyor[] = " or %s";
5709 char yyformat[sizeof yyunexpected
5710 + sizeof yyexpecting - 1
5711 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5712 * (sizeof yyor - 1))];
5713 char const *yyprefix = yyexpecting;
5714
5715 /* Start YYX at -YYN if negative to avoid negative indexes in
5716 YYCHECK. */
5717 int yyxbegin = yyn < 0 ? -yyn : 0;
5718
5719 /* Stay within bounds of both yycheck and yytname. */
5720 int yychecklim = YYLAST - yyn;
5721 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5722 int yycount = 1;
5723
5724 yyarg[0] = yytname[yytype];
5725 yyfmt = yystpcpy (yyformat, yyunexpected);
5726
5727 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5728 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5729 {
5730 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5731 {
5732 yycount = 1;
5733 yysize = yysize0;
5734 yyformat[sizeof yyunexpected - 1] = '\0';
5735 break;
5736 }
5737 yyarg[yycount++] = yytname[yyx];
5738 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5739 yysize_overflow |= yysize1 < yysize;
5740 yysize = yysize1;
5741 yyfmt = yystpcpy (yyfmt, yyprefix);
5742 yyprefix = yyor;
5743 }
5744
5745 yyf = YY_(yyformat);
5746 yysize1 = yysize + yystrlen (yyf);
5747 yysize_overflow |= yysize1 < yysize;
5748 yysize = yysize1;
5749
5750 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5751 yymsg = (char *) YYSTACK_ALLOC (yysize);
5752 if (yymsg)
Chris Lattner9d2fda62007-02-13 05:53:56 +00005753 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005754 /* Avoid sprintf, as that infringes on the user's name space.
5755 Don't have undefined behavior even if the translation
5756 produced a string with the wrong number of "%s"s. */
5757 char *yyp = yymsg;
5758 int yyi = 0;
5759 while ((*yyp = *yyf))
Chris Lattner9d2fda62007-02-13 05:53:56 +00005760 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005761 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5762 {
5763 yyp += yytnamerr (yyp, yyarg[yyi++]);
5764 yyf += 2;
5765 }
5766 else
5767 {
5768 yyp++;
5769 yyf++;
5770 }
Chris Lattner9d2fda62007-02-13 05:53:56 +00005771 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005772 yyerror (yymsg);
5773 YYSTACK_FREE (yymsg);
Chris Lattner9d2fda62007-02-13 05:53:56 +00005774 }
5775 else
Reid Spencer38c91a92007-02-28 02:24:54 +00005776 {
5777 yyerror (YY_("syntax error"));
5778 goto yyexhaustedlab;
5779 }
Chris Lattner9d2fda62007-02-13 05:53:56 +00005780 }
5781 else
5782#endif /* YYERROR_VERBOSE */
Reid Spencer38c91a92007-02-28 02:24:54 +00005783 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005784 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00005785
Reid Spencer38c91a92007-02-28 02:24:54 +00005786
Reid Spencer41dff5e2007-01-26 08:05:27 +00005787
5788 if (yyerrstatus == 3)
5789 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005790 /* If just tried and failed to reuse look-ahead token after an
5791 error, discard it. */
Reid Spencer41dff5e2007-01-26 08:05:27 +00005792
Reid Spencer38c91a92007-02-28 02:24:54 +00005793 if (yychar <= YYEOF)
5794 {
5795 /* Return failure if at end of input. */
5796 if (yychar == YYEOF)
5797 YYABORT;
5798 }
5799 else
5800 {
5801 yydestruct ("Error: discarding", yytoken, &yylval);
5802 yychar = YYEMPTY;
5803 }
5804 }
5805
5806 /* Else will try to reuse look-ahead token after shifting the error
5807 token. */
5808 goto yyerrlab1;
5809
5810
5811/*---------------------------------------------------.
5812| yyerrorlab -- error raised explicitly by YYERROR. |
5813`---------------------------------------------------*/
5814yyerrorlab:
5815
5816 /* Pacify compilers like GCC when the user code never invokes
5817 YYERROR and the label yyerrorlab therefore never appears in user
5818 code. */
5819 if (0)
5820 goto yyerrorlab;
5821
5822yyvsp -= yylen;
5823 yyssp -= yylen;
5824 yystate = *yyssp;
5825 goto yyerrlab1;
5826
5827
5828/*-------------------------------------------------------------.
5829| yyerrlab1 -- common code for both syntax error and YYERROR. |
5830`-------------------------------------------------------------*/
5831yyerrlab1:
5832 yyerrstatus = 3; /* Each real token shifted decrements this. */
5833
5834 for (;;)
5835 {
5836 yyn = yypact[yystate];
5837 if (yyn != YYPACT_NINF)
5838 {
5839 yyn += YYTERROR;
5840 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5841 {
5842 yyn = yytable[yyn];
5843 if (0 < yyn)
5844 break;
5845 }
5846 }
5847
5848 /* Pop the current state because it cannot handle the error token. */
5849 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005850 YYABORT;
5851
Reid Spencere4d87aa2006-12-23 06:05:41 +00005852
Reid Spencer38c91a92007-02-28 02:24:54 +00005853 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5854 YYPOPSTACK;
5855 yystate = *yyssp;
5856 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005857 }
5858
5859 if (yyn == YYFINAL)
5860 YYACCEPT;
5861
Reid Spencer68a24bd2005-08-27 18:50:39 +00005862 *++yyvsp = yylval;
Reid Spencer38c91a92007-02-28 02:24:54 +00005863
5864
5865 /* Shift the error token. */
5866 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer41dff5e2007-01-26 08:05:27 +00005867
Reid Spencer68a24bd2005-08-27 18:50:39 +00005868 yystate = yyn;
5869 goto yynewstate;
5870
Chris Lattner32980692007-02-19 07:44:24 +00005871
Reid Spencer38c91a92007-02-28 02:24:54 +00005872/*-------------------------------------.
5873| yyacceptlab -- YYACCEPT comes here. |
5874`-------------------------------------*/
5875yyacceptlab:
5876 yyresult = 0;
5877 goto yyreturn;
5878
5879/*-----------------------------------.
5880| yyabortlab -- YYABORT comes here. |
5881`-----------------------------------*/
5882yyabortlab:
5883 yyresult = 1;
5884 goto yyreturn;
5885
5886#ifndef yyoverflow
5887/*-------------------------------------------------.
5888| yyexhaustedlab -- memory exhaustion comes here. |
5889`-------------------------------------------------*/
5890yyexhaustedlab:
5891 yyerror (YY_("memory exhausted"));
5892 yyresult = 2;
5893 /* Fall through. */
Chris Lattner32980692007-02-19 07:44:24 +00005894#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00005895
5896yyreturn:
5897 if (yychar != YYEOF && yychar != YYEMPTY)
5898 yydestruct ("Cleanup: discarding lookahead",
5899 yytoken, &yylval);
5900 while (yyssp != yyss)
5901 {
5902 yydestruct ("Cleanup: popping",
5903 yystos[*yyssp], yyvsp);
5904 YYPOPSTACK;
Chris Lattner32980692007-02-19 07:44:24 +00005905 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005906#ifndef yyoverflow
5907 if (yyss != yyssa)
5908 YYSTACK_FREE (yyss);
5909#endif
5910 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005911}
Reid Spencer38c91a92007-02-28 02:24:54 +00005912
5913
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005914#line 2923 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005915
5916
Reid Spencer14310612006-12-31 05:40:51 +00005917// common code from the two 'RunVMAsmParser' functions
5918static Module* RunParser(Module * M) {
5919
5920 llvmAsmlineno = 1; // Reset the current line number...
5921 CurModule.CurrentModule = M;
5922#if YYDEBUG
5923 yydebug = Debug;
5924#endif
5925
5926 // Check to make sure the parser succeeded
5927 if (yyparse()) {
5928 if (ParserResult)
5929 delete ParserResult;
5930 return 0;
5931 }
5932
Reid Spencer0d60b5a2007-03-30 01:37:39 +00005933 // Emit an error if there are any unresolved types left.
5934 if (!CurModule.LateResolveTypes.empty()) {
5935 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5936 if (DID.Type == ValID::LocalName) {
5937 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5938 } else {
5939 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5940 }
5941 if (ParserResult)
5942 delete ParserResult;
5943 return 0;
5944 }
5945
5946 // Emit an error if there are any unresolved values left.
5947 if (!CurModule.LateResolveValues.empty()) {
5948 Value *V = CurModule.LateResolveValues.back();
5949 std::map<Value*, std::pair<ValID, int> >::iterator I =
5950 CurModule.PlaceHolderInfo.find(V);
5951
5952 if (I != CurModule.PlaceHolderInfo.end()) {
5953 ValID &DID = I->second.first;
5954 if (DID.Type == ValID::LocalName) {
5955 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5956 } else {
5957 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5958 }
5959 if (ParserResult)
5960 delete ParserResult;
5961 return 0;
5962 }
5963 }
5964
Reid Spencer14310612006-12-31 05:40:51 +00005965 // Check to make sure that parsing produced a result
5966 if (!ParserResult)
5967 return 0;
5968
5969 // Reset ParserResult variable while saving its value for the result.
5970 Module *Result = ParserResult;
5971 ParserResult = 0;
5972
5973 return Result;
5974}
5975
Reid Spencer61c83e02006-08-18 08:43:06 +00005976void llvm::GenerateError(const std::string &message, int LineNo) {
5977 if (LineNo == -1) LineNo = llvmAsmlineno;
5978 // TODO: column number in exception
5979 if (TheParseError)
5980 TheParseError->setError(CurFilename, message, LineNo);
5981 TriggerError = 1;
5982}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005983
5984int yyerror(const char *ErrorMsg) {
5985 std::string where
5986 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5987 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00005988 std::string errMsg = where + "error: " + std::string(ErrorMsg);
5989 if (yychar != YYEMPTY && yychar != 0)
5990 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
5991 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005992 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005993 return 0;
5994}
Reid Spencer38c91a92007-02-28 02:24:54 +00005995