blob: f73f2ee5a448bee97f44436315af5b86197a968c [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 Spencer7b5d4662007-04-09 06:16:21 +0000337#line 14 "/proj/llvm/llvm-1/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 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000527} CurModule;
528
529static struct PerFunctionInfo {
530 Function *CurrentFunction; // Pointer to current function being created
531
Reid Spencer93c40032007-03-19 18:40:50 +0000532 ValueList Values; // Keep track of #'d definitions
533 unsigned NextValNum;
534 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000535 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000536 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000537 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000538
539 /// BBForwardRefs - When we see forward references to basic blocks, keep
540 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000541 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000542
543 inline PerFunctionInfo() {
544 CurrentFunction = 0;
545 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000546 Linkage = GlobalValue::ExternalLinkage;
547 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000548 }
549
550 inline void FunctionStart(Function *M) {
551 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000552 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000553 }
554
555 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000556 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000557 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000558 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000559 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000560 return;
561 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000562
563 // Resolve all forward references now.
564 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
565
566 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000567 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000568 CurrentFunction = 0;
569 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000570 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000571 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000572 }
573} CurFun; // Info for the current function...
574
575static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
576
577
578//===----------------------------------------------------------------------===//
579// Code to handle definitions of all the types
580//===----------------------------------------------------------------------===//
581
Reid Spencer93c40032007-03-19 18:40:50 +0000582static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
583 // Things that have names or are void typed don't get slot numbers
584 if (V->hasName() || (V->getType() == Type::VoidTy))
585 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000586
Reid Spencer93c40032007-03-19 18:40:50 +0000587 // In the case of function values, we have to allow for the forward reference
588 // of basic blocks, which are included in the numbering. Consequently, we keep
589 // track of the next insertion location with NextValNum. When a BB gets
590 // inserted, it could change the size of the CurFun.Values vector.
591 if (&ValueTab == &CurFun.Values) {
592 if (ValueTab.size() <= CurFun.NextValNum)
593 ValueTab.resize(CurFun.NextValNum+1);
594 ValueTab[CurFun.NextValNum++] = V;
595 return;
596 }
597 // For all other lists, its okay to just tack it on the back of the vector.
598 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000599}
600
601static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
602 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000603 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000604 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000605 if (D.Num < CurModule.Types.size())
606 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000607 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000608 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000609 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
610 D.destroy(); // Free old strdup'd memory...
611 return N;
612 }
613 break;
614 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000615 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000616 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000617 }
618
619 // If we reached here, we referenced either a symbol that we don't know about
620 // or an id number that hasn't been read yet. We may be referencing something
621 // forward, so just create an entry to be resolved later and get to it...
622 //
623 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
624
625
626 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000627 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000628 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000629 return 0;
630 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000631 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000632 return 0;
633 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000634 }
635
Reid Spencer861d9d62006-11-28 07:29:44 +0000636 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000637 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000638 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000639
Reid Spencer861d9d62006-11-28 07:29:44 +0000640 Type *Typ = OpaqueType::get();
641 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
642 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000643 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000644
Reid Spencer93c40032007-03-19 18:40:50 +0000645// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000646// the provided ValID. If the value exists and has already been defined, return
647// it. Otherwise return null.
648//
Reid Spencer93c40032007-03-19 18:40:50 +0000649static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000650 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000651 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000652 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000653 return 0;
654 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000655
656 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000657 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000658 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000659 if (D.Num >= CurFun.Values.size())
660 return 0;
661 Value *Result = CurFun.Values[D.Num];
662 if (Ty != Result->getType()) {
663 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
664 Result->getType()->getDescription() + "' does not match "
665 "expected type, '" + Ty->getDescription() + "'");
666 return 0;
667 }
668 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000669 }
670 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000671 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000672 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000673 Value *Result = CurModule.Values[D.Num];
674 if (Ty != Result->getType()) {
675 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
676 Result->getType()->getDescription() + "' does not match "
677 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000678 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000679 }
680 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000681 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000682
683 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000684 if (!inFunctionScope())
685 return 0;
686 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
687 Value *N = SymTab.lookup(D.Name);
688 if (N == 0)
689 return 0;
690 if (N->getType() != Ty)
691 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000692
693 D.destroy(); // Free old strdup'd memory...
694 return N;
695 }
696 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000697 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
698 Value *N = SymTab.lookup(D.Name);
699 if (N == 0)
700 return 0;
701 if (N->getType() != Ty)
702 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000703
704 D.destroy(); // Free old strdup'd memory...
705 return N;
706 }
707
708 // Check to make sure that "Ty" is an integral type, and that our
709 // value will fit into the specified type...
710 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000711 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000712 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000713 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000714 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000715 return 0;
716 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000717 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000718
719 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000720 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
721 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000722 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000723 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000724 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000725 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000726 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000727 }
728 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000729 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000730 }
731
732 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000733 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000734 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000735 return 0;
736 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000737 return ConstantFP::get(Ty, D.ConstPoolFP);
738
739 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000740 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000741 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000742 return 0;
743 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000744 return ConstantPointerNull::get(cast<PointerType>(Ty));
745
746 case ValID::ConstUndefVal: // Is it an undef value?
747 return UndefValue::get(Ty);
748
Chris Lattner7aa61892005-12-21 17:53:23 +0000749 case ValID::ConstZeroVal: // Is it a zero value?
750 return Constant::getNullValue(Ty);
751
Reid Spencer68a24bd2005-08-27 18:50:39 +0000752 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000753 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000754 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000755 return 0;
756 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000757 return D.ConstantValue;
758
Chris Lattner0e9c3762006-01-25 22:27:16 +0000759 case ValID::InlineAsmVal: { // Inline asm expression
760 const PointerType *PTy = dyn_cast<PointerType>(Ty);
761 const FunctionType *FTy =
762 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000763 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000764 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000765 return 0;
766 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000767 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
768 D.IAD->HasSideEffects);
769 D.destroy(); // Free InlineAsmDescriptor.
770 return IA;
771 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000772 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000773 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000774 return 0;
775 } // End of switch
776
Reid Spencera9720f52007-02-05 17:04:00 +0000777 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000778 return 0;
779}
780
Reid Spencer93c40032007-03-19 18:40:50 +0000781// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000782// value is not already defined, it "improvises" by creating a placeholder var
783// that looks and acts just like the requested variable. When the value is
784// defined later, all uses of the placeholder variable are replaced with the
785// real thing.
786//
787static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000788 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000789 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000790 return 0;
791 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000792
793 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000794 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000795 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000796 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000797
Reid Spencer5b7e7532006-09-28 19:28:24 +0000798 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000799 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000800 return 0;
801 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000802
803 // If we reached here, we referenced either a symbol that we don't know about
804 // or an id number that hasn't been read yet. We may be referencing something
805 // forward, so just create an entry to be resolved later and get to it...
806 //
807 V = new Argument(Ty);
808
809 // Remember where this forward reference came from. FIXME, shouldn't we try
810 // to recycle these things??
811 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
812 llvmAsmlineno)));
813
814 if (inFunctionScope())
815 InsertValue(V, CurFun.LateResolveValues);
816 else
817 InsertValue(V, CurModule.LateResolveValues);
818 return V;
819}
820
Reid Spencer93c40032007-03-19 18:40:50 +0000821/// defineBBVal - This is a definition of a new basic block with the specified
822/// identifier which must be the same as CurFun.NextValNum, if its numeric.
823static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000824 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000825
Reid Spencer68a24bd2005-08-27 18:50:39 +0000826 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000827
Reid Spencer93c40032007-03-19 18:40:50 +0000828 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000829
Reid Spencer93c40032007-03-19 18:40:50 +0000830 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
831 if (BBI != CurFun.BBForwardRefs.end()) {
832 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000833 // The forward declaration could have been inserted anywhere in the
834 // function: insert it into the correct place now.
835 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
836 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000837
Reid Spencer66728ef2007-03-20 01:13:36 +0000838 // We're about to erase the entry, save the key so we can clean it up.
839 ValID Tmp = BBI->first;
840
Reid Spencer93c40032007-03-19 18:40:50 +0000841 // Erase the forward ref from the map as its no longer "forward"
842 CurFun.BBForwardRefs.erase(ID);
843
Reid Spencer66728ef2007-03-20 01:13:36 +0000844 // The key has been removed from the map but so we don't want to leave
845 // strdup'd memory around so destroy it too.
846 Tmp.destroy();
847
Reid Spencer93c40032007-03-19 18:40:50 +0000848 // If its a numbered definition, bump the number and set the BB value.
849 if (ID.Type == ValID::LocalID) {
850 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
851 InsertValue(BB);
852 }
853
854 ID.destroy();
855 return BB;
856 }
857
858 // We haven't seen this BB before and its first mention is a definition.
859 // Just create it and return it.
860 std::string Name (ID.Type == ValID::LocalName ? ID.Name : "");
861 BB = new BasicBlock(Name, CurFun.CurrentFunction);
862 if (ID.Type == ValID::LocalID) {
863 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
864 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000865 }
Reid Spencer93c40032007-03-19 18:40:50 +0000866
867 ID.destroy(); // Free strdup'd memory
868 return BB;
869}
870
871/// getBBVal - get an existing BB value or create a forward reference for it.
872///
873static BasicBlock *getBBVal(const ValID &ID) {
874 assert(inFunctionScope() && "Can't get basic block at global scope!");
875
876 BasicBlock *BB = 0;
877
878 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
879 if (BBI != CurFun.BBForwardRefs.end()) {
880 BB = BBI->second;
881 } if (ID.Type == ValID::LocalName) {
882 std::string Name = ID.Name;
883 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
884 if (N)
885 if (N->getType()->getTypeID() == Type::LabelTyID)
886 BB = cast<BasicBlock>(N);
887 else
888 GenerateError("Reference to label '" + Name + "' is actually of type '"+
889 N->getType()->getDescription() + "'");
890 } else if (ID.Type == ValID::LocalID) {
891 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
892 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
893 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
894 else
895 GenerateError("Reference to label '%" + utostr(ID.Num) +
896 "' is actually of type '"+
897 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
898 }
899 } else {
900 GenerateError("Illegal label reference " + ID.getName());
901 return 0;
902 }
903
904 // If its already been defined, return it now.
905 if (BB) {
906 ID.destroy(); // Free strdup'd memory.
907 return BB;
908 }
909
910 // Otherwise, this block has not been seen before, create it.
911 std::string Name;
912 if (ID.Type == ValID::LocalName)
913 Name = ID.Name;
914 BB = new BasicBlock(Name, CurFun.CurrentFunction);
915
916 // Insert it in the forward refs map.
917 CurFun.BBForwardRefs[ID] = BB;
918
Reid Spencer68a24bd2005-08-27 18:50:39 +0000919 return BB;
920}
921
922
923//===----------------------------------------------------------------------===//
924// Code to handle forward references in instructions
925//===----------------------------------------------------------------------===//
926//
927// This code handles the late binding needed with statements that reference
928// values not defined yet... for example, a forward branch, or the PHI node for
929// a loop body.
930//
931// This keeps a table (CurFun.LateResolveValues) of all such forward references
932// and back patchs after we are done.
933//
934
935// ResolveDefinitions - If we could not resolve some defs at parsing
936// time (forward branches, phi functions for loops, etc...) resolve the
937// defs now...
938//
939static void
Reid Spencer93c40032007-03-19 18:40:50 +0000940ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000941 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000942 while (!LateResolvers.empty()) {
943 Value *V = LateResolvers.back();
944 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000945
Reid Spencer93c40032007-03-19 18:40:50 +0000946 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
947 CurModule.PlaceHolderInfo.find(V);
948 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000949
Reid Spencer93c40032007-03-19 18:40:50 +0000950 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000951
Reid Spencer93c40032007-03-19 18:40:50 +0000952 Value *TheRealValue = getExistingVal(V->getType(), DID);
953 if (TriggerError)
954 return;
955 if (TheRealValue) {
956 V->replaceAllUsesWith(TheRealValue);
957 delete V;
958 CurModule.PlaceHolderInfo.erase(PHI);
959 } else if (FutureLateResolvers) {
960 // Functions have their unresolved items forwarded to the module late
961 // resolver table
962 InsertValue(V, *FutureLateResolvers);
963 } else {
964 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
965 GenerateError("Reference to an invalid definition: '" +DID.getName()+
966 "' of type '" + V->getType()->getDescription() + "'",
967 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000968 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000969 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000970 GenerateError("Reference to an invalid definition: #" +
971 itostr(DID.Num) + " of type '" +
972 V->getType()->getDescription() + "'",
973 PHI->second.second);
974 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000975 }
976 }
977 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000978 LateResolvers.clear();
979}
980
981// ResolveTypeTo - A brand new type was just declared. This means that (if
982// name is not null) things referencing Name can be resolved. Otherwise, things
983// refering to the number can be resolved. Do this now.
984//
985static void ResolveTypeTo(char *Name, const Type *ToTy) {
986 ValID D;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000987 if (Name) D = ValID::createLocalName(Name);
988 else D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000989
Reid Spencer861d9d62006-11-28 07:29:44 +0000990 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000991 CurModule.LateResolveTypes.find(D);
992 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000993 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000994 CurModule.LateResolveTypes.erase(I);
995 }
996}
997
998// setValueName - Set the specified value to the name given. The name may be
999// null potentially, in which case this is a noop. The string passed in is
1000// assumed to be a malloc'd string buffer, and is free'd by this function.
1001//
1002static void setValueName(Value *V, char *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001003 if (!NameStr) return;
1004 std::string Name(NameStr); // Copy string
1005 free(NameStr); // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001006
Reid Spencer41dff5e2007-01-26 08:05:27 +00001007 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001008 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001009 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001010 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001011
Reid Spencera9720f52007-02-05 17:04:00 +00001012 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001013 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1014 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001015 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001016 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001017 return;
1018 }
1019
1020 // Set the name.
1021 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001022}
1023
1024/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1025/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001026static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001027ParseGlobalVariable(char *NameStr,
1028 GlobalValue::LinkageTypes Linkage,
1029 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001030 bool isConstantGlobal, const Type *Ty,
1031 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001032 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001033 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001034 return 0;
1035 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001036
1037 const PointerType *PTy = PointerType::get(Ty);
1038
1039 std::string Name;
1040 if (NameStr) {
1041 Name = NameStr; // Copy string
1042 free(NameStr); // Free old string
1043 }
1044
1045 // See if this global value was forward referenced. If so, recycle the
1046 // object.
1047 ValID ID;
1048 if (!Name.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001049 ID = ValID::createGlobalName((char*)Name.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001050 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001051 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001052 }
1053
1054 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1055 // Move the global to the end of the list, from whereever it was
1056 // previously inserted.
1057 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1058 CurModule.CurrentModule->getGlobalList().remove(GV);
1059 CurModule.CurrentModule->getGlobalList().push_back(GV);
1060 GV->setInitializer(Initializer);
1061 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001062 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001063 GV->setConstant(isConstantGlobal);
1064 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001065 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001066 }
1067
Reid Spenceref9b9a72007-02-05 20:47:22 +00001068 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001069 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001070 // if the global we're parsing has an initializer (is a definition) and
1071 // has external linkage.
1072 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1073 // If there is already a global with external linkage with this name
1074 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1075 // If we allow this GVar to get created, it will be renamed in the
1076 // symbol table because it conflicts with an existing GVar. We can't
1077 // allow redefinition of GVars whose linking indicates that their name
1078 // must stay the same. Issue the error.
1079 GenerateError("Redefinition of global variable named '" + Name +
1080 "' of type '" + Ty->getDescription() + "'");
1081 return 0;
1082 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001083 }
1084
1085 // Otherwise there is no existing GV to use, create one now.
1086 GlobalVariable *GV =
1087 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1088 CurModule.CurrentModule);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001089 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001090 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001091 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001092}
1093
1094// setTypeName - Set the specified type to the name given. The name may be
1095// null potentially, in which case this is a noop. The string passed in is
1096// assumed to be a malloc'd string buffer, and is freed by this function.
1097//
1098// This function returns true if the type has already been defined, but is
1099// allowed to be redefined in the specified context. If the name is a new name
1100// for the type plane, it is inserted and false is returned.
1101static bool setTypeName(const Type *T, char *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001102 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001103 if (NameStr == 0) return false;
1104
1105 std::string Name(NameStr); // Copy string
1106 free(NameStr); // Free old string
1107
1108 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001109 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001110 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001111 return false;
1112 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001113
1114 // Set the type name, checking for conflicts as we do so.
1115 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1116
1117 if (AlreadyExists) { // Inserting a name that is already defined???
1118 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001119 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001120
1121 // There is only one case where this is allowed: when we are refining an
1122 // opaque type. In this case, Existing will be an opaque type.
1123 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1124 // We ARE replacing an opaque type!
1125 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1126 return true;
1127 }
1128
1129 // Otherwise, this is an attempt to redefine a type. That's okay if
1130 // the redefinition is identical to the original. This will be so if
1131 // Existing and T point to the same Type object. In this one case we
1132 // allow the equivalent redefinition.
1133 if (Existing == T) return true; // Yes, it's equal.
1134
1135 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001136 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001137 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001138 }
1139
1140 return false;
1141}
1142
1143//===----------------------------------------------------------------------===//
1144// Code for handling upreferences in type names...
1145//
1146
1147// TypeContains - Returns true if Ty directly contains E in it.
1148//
1149static bool TypeContains(const Type *Ty, const Type *E) {
1150 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1151 E) != Ty->subtype_end();
1152}
1153
1154namespace {
1155 struct UpRefRecord {
1156 // NestingLevel - The number of nesting levels that need to be popped before
1157 // this type is resolved.
1158 unsigned NestingLevel;
1159
1160 // LastContainedTy - This is the type at the current binding level for the
1161 // type. Every time we reduce the nesting level, this gets updated.
1162 const Type *LastContainedTy;
1163
1164 // UpRefTy - This is the actual opaque type that the upreference is
1165 // represented with.
1166 OpaqueType *UpRefTy;
1167
1168 UpRefRecord(unsigned NL, OpaqueType *URTy)
1169 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1170 };
1171}
1172
1173// UpRefs - A list of the outstanding upreferences that need to be resolved.
1174static std::vector<UpRefRecord> UpRefs;
1175
1176/// HandleUpRefs - Every time we finish a new layer of types, this function is
1177/// called. It loops through the UpRefs vector, which is a list of the
1178/// currently active types. For each type, if the up reference is contained in
1179/// the newly completed type, we decrement the level count. When the level
1180/// count reaches zero, the upreferenced type is the type that is passed in:
1181/// thus we can complete the cycle.
1182///
1183static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001184 // If Ty isn't abstract, or if there are no up-references in it, then there is
1185 // nothing to resolve here.
1186 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1187
Reid Spencer68a24bd2005-08-27 18:50:39 +00001188 PATypeHolder Ty(ty);
1189 UR_OUT("Type '" << Ty->getDescription() <<
1190 "' newly formed. Resolving upreferences.\n" <<
1191 UpRefs.size() << " upreferences active!\n");
1192
1193 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1194 // to zero), we resolve them all together before we resolve them to Ty. At
1195 // the end of the loop, if there is anything to resolve to Ty, it will be in
1196 // this variable.
1197 OpaqueType *TypeToResolve = 0;
1198
1199 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1200 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1201 << UpRefs[i].second->getDescription() << ") = "
1202 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1203 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1204 // Decrement level of upreference
1205 unsigned Level = --UpRefs[i].NestingLevel;
1206 UpRefs[i].LastContainedTy = Ty;
1207 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1208 if (Level == 0) { // Upreference should be resolved!
1209 if (!TypeToResolve) {
1210 TypeToResolve = UpRefs[i].UpRefTy;
1211 } else {
1212 UR_OUT(" * Resolving upreference for "
1213 << UpRefs[i].second->getDescription() << "\n";
1214 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1215 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1216 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1217 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1218 }
1219 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1220 --i; // Do not skip the next element...
1221 }
1222 }
1223 }
1224
1225 if (TypeToResolve) {
1226 UR_OUT(" * Resolving upreference for "
1227 << UpRefs[i].second->getDescription() << "\n";
1228 std::string OldName = TypeToResolve->getDescription());
1229 TypeToResolve->refineAbstractTypeTo(Ty);
1230 }
1231
1232 return Ty;
1233}
1234
Reid Spencer68a24bd2005-08-27 18:50:39 +00001235//===----------------------------------------------------------------------===//
1236// RunVMAsmParser - Define an interface to this parser
1237//===----------------------------------------------------------------------===//
1238//
Reid Spencer14310612006-12-31 05:40:51 +00001239static Module* RunParser(Module * M);
1240
Reid Spencer68a24bd2005-08-27 18:50:39 +00001241Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1242 set_scan_file(F);
1243
1244 CurFilename = Filename;
1245 return RunParser(new Module(CurFilename));
1246}
1247
1248Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1249 set_scan_string(AsmString);
1250
1251 CurFilename = "from_memory";
1252 if (M == NULL) {
1253 return RunParser(new Module (CurFilename));
1254 } else {
1255 return RunParser(M);
1256 }
1257}
1258
1259
Reid Spencer38c91a92007-02-28 02:24:54 +00001260
1261/* Enabling traces. */
1262#ifndef YYDEBUG
1263# define YYDEBUG 0
1264#endif
1265
1266/* Enabling verbose error messages. */
1267#ifdef YYERROR_VERBOSE
1268# undef YYERROR_VERBOSE
1269# define YYERROR_VERBOSE 1
1270#else
1271# define YYERROR_VERBOSE 0
1272#endif
1273
1274/* Enabling the token table. */
1275#ifndef YYTOKEN_TABLE
1276# define YYTOKEN_TABLE 0
1277#endif
1278
1279#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer7b5d4662007-04-09 06:16:21 +00001280#line 937 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00001281typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001282 llvm::Module *ModuleVal;
1283 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001284 llvm::BasicBlock *BasicBlockVal;
1285 llvm::TerminatorInst *TermInstVal;
1286 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001287 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001288
Reid Spencera132e042006-12-03 05:46:11 +00001289 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001290 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001291 llvm::PATypeHolder *TypeVal;
1292 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001293 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001294 llvm::ArgListType *ArgList;
1295 llvm::TypeWithAttrs TypeWithAttrs;
1296 llvm::TypeWithAttrsList *TypeWithAttrsList;
1297 llvm::ValueRefList *ValueRefList;
1298
Reid Spencer68a24bd2005-08-27 18:50:39 +00001299 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001300 std::list<std::pair<llvm::Value*,
1301 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001302 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001303 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001304
1305 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001306 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001307 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001308 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001309 int64_t SInt64Val;
1310 uint64_t UInt64Val;
1311 int SIntVal;
1312 unsigned UIntVal;
1313 double FPVal;
1314 bool BoolVal;
1315
1316 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001317 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001318
Reid Spencera132e042006-12-03 05:46:11 +00001319 llvm::Instruction::BinaryOps BinaryOpVal;
1320 llvm::Instruction::TermOps TermOpVal;
1321 llvm::Instruction::MemoryOps MemOpVal;
1322 llvm::Instruction::CastOps CastOpVal;
1323 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001324 llvm::ICmpInst::Predicate IPredicate;
1325 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner9d2fda62007-02-13 05:53:56 +00001326} YYSTYPE;
Reid Spencer38c91a92007-02-28 02:24:54 +00001327/* Line 196 of yacc.c. */
Reid Spencer7b5d4662007-04-09 06:16:21 +00001328#line 1329 "llvmAsmParser.tab.c"
Reid Spencer38c91a92007-02-28 02:24:54 +00001329# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1330# define YYSTYPE_IS_DECLARED 1
1331# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001332#endif
1333
Reid Spencer41dff5e2007-01-26 08:05:27 +00001334
Reid Spencer68a24bd2005-08-27 18:50:39 +00001335
Reid Spencer38c91a92007-02-28 02:24:54 +00001336/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001337
1338
Reid Spencer38c91a92007-02-28 02:24:54 +00001339/* Line 219 of yacc.c. */
Reid Spencer7b5d4662007-04-09 06:16:21 +00001340#line 1341 "llvmAsmParser.tab.c"
Reid Spencer41dff5e2007-01-26 08:05:27 +00001341
Reid Spencer38c91a92007-02-28 02:24:54 +00001342#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1343# define YYSIZE_T __SIZE_TYPE__
1344#endif
1345#if ! defined (YYSIZE_T) && defined (size_t)
1346# define YYSIZE_T size_t
1347#endif
1348#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1349# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1350# define YYSIZE_T size_t
1351#endif
1352#if ! defined (YYSIZE_T)
1353# define YYSIZE_T unsigned int
1354#endif
Chris Lattner9d2fda62007-02-13 05:53:56 +00001355
Reid Spencer38c91a92007-02-28 02:24:54 +00001356#ifndef YY_
1357# if YYENABLE_NLS
1358# if ENABLE_NLS
1359# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1360# define YY_(msgid) dgettext ("bison-runtime", msgid)
1361# endif
1362# endif
1363# ifndef YY_
1364# define YY_(msgid) msgid
1365# endif
1366#endif
1367
1368#if ! defined (yyoverflow) || YYERROR_VERBOSE
1369
1370/* The parser invokes alloca or malloc; define the necessary symbols. */
1371
1372# ifdef YYSTACK_USE_ALLOCA
1373# if YYSTACK_USE_ALLOCA
1374# ifdef __GNUC__
1375# define YYSTACK_ALLOC __builtin_alloca
1376# else
1377# define YYSTACK_ALLOC alloca
1378# if defined (__STDC__) || defined (__cplusplus)
1379# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1380# define YYINCLUDED_STDLIB_H
1381# endif
1382# endif
1383# endif
1384# endif
1385
1386# ifdef YYSTACK_ALLOC
1387 /* Pacify GCC's `empty if-body' warning. */
1388# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1389# ifndef YYSTACK_ALLOC_MAXIMUM
1390 /* The OS might guarantee only one guard page at the bottom of the stack,
1391 and a page size can be as small as 4096 bytes. So we cannot safely
1392 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1393 to allow for a few compiler-allocated temporary stack slots. */
1394# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1395# endif
1396# else
1397# define YYSTACK_ALLOC YYMALLOC
1398# define YYSTACK_FREE YYFREE
1399# ifndef YYSTACK_ALLOC_MAXIMUM
1400# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1401# endif
1402# ifdef __cplusplus
1403extern "C" {
1404# endif
1405# ifndef YYMALLOC
1406# define YYMALLOC malloc
1407# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1408 && (defined (__STDC__) || defined (__cplusplus)))
1409void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1410# endif
1411# endif
1412# ifndef YYFREE
1413# define YYFREE free
1414# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1415 && (defined (__STDC__) || defined (__cplusplus)))
1416void free (void *); /* INFRINGES ON USER NAME SPACE */
1417# endif
1418# endif
1419# ifdef __cplusplus
1420}
1421# endif
1422# endif
1423#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1424
1425
1426#if (! defined (yyoverflow) \
1427 && (! defined (__cplusplus) \
1428 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1429
1430/* A type that is properly aligned for any stack member. */
1431union yyalloc
1432{
1433 short int yyss;
1434 YYSTYPE yyvs;
1435 };
1436
1437/* The size of the maximum gap between one aligned stack and the next. */
1438# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1439
1440/* The size of an array large to enough to hold all stacks, each with
1441 N elements. */
1442# define YYSTACK_BYTES(N) \
1443 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1444 + YYSTACK_GAP_MAXIMUM)
1445
1446/* Copy COUNT objects from FROM to TO. The source and destination do
1447 not overlap. */
1448# ifndef YYCOPY
1449# if defined (__GNUC__) && 1 < __GNUC__
1450# define YYCOPY(To, From, Count) \
1451 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1452# else
1453# define YYCOPY(To, From, Count) \
1454 do \
1455 { \
1456 YYSIZE_T yyi; \
1457 for (yyi = 0; yyi < (Count); yyi++) \
1458 (To)[yyi] = (From)[yyi]; \
1459 } \
1460 while (0)
1461# endif
1462# endif
1463
1464/* Relocate STACK from its old location to the new one. The
1465 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1466 elements in the stack, and YYPTR gives the new location of the
1467 stack. Advance YYPTR to a properly aligned location for the next
1468 stack. */
1469# define YYSTACK_RELOCATE(Stack) \
1470 do \
1471 { \
1472 YYSIZE_T yynewbytes; \
1473 YYCOPY (&yyptr->Stack, Stack, yysize); \
1474 Stack = &yyptr->Stack; \
1475 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1476 yyptr += yynewbytes / sizeof (*yyptr); \
1477 } \
1478 while (0)
Chris Lattner9d2fda62007-02-13 05:53:56 +00001479
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001480#endif
1481
Reid Spencer38c91a92007-02-28 02:24:54 +00001482#if defined (__STDC__) || defined (__cplusplus)
1483 typedef signed char yysigned_char;
Reid Spencer5cbf9852007-01-30 20:08:39 +00001484#else
Reid Spencer38c91a92007-02-28 02:24:54 +00001485 typedef short int yysigned_char;
Reid Spencer5cbf9852007-01-30 20:08:39 +00001486#endif
1487
Reid Spencer38c91a92007-02-28 02:24:54 +00001488/* YYFINAL -- State number of the termination state. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001489#define YYFINAL 39
Reid Spencer38c91a92007-02-28 02:24:54 +00001490/* YYLAST -- Last index in YYTABLE. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001491#define YYLAST 1441
Reid Spencer38c91a92007-02-28 02:24:54 +00001492
1493/* YYNTOKENS -- Number of terminals. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001494#define YYNTOKENS 148
Reid Spencer38c91a92007-02-28 02:24:54 +00001495/* YYNNTS -- Number of nonterminals. */
1496#define YYNNTS 78
1497/* YYNRULES -- Number of rules. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001498#define YYNRULES 286
Reid Spencer38c91a92007-02-28 02:24:54 +00001499/* YYNRULES -- Number of states. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001500#define YYNSTATES 559
Reid Spencer38c91a92007-02-28 02:24:54 +00001501
1502/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1503#define YYUNDEFTOK 2
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001504#define YYMAXUTOK 388
Reid Spencer38c91a92007-02-28 02:24:54 +00001505
1506#define YYTRANSLATE(YYX) \
1507 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1508
1509/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1510static const unsigned char yytranslate[] =
1511{
1512 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1514 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001516 138, 139, 136, 2, 135, 2, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001518 143, 134, 144, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1520 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001521 2, 140, 137, 142, 2, 2, 2, 2, 2, 147,
Reid Spencer38c91a92007-02-28 02:24:54 +00001522 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001524 141, 2, 2, 145, 2, 146, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1527 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, 1, 2, 3, 4,
1538 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1539 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1540 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1541 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1542 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1543 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1544 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1545 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1546 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1547 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1548 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1549 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001550 125, 126, 127, 128, 129, 130, 131, 132, 133
Reid Spencer38c91a92007-02-28 02:24:54 +00001551};
1552
1553#if YYDEBUG
1554/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1555 YYRHS. */
1556static const unsigned short int yyprhs[] =
1557{
1558 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1559 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1560 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1561 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1562 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1563 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1564 119, 121, 122, 125, 126, 128, 130, 133, 134, 136,
1565 138, 140, 142, 144, 146, 148, 150, 151, 153, 154,
1566 156, 158, 159, 161, 163, 165, 167, 168, 170, 172,
1567 174, 176, 178, 181, 183, 185, 187, 189, 190, 193,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001568 195, 197, 199, 200, 203, 204, 207, 208, 212, 215,
1569 216, 218, 219, 223, 225, 228, 230, 232, 234, 236,
1570 238, 240, 243, 245, 248, 254, 260, 266, 272, 276,
1571 279, 285, 290, 293, 295, 297, 299, 303, 305, 309,
1572 311, 312, 314, 318, 323, 327, 331, 336, 341, 345,
1573 352, 358, 361, 364, 367, 370, 373, 376, 379, 382,
1574 385, 388, 391, 394, 401, 407, 416, 423, 430, 438,
1575 446, 453, 462, 471, 475, 477, 479, 481, 483, 484,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001576 486, 489, 490, 494, 495, 499, 503, 507, 511, 512,
1577 519, 520, 528, 529, 537, 540, 544, 546, 550, 554,
1578 558, 562, 564, 565, 571, 575, 577, 581, 583, 584,
1579 594, 596, 598, 603, 605, 607, 610, 614, 615, 617,
1580 619, 621, 623, 625, 627, 629, 631, 633, 637, 639,
1581 645, 647, 649, 651, 653, 655, 657, 660, 663, 666,
1582 670, 673, 674, 676, 679, 682, 686, 696, 706, 715,
1583 730, 732, 734, 741, 747, 750, 757, 765, 769, 775,
1584 776, 777, 781, 784, 786, 792, 798, 805, 812, 817,
1585 824, 829, 834, 841, 848, 851, 860, 862, 864, 865,
1586 869, 876, 880, 887, 890, 895, 902
Reid Spencer38c91a92007-02-28 02:24:54 +00001587};
1588
1589/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1590static const short int yyrhs[] =
1591{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001592 188, 0, -1, 67, -1, 68, -1, 69, -1, 70,
1593 -1, 71, -1, 72, -1, 73, -1, 74, -1, 75,
1594 -1, 79, -1, 80, -1, 81, -1, 76, -1, 77,
1595 -1, 78, -1, 110, -1, 111, -1, 112, -1, 113,
1596 -1, 114, -1, 115, -1, 116, -1, 117, -1, 118,
1597 -1, 119, -1, 120, -1, 121, -1, 84, -1, 85,
1598 -1, 86, -1, 87, -1, 88, -1, 89, -1, 90,
1599 -1, 91, -1, 92, -1, 93, -1, 94, -1, 95,
1600 -1, 96, -1, 97, -1, 98, -1, 99, -1, 100,
1601 -1, 101, -1, 102, -1, 103, -1, 90, -1, 91,
1602 -1, 92, -1, 93, -1, 22, -1, 23, -1, 11,
1603 -1, 12, -1, 13, -1, 16, -1, 19, -1, 156,
1604 -1, -1, 156, 134, -1, -1, 17, -1, 20, -1,
1605 159, 134, -1, -1, 36, -1, 38, -1, 37, -1,
1606 39, -1, 41, -1, 40, -1, 42, -1, 44, -1,
1607 -1, 133, -1, -1, 40, -1, 42, -1, -1, 36,
1608 -1, 37, -1, 38, -1, 41, -1, -1, 55, -1,
1609 56, -1, 57, -1, 58, -1, 59, -1, 54, 4,
1610 -1, 111, -1, 112, -1, 129, -1, 130, -1, -1,
1611 168, 167, -1, 128, -1, 131, -1, 167, -1, -1,
1612 170, 169, -1, -1, 47, 4, -1, -1, 135, 47,
1613 4, -1, 30, 19, -1, -1, 173, -1, -1, 135,
1614 176, 175, -1, 173, -1, 47, 4, -1, 11, -1,
1615 12, -1, 13, -1, 14, -1, 43, -1, 177, -1,
1616 178, 136, -1, 210, -1, 137, 4, -1, 178, 138,
1617 182, 139, 170, -1, 10, 138, 182, 139, 170, -1,
1618 140, 4, 141, 178, 142, -1, 143, 4, 141, 178,
1619 144, -1, 145, 183, 146, -1, 145, 146, -1, 143,
1620 145, 183, 146, 144, -1, 143, 145, 146, 144, -1,
1621 178, 168, -1, 178, -1, 10, -1, 179, -1, 181,
1622 135, 179, -1, 181, -1, 181, 135, 33, -1, 33,
1623 -1, -1, 178, -1, 183, 135, 178, -1, 178, 140,
1624 186, 142, -1, 178, 140, 142, -1, 178, 147, 19,
1625 -1, 178, 143, 186, 144, -1, 178, 145, 186, 146,
1626 -1, 178, 145, 146, -1, 178, 143, 145, 186, 146,
1627 144, -1, 178, 143, 145, 146, 144, -1, 178, 34,
1628 -1, 178, 35, -1, 178, 210, -1, 178, 185, -1,
1629 178, 21, -1, 154, 3, -1, 154, 5, -1, 154,
1630 4, -1, 154, 6, -1, 11, 22, -1, 11, 23,
1631 -1, 155, 9, -1, 151, 138, 184, 32, 178, 139,
1632 -1, 109, 138, 184, 221, 139, -1, 123, 138, 184,
1633 135, 184, 135, 184, 139, -1, 149, 138, 184, 135,
1634 184, 139, -1, 150, 138, 184, 135, 184, 139, -1,
1635 82, 152, 138, 184, 135, 184, 139, -1, 83, 153,
1636 138, 184, 135, 184, 139, -1, 125, 138, 184, 135,
1637 184, 139, -1, 126, 138, 184, 135, 184, 135, 184,
1638 139, -1, 127, 138, 184, 135, 184, 135, 184, 139,
1639 -1, 186, 135, 184, -1, 184, -1, 28, -1, 29,
1640 -1, 189, -1, -1, 190, -1, 189, 190, -1, -1,
1641 27, 191, 206, -1, -1, 26, 192, 207, -1, 52,
1642 51, 196, -1, 158, 15, 178, -1, 158, 15, 10,
1643 -1, -1, 160, 163, 187, 184, 193, 175, -1, -1,
1644 160, 161, 163, 187, 184, 194, 175, -1, -1, 160,
1645 162, 163, 187, 178, 195, 175, -1, 45, 197, -1,
1646 48, 134, 198, -1, 19, -1, 46, 134, 19, -1,
1647 60, 134, 19, -1, 140, 199, 142, -1, 199, 135,
1648 19, -1, 19, -1, -1, 200, 135, 178, 168, 157,
1649 -1, 178, 168, 157, -1, 200, -1, 200, 135, 33,
1650 -1, 33, -1, -1, 166, 180, 159, 138, 201, 139,
1651 170, 174, 171, -1, 24, -1, 145, -1, 165, 163,
1652 202, 203, -1, 25, -1, 146, -1, 213, 205, -1,
1653 164, 163, 202, -1, -1, 53, -1, 3, -1, 4,
1654 -1, 9, -1, 22, -1, 23, -1, 34, -1, 35,
1655 -1, 21, -1, 143, 186, 144, -1, 185, -1, 51,
1656 208, 19, 135, 19, -1, 7, -1, 8, -1, 156,
1657 -1, 159, -1, 210, -1, 209, -1, 178, 211, -1,
1658 213, 214, -1, 204, 214, -1, 215, 158, 216, -1,
1659 215, 218, -1, -1, 18, -1, 61, 212, -1, 61,
1660 10, -1, 62, 14, 211, -1, 62, 11, 211, 135,
1661 14, 211, 135, 14, 211, -1, 63, 154, 211, 135,
1662 14, 211, 140, 217, 142, -1, 63, 154, 211, 135,
1663 14, 211, 140, 142, -1, 64, 166, 180, 211, 138,
1664 220, 139, 170, 32, 14, 211, 65, 14, 211, -1,
1665 65, -1, 66, -1, 217, 154, 209, 135, 14, 211,
1666 -1, 154, 209, 135, 14, 211, -1, 158, 223, -1,
1667 178, 140, 211, 135, 211, 142, -1, 219, 135, 140,
1668 211, 135, 211, 142, -1, 178, 211, 168, -1, 220,
1669 135, 178, 211, 168, -1, -1, -1, 221, 135, 212,
1670 -1, 50, 49, -1, 49, -1, 149, 178, 211, 135,
1671 211, -1, 150, 178, 211, 135, 211, -1, 82, 152,
1672 178, 211, 135, 211, -1, 83, 153, 178, 211, 135,
1673 211, -1, 151, 212, 32, 178, -1, 123, 212, 135,
1674 212, 135, 212, -1, 124, 212, 135, 178, -1, 125,
1675 212, 135, 212, -1, 126, 212, 135, 212, 135, 212,
1676 -1, 127, 212, 135, 212, 135, 212, -1, 122, 219,
1677 -1, 222, 166, 180, 211, 138, 220, 139, 170, -1,
1678 225, -1, 31, -1, -1, 104, 178, 172, -1, 104,
1679 178, 135, 11, 211, 172, -1, 105, 178, 172, -1,
1680 105, 178, 135, 11, 211, 172, -1, 106, 212, -1,
1681 224, 107, 178, 211, -1, 224, 108, 212, 135, 178,
1682 211, -1, 109, 178, 211, 221, -1
Reid Spencer38c91a92007-02-28 02:24:54 +00001683};
1684
1685/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1686static const unsigned short int yyrline[] =
1687{
Reid Spencer7b5d4662007-04-09 06:16:21 +00001688 0, 1091, 1091, 1091, 1091, 1091, 1091, 1091, 1091, 1091,
1689 1091, 1092, 1092, 1092, 1092, 1092, 1092, 1093, 1093, 1093,
1690 1093, 1093, 1093, 1094, 1094, 1094, 1094, 1094, 1094, 1097,
1691 1097, 1098, 1098, 1099, 1099, 1100, 1100, 1101, 1101, 1105,
1692 1105, 1106, 1106, 1107, 1107, 1108, 1108, 1109, 1109, 1110,
1693 1110, 1111, 1111, 1112, 1113, 1118, 1119, 1119, 1121, 1121,
1694 1122, 1122, 1126, 1130, 1135, 1135, 1137, 1141, 1147, 1148,
1695 1149, 1150, 1151, 1155, 1156, 1157, 1161, 1162, 1166, 1167,
1696 1168, 1172, 1173, 1174, 1175, 1176, 1179, 1180, 1181, 1182,
1697 1183, 1184, 1185, 1192, 1193, 1194, 1195, 1198, 1199, 1204,
1698 1205, 1206, 1209, 1210, 1217, 1218, 1224, 1225, 1233, 1241,
1699 1242, 1247, 1248, 1249, 1254, 1267, 1267, 1267, 1267, 1270,
1700 1274, 1278, 1285, 1290, 1298, 1324, 1351, 1356, 1368, 1378,
1701 1382, 1392, 1399, 1406, 1413, 1418, 1423, 1430, 1431, 1438,
1702 1445, 1453, 1459, 1471, 1499, 1515, 1544, 1572, 1597, 1616,
1703 1642, 1662, 1674, 1681, 1747, 1757, 1767, 1773, 1783, 1789,
1704 1799, 1804, 1809, 1817, 1829, 1851, 1859, 1865, 1876, 1881,
1705 1886, 1892, 1898, 1907, 1911, 1919, 1919, 1930, 1935, 1943,
1706 1944, 1948, 1948, 1952, 1952, 1955, 1958, 1982, 1993, 1993,
1707 2003, 2003, 2011, 2011, 2021, 2024, 2030, 2043, 2047, 2052,
1708 2054, 2059, 2064, 2073, 2083, 2094, 2098, 2107, 2116, 2121,
1709 2240, 2240, 2242, 2251, 2251, 2253, 2258, 2270, 2274, 2279,
1710 2283, 2287, 2291, 2295, 2299, 2303, 2307, 2311, 2336, 2340,
1711 2354, 2358, 2362, 2366, 2372, 2372, 2378, 2387, 2391, 2400,
1712 2409, 2418, 2422, 2427, 2431, 2435, 2440, 2450, 2469, 2478,
1713 2554, 2558, 2565, 2576, 2589, 2599, 2610, 2620, 2629, 2638,
1714 2641, 2642, 2649, 2653, 2658, 2679, 2696, 2710, 2724, 2736,
1715 2744, 2751, 2757, 2763, 2769, 2784, 2856, 2861, 2865, 2872,
1716 2879, 2887, 2894, 2902, 2910, 2924, 2941
Reid Spencer38c91a92007-02-28 02:24:54 +00001717};
1718#endif
1719
1720#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1721/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1722 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1723static const char *const yytname[] =
1724{
1725 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1726 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1727 "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001728 "STRINGCONSTANT", "ATSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1729 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1730 "CONSTANT", "SECTION", "VOLATILE", "TO", "DOTDOTDOT", "NULL_TOK",
1731 "UNDEF", "INTERNAL", "LINKONCE", "WEAK", "APPENDING", "DLLIMPORT",
1732 "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", "EXTERNAL", "TARGET", "TRIPLE",
1733 "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT",
1734 "CC_TOK", "CCC_TOK", "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK",
1735 "X86_FASTCALLCC_TOK", "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE",
1736 "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV",
1737 "UREM", "SREM", "FREM", "AND", "OR", "XOR", "SHL", "LSHR", "ASHR",
1738 "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT",
1739 "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO",
1740 "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE",
1741 "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST",
1742 "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT",
1743 "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT",
1744 "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET", "NOUNWIND", "DEFAULT",
1745 "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'",
1746 "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps",
1747 "LogicalOps", "CastOps", "IPredicates", "FPredicates", "IntType",
1748 "FPType", "LocalName", "OptLocalName", "OptLocalAssign", "GlobalName",
1749 "OptGlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1750 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1751 "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr",
1752 "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString", "OptSection",
1753 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1754 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
1755 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "Module",
1756 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1757 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1758 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1759 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
Reid Spencer38c91a92007-02-28 02:24:54 +00001760 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1761 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1762 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1763 "OptVolatile", "MemoryInst", 0
1764};
1765#endif
1766
1767# ifdef YYPRINT
1768/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1769 token YYLEX-NUM. */
1770static const unsigned short int yytoknum[] =
1771{
1772 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1773 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1774 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1775 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1776 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1777 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1778 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1779 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1780 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1781 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1782 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1783 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1784 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001785 385, 386, 387, 388, 61, 44, 42, 92, 40, 41,
1786 91, 120, 93, 60, 62, 123, 125, 99
Reid Spencer38c91a92007-02-28 02:24:54 +00001787};
1788# endif
1789
1790/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1791static const unsigned char yyr1[] =
1792{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001793 0, 148, 149, 149, 149, 149, 149, 149, 149, 149,
1794 149, 150, 150, 150, 150, 150, 150, 151, 151, 151,
1795 151, 151, 151, 151, 151, 151, 151, 151, 151, 152,
Reid Spencer38c91a92007-02-28 02:24:54 +00001796 152, 152, 152, 152, 152, 152, 152, 152, 152, 153,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001797 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
1798 153, 153, 153, 153, 153, 154, 155, 155, 156, 156,
1799 157, 157, 158, 158, 159, 159, 160, 160, 161, 161,
1800 161, 161, 161, 162, 162, 162, 163, 163, 164, 164,
1801 164, 165, 165, 165, 165, 165, 166, 166, 166, 166,
1802 166, 166, 166, 167, 167, 167, 167, 168, 168, 169,
1803 169, 169, 170, 170, 171, 171, 172, 172, 173, 174,
1804 174, 175, 175, 176, 176, 177, 177, 177, 177, 178,
1805 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
1806 178, 178, 179, 180, 180, 181, 181, 182, 182, 182,
1807 182, 183, 183, 184, 184, 184, 184, 184, 184, 184,
1808 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
1809 184, 184, 184, 185, 185, 185, 185, 185, 185, 185,
1810 185, 185, 185, 186, 186, 187, 187, 188, 188, 189,
1811 189, 191, 190, 192, 190, 190, 190, 190, 193, 190,
1812 194, 190, 195, 190, 190, 190, 196, 197, 197, 198,
1813 199, 199, 199, 200, 200, 201, 201, 201, 201, 202,
1814 203, 203, 204, 205, 205, 206, 207, 208, 208, 209,
1815 209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
1816 210, 210, 210, 210, 211, 211, 212, 213, 213, 214,
1817 215, 215, 215, 216, 216, 216, 216, 216, 216, 216,
1818 216, 216, 217, 217, 218, 219, 219, 220, 220, 220,
1819 221, 221, 222, 222, 223, 223, 223, 223, 223, 223,
1820 223, 223, 223, 223, 223, 223, 223, 224, 224, 225,
1821 225, 225, 225, 225, 225, 225, 225
Reid Spencer38c91a92007-02-28 02:24:54 +00001822};
1823
1824/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1825static const unsigned char yyr2[] =
1826{
1827 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1828 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1829 1, 1, 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, 0, 2, 0, 1, 1, 2, 0, 1, 1,
1834 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
1835 1, 0, 1, 1, 1, 1, 0, 1, 1, 1,
1836 1, 1, 2, 1, 1, 1, 1, 0, 2, 1,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001837 1, 1, 0, 2, 0, 2, 0, 3, 2, 0,
1838 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1839 1, 2, 1, 2, 5, 5, 5, 5, 3, 2,
1840 5, 4, 2, 1, 1, 1, 3, 1, 3, 1,
1841 0, 1, 3, 4, 3, 3, 4, 4, 3, 6,
1842 5, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1843 2, 2, 2, 6, 5, 8, 6, 6, 7, 7,
1844 6, 8, 8, 3, 1, 1, 1, 1, 0, 1,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001845 2, 0, 3, 0, 3, 3, 3, 3, 0, 6,
1846 0, 7, 0, 7, 2, 3, 1, 3, 3, 3,
1847 3, 1, 0, 5, 3, 1, 3, 1, 0, 9,
1848 1, 1, 4, 1, 1, 2, 3, 0, 1, 1,
1849 1, 1, 1, 1, 1, 1, 1, 3, 1, 5,
1850 1, 1, 1, 1, 1, 1, 2, 2, 2, 3,
1851 2, 0, 1, 2, 2, 3, 9, 9, 8, 14,
1852 1, 1, 6, 5, 2, 6, 7, 3, 5, 0,
1853 0, 3, 2, 1, 5, 5, 6, 6, 4, 6,
1854 4, 4, 6, 6, 2, 8, 1, 1, 0, 3,
1855 6, 3, 6, 2, 4, 6, 4
Reid Spencer38c91a92007-02-28 02:24:54 +00001856};
1857
1858/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1859 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1860 means the default is an error. */
1861static const unsigned short int yydefact[] =
1862{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001863 67, 58, 64, 59, 65, 183, 181, 0, 0, 0,
1864 0, 0, 0, 76, 0, 67, 179, 78, 81, 0,
1865 0, 194, 0, 0, 62, 0, 66, 68, 70, 69,
1866 71, 73, 72, 74, 75, 77, 76, 76, 0, 1,
1867 180, 79, 80, 76, 184, 82, 83, 84, 85, 76,
1868 241, 182, 241, 0, 0, 202, 195, 196, 185, 230,
1869 231, 187, 115, 116, 117, 118, 119, 0, 0, 0,
1870 0, 232, 233, 120, 186, 122, 0, 0, 175, 176,
1871 0, 86, 86, 242, 238, 63, 213, 214, 215, 237,
1872 197, 198, 201, 0, 140, 123, 0, 0, 0, 0,
1873 129, 141, 0, 121, 140, 0, 0, 115, 116, 117,
1874 0, 0, 0, 188, 0, 87, 88, 89, 90, 91,
1875 0, 216, 0, 278, 240, 0, 199, 139, 97, 135,
1876 137, 0, 0, 0, 0, 0, 0, 128, 0, 190,
1877 192, 160, 161, 156, 158, 157, 159, 162, 155, 151,
1878 152, 2, 3, 4, 5, 6, 7, 8, 9, 10,
1879 14, 15, 16, 11, 12, 13, 0, 0, 0, 17,
1880 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1881 28, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1882 0, 0, 154, 153, 111, 92, 134, 133, 0, 210,
1883 211, 212, 277, 263, 0, 0, 0, 0, 86, 250,
1884 251, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1885 0, 0, 0, 0, 0, 0, 239, 86, 254, 0,
1886 276, 200, 132, 0, 102, 0, 0, 131, 0, 142,
1887 102, 111, 111, 29, 30, 31, 32, 33, 34, 35,
1888 36, 37, 38, 0, 53, 54, 49, 50, 51, 52,
1889 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
1890 0, 0, 0, 0, 0, 0, 144, 174, 0, 0,
1891 0, 148, 0, 145, 0, 0, 0, 0, 189, 0,
1892 262, 244, 0, 243, 0, 0, 55, 0, 0, 0,
1893 0, 106, 106, 283, 0, 0, 274, 0, 0, 0,
1894 0, 0, 0, 0, 0, 0, 0, 0, 93, 94,
1895 95, 96, 98, 138, 136, 125, 126, 127, 130, 124,
1896 191, 193, 0, 0, 260, 0, 0, 0, 0, 0,
1897 143, 129, 141, 0, 146, 147, 0, 0, 0, 0,
1898 0, 113, 111, 208, 219, 220, 221, 226, 222, 223,
1899 224, 225, 217, 0, 228, 235, 234, 236, 0, 245,
1900 0, 0, 0, 0, 0, 279, 0, 281, 260, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00001901 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001902 0, 0, 99, 100, 101, 103, 0, 0, 0, 0,
1903 0, 0, 0, 173, 150, 0, 0, 0, 0, 108,
1904 114, 112, 207, 97, 205, 0, 218, 0, 0, 0,
1905 0, 0, 0, 0, 0, 0, 0, 286, 0, 0,
1906 0, 270, 271, 0, 0, 0, 0, 268, 0, 284,
1907 0, 0, 0, 0, 164, 0, 0, 0, 0, 149,
1908 0, 0, 0, 61, 0, 102, 0, 227, 0, 0,
1909 259, 0, 0, 106, 107, 106, 0, 0, 0, 0,
1910 0, 264, 265, 259, 0, 0, 0, 261, 0, 170,
1911 0, 0, 166, 167, 163, 60, 204, 206, 97, 109,
1912 0, 0, 0, 0, 0, 266, 267, 0, 280, 282,
1913 0, 0, 269, 272, 273, 0, 285, 168, 169, 0,
1914 0, 0, 61, 110, 104, 229, 0, 0, 97, 0,
1915 102, 255, 0, 102, 165, 171, 172, 203, 0, 209,
1916 0, 248, 0, 0, 257, 0, 0, 256, 275, 105,
1917 246, 0, 247, 0, 97, 0, 0, 0, 258, 0,
1918 0, 0, 0, 253, 0, 0, 252, 0, 249
Reid Spencer38c91a92007-02-28 02:24:54 +00001919};
1920
1921/* YYDEFGOTO[NTERM-NUM]. */
1922static const short int yydefgoto[] =
1923{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001924 -1, 189, 190, 191, 253, 270, 110, 111, 71, 486,
1925 11, 72, 13, 36, 37, 38, 43, 49, 120, 322,
1926 232, 395, 325, 529, 375, 351, 514, 288, 352, 73,
1927 112, 129, 198, 130, 131, 102, 277, 364, 278, 80,
1928 14, 15, 16, 18, 17, 194, 241, 242, 58, 21,
1929 56, 93, 414, 415, 121, 201, 50, 88, 51, 44,
1930 417, 365, 75, 367, 293, 52, 84, 85, 226, 533,
1931 124, 306, 494, 398, 227, 228, 229, 230
Reid Spencer38c91a92007-02-28 02:24:54 +00001932};
1933
1934/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1935 STATE-NUM. */
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001936#define YYPACT_NINF -428
Reid Spencer38c91a92007-02-28 02:24:54 +00001937static const short int yypact[] =
1938{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00001939 262, -428, -428, -428, -428, -428, -428, -26, -85, 60,
1940 5, 50, 9, 282, 135, 406, -428, 203, 191, 32,
1941 74, -428, 73, 134, -428, 1106, -428, -428, -428, -428,
1942 -428, -428, -428, -428, -428, -428, 87, 87, 150, -428,
1943 -428, -428, -428, 87, -428, -428, -428, -428, -428, 87,
1944 208, -428, 1, 228, 234, 248, -428, -428, -428, -428,
1945 -428, 130, -428, -428, -428, -428, -428, 276, 280, 4,
1946 111, -428, -428, -428, -57, -428, 150, 150, -428, -428,
1947 1143, 311, 311, -428, -428, 118, -428, -428, -428, -428,
1948 -428, -428, -428, -6, 40, -428, 144, 146, 908, 130,
1949 -428, -57, -68, -428, 40, 1143, 1157, 39, 281, 285,
1950 232, 286, 738, -428, 292, -428, -428, -428, -428, -428,
1951 1191, -428, -7, 1314, -428, 278, -428, -428, -57, -428,
1952 166, 163, 1157, 1157, 159, -36, 1157, -428, 165, -428,
1953 -57, -428, -428, -428, -428, -428, -428, -428, -428, -428,
1954 -428, -428, -428, -428, -428, -428, -428, -428, -428, -428,
1955 -428, -428, -428, -428, -428, -428, 255, 594, 167, -428,
1956 -428, -428, -428, -428, -428, -428, -428, -428, -428, -428,
1957 -428, 170, 171, 173, 175, 497, 1207, 945, 296, 187,
1958 196, 197, -428, -428, 192, -428, 130, -57, 213, -428,
1959 -428, -428, -428, -428, 287, 1228, 247, 338, 311, -428,
1960 -428, 255, 594, 1157, 1157, 1157, 1157, 1157, 1157, 1157,
1961 1157, 1157, 1157, 1157, 1157, 1157, -428, 311, -428, 152,
1962 -428, -428, -43, 1003, -428, -41, -103, -428, 206, -57,
1963 -428, 192, 192, -428, -428, -428, -428, -428, -428, -428,
1964 -428, -428, -428, 214, -428, -428, -428, -428, -428, -428,
1965 -428, -428, -428, -428, -428, -428, -428, -428, -428, -428,
1966 216, 1143, 1143, 1143, 1143, 1143, -428, -428, 17, 987,
1967 -18, -428, -33, -428, 1143, 1143, 1143, 8, -428, 217,
1968 -428, 130, 592, -428, 717, 717, -428, 717, 1191, 1157,
1969 1157, 106, 114, -428, 592, 31, 236, 239, 240, 241,
1970 242, 243, 592, 592, 347, 1191, 1157, 1157, -428, -428,
1971 -428, -428, -428, -428, -428, -40, -428, -428, -428, -40,
1972 -428, -428, 1143, 1143, -428, 245, 246, 252, 256, 1143,
1973 -428, 238, 738, -31, -428, -428, 257, 259, 351, 371,
1974 393, -428, 192, 1050, -428, -428, -428, -428, -428, -428,
1975 -428, -428, 346, 1143, -428, -428, -428, -428, 265, -428,
1976 267, 717, 592, 592, 16, -428, 19, -428, -428, 717,
1977 263, 1157, 1157, 1157, 1157, 1157, 269, 272, 1157, 717,
1978 592, 273, -428, -428, -428, -428, 275, 283, -32, 1143,
1979 1143, 1143, 1143, -428, -428, 290, 1143, 1143, 1157, -428,
1980 -428, -428, -428, -57, 289, 288, -428, 398, 13, 415,
1981 417, 297, 302, 303, 717, 435, 717, 305, 306, 717,
1982 307, -57, -428, 308, 312, 717, 717, -57, 310, -428,
1983 1157, 1143, 1143, 1157, -428, 315, 313, 320, 321, -428,
1984 322, 324, 22, 21, 1088, -428, 325, -428, 717, 717,
1985 1157, 717, 717, 329, -428, 329, 717, 330, 1157, 1157,
1986 1157, -428, -428, 1157, 592, 327, 328, -428, 1143, -428,
1987 1143, 1143, -428, -428, -428, -428, -428, -428, -57, 34,
1988 440, 333, 331, 592, 72, -428, -428, 422, -428, -428,
1989 336, 717, -428, -428, -428, 75, -428, -428, -428, 340,
1990 343, 344, 21, -428, 423, -428, 461, -1, -428, 1157,
1991 -428, -428, 345, -428, -428, -428, -428, -428, 481, -428,
1992 717, -428, 866, 2, -43, 592, 44, -428, -40, -428,
1993 -428, 353, -428, 866, -428, 472, 475, 357, -43, 717,
1994 717, 479, 429, -428, 717, 482, -428, 717, -428
Reid Spencer38c91a92007-02-28 02:24:54 +00001995};
1996
1997/* YYPGOTO[NTERM-NUM]. */
1998static const short int yypgoto[] =
1999{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002000 -428, 374, 375, 376, 291, 294, -205, -428, 0, -12,
2001 416, 14, -428, -428, -428, 57, -428, -428, -150, -313,
2002 -404, -428, -237, -428, -295, 26, -428, -210, -428, -428,
2003 -24, 270, -223, -428, 414, 421, -69, -108, -181, 189,
2004 -428, -428, 505, -428, -428, -428, -428, -428, -428, -428,
2005 -428, -428, -428, -428, 439, -428, -428, -428, -428, -428,
2006 -428, -427, -73, 101, -197, -428, 470, -428, -428, -428,
2007 -428, -428, 51, 145, -428, -428, -428, -428
Reid Spencer38c91a92007-02-28 02:24:54 +00002008};
2009
2010/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2011 positive, shift that token. If negative, reduce the rule which
2012 number is the opposite. If zero, do what YYDEFACT says.
2013 If YYTABLE_NINF, syntax error. */
Reid Spencer67d8ed92007-03-22 02:14:08 +00002014#define YYTABLE_NINF -179
Reid Spencer38c91a92007-02-28 02:24:54 +00002015static const short int yytable[] =
2016{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002017 10, 74, 297, 329, 192, 280, 282, 377, 97, 453,
2018 296, 113, 394, 296, 12, 10, 394, 199, 303, 83,
2019 19, 307, 308, 309, 310, 311, 86, 424, 314, 12,
2020 426, 330, 331, 103, 20, 104, 139, 1, 349, 193,
2021 3, 327, -55, -55, -55, -55, 101, 59, 60, 22,
2022 99, 62, 63, 64, 65, 350, 1, 2, 298, 3,
2023 4, 141, 142, 425, 349, 25, 425, 136, 318, 319,
2024 128, 318, 319, 127, 101, 371, 545, 315, 137, 103,
2025 128, 104, 140, 66, 512, 10, 320, 321, 392, 320,
2026 321, 393, 389, 76, 77, 103, 197, 104, 343, 136,
2027 81, 326, 339, 443, 339, 541, 82, 444, 235, 236,
2028 238, 23, 239, 345, 534, 405, 547, 339, 59, 60,
2029 391, 99, 62, 63, 64, 65, 344, 1, 2, 125,
2030 3, 4, 318, 319, 1, 39, 126, 3, 200, 24,
2031 548, 531, 411, 26, 542, 318, 319, 87, 339, 98,
2032 320, 321, 339, 57, 66, 318, 319, 457, 103, 340,
2033 104, 484, 392, 320, 321, 393, 53, 103, 498, 104,
2034 499, 379, 392, 320, 321, 393, 394, 67, 78, 79,
2035 68, 292, 418, 69, 430, 70, 432, 433, 434, 301,
2036 302, 292, 304, 305, 292, 292, 292, 292, 292, 312,
2037 313, 292, 334, 335, 336, 337, 338, 519, 54, 128,
2038 519, 520, 289, 55, 523, 346, 347, 348, 489, 366,
2039 35, 366, 366, 394, 366, 394, 83, 45, 46, 47,
2040 2, 366, 48, 4, 192, 143, 144, 145, 146, 366,
2041 366, 374, 103, 41, 104, 42, 477, 90, 67, 376,
2042 103, 68, 104, 91, 69, 342, 70, 100, 294, 316,
2043 317, 295, -178, 396, 397, 105, 106, 92, 94, 193,
2044 403, 502, 503, 504, 197, 372, 373, -63, 1, 2,
2045 95, 3, 4, 536, 96, 132, 538, 133, 5, 6,
2046 -56, 197, 390, 292, -57, 147, 195, 231, 366, 366,
2047 366, 233, 234, 237, 240, 271, 366, 7, 272, 273,
2048 8, 274, 532, 275, 9, 283, 366, 366, 27, 28,
2049 29, 30, 31, 32, 33, 284, 34, 287, 543, 413,
2050 445, 446, 447, 448, 285, 286, 290, 450, 451, 243,
2051 244, 245, 246, 247, 248, 249, 250, 251, 252, 296,
2052 328, 366, 332, 366, 333, 353, 366, 292, 431, 292,
2053 292, 292, 366, 366, 437, 114, 115, 116, 117, 118,
2054 119, 380, 475, 476, 381, 382, 383, 384, 385, 388,
2055 399, 400, 404, 408, 452, 366, 366, 401, 366, 366,
2056 409, 402, 406, 366, 407, 368, 369, 410, 370, 416,
2057 419, 366, 420, 429, 435, 378, -177, 436, 440, 509,
2058 441, 510, 511, 386, 387, 35, 474, 456, 442, 292,
2059 366, -63, 1, 2, 454, 3, 4, 455, 366, 458,
2060 488, 459, 5, 6, 449, 460, 493, 461, 462, 464,
2061 443, 466, 468, 469, 292, 292, 292, 470, 473, 493,
2062 478, 7, 479, 485, 8, 480, 481, 366, 9, 515,
2063 490, 482, 366, 483, 497, 501, 507, 508, 516, 425,
2064 528, 517, 421, 422, 423, 530, 366, 366, 521, 524,
2065 428, 366, 525, 526, 366, 539, 549, 537, 546, 550,
2066 438, 439, 551, 554, 555, 535, 557, 223, 224, 225,
2067 527, 123, 299, 324, 59, 60, 300, 99, 107, 108,
2068 109, 65, 485, 1, 2, 513, 3, 4, 138, 135,
2069 40, 122, 89, 427, 505, 463, 0, 465, 0, 0,
2070 467, 0, 0, 0, 0, 0, 471, 472, 0, 0,
2071 66, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2072 0, 0, 0, 0, 0, 0, 0, 0, 0, 491,
2073 492, 0, 495, 496, 0, 0, 0, 500, 0, 0,
2074 0, 0, 0, 0, 0, 506, 0, 0, 0, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00002075 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002076 0, 0, 0, 0, 518, 354, 355, 0, 0, 59,
2077 60, 356, 522, 0, 0, 0, 0, 0, 1, 2,
2078 0, 3, 4, 357, 358, 359, 254, 255, 0, 0,
2079 0, 0, 0, 0, 0, 0, 360, 361, 0, 0,
2080 0, 540, 0, 0, 67, 0, 544, 68, 0, 276,
2081 69, 0, 70, 362, 0, 0, 0, 0, 0, 0,
2082 552, 553, 0, 0, 0, 556, 0, 0, 558, 151,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002083 152, 153, 154, 155, 156, 157, 158, 159, 160, 161,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002084 162, 163, 164, 165, 166, 167, 0, 0, 0, 0,
2085 0, 0, 0, 0, 256, 257, 258, 259, 260, 261,
2086 262, 263, 264, 265, 266, 267, 268, 269, 0, 0,
2087 0, 168, 169, 170, 171, 172, 173, 174, 175, 176,
2088 177, 178, 179, 180, 0, 181, 0, 182, 183, 184,
2089 354, 355, 0, 0, 59, 60, 356, 0, 103, 0,
2090 104, 0, 0, 1, 2, 363, 3, 4, 357, 358,
2091 359, 0, 0, 0, 0, 59, 60, 0, 0, 0,
2092 0, 360, 361, 0, 1, 2, 0, 3, 4, 148,
2093 0, 0, 0, 0, 0, 0, 0, 0, 362, 0,
2094 0, 0, 149, 150, 0, 0, 0, 0, 0, 0,
2095 0, 0, 0, 0, 151, 152, 153, 154, 155, 156,
2096 157, 158, 159, 160, 161, 162, 163, 164, 165, 166,
2097 167, 0, 0, 0, 0, 151, 152, 153, 154, 155,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002098 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002099 166, 167, 0, 0, 0, 0, 168, 169, 170, 171,
2100 172, 173, 174, 175, 176, 177, 178, 179, 180, 0,
2101 181, 0, 182, 183, 184, 0, 0, 168, 169, 170,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002102 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002103 363, 181, 0, 182, 183, 184, 0, 0, 0, 354,
2104 355, 0, 0, 0, 103, 356, 104, 0, 185, 0,
2105 0, 186, 0, 187, 0, 188, 0, 357, 358, 359,
2106 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2107 360, 361, 0, 0, 0, 0, 0, 0, 0, 0,
2108 0, 0, 0, 0, 0, 59, 60, 362, 99, 62,
2109 63, 64, 65, 0, 1, 2, 0, 3, 4, 0,
2110 0, 0, 0, 151, 152, 153, 154, 155, 156, 157,
Reid Spencer38c91a92007-02-28 02:24:54 +00002111 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002112 0, 66, 59, 60, 0, 99, 107, 108, 109, 65,
2113 0, 1, 2, 0, 3, 4, 0, 0, 0, 0,
2114 0, 0, 0, 0, 0, 168, 169, 170, 171, 172,
2115 173, 174, 175, 176, 177, 178, 179, 180, 66, 181,
2116 0, 182, 183, 184, 59, 60, 0, 99, 107, 108,
2117 109, 65, 0, 1, 2, 0, 3, 4, 0, 363,
2118 59, 60, 0, 99, 62, 63, 64, 65, 0, 1,
2119 2, 0, 3, 4, 0, 0, 0, 0, 0, 0,
2120 66, 0, 0, 0, 0, 0, 323, 0, 0, 0,
2121 0, 0, 0, 0, 0, 67, 66, 0, 68, 0,
2122 0, 69, 0, 70, 134, 0, 0, 59, 60, 0,
2123 99, 62, 63, 64, 65, 0, 1, 2, 0, 3,
2124 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2125 0, 0, 67, 412, 0, 68, 0, 0, 69, 0,
2126 70, 281, 0, 66, 0, 59, 60, 0, 99, 62,
2127 63, 64, 65, 0, 1, 2, 0, 3, 4, 0,
2128 0, 0, 0, 59, 60, 0, 61, 62, 63, 64,
2129 65, 487, 1, 2, 67, 3, 4, 68, 0, 0,
2130 69, 66, 70, 341, 0, 0, 0, 0, 0, 0,
2131 67, 0, 0, 68, 0, 0, 69, 0, 70, 66,
2132 59, 60, 0, 99, 107, 108, 109, 65, 0, 1,
2133 2, 0, 3, 4, 59, 60, 0, 99, 62, 63,
2134 64, 65, 0, 1, 2, 0, 3, 4, 0, 0,
2135 0, 0, 0, 0, 0, 0, 66, 67, 0, 0,
2136 68, 0, 0, 69, 0, 70, 0, 0, 59, 60,
2137 66, 196, 62, 63, 64, 65, 0, 1, 2, 0,
2138 3, 4, 0, 0, 59, 60, 0, 99, 107, 108,
2139 109, 65, 0, 1, 2, 67, 3, 4, 68, 0,
2140 0, 69, 0, 70, 66, 59, 60, 0, 291, 62,
2141 63, 64, 65, 67, 1, 2, 68, 3, 4, 69,
2142 66, 70, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002144 0, 66, 0, 0, 0, 0, 0, 0, 0, 0,
2145 67, 0, 0, 68, 0, 0, 69, 0, 70, 0,
2146 0, 0, 0, 0, 67, 0, 0, 68, 0, 0,
2147 69, 0, 70, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002149 0, 0, 0, 0, 0, 0, 0, 0, 67, 0,
2150 0, 68, 0, 0, 69, 0, 70, 0, 0, 0,
2151 0, 0, 0, 0, 67, 202, 0, 68, 0, 0,
2152 69, 0, 279, 0, 0, 0, 0, 0, 0, 0,
2153 0, 0, 0, 203, 204, 67, 0, 0, 68, 0,
2154 0, 69, 0, 70, 0, 205, 206, 207, 208, 209,
2155 210, 151, 152, 153, 154, 155, 156, 157, 158, 159,
2156 160, 161, 162, 163, 164, 165, 211, 212, 0, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00002157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002158 0, 0, 0, 0, 0, 0, 0, 0, 213, 214,
2159 215, 0, 0, 216, 169, 170, 171, 172, 173, 174,
2160 175, 176, 177, 178, 179, 180, 217, 218, 219, 220,
2161 221, 222
Reid Spencer38c91a92007-02-28 02:24:54 +00002162};
2163
2164static const short int yycheck[] =
2165{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002166 0, 25, 207, 240, 112, 186, 187, 302, 4, 413,
2167 11, 80, 325, 11, 0, 15, 329, 24, 215, 18,
2168 46, 218, 219, 220, 221, 222, 25, 11, 225, 15,
2169 11, 241, 242, 136, 60, 138, 105, 16, 30, 112,
2170 19, 144, 3, 4, 5, 6, 70, 7, 8, 134,
2171 10, 11, 12, 13, 14, 47, 16, 17, 208, 19,
2172 20, 22, 23, 47, 30, 15, 47, 135, 111, 112,
2173 94, 111, 112, 33, 98, 298, 32, 227, 146, 136,
2174 104, 138, 106, 43, 488, 85, 129, 130, 128, 129,
2175 130, 131, 315, 36, 37, 136, 120, 138, 279, 135,
2176 43, 142, 135, 135, 135, 532, 49, 139, 132, 133,
2177 146, 51, 136, 146, 518, 146, 543, 135, 7, 8,
2178 317, 10, 11, 12, 13, 14, 144, 16, 17, 135,
2179 19, 20, 111, 112, 16, 0, 142, 19, 145, 134,
2180 544, 142, 352, 134, 142, 111, 112, 146, 135, 145,
2181 129, 130, 135, 19, 43, 111, 112, 144, 136, 142,
2182 138, 139, 128, 129, 130, 131, 134, 136, 463, 138,
2183 465, 140, 128, 129, 130, 131, 489, 137, 28, 29,
2184 140, 205, 363, 143, 381, 145, 383, 384, 385, 213,
2185 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
2186 224, 225, 271, 272, 273, 274, 275, 135, 134, 233,
2187 135, 139, 198, 140, 139, 284, 285, 286, 455, 292,
2188 133, 294, 295, 536, 297, 538, 18, 36, 37, 38,
2189 17, 304, 41, 20, 342, 3, 4, 5, 6, 312,
2190 313, 135, 136, 40, 138, 42, 443, 19, 137, 135,
2191 136, 140, 138, 19, 143, 279, 145, 146, 11, 107,
2192 108, 14, 0, 332, 333, 76, 77, 19, 138, 342,
2193 339, 468, 469, 470, 298, 299, 300, 15, 16, 17,
2194 4, 19, 20, 520, 4, 141, 523, 141, 26, 27,
2195 9, 315, 316, 317, 9, 9, 4, 19, 371, 372,
2196 373, 135, 139, 144, 139, 138, 379, 45, 138, 138,
2197 48, 138, 517, 138, 52, 19, 389, 390, 36, 37,
2198 38, 39, 40, 41, 42, 138, 44, 135, 533, 353,
2199 399, 400, 401, 402, 138, 138, 49, 406, 407, 84,
2200 85, 86, 87, 88, 89, 90, 91, 92, 93, 11,
2201 144, 424, 138, 426, 138, 138, 429, 381, 382, 383,
2202 384, 385, 435, 436, 388, 54, 55, 56, 57, 58,
2203 59, 135, 441, 442, 135, 135, 135, 135, 135, 32,
2204 135, 135, 144, 32, 408, 458, 459, 135, 461, 462,
2205 19, 135, 135, 466, 135, 294, 295, 4, 297, 53,
2206 135, 474, 135, 140, 135, 304, 0, 135, 135, 478,
2207 135, 480, 481, 312, 313, 133, 440, 19, 135, 443,
2208 493, 15, 16, 17, 135, 19, 20, 139, 501, 14,
2209 454, 14, 26, 27, 144, 138, 460, 135, 135, 4,
2210 135, 135, 135, 135, 468, 469, 470, 135, 138, 473,
2211 135, 45, 139, 453, 48, 135, 135, 530, 52, 19,
2212 135, 139, 535, 139, 135, 135, 139, 139, 135, 47,
2213 47, 140, 371, 372, 373, 14, 549, 550, 142, 139,
2214 379, 554, 139, 139, 557, 4, 14, 142, 135, 14,
2215 389, 390, 135, 14, 65, 519, 14, 123, 123, 123,
2216 512, 85, 211, 233, 7, 8, 212, 10, 11, 12,
2217 13, 14, 512, 16, 17, 489, 19, 20, 104, 98,
2218 15, 82, 52, 378, 473, 424, -1, 426, -1, -1,
2219 429, -1, -1, -1, -1, -1, 435, 436, -1, -1,
2220 43, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2221 -1, -1, -1, -1, -1, -1, -1, -1, -1, 458,
2222 459, -1, 461, 462, -1, -1, -1, 466, -1, -1,
2223 -1, -1, -1, -1, -1, 474, -1, -1, -1, -1,
Reid Spencer38c91a92007-02-28 02:24:54 +00002224 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002225 -1, -1, -1, -1, 493, 3, 4, -1, -1, 7,
2226 8, 9, 501, -1, -1, -1, -1, -1, 16, 17,
2227 -1, 19, 20, 21, 22, 23, 22, 23, -1, -1,
2228 -1, -1, -1, -1, -1, -1, 34, 35, -1, -1,
2229 -1, 530, -1, -1, 137, -1, 535, 140, -1, 142,
2230 143, -1, 145, 51, -1, -1, -1, -1, -1, -1,
2231 549, 550, -1, -1, -1, 554, -1, -1, 557, 67,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002232 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002233 78, 79, 80, 81, 82, 83, -1, -1, -1, -1,
2234 -1, -1, -1, -1, 90, 91, 92, 93, 94, 95,
2235 96, 97, 98, 99, 100, 101, 102, 103, -1, -1,
2236 -1, 109, 110, 111, 112, 113, 114, 115, 116, 117,
2237 118, 119, 120, 121, -1, 123, -1, 125, 126, 127,
2238 3, 4, -1, -1, 7, 8, 9, -1, 136, -1,
2239 138, -1, -1, 16, 17, 143, 19, 20, 21, 22,
2240 23, -1, -1, -1, -1, 7, 8, -1, -1, -1,
2241 -1, 34, 35, -1, 16, 17, -1, 19, 20, 21,
2242 -1, -1, -1, -1, -1, -1, -1, -1, 51, -1,
2243 -1, -1, 34, 35, -1, -1, -1, -1, -1, -1,
2244 -1, -1, -1, -1, 67, 68, 69, 70, 71, 72,
2245 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2246 83, -1, -1, -1, -1, 67, 68, 69, 70, 71,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002247 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002248 82, 83, -1, -1, -1, -1, 109, 110, 111, 112,
2249 113, 114, 115, 116, 117, 118, 119, 120, 121, -1,
2250 123, -1, 125, 126, 127, -1, -1, 109, 110, 111,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002251 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002252 143, 123, -1, 125, 126, 127, -1, -1, -1, 3,
2253 4, -1, -1, -1, 136, 9, 138, -1, 140, -1,
2254 -1, 143, -1, 145, -1, 147, -1, 21, 22, 23,
2255 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2256 34, 35, -1, -1, -1, -1, -1, -1, -1, -1,
2257 -1, -1, -1, -1, -1, 7, 8, 51, 10, 11,
2258 12, 13, 14, -1, 16, 17, -1, 19, 20, -1,
2259 -1, -1, -1, 67, 68, 69, 70, 71, 72, 73,
Reid Spencer38c91a92007-02-28 02:24:54 +00002260 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002261 -1, 43, 7, 8, -1, 10, 11, 12, 13, 14,
2262 -1, 16, 17, -1, 19, 20, -1, -1, -1, -1,
2263 -1, -1, -1, -1, -1, 109, 110, 111, 112, 113,
2264 114, 115, 116, 117, 118, 119, 120, 121, 43, 123,
2265 -1, 125, 126, 127, 7, 8, -1, 10, 11, 12,
2266 13, 14, -1, 16, 17, -1, 19, 20, -1, 143,
2267 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
2268 17, -1, 19, 20, -1, -1, -1, -1, -1, -1,
2269 43, -1, -1, -1, -1, -1, 33, -1, -1, -1,
2270 -1, -1, -1, -1, -1, 137, 43, -1, 140, -1,
2271 -1, 143, -1, 145, 146, -1, -1, 7, 8, -1,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002272 10, 11, 12, 13, 14, -1, 16, 17, -1, 19,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002273 20, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2274 -1, -1, 137, 33, -1, 140, -1, -1, 143, -1,
2275 145, 146, -1, 43, -1, 7, 8, -1, 10, 11,
2276 12, 13, 14, -1, 16, 17, -1, 19, 20, -1,
2277 -1, -1, -1, 7, 8, -1, 10, 11, 12, 13,
2278 14, 33, 16, 17, 137, 19, 20, 140, -1, -1,
2279 143, 43, 145, 146, -1, -1, -1, -1, -1, -1,
2280 137, -1, -1, 140, -1, -1, 143, -1, 145, 43,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002281 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
Reid Spencer38c91a92007-02-28 02:24:54 +00002282 17, -1, 19, 20, 7, 8, -1, 10, 11, 12,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002283 13, 14, -1, 16, 17, -1, 19, 20, -1, -1,
2284 -1, -1, -1, -1, -1, -1, 43, 137, -1, -1,
2285 140, -1, -1, 143, -1, 145, -1, -1, 7, 8,
2286 43, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2287 19, 20, -1, -1, 7, 8, -1, 10, 11, 12,
2288 13, 14, -1, 16, 17, 137, 19, 20, 140, -1,
2289 -1, 143, -1, 145, 43, 7, 8, -1, 10, 11,
2290 12, 13, 14, 137, 16, 17, 140, 19, 20, 143,
2291 43, 145, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer38c91a92007-02-28 02:24:54 +00002292 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002293 -1, 43, -1, -1, -1, -1, -1, -1, -1, -1,
2294 137, -1, -1, 140, -1, -1, 143, -1, 145, -1,
2295 -1, -1, -1, -1, 137, -1, -1, 140, -1, -1,
2296 143, -1, 145, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer38c91a92007-02-28 02:24:54 +00002297 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002298 -1, -1, -1, -1, -1, -1, -1, -1, 137, -1,
2299 -1, 140, -1, -1, 143, -1, 145, -1, -1, -1,
2300 -1, -1, -1, -1, 137, 31, -1, 140, -1, -1,
2301 143, -1, 145, -1, -1, -1, -1, -1, -1, -1,
2302 -1, -1, -1, 49, 50, 137, -1, -1, 140, -1,
2303 -1, 143, -1, 145, -1, 61, 62, 63, 64, 65,
2304 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
2305 76, 77, 78, 79, 80, 81, 82, 83, -1, -1,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002306 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002307 -1, -1, -1, -1, -1, -1, -1, -1, 104, 105,
2308 106, -1, -1, 109, 110, 111, 112, 113, 114, 115,
2309 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
2310 126, 127
Reid Spencer38c91a92007-02-28 02:24:54 +00002311};
2312
2313/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2314 symbol of state STATE-NUM. */
2315static const unsigned char yystos[] =
2316{
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002317 0, 16, 17, 19, 20, 26, 27, 45, 48, 52,
2318 156, 158, 159, 160, 188, 189, 190, 192, 191, 46,
2319 60, 197, 134, 51, 134, 15, 134, 36, 37, 38,
2320 39, 40, 41, 42, 44, 133, 161, 162, 163, 0,
2321 190, 40, 42, 164, 207, 36, 37, 38, 41, 165,
2322 204, 206, 213, 134, 134, 140, 198, 19, 196, 7,
2323 8, 10, 11, 12, 13, 14, 43, 137, 140, 143,
2324 145, 156, 159, 177, 178, 210, 163, 163, 28, 29,
2325 187, 163, 163, 18, 214, 215, 25, 146, 205, 214,
2326 19, 19, 19, 199, 138, 4, 4, 4, 145, 10,
2327 146, 178, 183, 136, 138, 187, 187, 11, 12, 13,
2328 154, 155, 178, 184, 54, 55, 56, 57, 58, 59,
2329 166, 202, 202, 158, 218, 135, 142, 33, 178, 179,
2330 181, 182, 141, 141, 146, 183, 135, 146, 182, 184,
2331 178, 22, 23, 3, 4, 5, 6, 9, 21, 34,
2332 35, 67, 68, 69, 70, 71, 72, 73, 74, 75,
2333 76, 77, 78, 79, 80, 81, 82, 83, 109, 110,
Reid Spencer38c91a92007-02-28 02:24:54 +00002334 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002335 121, 123, 125, 126, 127, 140, 143, 145, 147, 149,
2336 150, 151, 185, 210, 193, 4, 10, 178, 180, 24,
2337 145, 203, 31, 49, 50, 61, 62, 63, 64, 65,
2338 66, 82, 83, 104, 105, 106, 109, 122, 123, 124,
2339 125, 126, 127, 149, 150, 151, 216, 222, 223, 224,
2340 225, 19, 168, 135, 139, 178, 178, 144, 146, 178,
2341 139, 194, 195, 84, 85, 86, 87, 88, 89, 90,
2342 91, 92, 93, 152, 22, 23, 90, 91, 92, 93,
Reid Spencer38c91a92007-02-28 02:24:54 +00002343 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
Reid Spencer3d6b71e2007-04-09 01:56:05 +00002344 153, 138, 138, 138, 138, 138, 142, 184, 186, 145,
2345 186, 146, 186, 19, 138, 138, 138, 135, 175, 159,
2346 49, 10, 178, 212, 11, 14, 11, 154, 166, 152,
2347 153, 178, 178, 212, 178, 178, 219, 212, 212, 212,
2348 212, 212, 178, 178, 212, 166, 107, 108, 111, 112,
2349 129, 130, 167, 33, 179, 170, 142, 144, 144, 170,
2350 175, 175, 138, 138, 184, 184, 184, 184, 184, 135,
2351 142, 146, 178, 186, 144, 146, 184, 184, 184, 30,
2352 47, 173, 176, 138, 3, 4, 9, 21, 22, 23,
2353 34, 35, 51, 143, 185, 209, 210, 211, 211, 211,
2354 211, 180, 178, 178, 135, 172, 135, 172, 211, 140,
2355 135, 135, 135, 135, 135, 135, 211, 211, 32, 180,
2356 178, 212, 128, 131, 167, 169, 184, 184, 221, 135,
2357 135, 135, 135, 184, 144, 146, 135, 135, 32, 19,
2358 4, 175, 33, 178, 200, 201, 53, 208, 186, 135,
2359 135, 211, 211, 211, 11, 47, 11, 221, 211, 140,
2360 212, 178, 212, 212, 212, 135, 135, 178, 211, 211,
2361 135, 135, 135, 135, 139, 184, 184, 184, 184, 144,
2362 184, 184, 178, 168, 135, 139, 19, 144, 14, 14,
2363 138, 135, 135, 211, 4, 211, 135, 211, 135, 135,
2364 135, 211, 211, 138, 178, 184, 184, 212, 135, 139,
2365 135, 135, 139, 139, 139, 156, 157, 33, 178, 170,
2366 135, 211, 211, 178, 220, 211, 211, 135, 172, 172,
2367 211, 135, 212, 212, 212, 220, 211, 139, 139, 184,
2368 184, 184, 168, 173, 174, 19, 135, 140, 211, 135,
2369 139, 142, 211, 139, 139, 139, 139, 157, 47, 171,
2370 14, 142, 154, 217, 168, 178, 170, 142, 170, 4,
2371 211, 209, 142, 154, 211, 32, 135, 209, 168, 14,
2372 14, 135, 211, 211, 14, 65, 211, 14, 211
Reid Spencer38c91a92007-02-28 02:24:54 +00002373};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002374
2375#define yyerrok (yyerrstatus = 0)
2376#define yyclearin (yychar = YYEMPTY)
Reid Spencer38c91a92007-02-28 02:24:54 +00002377#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002378#define YYEOF 0
Reid Spencer38c91a92007-02-28 02:24:54 +00002379
Reid Spencer68a24bd2005-08-27 18:50:39 +00002380#define YYACCEPT goto yyacceptlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002381#define YYABORT goto yyabortlab
2382#define YYERROR goto yyerrorlab
2383
2384
2385/* Like YYERROR except do call yyerror. This remains here temporarily
2386 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002387 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002388
Reid Spencer68a24bd2005-08-27 18:50:39 +00002389#define YYFAIL goto yyerrlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002390
Reid Spencer68a24bd2005-08-27 18:50:39 +00002391#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002392
2393#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002394do \
2395 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer38c91a92007-02-28 02:24:54 +00002396 { \
2397 yychar = (Token); \
2398 yylval = (Value); \
2399 yytoken = YYTRANSLATE (yychar); \
Chris Lattner9d2fda62007-02-13 05:53:56 +00002400 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002401 goto yybackup; \
2402 } \
2403 else \
Reid Spencer38c91a92007-02-28 02:24:54 +00002404 { \
2405 yyerror (YY_("syntax error: cannot back up")); \
2406 YYERROR; \
2407 } \
Chris Lattner9d2fda62007-02-13 05:53:56 +00002408while (0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002409
Reid Spencer38c91a92007-02-28 02:24:54 +00002410
Reid Spencer68a24bd2005-08-27 18:50:39 +00002411#define YYTERROR 1
2412#define YYERRCODE 256
2413
Reid Spencer38c91a92007-02-28 02:24:54 +00002414
2415/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2416 If N is 0, then set CURRENT to the empty location which ends
2417 the previous symbol: RHS[0] (always defined). */
2418
2419#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2420#ifndef YYLLOC_DEFAULT
2421# define YYLLOC_DEFAULT(Current, Rhs, N) \
2422 do \
2423 if (N) \
2424 { \
2425 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2426 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2427 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2428 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2429 } \
2430 else \
2431 { \
2432 (Current).first_line = (Current).last_line = \
2433 YYRHSLOC (Rhs, 0).last_line; \
2434 (Current).first_column = (Current).last_column = \
2435 YYRHSLOC (Rhs, 0).last_column; \
2436 } \
2437 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002438#endif
2439
Reid Spencer38c91a92007-02-28 02:24:54 +00002440
2441/* YY_LOCATION_PRINT -- Print the location on the stream.
2442 This macro was not mandated originally: define only if we know
2443 we won't break user code: when these are the locations we know. */
2444
2445#ifndef YY_LOCATION_PRINT
2446# if YYLTYPE_IS_TRIVIAL
2447# define YY_LOCATION_PRINT(File, Loc) \
2448 fprintf (File, "%d.%d-%d.%d", \
2449 (Loc).first_line, (Loc).first_column, \
2450 (Loc).last_line, (Loc).last_column)
2451# else
2452# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2453# endif
2454#endif
2455
2456
2457/* YYLEX -- calling `yylex' with the right arguments. */
2458
Reid Spencer41dff5e2007-01-26 08:05:27 +00002459#ifdef YYLEX_PARAM
Reid Spencer38c91a92007-02-28 02:24:54 +00002460# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer41dff5e2007-01-26 08:05:27 +00002461#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002462# define YYLEX yylex ()
Chris Lattner32980692007-02-19 07:44:24 +00002463#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002464
2465/* Enable debugging if requested. */
2466#if YYDEBUG
2467
2468# ifndef YYFPRINTF
2469# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2470# define YYFPRINTF fprintf
2471# endif
2472
2473# define YYDPRINTF(Args) \
2474do { \
2475 if (yydebug) \
2476 YYFPRINTF Args; \
2477} while (0)
2478
2479# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2480do { \
2481 if (yydebug) \
2482 { \
2483 YYFPRINTF (stderr, "%s ", Title); \
2484 yysymprint (stderr, \
2485 Type, Value); \
2486 YYFPRINTF (stderr, "\n"); \
2487 } \
2488} while (0)
2489
2490/*------------------------------------------------------------------.
2491| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2492| TOP (included). |
2493`------------------------------------------------------------------*/
2494
2495#if defined (__STDC__) || defined (__cplusplus)
2496static void
2497yy_stack_print (short int *bottom, short int *top)
Chris Lattner32980692007-02-19 07:44:24 +00002498#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002499static void
2500yy_stack_print (bottom, top)
2501 short int *bottom;
2502 short int *top;
Chris Lattner32980692007-02-19 07:44:24 +00002503#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002504{
2505 YYFPRINTF (stderr, "Stack now");
2506 for (/* Nothing. */; bottom <= top; ++bottom)
2507 YYFPRINTF (stderr, " %d", *bottom);
2508 YYFPRINTF (stderr, "\n");
2509}
2510
2511# define YY_STACK_PRINT(Bottom, Top) \
2512do { \
2513 if (yydebug) \
2514 yy_stack_print ((Bottom), (Top)); \
2515} while (0)
2516
2517
2518/*------------------------------------------------.
2519| Report that the YYRULE is going to be reduced. |
2520`------------------------------------------------*/
2521
2522#if defined (__STDC__) || defined (__cplusplus)
2523static void
2524yy_reduce_print (int yyrule)
2525#else
2526static void
2527yy_reduce_print (yyrule)
2528 int yyrule;
Chris Lattner9d2fda62007-02-13 05:53:56 +00002529#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002530{
2531 int yyi;
2532 unsigned long int yylno = yyrline[yyrule];
2533 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2534 yyrule - 1, yylno);
2535 /* Print the symbols being reduced, and their result. */
2536 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2537 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2538 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2539}
Reid Spencer9d6565a2007-02-15 02:26:10 +00002540
Reid Spencer38c91a92007-02-28 02:24:54 +00002541# define YY_REDUCE_PRINT(Rule) \
2542do { \
2543 if (yydebug) \
2544 yy_reduce_print (Rule); \
2545} while (0)
Reid Spencer9d6565a2007-02-15 02:26:10 +00002546
Reid Spencer38c91a92007-02-28 02:24:54 +00002547/* Nonzero means print parse trace. It is left uninitialized so that
2548 multiple parsers can coexist. */
2549int yydebug;
2550#else /* !YYDEBUG */
2551# define YYDPRINTF(Args)
2552# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2553# define YY_STACK_PRINT(Bottom, Top)
2554# define YY_REDUCE_PRINT(Rule)
2555#endif /* !YYDEBUG */
Reid Spencer9d6565a2007-02-15 02:26:10 +00002556
Reid Spencer9d6565a2007-02-15 02:26:10 +00002557
Reid Spencer38c91a92007-02-28 02:24:54 +00002558/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002559#ifndef YYINITDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002560# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002561#endif
2562
Reid Spencer38c91a92007-02-28 02:24:54 +00002563/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2564 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002565
Reid Spencer38c91a92007-02-28 02:24:54 +00002566 Do not make this value too large; the results are undefined if
2567 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2568 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002569
2570#ifndef YYMAXDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002571# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002572#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002573
Reid Spencer68a24bd2005-08-27 18:50:39 +00002574
2575
Reid Spencer38c91a92007-02-28 02:24:54 +00002576#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002577
Reid Spencer38c91a92007-02-28 02:24:54 +00002578# ifndef yystrlen
2579# if defined (__GLIBC__) && defined (_STRING_H)
2580# define yystrlen strlen
2581# else
2582/* Return the length of YYSTR. */
2583static YYSIZE_T
2584# if defined (__STDC__) || defined (__cplusplus)
2585yystrlen (const char *yystr)
2586# else
2587yystrlen (yystr)
2588 const char *yystr;
2589# endif
Chris Lattner32980692007-02-19 07:44:24 +00002590{
Reid Spencer38c91a92007-02-28 02:24:54 +00002591 const char *yys = yystr;
Chris Lattner32980692007-02-19 07:44:24 +00002592
Reid Spencer38c91a92007-02-28 02:24:54 +00002593 while (*yys++ != '\0')
2594 continue;
2595
2596 return yys - yystr - 1;
Chris Lattner32980692007-02-19 07:44:24 +00002597}
Reid Spencer38c91a92007-02-28 02:24:54 +00002598# endif
2599# endif
Chris Lattner32980692007-02-19 07:44:24 +00002600
Reid Spencer38c91a92007-02-28 02:24:54 +00002601# ifndef yystpcpy
2602# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2603# define yystpcpy stpcpy
2604# else
2605/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2606 YYDEST. */
2607static char *
2608# if defined (__STDC__) || defined (__cplusplus)
2609yystpcpy (char *yydest, const char *yysrc)
2610# else
2611yystpcpy (yydest, yysrc)
2612 char *yydest;
2613 const char *yysrc;
2614# endif
Chris Lattner32980692007-02-19 07:44:24 +00002615{
Reid Spencer38c91a92007-02-28 02:24:54 +00002616 char *yyd = yydest;
2617 const char *yys = yysrc;
Chris Lattner32980692007-02-19 07:44:24 +00002618
Reid Spencer38c91a92007-02-28 02:24:54 +00002619 while ((*yyd++ = *yys++) != '\0')
2620 continue;
2621
2622 return yyd - 1;
Chris Lattner32980692007-02-19 07:44:24 +00002623}
Reid Spencer38c91a92007-02-28 02:24:54 +00002624# endif
2625# endif
Chris Lattner32980692007-02-19 07:44:24 +00002626
Reid Spencer38c91a92007-02-28 02:24:54 +00002627# ifndef yytnamerr
2628/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2629 quotes and backslashes, so that it's suitable for yyerror. The
2630 heuristic is that double-quoting is unnecessary unless the string
2631 contains an apostrophe, a comma, or backslash (other than
2632 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2633 null, do not copy; instead, return the length of what the result
2634 would have been. */
2635static YYSIZE_T
2636yytnamerr (char *yyres, const char *yystr)
2637{
2638 if (*yystr == '"')
2639 {
2640 size_t yyn = 0;
2641 char const *yyp = yystr;
2642
2643 for (;;)
2644 switch (*++yyp)
2645 {
2646 case '\'':
2647 case ',':
2648 goto do_not_strip_quotes;
2649
2650 case '\\':
2651 if (*++yyp != '\\')
2652 goto do_not_strip_quotes;
2653 /* Fall through. */
2654 default:
2655 if (yyres)
2656 yyres[yyn] = *yyp;
2657 yyn++;
2658 break;
2659
2660 case '"':
2661 if (yyres)
2662 yyres[yyn] = '\0';
2663 return yyn;
2664 }
2665 do_not_strip_quotes: ;
2666 }
2667
2668 if (! yyres)
2669 return yystrlen (yystr);
2670
2671 return yystpcpy (yyres, yystr) - yyres;
2672}
2673# endif
2674
2675#endif /* YYERROR_VERBOSE */
2676
Reid Spencer9d6565a2007-02-15 02:26:10 +00002677
2678
Reid Spencer38c91a92007-02-28 02:24:54 +00002679#if YYDEBUG
2680/*--------------------------------.
2681| Print this symbol on YYOUTPUT. |
2682`--------------------------------*/
Reid Spencer9d6565a2007-02-15 02:26:10 +00002683
Reid Spencer38c91a92007-02-28 02:24:54 +00002684#if defined (__STDC__) || defined (__cplusplus)
2685static void
2686yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner32980692007-02-19 07:44:24 +00002687#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002688static void
2689yysymprint (yyoutput, yytype, yyvaluep)
2690 FILE *yyoutput;
2691 int yytype;
2692 YYSTYPE *yyvaluep;
2693#endif
2694{
2695 /* Pacify ``unused variable'' warnings. */
2696 (void) yyvaluep;
2697
2698 if (yytype < YYNTOKENS)
2699 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2700 else
2701 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2702
2703
2704# ifdef YYPRINT
2705 if (yytype < YYNTOKENS)
2706 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2707# endif
2708 switch (yytype)
2709 {
2710 default:
2711 break;
2712 }
2713 YYFPRINTF (yyoutput, ")");
2714}
2715
2716#endif /* ! YYDEBUG */
2717/*-----------------------------------------------.
2718| Release the memory associated to this symbol. |
2719`-----------------------------------------------*/
2720
2721#if defined (__STDC__) || defined (__cplusplus)
2722static void
2723yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2724#else
2725static void
2726yydestruct (yymsg, yytype, yyvaluep)
2727 const char *yymsg;
2728 int yytype;
2729 YYSTYPE *yyvaluep;
2730#endif
2731{
2732 /* Pacify ``unused variable'' warnings. */
2733 (void) yyvaluep;
2734
2735 if (!yymsg)
2736 yymsg = "Deleting";
2737 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2738
2739 switch (yytype)
2740 {
2741
2742 default:
2743 break;
2744 }
2745}
2746
2747
2748/* Prevent warnings from -Wmissing-prototypes. */
2749
2750#ifdef YYPARSE_PARAM
2751# if defined (__STDC__) || defined (__cplusplus)
2752int yyparse (void *YYPARSE_PARAM);
2753# else
2754int yyparse ();
2755# endif
2756#else /* ! YYPARSE_PARAM */
2757#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002758int yyparse (void);
Chris Lattner32980692007-02-19 07:44:24 +00002759#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002760int yyparse ();
2761#endif
2762#endif /* ! YYPARSE_PARAM */
2763
2764
2765
2766/* The look-ahead symbol. */
2767int yychar;
2768
2769/* The semantic value of the look-ahead symbol. */
2770YYSTYPE yylval;
2771
2772/* Number of syntax errors so far. */
2773int yynerrs;
2774
2775
2776
2777/*----------.
2778| yyparse. |
2779`----------*/
2780
2781#ifdef YYPARSE_PARAM
2782# if defined (__STDC__) || defined (__cplusplus)
2783int yyparse (void *YYPARSE_PARAM)
2784# else
2785int yyparse (YYPARSE_PARAM)
2786 void *YYPARSE_PARAM;
2787# endif
2788#else /* ! YYPARSE_PARAM */
2789#if defined (__STDC__) || defined (__cplusplus)
2790int
2791yyparse (void)
2792#else
2793int
2794yyparse ()
2795
2796#endif
2797#endif
2798{
2799
2800 int yystate;
2801 int yyn;
2802 int yyresult;
2803 /* Number of tokens to shift before error messages enabled. */
2804 int yyerrstatus;
2805 /* Look-ahead token as an internal (translated) token number. */
2806 int yytoken = 0;
2807
2808 /* Three stacks and their tools:
2809 `yyss': related to states,
2810 `yyvs': related to semantic values,
2811 `yyls': related to locations.
2812
2813 Refer to the stacks thru separate pointers, to allow yyoverflow
2814 to reallocate them elsewhere. */
2815
2816 /* The state stack. */
2817 short int yyssa[YYINITDEPTH];
2818 short int *yyss = yyssa;
2819 short int *yyssp;
2820
2821 /* The semantic value stack. */
2822 YYSTYPE yyvsa[YYINITDEPTH];
2823 YYSTYPE *yyvs = yyvsa;
2824 YYSTYPE *yyvsp;
2825
2826
2827
Chris Lattner9d2fda62007-02-13 05:53:56 +00002828#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002829
Reid Spencer38c91a92007-02-28 02:24:54 +00002830 YYSIZE_T yystacksize = YYINITDEPTH;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002831
Reid Spencer38c91a92007-02-28 02:24:54 +00002832 /* The variables used to return semantic value and location from the
2833 action routines. */
2834 YYSTYPE yyval;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002835
Chris Lattner7d9801d2007-02-13 00:58:01 +00002836
Reid Spencer38c91a92007-02-28 02:24:54 +00002837 /* When reducing, the number of symbols on the RHS of the reduced
2838 rule. */
Chris Lattner9d2fda62007-02-13 05:53:56 +00002839 int yylen;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002840
Reid Spencer38c91a92007-02-28 02:24:54 +00002841 YYDPRINTF ((stderr, "Starting parse\n"));
Chris Lattner7d9801d2007-02-13 00:58:01 +00002842
Reid Spencer68a24bd2005-08-27 18:50:39 +00002843 yystate = 0;
2844 yyerrstatus = 0;
2845 yynerrs = 0;
2846 yychar = YYEMPTY; /* Cause a token to be read. */
2847
2848 /* Initialize stack pointers.
2849 Waste one element of value and location stack
2850 so that they stay on the same level as the state stack.
2851 The wasted elements are never initialized. */
2852
Reid Spencer38c91a92007-02-28 02:24:54 +00002853 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002854 yyvsp = yyvs;
2855
Reid Spencer38c91a92007-02-28 02:24:54 +00002856 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002857
Reid Spencer38c91a92007-02-28 02:24:54 +00002858/*------------------------------------------------------------.
2859| yynewstate -- Push a new state, which is found in yystate. |
2860`------------------------------------------------------------*/
2861 yynewstate:
2862 /* In all cases, when you get here, the value and location stacks
2863 have just been pushed. so pushing a state here evens the stacks.
2864 */
2865 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002866
Reid Spencer38c91a92007-02-28 02:24:54 +00002867 yysetstate:
2868 *yyssp = yystate;
2869
2870 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002871 {
2872 /* Get the current used size of the three stacks, in elements. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002873 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002874
2875#ifdef yyoverflow
Reid Spencer38c91a92007-02-28 02:24:54 +00002876 {
2877 /* Give user a chance to reallocate the stack. Use copies of
2878 these so that the &'s don't force the real ones into
2879 memory. */
2880 YYSTYPE *yyvs1 = yyvs;
2881 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002882
Reid Spencer38c91a92007-02-28 02:24:54 +00002883
2884 /* Each stack pointer address is followed by the size of the
2885 data in use in that stack, in bytes. This used to be a
2886 conditional around just the two extra args, but that might
2887 be undefined if yyoverflow is a macro. */
2888 yyoverflow (YY_("memory exhausted"),
2889 &yyss1, yysize * sizeof (*yyssp),
2890 &yyvs1, yysize * sizeof (*yyvsp),
2891
2892 &yystacksize);
2893
2894 yyss = yyss1;
2895 yyvs = yyvs1;
2896 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002897#else /* no yyoverflow */
Reid Spencer38c91a92007-02-28 02:24:54 +00002898# ifndef YYSTACK_RELOCATE
2899 goto yyexhaustedlab;
2900# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002901 /* Extend the stack our own way. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002902 if (YYMAXDEPTH <= yystacksize)
2903 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002904 yystacksize *= 2;
Reid Spencer38c91a92007-02-28 02:24:54 +00002905 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002906 yystacksize = YYMAXDEPTH;
Reid Spencer38c91a92007-02-28 02:24:54 +00002907
2908 {
2909 short int *yyss1 = yyss;
2910 union yyalloc *yyptr =
2911 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2912 if (! yyptr)
2913 goto yyexhaustedlab;
2914 YYSTACK_RELOCATE (yyss);
2915 YYSTACK_RELOCATE (yyvs);
2916
2917# undef YYSTACK_RELOCATE
2918 if (yyss1 != yyssa)
2919 YYSTACK_FREE (yyss1);
2920 }
2921# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002922#endif /* no yyoverflow */
2923
Reid Spencer38c91a92007-02-28 02:24:54 +00002924 yyssp = yyss + yysize - 1;
2925 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002926
2927
Reid Spencer38c91a92007-02-28 02:24:54 +00002928 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2929 (unsigned long int) yystacksize));
2930
2931 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002932 YYABORT;
2933 }
2934
Reid Spencer38c91a92007-02-28 02:24:54 +00002935 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002936
2937 goto yybackup;
Reid Spencer38c91a92007-02-28 02:24:54 +00002938
2939/*-----------.
2940| yybackup. |
2941`-----------*/
2942yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002943
Chris Lattner9d2fda62007-02-13 05:53:56 +00002944/* Do appropriate processing given the current state. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002945/* Read a look-ahead token if we need one and don't already have one. */
Chris Lattner9d2fda62007-02-13 05:53:56 +00002946/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002947
Reid Spencer38c91a92007-02-28 02:24:54 +00002948 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer5cbf9852007-01-30 20:08:39 +00002949
Reid Spencer68a24bd2005-08-27 18:50:39 +00002950 yyn = yypact[yystate];
Reid Spencer38c91a92007-02-28 02:24:54 +00002951 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002952 goto yydefault;
2953
Reid Spencer38c91a92007-02-28 02:24:54 +00002954 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002955
Reid Spencer38c91a92007-02-28 02:24:54 +00002956 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002957 if (yychar == YYEMPTY)
2958 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002959 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002960 yychar = YYLEX;
2961 }
2962
Reid Spencer38c91a92007-02-28 02:24:54 +00002963 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002964 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002965 yychar = yytoken = YYEOF;
2966 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002967 }
2968 else
2969 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002970 yytoken = YYTRANSLATE (yychar);
2971 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002972 }
2973
Reid Spencer38c91a92007-02-28 02:24:54 +00002974 /* If the proper action on seeing token YYTOKEN is to reduce or to
2975 detect an error, take that action. */
2976 yyn += yytoken;
2977 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002978 goto yydefault;
2979 yyn = yytable[yyn];
Reid Spencer38c91a92007-02-28 02:24:54 +00002980 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002981 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002982 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002983 goto yyerrlab;
2984 yyn = -yyn;
2985 goto yyreduce;
2986 }
2987
2988 if (yyn == YYFINAL)
2989 YYACCEPT;
2990
Reid Spencer38c91a92007-02-28 02:24:54 +00002991 /* Shift the look-ahead token. */
2992 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer5cbf9852007-01-30 20:08:39 +00002993
Chris Lattner9d2fda62007-02-13 05:53:56 +00002994 /* Discard the token being shifted unless it is eof. */
Reid Spencer5cbf9852007-01-30 20:08:39 +00002995 if (yychar != YYEOF)
2996 yychar = YYEMPTY;
2997
Chris Lattner7d9801d2007-02-13 00:58:01 +00002998 *++yyvsp = yylval;
2999
Reid Spencer38c91a92007-02-28 02:24:54 +00003000
3001 /* Count tokens shifted since error; after three, turn off error
3002 status. */
3003 if (yyerrstatus)
3004 yyerrstatus--;
Chris Lattner9d2fda62007-02-13 05:53:56 +00003005
3006 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003007 goto yynewstate;
3008
Chris Lattner32980692007-02-19 07:44:24 +00003009
Reid Spencer38c91a92007-02-28 02:24:54 +00003010/*-----------------------------------------------------------.
3011| yydefault -- do the default action for the current state. |
3012`-----------------------------------------------------------*/
3013yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003014 yyn = yydefact[yystate];
3015 if (yyn == 0)
3016 goto yyerrlab;
Reid Spencer38c91a92007-02-28 02:24:54 +00003017 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003018
Reid Spencer38c91a92007-02-28 02:24:54 +00003019
3020/*-----------------------------.
3021| yyreduce -- Do a reduction. |
3022`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003023yyreduce:
Reid Spencer38c91a92007-02-28 02:24:54 +00003024 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003025 yylen = yyr2[yyn];
3026
Reid Spencer38c91a92007-02-28 02:24:54 +00003027 /* If YYLEN is nonzero, implement the default value of the action:
3028 `$$ = $1'.
3029
3030 Otherwise, the following line sets YYVAL to garbage.
3031 This behavior is undocumented and Bison
3032 users should not rely upon it. Assigning to YYVAL
3033 unconditionally makes the parser a bit smaller, and it avoids a
3034 GCC warning that YYVAL may be used uninitialized. */
3035 yyval = yyvsp[1-yylen];
3036
3037
3038 YY_REDUCE_PRINT (yyn);
3039 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003040 {
Reid Spencer38c91a92007-02-28 02:24:54 +00003041 case 29:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003042#line 1097 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003043 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3044 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003045
Reid Spencer38c91a92007-02-28 02:24:54 +00003046 case 30:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003047#line 1097 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003048 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3049 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003050
Reid Spencer38c91a92007-02-28 02:24:54 +00003051 case 31:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003052#line 1098 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003053 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3054 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003055
Reid Spencer38c91a92007-02-28 02:24:54 +00003056 case 32:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003057#line 1098 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003058 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3059 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003060
Reid Spencer38c91a92007-02-28 02:24:54 +00003061 case 33:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003062#line 1099 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003063 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3064 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003065
Reid Spencer38c91a92007-02-28 02:24:54 +00003066 case 34:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003067#line 1099 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003068 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3069 break;
3070
3071 case 35:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003072#line 1100 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003073 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3074 break;
3075
3076 case 36:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003077#line 1100 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003078 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3079 break;
3080
3081 case 37:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003082#line 1101 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003083 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3084 break;
3085
3086 case 38:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003087#line 1101 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003088 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3089 break;
3090
3091 case 39:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003092#line 1105 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003093 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3094 break;
3095
3096 case 40:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003097#line 1105 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003098 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3099 break;
3100
3101 case 41:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003102#line 1106 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003103 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3104 break;
3105
3106 case 42:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003107#line 1106 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003108 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3109 break;
3110
3111 case 43:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003112#line 1107 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003113 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3114 break;
3115
3116 case 44:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003117#line 1107 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003118 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3119 break;
3120
3121 case 45:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003122#line 1108 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003123 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3124 break;
3125
3126 case 46:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003127#line 1108 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003128 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3129 break;
3130
3131 case 47:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003132#line 1109 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003133 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3134 break;
3135
3136 case 48:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003137#line 1109 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003138 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3139 break;
3140
3141 case 49:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003142#line 1110 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003143 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3144 break;
3145
3146 case 50:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003147#line 1110 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003148 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3149 break;
3150
3151 case 51:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003152#line 1111 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003153 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3154 break;
3155
3156 case 52:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003157#line 1111 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003158 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3159 break;
3160
3161 case 53:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003162#line 1112 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003163 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3164 break;
3165
3166 case 54:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003167#line 1113 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003168 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3169 break;
3170
3171 case 61:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003172#line 1122 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003173 { (yyval.StrVal) = 0; ;}
3174 break;
3175
3176 case 62:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003177#line 1126 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003178 {
3179 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003180 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003181 ;}
3182 break;
3183
3184 case 63:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003185#line 1130 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003186 {
3187 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003188 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003189 ;}
3190 break;
3191
3192 case 66:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003193#line 1137 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003194 {
3195 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003196 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003197 ;}
3198 break;
3199
3200 case 67:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003201#line 1141 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003202 {
3203 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003204 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003205 ;}
3206 break;
3207
3208 case 68:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003209#line 1147 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003210 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3211 break;
3212
3213 case 69:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003214#line 1148 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003215 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3216 break;
3217
3218 case 70:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003219#line 1149 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003220 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3221 break;
3222
3223 case 71:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003224#line 1150 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003225 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3226 break;
3227
3228 case 72:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003229#line 1151 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003230 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3231 break;
3232
3233 case 73:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003234#line 1155 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003235 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3236 break;
3237
3238 case 74:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003239#line 1156 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003240 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3241 break;
3242
3243 case 75:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003244#line 1157 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003245 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3246 break;
3247
3248 case 76:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003249#line 1161 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003250 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3251 break;
3252
3253 case 77:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003254#line 1162 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003255 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3256 break;
3257
3258 case 78:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003259#line 1166 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003260 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3261 break;
3262
3263 case 79:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003264#line 1167 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003265 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3266 break;
3267
3268 case 80:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003269#line 1168 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003270 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3271 break;
3272
3273 case 81:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003274#line 1172 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003275 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3276 break;
3277
3278 case 82:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003279#line 1173 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003280 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3281 break;
3282
3283 case 83:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003284#line 1174 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003285 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3286 break;
3287
3288 case 84:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003289#line 1175 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003290 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3291 break;
3292
3293 case 85:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003294#line 1176 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003295 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3296 break;
3297
3298 case 86:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003299#line 1179 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003300 { (yyval.UIntVal) = CallingConv::C; ;}
3301 break;
3302
3303 case 87:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003304#line 1180 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003305 { (yyval.UIntVal) = CallingConv::C; ;}
3306 break;
3307
3308 case 88:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003309#line 1181 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003310 { (yyval.UIntVal) = CallingConv::Fast; ;}
3311 break;
3312
3313 case 89:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003314#line 1182 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003315 { (yyval.UIntVal) = CallingConv::Cold; ;}
3316 break;
3317
3318 case 90:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003319#line 1183 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003320 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3321 break;
3322
3323 case 91:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003324#line 1184 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003325 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3326 break;
3327
3328 case 92:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003329#line 1185 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003330 {
3331 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencerb5334b02007-02-05 10:18:06 +00003332 GEN_ERROR("Calling conv too large");
Reid Spencer38c91a92007-02-28 02:24:54 +00003333 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003334 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003335 ;}
3336 break;
3337
3338 case 93:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003339#line 1192 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3340 { (yyval.ParamAttrs) = ZExtAttribute; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003341 break;
3342
3343 case 94:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003344#line 1193 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3345 { (yyval.ParamAttrs) = SExtAttribute; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003346 break;
3347
3348 case 95:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003349#line 1194 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3350 { (yyval.ParamAttrs) = InRegAttribute; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003351 break;
3352
3353 case 96:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003354#line 1195 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3355 { (yyval.ParamAttrs) = StructRetAttribute; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003356 break;
3357
3358 case 97:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003359#line 1198 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3360 { (yyval.ParamAttrs) = NoAttributeSet; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003361 break;
3362
3363 case 98:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003364#line 1199 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003365 {
Reid Spencer7b5d4662007-04-09 06:16:21 +00003366 (yyval.ParamAttrs) = (yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs);
Reid Spencer38c91a92007-02-28 02:24:54 +00003367 ;}
3368 break;
3369
3370 case 99:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003371#line 1204 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3372 { (yyval.ParamAttrs) = NoReturnAttribute; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003373 break;
3374
Reid Spencer67d8ed92007-03-22 02:14:08 +00003375 case 100:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003376#line 1205 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3377 { (yyval.ParamAttrs) = NoUnwindAttribute; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003378 break;
3379
3380 case 102:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003381#line 1209 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3382 { (yyval.ParamAttrs) = NoAttributeSet; ;}
Reid Spencer67d8ed92007-03-22 02:14:08 +00003383 break;
3384
3385 case 103:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003386#line 1210 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003387 {
Reid Spencer7b5d4662007-04-09 06:16:21 +00003388 (yyval.ParamAttrs) = (yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs);
Reid Spencer38c91a92007-02-28 02:24:54 +00003389 ;}
3390 break;
3391
Reid Spencer67d8ed92007-03-22 02:14:08 +00003392 case 104:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003393#line 1217 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003394 { (yyval.UIntVal) = 0; ;}
3395 break;
3396
Reid Spencer67d8ed92007-03-22 02:14:08 +00003397 case 105:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003398#line 1218 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003399 {
3400 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3401 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003402 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003403 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003404;}
3405 break;
3406
Reid Spencer66728ef2007-03-20 01:13:36 +00003407 case 106:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003408#line 1224 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003409 { (yyval.UIntVal) = 0; ;}
3410 break;
3411
3412 case 107:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003413#line 1225 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer66728ef2007-03-20 01:13:36 +00003414 {
3415 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3416 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3417 GEN_ERROR("Alignment must be a power of two");
3418 CHECK_FOR_ERROR
3419;}
3420 break;
3421
Reid Spencer67d8ed92007-03-22 02:14:08 +00003422 case 108:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003423#line 1233 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003424 {
3425 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3426 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencerb5334b02007-02-05 10:18:06 +00003427 GEN_ERROR("Invalid character in section name");
Reid Spencer38c91a92007-02-28 02:24:54 +00003428 (yyval.StrVal) = (yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003429 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003430;}
3431 break;
3432
Reid Spencer67d8ed92007-03-22 02:14:08 +00003433 case 109:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003434#line 1241 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003435 { (yyval.StrVal) = 0; ;}
3436 break;
3437
Reid Spencer38c91a92007-02-28 02:24:54 +00003438 case 110:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003439#line 1242 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003440 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003441 break;
3442
3443 case 111:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003444#line 1247 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003445 {;}
3446 break;
3447
3448 case 112:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003449#line 1248 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003450 {;}
3451 break;
3452
3453 case 113:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003454#line 1249 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003455 {
3456 CurGV->setSection((yyvsp[0].StrVal));
3457 free((yyvsp[0].StrVal));
Reid Spencer6f407902007-01-13 05:00:46 +00003458 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003459 ;}
3460 break;
3461
Reid Spencer67d8ed92007-03-22 02:14:08 +00003462 case 114:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003463#line 1254 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003464 {
3465 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003466 GEN_ERROR("Alignment must be a power of two");
Reid Spencer38c91a92007-02-28 02:24:54 +00003467 CurGV->setAlignment((yyvsp[0].UInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003468 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003469 ;}
3470 break;
3471
Reid Spencer67d8ed92007-03-22 02:14:08 +00003472 case 119:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003473#line 1270 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003474 {
3475 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003476 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003477 ;}
3478 break;
3479
Reid Spencer67d8ed92007-03-22 02:14:08 +00003480 case 120:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003481#line 1274 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003482 {
3483 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003484 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003485 ;}
3486 break;
3487
Reid Spencer67d8ed92007-03-22 02:14:08 +00003488 case 121:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003489#line 1278 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003490 { // Pointer type?
3491 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003492 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencer38c91a92007-02-28 02:24:54 +00003493 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3494 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003495 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003496 ;}
3497 break;
3498
Reid Spencer67d8ed92007-03-22 02:14:08 +00003499 case 122:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003500#line 1285 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003501 { // Named types are also simple types...
3502 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003503 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003504 (yyval.TypeVal) = new PATypeHolder(tmp);
3505 ;}
3506 break;
3507
Reid Spencer67d8ed92007-03-22 02:14:08 +00003508 case 123:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003509#line 1290 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003510 { // Type UpReference
3511 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003512 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer38c91a92007-02-28 02:24:54 +00003513 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3514 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003515 UR_OUT("New Upreference!\n");
3516 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003517 ;}
3518 break;
3519
Reid Spencer67d8ed92007-03-22 02:14:08 +00003520 case 124:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003521#line 1298 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003522 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003523 std::vector<const Type*> Params;
Reid Spencer7b5d4662007-04-09 06:16:21 +00003524 ParamAttrsList Attrs;
3525 if ((yyvsp[0].ParamAttrs) != NoAttributeSet)
3526 Attrs.addAttributes(0, (yyvsp[0].ParamAttrs));
3527 unsigned index = 1;
3528 TypeWithAttrsList::iterator I = (yyvsp[-2].TypeWithAttrsList)->begin(), E = (yyvsp[-2].TypeWithAttrsList)->end();
3529 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003530 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003531 Params.push_back(Ty);
3532 if (Ty != Type::VoidTy)
Reid Spencer7b5d4662007-04-09 06:16:21 +00003533 if (I->Attrs != NoAttributeSet)
3534 Attrs.addAttributes(index, I->Attrs);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003535 }
3536 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3537 if (isVarArg) Params.pop_back();
3538
Reid Spencer7b5d4662007-04-09 06:16:21 +00003539 ParamAttrsList *ActualAttrs = 0;
3540 if (!Attrs.empty())
3541 ActualAttrs = new ParamAttrsList(Attrs);
3542 FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, ActualAttrs);
Reid Spencer38c91a92007-02-28 02:24:54 +00003543 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3544 delete (yyvsp[-4].TypeVal); // Delete the return type handle
3545 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003546 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003547 ;}
3548 break;
3549
Reid Spencer67d8ed92007-03-22 02:14:08 +00003550 case 125:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003551#line 1324 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003552 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003553 std::vector<const Type*> Params;
Reid Spencer7b5d4662007-04-09 06:16:21 +00003554 ParamAttrsList Attrs;
3555 if ((yyvsp[0].ParamAttrs) != NoAttributeSet)
3556 Attrs.addAttributes(0, (yyvsp[0].ParamAttrs));
3557 TypeWithAttrsList::iterator I = (yyvsp[-2].TypeWithAttrsList)->begin(), E = (yyvsp[-2].TypeWithAttrsList)->end();
3558 unsigned index = 1;
3559 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003560 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003561 Params.push_back(Ty);
3562 if (Ty != Type::VoidTy)
Reid Spencer7b5d4662007-04-09 06:16:21 +00003563 if (I->Attrs != NoAttributeSet)
3564 Attrs.addAttributes(index, I->Attrs);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003565 }
3566 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3567 if (isVarArg) Params.pop_back();
3568
Reid Spencer7b5d4662007-04-09 06:16:21 +00003569 ParamAttrsList *ActualAttrs = 0;
3570 if (!Attrs.empty())
3571 ActualAttrs = new ParamAttrsList(Attrs);
3572
3573 FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, ActualAttrs);
Reid Spencer38c91a92007-02-28 02:24:54 +00003574 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3575 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003576 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003577 ;}
3578 break;
3579
Reid Spencer67d8ed92007-03-22 02:14:08 +00003580 case 126:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003581#line 1351 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003582 { // Sized array type?
3583 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3584 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003585 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003586 ;}
3587 break;
3588
Reid Spencer67d8ed92007-03-22 02:14:08 +00003589 case 127:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003590#line 1356 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003591 { // Vector type?
3592 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3593 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003594 GEN_ERROR("Unsigned result not equal to signed result");
3595 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
Reid Spencer9d6565a2007-02-15 02:26:10 +00003596 GEN_ERROR("Element type of a VectorType must be primitive");
Reid Spencer38c91a92007-02-28 02:24:54 +00003597 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003598 GEN_ERROR("Vector length should be a power of 2");
Reid Spencer38c91a92007-02-28 02:24:54 +00003599 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3600 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003601 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003602 ;}
3603 break;
3604
Reid Spencer67d8ed92007-03-22 02:14:08 +00003605 case 128:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003606#line 1368 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003607 { // Structure type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003608 std::vector<const Type*> Elements;
Reid Spencer38c91a92007-02-28 02:24:54 +00003609 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3610 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003611 Elements.push_back(*I);
3612
Reid Spencer38c91a92007-02-28 02:24:54 +00003613 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3614 delete (yyvsp[-1].TypeList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003615 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003616 ;}
3617 break;
3618
Reid Spencer67d8ed92007-03-22 02:14:08 +00003619 case 129:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003620#line 1378 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003621 { // Empty structure type?
3622 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003623 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003624 ;}
3625 break;
3626
Reid Spencer67d8ed92007-03-22 02:14:08 +00003627 case 130:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003628#line 1382 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003629 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003630 std::vector<const Type*> Elements;
Reid Spencer38c91a92007-02-28 02:24:54 +00003631 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3632 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003633 Elements.push_back(*I);
3634
Reid Spencer38c91a92007-02-28 02:24:54 +00003635 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3636 delete (yyvsp[-2].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003637 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003638 ;}
3639 break;
3640
Reid Spencer67d8ed92007-03-22 02:14:08 +00003641 case 131:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003642#line 1392 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003643 { // Empty structure type?
3644 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003645 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003646 ;}
3647 break;
3648
Reid Spencer67d8ed92007-03-22 02:14:08 +00003649 case 132:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003650#line 1399 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003651 {
3652 (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal);
3653 (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs);
3654 ;}
3655 break;
3656
Reid Spencer67d8ed92007-03-22 02:14:08 +00003657 case 133:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003658#line 1406 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003659 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003660 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003661 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3662 if (!(*(yyvsp[0].TypeVal))->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00003663 GEN_ERROR("LLVM functions cannot return aggregate types");
Reid Spencer38c91a92007-02-28 02:24:54 +00003664 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3665 ;}
3666 break;
3667
Reid Spencer67d8ed92007-03-22 02:14:08 +00003668 case 134:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003669#line 1413 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003670 {
3671 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3672 ;}
3673 break;
3674
Reid Spencer67d8ed92007-03-22 02:14:08 +00003675 case 135:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003676#line 1418 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003677 {
3678 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3679 (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer6f407902007-01-13 05:00:46 +00003680 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003681 ;}
3682 break;
3683
Reid Spencer67d8ed92007-03-22 02:14:08 +00003684 case 136:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003685#line 1423 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003686 {
3687 ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00003688 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003689 ;}
3690 break;
3691
Reid Spencer67d8ed92007-03-22 02:14:08 +00003692 case 138:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003693#line 1431 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003694 {
3695 (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList);
Reid Spencer7b5d4662007-04-09 06:16:21 +00003696 TypeWithAttrs TWA; TWA.Attrs = NoAttributeSet;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003697 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003698 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003699 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003700 ;}
3701 break;
3702
Reid Spencer67d8ed92007-03-22 02:14:08 +00003703 case 139:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003704#line 1438 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003705 {
3706 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Reid Spencer7b5d4662007-04-09 06:16:21 +00003707 TypeWithAttrs TWA; TWA.Attrs = NoAttributeSet;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003708 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003709 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003710 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003711 ;}
3712 break;
3713
Reid Spencer67d8ed92007-03-22 02:14:08 +00003714 case 140:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003715#line 1445 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003716 {
3717 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003718 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003719 ;}
3720 break;
3721
Reid Spencer67d8ed92007-03-22 02:14:08 +00003722 case 141:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003723#line 1453 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003724 {
3725 (yyval.TypeList) = new std::list<PATypeHolder>();
Reid Spencer66728ef2007-03-20 01:13:36 +00003726 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal));
3727 delete (yyvsp[0].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003728 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003729 ;}
3730 break;
3731
Reid Spencer67d8ed92007-03-22 02:14:08 +00003732 case 142:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003733#line 1459 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003734 {
Reid Spencer66728ef2007-03-20 01:13:36 +00003735 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal));
3736 delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003737 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003738 ;}
3739 break;
3740
Reid Spencer67d8ed92007-03-22 02:14:08 +00003741 case 143:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003742#line 1471 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003743 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003744 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003745 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3746 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003747 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003748 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003749 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003750 const Type *ETy = ATy->getElementType();
3751 int NumElements = ATy->getNumElements();
3752
3753 // Verify that we have the correct size...
Reid Spencer38c91a92007-02-28 02:24:54 +00003754 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003755 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003756 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003757 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003758
3759 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00003760 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3761 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003762 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3763 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer38c91a92007-02-28 02:24:54 +00003764 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003765 }
3766
Reid Spencer38c91a92007-02-28 02:24:54 +00003767 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3768 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003769 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003770 ;}
3771 break;
3772
Reid Spencer67d8ed92007-03-22 02:14:08 +00003773 case 144:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003774#line 1499 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003775 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003776 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003777 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3778 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003779 if (ATy == 0)
3780 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003781 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003782
Andrew Lenharth6353e052006-12-08 18:07:09 +00003783 int NumElements = ATy->getNumElements();
3784 if (NumElements != -1 && NumElements != 0)
3785 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003786 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencer38c91a92007-02-28 02:24:54 +00003787 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3788 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003789 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003790 ;}
3791 break;
3792
Reid Spencer67d8ed92007-03-22 02:14:08 +00003793 case 145:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003794#line 1515 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003795 {
Reid Spencer14310612006-12-31 05:40:51 +00003796 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003797 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3798 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003799 if (ATy == 0)
3800 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003801 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer61c83e02006-08-18 08:43:06 +00003802
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003803 int NumElements = ATy->getNumElements();
3804 const Type *ETy = ATy->getElementType();
Reid Spencer38c91a92007-02-28 02:24:54 +00003805 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3806 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003807 GEN_ERROR("Can't build string constant of size " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003808 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003809 " when array has size " + itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003810 std::vector<Constant*> Vals;
3811 if (ETy == Type::Int8Ty) {
Reid Spencer38c91a92007-02-28 02:24:54 +00003812 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003813 C != (unsigned char*)EndStr; ++C)
3814 Vals.push_back(ConstantInt::get(ETy, *C));
3815 } else {
Reid Spencer38c91a92007-02-28 02:24:54 +00003816 free((yyvsp[0].StrVal));
Reid Spencerb5334b02007-02-05 10:18:06 +00003817 GEN_ERROR("Cannot build string arrays of non byte sized elements");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003818 }
Reid Spencer38c91a92007-02-28 02:24:54 +00003819 free((yyvsp[0].StrVal));
3820 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3821 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003822 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003823 ;}
3824 break;
3825
Reid Spencer67d8ed92007-03-22 02:14:08 +00003826 case 146:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003827#line 1544 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003828 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003829 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003830 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3831 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003832 if (PTy == 0)
3833 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003834 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003835 const Type *ETy = PTy->getElementType();
3836 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003837
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003838 // Verify that we have the correct size...
Reid Spencer38c91a92007-02-28 02:24:54 +00003839 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003840 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003841 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003842 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003843
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003844 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00003845 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3846 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003847 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3848 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer38c91a92007-02-28 02:24:54 +00003849 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003850 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003851
Reid Spencer38c91a92007-02-28 02:24:54 +00003852 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[-1].ConstVector));
3853 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003854 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003855 ;}
3856 break;
3857
Reid Spencer67d8ed92007-03-22 02:14:08 +00003858 case 147:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003859#line 1572 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003860 {
3861 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003862 if (STy == 0)
3863 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003864 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003865
Reid Spencer38c91a92007-02-28 02:24:54 +00003866 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003867 GEN_ERROR("Illegal number of initializers for structure type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003868
3869 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer38c91a92007-02-28 02:24:54 +00003870 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3871 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003872 GEN_ERROR("Expected type '" +
3873 STy->getElementType(i)->getDescription() +
3874 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003875 " of structure initializer");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003876
3877 // Check to ensure that Type is not packed
3878 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003879 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003880
Reid Spencer38c91a92007-02-28 02:24:54 +00003881 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3882 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003883 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003884 ;}
3885 break;
3886
Reid Spencer67d8ed92007-03-22 02:14:08 +00003887 case 148:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003888#line 1597 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003889 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003890 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003891 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3892 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003893 if (STy == 0)
3894 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003895 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003896
3897 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003898 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003899
3900 // Check to ensure that Type is not packed
3901 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003902 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003903
Reid Spencer38c91a92007-02-28 02:24:54 +00003904 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3905 delete (yyvsp[-2].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003906 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003907 ;}
3908 break;
3909
Reid Spencer67d8ed92007-03-22 02:14:08 +00003910 case 149:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003911#line 1616 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003912 {
3913 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003914 if (STy == 0)
3915 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003916 (*(yyvsp[-5].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003917
Reid Spencer38c91a92007-02-28 02:24:54 +00003918 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003919 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003920
3921 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer38c91a92007-02-28 02:24:54 +00003922 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i)
3923 if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003924 GEN_ERROR("Expected type '" +
3925 STy->getElementType(i)->getDescription() +
3926 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003927 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003928
3929 // Check to ensure that Type is packed
3930 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003931 GEN_ERROR("Vector initializer to non-vector type '" +
3932 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003933
Reid Spencer38c91a92007-02-28 02:24:54 +00003934 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector));
3935 delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003936 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003937 ;}
3938 break;
3939
Reid Spencer67d8ed92007-03-22 02:14:08 +00003940 case 150:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003941#line 1642 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003942 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003943 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003944 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
3945 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003946 if (STy == 0)
3947 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003948 (*(yyvsp[-4].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003949
3950 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003951 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003952
3953 // Check to ensure that Type is packed
3954 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003955 GEN_ERROR("Vector initializer to non-vector type '" +
3956 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003957
Reid Spencer38c91a92007-02-28 02:24:54 +00003958 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3959 delete (yyvsp[-4].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003960 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003961 ;}
3962 break;
3963
Reid Spencer67d8ed92007-03-22 02:14:08 +00003964 case 151:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003965#line 1662 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003966 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003967 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003968 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3969 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003970 if (PTy == 0)
3971 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003972 (*(yyvsp[-1].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003973
Reid Spencer38c91a92007-02-28 02:24:54 +00003974 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3975 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003976 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003977 ;}
3978 break;
3979
Reid Spencer67d8ed92007-03-22 02:14:08 +00003980 case 152:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003981#line 1674 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003982 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003983 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003984 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3985 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3986 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003987 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003988 ;}
3989 break;
3990
Reid Spencer67d8ed92007-03-22 02:14:08 +00003991 case 153:
Reid Spencer7b5d4662007-04-09 06:16:21 +00003992#line 1681 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003993 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003994 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003995 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3996 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003997 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003998 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003999
4000 // ConstExprs can exist in the body of a function, thus creating
4001 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004002 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004003 // symbol table instead of the module symbol table for the global symbol,
4004 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004005 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004006 //
4007 Function *SavedCurFn = CurFun.CurrentFunction;
4008 CurFun.CurrentFunction = 0;
4009
Reid Spencer93c40032007-03-19 18:40:50 +00004010 Value *V = getExistingVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004011 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004012
4013 CurFun.CurrentFunction = SavedCurFn;
4014
4015 // If this is an initializer for a constant pointer, which is referencing a
4016 // (currently) undefined variable, create a stub now that shall be replaced
4017 // in the future with the right type of variable.
4018 //
4019 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004020 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004021 const PointerType *PT = cast<PointerType>(Ty);
4022
4023 // First check to see if the forward references value is already created!
4024 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer38c91a92007-02-28 02:24:54 +00004025 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004026
4027 if (I != CurModule.GlobalRefs.end()) {
4028 V = I->second; // Placeholder already exists, use it...
Reid Spencer38c91a92007-02-28 02:24:54 +00004029 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004030 } else {
4031 std::string Name;
Reid Spencer38c91a92007-02-28 02:24:54 +00004032 if ((yyvsp[0].ValIDVal).Type == ValID::GlobalName)
4033 Name = (yyvsp[0].ValIDVal).Name;
4034 else if ((yyvsp[0].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004035 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004036
4037 // Create the forward referenced global.
4038 GlobalValue *GV;
4039 if (const FunctionType *FTy =
4040 dyn_cast<FunctionType>(PT->getElementType())) {
4041 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4042 CurModule.CurrentModule);
4043 } else {
4044 GV = new GlobalVariable(PT->getElementType(), false,
4045 GlobalValue::ExternalLinkage, 0,
4046 Name, CurModule.CurrentModule);
4047 }
4048
4049 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer38c91a92007-02-28 02:24:54 +00004050 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004051 V = GV;
4052 }
4053 }
4054
Reid Spencer38c91a92007-02-28 02:24:54 +00004055 (yyval.ConstVal) = cast<GlobalValue>(V);
4056 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004057 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004058 ;}
4059 break;
4060
Reid Spencer67d8ed92007-03-22 02:14:08 +00004061 case 154:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004062#line 1747 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004063 {
Reid Spencer14310612006-12-31 05:40:51 +00004064 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004065 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4066 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004067 GEN_ERROR("Mismatched types for constant expression: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00004068 (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription());
4069 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4070 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004071 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004072 ;}
4073 break;
4074
Reid Spencer67d8ed92007-03-22 02:14:08 +00004075 case 155:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004076#line 1757 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004077 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004078 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004079 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4080 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004081 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencerb5334b02007-02-05 10:18:06 +00004082 GEN_ERROR("Cannot create a null initialized value of this type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004083 (yyval.ConstVal) = Constant::getNullValue(Ty);
4084 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004085 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004086 ;}
4087 break;
4088
Reid Spencer67d8ed92007-03-22 02:14:08 +00004089 case 156:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004090#line 1767 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004091 { // integral constants
4092 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004093 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer49d273e2007-03-19 20:40:51 +00004094 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val), true);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004095 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004096 ;}
4097 break;
4098
Reid Spencer67d8ed92007-03-22 02:14:08 +00004099 case 157:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004100#line 1773 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004101 { // arbitrary precision integer constants
4102 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4103 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
4104 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004105 }
4106 (yyvsp[0].APIntVal)->sextOrTrunc(BitWidth);
4107 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004108 delete (yyvsp[0].APIntVal);
4109 CHECK_FOR_ERROR
4110 ;}
4111 break;
4112
Reid Spencer67d8ed92007-03-22 02:14:08 +00004113 case 158:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004114#line 1783 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004115 { // integral constants
4116 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004117 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer49d273e2007-03-19 20:40:51 +00004118 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004119 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004120 ;}
4121 break;
4122
Reid Spencer67d8ed92007-03-22 02:14:08 +00004123 case 159:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004124#line 1789 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004125 { // arbitrary precision integer constants
4126 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4127 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
4128 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004129 }
4130 (yyvsp[0].APIntVal)->zextOrTrunc(BitWidth);
4131 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004132 delete (yyvsp[0].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004133 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004134 ;}
4135 break;
4136
Reid Spencer67d8ed92007-03-22 02:14:08 +00004137 case 160:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004138#line 1799 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004139 { // Boolean constants
4140 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4141 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004142 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004143 ;}
4144 break;
4145
Reid Spencer67d8ed92007-03-22 02:14:08 +00004146 case 161:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004147#line 1804 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004148 { // Boolean constants
4149 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4150 (yyval.ConstVal) = ConstantInt::getFalse();
4151 CHECK_FOR_ERROR
4152 ;}
4153 break;
4154
Reid Spencer67d8ed92007-03-22 02:14:08 +00004155 case 162:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004156#line 1809 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004157 { // Float & Double constants
4158 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004159 GEN_ERROR("Floating point constant invalid for type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004160 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004161 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004162 ;}
4163 break;
4164
Reid Spencer67d8ed92007-03-22 02:14:08 +00004165 case 163:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004166#line 1817 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004167 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004168 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004169 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4170 Constant *Val = (yyvsp[-3].ConstVal);
4171 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4172 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004173 GEN_ERROR("invalid cast opcode for cast from '" +
4174 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004175 DestTy->getDescription() + "'");
Reid Spencer38c91a92007-02-28 02:24:54 +00004176 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
4177 delete (yyvsp[-1].TypeVal);
4178 ;}
4179 break;
4180
Reid Spencer67d8ed92007-03-22 02:14:08 +00004181 case 164:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004182#line 1829 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004183 {
4184 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004185 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004186
4187 const Type *IdxTy =
Reid Spencer38c91a92007-02-28 02:24:54 +00004188 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), &(*(yyvsp[-1].ValueList))[0], (yyvsp[-1].ValueList)->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004189 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004190 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004191 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004192
Chris Lattnerf7469af2007-01-31 04:44:08 +00004193 SmallVector<Constant*, 8> IdxVec;
Reid Spencer38c91a92007-02-28 02:24:54 +00004194 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
4195 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004196 IdxVec.push_back(C);
4197 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004198 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004199
Reid Spencer38c91a92007-02-28 02:24:54 +00004200 delete (yyvsp[-1].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004201
Reid Spencer38c91a92007-02-28 02:24:54 +00004202 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004203 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004204 ;}
4205 break;
4206
Reid Spencer67d8ed92007-03-22 02:14:08 +00004207 case 165:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004208#line 1851 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004209 {
4210 if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00004211 GEN_ERROR("Select condition must be of boolean type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004212 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004213 GEN_ERROR("Select operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004214 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004215 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004216 ;}
4217 break;
4218
Reid Spencer67d8ed92007-03-22 02:14:08 +00004219 case 166:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004220#line 1859 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004221 {
4222 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004223 GEN_ERROR("Binary operator types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004224 CHECK_FOR_ERROR;
Reid Spencer38c91a92007-02-28 02:24:54 +00004225 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4226 ;}
4227 break;
4228
Reid Spencer67d8ed92007-03-22 02:14:08 +00004229 case 167:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004230#line 1865 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004231 {
4232 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004233 GEN_ERROR("Logical operator types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004234 if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) {
4235 if (Instruction::isShift((yyvsp[-5].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].ConstVal)->getType()) ||
4236 !cast<VectorType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00004237 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004238 }
Reid Spencer38c91a92007-02-28 02:24:54 +00004239 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004240 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004241 ;}
4242 break;
4243
Reid Spencer67d8ed92007-03-22 02:14:08 +00004244 case 168:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004245#line 1876 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004246 {
4247 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004248 GEN_ERROR("icmp operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004249 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4250 ;}
4251 break;
4252
Reid Spencer67d8ed92007-03-22 02:14:08 +00004253 case 169:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004254#line 1881 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004255 {
4256 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004257 GEN_ERROR("fcmp operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004258 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4259 ;}
4260 break;
4261
Reid Spencer67d8ed92007-03-22 02:14:08 +00004262 case 170:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004263#line 1886 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004264 {
4265 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004266 GEN_ERROR("Invalid extractelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004267 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004268 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004269 ;}
4270 break;
4271
Reid Spencer67d8ed92007-03-22 02:14:08 +00004272 case 171:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004273#line 1892 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004274 {
4275 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004276 GEN_ERROR("Invalid insertelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004277 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004278 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004279 ;}
4280 break;
4281
Reid Spencer67d8ed92007-03-22 02:14:08 +00004282 case 172:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004283#line 1898 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004284 {
4285 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004286 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004287 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004288 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004289 ;}
4290 break;
4291
Reid Spencer67d8ed92007-03-22 02:14:08 +00004292 case 173:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004293#line 1907 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004294 {
4295 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004296 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004297 ;}
4298 break;
4299
Reid Spencer67d8ed92007-03-22 02:14:08 +00004300 case 174:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004301#line 1911 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004302 {
4303 (yyval.ConstVector) = new std::vector<Constant*>();
4304 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004305 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004306 ;}
4307 break;
4308
Reid Spencer67d8ed92007-03-22 02:14:08 +00004309 case 175:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004310#line 1919 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004311 { (yyval.BoolVal) = false; ;}
4312 break;
4313
Reid Spencer67d8ed92007-03-22 02:14:08 +00004314 case 176:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004315#line 1919 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004316 { (yyval.BoolVal) = true; ;}
4317 break;
4318
Reid Spencer38c91a92007-02-28 02:24:54 +00004319 case 177:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004320#line 1930 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004321 {
4322 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004323 CurModule.ModuleDone();
4324 CHECK_FOR_ERROR;
Reid Spencer38c91a92007-02-28 02:24:54 +00004325 ;}
4326 break;
4327
Reid Spencer67d8ed92007-03-22 02:14:08 +00004328 case 178:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004329#line 1935 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00004330 {
4331 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4332 CurModule.ModuleDone();
4333 CHECK_FOR_ERROR;
4334 ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00004335 break;
4336
4337 case 181:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004338#line 1948 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00004339 { CurFun.isDeclare = false; ;}
4340 break;
4341
4342 case 182:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004343#line 1948 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004344 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004345 CurFun.FunctionDone();
4346 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004347 ;}
4348 break;
4349
Reid Spencer67d8ed92007-03-22 02:14:08 +00004350 case 183:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004351#line 1952 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004352 { CurFun.isDeclare = true; ;}
4353 break;
4354
Reid Spencer38c91a92007-02-28 02:24:54 +00004355 case 184:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004356#line 1952 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004357 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004358 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004359 ;}
4360 break;
4361
4362 case 185:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004363#line 1955 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00004364 {
4365 CHECK_FOR_ERROR
4366 ;}
4367 break;
4368
4369 case 186:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004370#line 1958 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004371 {
Reid Spencer14310612006-12-31 05:40:51 +00004372 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004373 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004374 // Eagerly resolve types. This is not an optimization, this is a
4375 // requirement that is due to the fact that we could have this:
4376 //
4377 // %list = type { %list * }
4378 // %list = type { %list * } ; repeated type decl
4379 //
4380 // If types are not resolved eagerly, then the two types will not be
4381 // determined to be the same type!
4382 //
Reid Spencer38c91a92007-02-28 02:24:54 +00004383 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004384
Reid Spencer38c91a92007-02-28 02:24:54 +00004385 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004386 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004387 // If this is a named type that is not a redefinition, add it to the slot
4388 // table.
Reid Spencer38c91a92007-02-28 02:24:54 +00004389 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004390 }
Reid Spencera132e042006-12-03 05:46:11 +00004391
Reid Spencer38c91a92007-02-28 02:24:54 +00004392 delete (yyvsp[0].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004393 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004394 ;}
4395 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004396
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004397 case 187:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004398#line 1982 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004399 {
4400 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType));
4401
4402 if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004403 CHECK_FOR_ERROR
4404 // If this is a named type that is not a redefinition, add it to the slot
4405 // table.
Reid Spencer38c91a92007-02-28 02:24:54 +00004406 CurModule.Types.push_back((yyvsp[0].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004407 }
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004408 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004409 ;}
4410 break;
4411
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004412 case 188:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004413#line 1993 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004414 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004415 /* "Externally Visible" Linkage */
Reid Spencer38c91a92007-02-28 02:24:54 +00004416 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004417 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer38c91a92007-02-28 02:24:54 +00004418 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage,
4419 (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004420 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004421 ;}
4422 break;
4423
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004424 case 189:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004425#line 2000 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004426 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004427 CurGV = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00004428 ;}
4429 break;
4430
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004431 case 190:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004432#line 2003 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004433 {
4434 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004435 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer38c91a92007-02-28 02:24:54 +00004436 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 +00004437 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004438 ;}
4439 break;
4440
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004441 case 191:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004442#line 2008 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004443 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004444 CurGV = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00004445 ;}
4446 break;
4447
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004448 case 192:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004449#line 2011 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004450 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004451 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004452 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
4453 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 +00004454 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004455 delete (yyvsp[0].TypeVal);
4456 ;}
4457 break;
4458
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004459 case 193:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004460#line 2017 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004461 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004462 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004463 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004464 ;}
4465 break;
4466
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004467 case 194:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004468#line 2021 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004469 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004470 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004471 ;}
4472 break;
4473
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004474 case 195:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004475#line 2024 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004476 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004477 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004478 ;}
4479 break;
4480
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004481 case 196:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004482#line 2030 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004483 {
Chris Lattner66316012006-01-24 04:14:29 +00004484 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer38c91a92007-02-28 02:24:54 +00004485 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4486 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4487 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004488
4489 if (AsmSoFar.empty())
4490 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4491 else
4492 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004493 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004494;}
4495 break;
4496
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004497 case 197:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004498#line 2043 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004499 {
4500 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4501 free((yyvsp[0].StrVal));
4502 ;}
4503 break;
4504
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004505 case 198:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004506#line 2047 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004507 {
4508 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4509 free((yyvsp[0].StrVal));
4510 ;}
4511 break;
4512
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004513 case 200:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004514#line 2054 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004515 {
4516 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4517 free((yyvsp[0].StrVal));
4518 CHECK_FOR_ERROR
4519 ;}
4520 break;
4521
Reid Spencer38c91a92007-02-28 02:24:54 +00004522 case 201:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004523#line 2059 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004524 {
4525 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4526 free((yyvsp[0].StrVal));
Reid Spencera54b7cb2007-01-12 07:05:14 +00004527 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004528 ;}
4529 break;
4530
4531 case 202:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004532#line 2064 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004533 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004534 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004535 ;}
4536 break;
4537
4538 case 203:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004539#line 2073 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004540 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004541 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004542 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4543 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004544 GEN_ERROR("void typed arguments are invalid");
Reid Spencer38c91a92007-02-28 02:24:54 +00004545 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4546 (yyval.ArgList) = (yyvsp[-4].ArgList);
4547 (yyvsp[-4].ArgList)->push_back(E);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004548 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004549 ;}
4550 break;
4551
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004552 case 204:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004553#line 2083 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004554 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004555 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004556 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4557 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004558 GEN_ERROR("void typed arguments are invalid");
Reid Spencer38c91a92007-02-28 02:24:54 +00004559 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4560 (yyval.ArgList) = new ArgListType;
4561 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004562 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004563 ;}
4564 break;
4565
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004566 case 205:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004567#line 2094 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004568 {
4569 (yyval.ArgList) = (yyvsp[0].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004570 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004571 ;}
4572 break;
4573
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004574 case 206:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004575#line 2098 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004576 {
4577 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004578 struct ArgListEntry E;
4579 E.Ty = new PATypeHolder(Type::VoidTy);
4580 E.Name = 0;
Reid Spencer7b5d4662007-04-09 06:16:21 +00004581 E.Attrs = NoAttributeSet;
Reid Spencer38c91a92007-02-28 02:24:54 +00004582 (yyval.ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004583 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004584 ;}
4585 break;
4586
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004587 case 207:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004588#line 2107 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004589 {
4590 (yyval.ArgList) = new ArgListType;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004591 struct ArgListEntry E;
4592 E.Ty = new PATypeHolder(Type::VoidTy);
4593 E.Name = 0;
Reid Spencer7b5d4662007-04-09 06:16:21 +00004594 E.Attrs = NoAttributeSet;
Reid Spencer38c91a92007-02-28 02:24:54 +00004595 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004596 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004597 ;}
4598 break;
4599
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004600 case 208:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004601#line 2116 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004602 {
4603 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004604 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004605 ;}
4606 break;
4607
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004608 case 209:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004609#line 2122 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004610 {
4611 UnEscapeLexed((yyvsp[-6].StrVal));
4612 std::string FunctionName((yyvsp[-6].StrVal));
4613 free((yyvsp[-6].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004614
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004615 // Check the function result for abstractness if this is a define. We should
4616 // have no abstract types at this point
Reid Spencer38c91a92007-02-28 02:24:54 +00004617 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal)))
4618 GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004619
Reid Spencer68a24bd2005-08-27 18:50:39 +00004620 std::vector<const Type*> ParamTypeList;
Reid Spencer7b5d4662007-04-09 06:16:21 +00004621 ParamAttrsList ParamAttrs;
4622 if ((yyvsp[-2].ParamAttrs) != NoAttributeSet)
4623 ParamAttrs.addAttributes(0, (yyvsp[-2].ParamAttrs));
Reid Spencer38c91a92007-02-28 02:24:54 +00004624 if ((yyvsp[-4].ArgList)) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004625 unsigned index = 1;
4626 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004627 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004628 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4629 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004630 ParamTypeList.push_back(Ty);
4631 if (Ty != Type::VoidTy)
Reid Spencer7b5d4662007-04-09 06:16:21 +00004632 if (I->Attrs != NoAttributeSet)
4633 ParamAttrs.addAttributes(index, I->Attrs);
Reid Spencer14310612006-12-31 05:40:51 +00004634 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004635 }
4636
4637 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4638 if (isVarArg) ParamTypeList.pop_back();
4639
Reid Spencer7b5d4662007-04-09 06:16:21 +00004640 ParamAttrsList *ActualAttrs = 0;
4641 if (!ParamAttrs.empty())
4642 ActualAttrs = new ParamAttrsList(ParamAttrs);
4643
4644 FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg,
4645 ActualAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004646 const PointerType *PFT = PointerType::get(FT);
Reid Spencer38c91a92007-02-28 02:24:54 +00004647 delete (yyvsp[-7].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004648
4649 ValID ID;
4650 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004651 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004652 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004653 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004654 }
4655
4656 Function *Fn = 0;
4657 // See if this function was forward referenced. If so, recycle the object.
4658 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4659 // Move the function to the end of the list, from whereever it was
4660 // previously inserted.
4661 Fn = cast<Function>(FWRef);
4662 CurModule.CurrentModule->getFunctionList().remove(Fn);
4663 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4664 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004665 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
4666 if (Fn->getFunctionType() != FT ) {
4667 // The existing function doesn't have the same type. This is an overload
4668 // error.
4669 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4670 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
4671 // Neither the existing or the current function is a declaration and they
4672 // have the same name and same type. Clearly this is a redefinition.
Reid Spencerb5334b02007-02-05 10:18:06 +00004673 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004674 } if (Fn->isDeclaration()) {
4675 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004676 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4677 AI != AE; ++AI)
4678 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004679 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004680 } else { // Not already defined?
4681 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4682 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004683
Reid Spencer68a24bd2005-08-27 18:50:39 +00004684 InsertValue(Fn, CurModule.Values);
4685 }
4686
4687 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004688
4689 if (CurFun.isDeclare) {
4690 // If we have declaration, always overwrite linkage. This will allow us to
4691 // correctly handle cases, when pointer to function is passed as argument to
4692 // another function.
4693 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004694 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004695 }
Reid Spencer38c91a92007-02-28 02:24:54 +00004696 Fn->setCallingConv((yyvsp[-8].UIntVal));
4697 Fn->setAlignment((yyvsp[0].UIntVal));
4698 if ((yyvsp[-1].StrVal)) {
4699 Fn->setSection((yyvsp[-1].StrVal));
4700 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004701 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004702
4703 // Add all of the arguments we parsed to the function...
Reid Spencer38c91a92007-02-28 02:24:54 +00004704 if ((yyvsp[-4].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004705 if (isVarArg) { // Nuke the last entry
Reid Spencer38c91a92007-02-28 02:24:54 +00004706 assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004707 "Not a varargs marker!");
Reid Spencer38c91a92007-02-28 02:24:54 +00004708 delete (yyvsp[-4].ArgList)->back().Ty;
4709 (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004710 }
4711 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004712 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004713 unsigned Idx = 1;
Reid Spencer38c91a92007-02-28 02:24:54 +00004714 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin();
4715 I != (yyvsp[-4].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004716 delete I->Ty; // Delete the typeholder...
Reid Spenceref9b9a72007-02-05 20:47:22 +00004717 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004718 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004719 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004720 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004721 }
Reid Spencera132e042006-12-03 05:46:11 +00004722
Reid Spencer38c91a92007-02-28 02:24:54 +00004723 delete (yyvsp[-4].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004724 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004725 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004726;}
4727 break;
4728
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004729 case 212:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004730#line 2242 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004731 {
4732 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004733
4734 // Make sure that we keep track of the linkage type even if there was a
4735 // previous "declare".
Reid Spencer38c91a92007-02-28 02:24:54 +00004736 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
4737 (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility));
4738;}
4739 break;
4740
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004741 case 215:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004742#line 2253 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004743 {
4744 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004745 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004746;}
4747 break;
4748
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004749 case 216:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004750#line 2258 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004751 {
4752 CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage));
4753 CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility));
4754 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004755 CurFun.FunctionDone();
4756 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004757 ;}
4758 break;
4759
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004760 case 217:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004761#line 2270 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004762 {
4763 (yyval.BoolVal) = false;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004764 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004765 ;}
4766 break;
4767
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004768 case 218:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004769#line 2274 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004770 {
4771 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004772 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004773 ;}
4774 break;
4775
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004776 case 219:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004777#line 2279 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004778 { // A reference to a direct constant
4779 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004780 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004781 ;}
4782 break;
4783
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004784 case 220:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004785#line 2283 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004786 {
4787 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Reid Spencer6f407902007-01-13 05:00:46 +00004788 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004789 ;}
4790 break;
4791
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004792 case 221:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004793#line 2287 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004794 { // Perhaps it's an FP constant?
4795 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004796 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004797 ;}
4798 break;
4799
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004800 case 222:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004801#line 2291 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004802 {
4803 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004804 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004805 ;}
4806 break;
4807
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004808 case 223:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004809#line 2295 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004810 {
4811 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004812 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004813 ;}
4814 break;
4815
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004816 case 224:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004817#line 2299 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004818 {
4819 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004820 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004821 ;}
4822 break;
4823
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004824 case 225:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004825#line 2303 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004826 {
4827 (yyval.ValIDVal) = ValID::createUndef();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004828 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004829 ;}
4830 break;
4831
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004832 case 226:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004833#line 2307 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004834 { // A vector zero constant.
4835 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00004836 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004837 ;}
4838 break;
4839
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004840 case 227:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004841#line 2311 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004842 { // Nonempty unsized packed vector
4843 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4844 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004845
Reid Spencer9d6565a2007-02-15 02:26:10 +00004846 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004847 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004848 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004849 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004850 ETy,
4851 NumElements)
4852 )
4853 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004854
4855 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00004856 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4857 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004858 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004859 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00004860 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004861 }
4862
Reid Spencer38c91a92007-02-28 02:24:54 +00004863 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[-1].ConstVector)));
4864 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004865 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004866 ;}
4867 break;
4868
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004869 case 228:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004870#line 2336 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004871 {
4872 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004873 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004874 ;}
4875 break;
4876
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004877 case 229:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004878#line 2340 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004879 {
4880 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4881 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4882 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4883 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4884 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4885 free((yyvsp[-2].StrVal));
4886 free((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004887 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004888 ;}
4889 break;
4890
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004891 case 230:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004892#line 2354 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004893 { // Is it an integer reference...?
4894 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004895 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004896 ;}
4897 break;
4898
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004899 case 231:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004900#line 2358 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004901 {
4902 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004903 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004904 ;}
4905 break;
4906
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004907 case 232:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004908#line 2362 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004909 { // Is it a named reference...?
4910 (yyval.ValIDVal) = ValID::createLocalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004911 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004912 ;}
4913 break;
4914
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004915 case 233:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004916#line 2366 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004917 { // Is it a named reference...?
4918 (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004919 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004920 ;}
4921 break;
4922
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004923 case 236:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004924#line 2378 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004925 {
Reid Spencer832254e2007-02-02 02:16:23 +00004926 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004927 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4928 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
4929 delete (yyvsp[-1].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004930 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004931 ;}
4932 break;
4933
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004934 case 237:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004935#line 2387 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004936 {
4937 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
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 238:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004943#line 2391 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004944 { // Do not allow functions with 0 basic blocks
4945 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004946 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004947 ;}
4948 break;
4949
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004950 case 239:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004951#line 2400 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004952 {
4953 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004954 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004955 InsertValue((yyvsp[0].TermInstVal));
4956 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004957 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004958 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004959 ;}
4960 break;
4961
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004962 case 240:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004963#line 2409 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004964 {
4965 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004966 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4967 if (CI2->getParent() == 0)
Reid Spencer38c91a92007-02-28 02:24:54 +00004968 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
4969 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4970 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004971 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004972 ;}
4973 break;
4974
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004975 case 241:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004976#line 2418 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004977 { // Empty space between instruction lists
4978 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004979 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004980 ;}
4981 break;
4982
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004983 case 242:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004984#line 2422 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004985 { // Labelled (named) basic block
4986 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName((yyvsp[0].StrVal)));
Reid Spencer3822ff52006-11-08 06:47:33 +00004987 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004988 ;}
4989 break;
Reid Spencer3822ff52006-11-08 06:47:33 +00004990
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004991 case 243:
Reid Spencer7b5d4662007-04-09 06:16:21 +00004992#line 2427 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004993 { // Return with a result...
4994 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
4995 CHECK_FOR_ERROR
4996 ;}
4997 break;
4998
Reid Spencer3d6b71e2007-04-09 01:56:05 +00004999 case 244:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005000#line 2431 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00005001 { // Return with no result...
Reid Spencer38c91a92007-02-28 02:24:54 +00005002 (yyval.TermInstVal) = new ReturnInst();
5003 CHECK_FOR_ERROR
5004 ;}
5005 break;
5006
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005007 case 245:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005008#line 2435 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00005009 { // Unconditional Branch...
Reid Spencer38c91a92007-02-28 02:24:54 +00005010 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5011 CHECK_FOR_ERROR
5012 (yyval.TermInstVal) = new BranchInst(tmpBB);
5013 ;}
5014 break;
5015
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005016 case 246:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005017#line 2440 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005018 {
5019 assert(cast<IntegerType>((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?");
5020 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5021 CHECK_FOR_ERROR
5022 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5023 CHECK_FOR_ERROR
5024 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
5025 CHECK_FOR_ERROR
5026 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5027 ;}
5028 break;
5029
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005030 case 247:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005031#line 2450 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005032 {
5033 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
5034 CHECK_FOR_ERROR
5035 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5036 CHECK_FOR_ERROR
5037 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
5038 (yyval.TermInstVal) = S;
5039
5040 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5041 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005042 for (; I != E; ++I) {
5043 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5044 S->addCase(CI, I->second);
5045 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005046 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005047 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005048 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005049 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005050 ;}
5051 break;
5052
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005053 case 248:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005054#line 2469 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005055 {
5056 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005057 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005058 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005059 CHECK_FOR_ERROR
5060 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencer38c91a92007-02-28 02:24:54 +00005061 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00005062 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005063 ;}
5064 break;
5065
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005066 case 249:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005067#line 2479 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005068 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005069
Reid Spencer14310612006-12-31 05:40:51 +00005070 // Handle the short syntax
5071 const PointerType *PFTy = 0;
5072 const FunctionType *Ty = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00005073 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005074 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5075 // Pull out the types of all of the arguments...
5076 std::vector<const Type*> ParamTypes;
Reid Spencer7b5d4662007-04-09 06:16:21 +00005077 ParamAttrsList ParamAttrs;
5078 if ((yyvsp[-6].ParamAttrs) != NoAttributeSet)
5079 ParamAttrs.addAttributes(0, (yyvsp[-6].ParamAttrs));
5080 ValueRefList::iterator I = (yyvsp[-8].ValueRefList)->begin(), E = (yyvsp[-8].ValueRefList)->end();
5081 unsigned index = 1;
5082 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005083 const Type *Ty = I->Val->getType();
5084 if (Ty == Type::VoidTy)
5085 GEN_ERROR("Short call syntax cannot be used with varargs");
5086 ParamTypes.push_back(Ty);
Reid Spencer7b5d4662007-04-09 06:16:21 +00005087 if (I->Attrs != NoAttributeSet)
5088 ParamAttrs.addAttributes(index, I->Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005089 }
5090
Reid Spencer7b5d4662007-04-09 06:16:21 +00005091 ParamAttrsList *Attrs = 0;
5092 if (!ParamAttrs.empty())
5093 Attrs = new ParamAttrsList(ParamAttrs);
5094 Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005095 PFTy = PointerType::get(Ty);
5096 }
5097
Reid Spencer66728ef2007-03-20 01:13:36 +00005098 delete (yyvsp[-11].TypeVal);
5099
Reid Spencer38c91a92007-02-28 02:24:54 +00005100 Value *V = getVal(PFTy, (yyvsp[-10].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005101 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005102 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005103 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005104 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005105 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005106
Reid Spencer14310612006-12-31 05:40:51 +00005107 // Check the arguments
5108 ValueList Args;
Reid Spencer38c91a92007-02-28 02:24:54 +00005109 if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005110 // Make sure no arguments is a good thing!
5111 if (Ty->getNumParams() != 0)
5112 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005113 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005114 } else { // Has arguments?
5115 // Loop through FunctionType's arguments and ensure they are specified
5116 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005117 FunctionType::param_iterator I = Ty->param_begin();
5118 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer38c91a92007-02-28 02:24:54 +00005119 ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005120
Reid Spencer14310612006-12-31 05:40:51 +00005121 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5122 if (ArgI->Val->getType() != *I)
5123 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005124 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005125 Args.push_back(ArgI->Val);
5126 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005127
Reid Spencer14310612006-12-31 05:40:51 +00005128 if (Ty->isVarArg()) {
5129 if (I == E)
5130 for (; ArgI != ArgE; ++ArgI)
5131 Args.push_back(ArgI->Val); // push the remaining varargs
5132 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005133 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005134 }
Reid Spencer14310612006-12-31 05:40:51 +00005135
5136 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005137 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencer38c91a92007-02-28 02:24:54 +00005138 II->setCallingConv((yyvsp[-12].UIntVal));
5139 (yyval.TermInstVal) = II;
5140 delete (yyvsp[-8].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005141 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005142 ;}
5143 break;
5144
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005145 case 250:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005146#line 2554 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005147 {
5148 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005149 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005150 ;}
5151 break;
5152
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005153 case 251:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005154#line 2558 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005155 {
5156 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005157 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005158 ;}
5159 break;
5160
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005161 case 252:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005162#line 2565 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005163 {
5164 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
Reid Spencer93c40032007-03-19 18:40:50 +00005165 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005166 CHECK_FOR_ERROR
5167 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005168 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005169
Reid Spencer38c91a92007-02-28 02:24:54 +00005170 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005171 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005172 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5173 ;}
5174 break;
5175
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005176 case 253:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005177#line 2576 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005178 {
5179 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencer93c40032007-03-19 18:40:50 +00005180 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005181 CHECK_FOR_ERROR
5182
5183 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005184 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005185
Reid Spencer38c91a92007-02-28 02:24:54 +00005186 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005187 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005188 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5189 ;}
5190 break;
5191
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005192 case 254:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005193#line 2589 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005194 {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005195 // Is this definition named?? if so, assign the name...
Reid Spencer38c91a92007-02-28 02:24:54 +00005196 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Reid Spenceref9b9a72007-02-05 20:47:22 +00005197 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005198 InsertValue((yyvsp[0].InstVal));
5199 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005200 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005201 ;}
5202 break;
5203
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005204 case 255:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005205#line 2599 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005206 { // Used for PHI nodes
Reid Spencer14310612006-12-31 05:40:51 +00005207 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005208 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription());
5209 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5210 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005211 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005212 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005213 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005214 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5215 delete (yyvsp[-5].TypeVal);
5216 ;}
5217 break;
5218
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005219 case 256:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005220#line 2610 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005221 {
5222 (yyval.PHIList) = (yyvsp[-6].PHIList);
5223 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005224 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005225 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005226 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005227 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5228 ;}
5229 break;
5230
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005231 case 257:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005232#line 2620 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005233 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005234 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005235 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005236 // Used for call and invoke instructions
Reid Spencer38c91a92007-02-28 02:24:54 +00005237 (yyval.ValueRefList) = new ValueRefList();
5238 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5239 (yyval.ValueRefList)->push_back(E);
Reid Spencer66728ef2007-03-20 01:13:36 +00005240 delete (yyvsp[-2].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005241 ;}
5242 break;
5243
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005244 case 258:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005245#line 2629 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005246 {
Reid Spencer14310612006-12-31 05:40:51 +00005247 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005248 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5249 (yyval.ValueRefList) = (yyvsp[-4].ValueRefList);
5250 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5251 (yyval.ValueRefList)->push_back(E);
Reid Spencer66728ef2007-03-20 01:13:36 +00005252 delete (yyvsp[-2].TypeVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005253 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005254 ;}
5255 break;
5256
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005257 case 259:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005258#line 2638 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00005259 { (yyval.ValueRefList) = new ValueRefList(); ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00005260 break;
5261
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005262 case 260:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005263#line 2641 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00005264 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5265 break;
5266
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005267 case 261:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005268#line 2642 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005269 {
5270 (yyval.ValueList) = (yyvsp[-2].ValueList);
5271 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer14310612006-12-31 05:40:51 +00005272 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005273 ;}
5274 break;
5275
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005276 case 262:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005277#line 2649 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005278 {
5279 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005280 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005281 ;}
5282 break;
5283
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005284 case 263:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005285#line 2653 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005286 {
5287 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005288 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005289 ;}
5290 break;
5291
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005292 case 264:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005293#line 2658 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005294 {
Reid Spencer14310612006-12-31 05:40:51 +00005295 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005296 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5297 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
5298 !isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005299 GEN_ERROR(
Reid Spencerb5334b02007-02-05 10:18:06 +00005300 "Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005301 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()) &&
5302 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
5303 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
5304 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
Chris Lattner32980692007-02-19 07:44:24 +00005305 GEN_ERROR("Remainder not supported on vector types");
Reid Spencer38c91a92007-02-28 02:24:54 +00005306 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005307 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005308 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005309 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005310 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
5311 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005312 GEN_ERROR("binary operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005313 delete (yyvsp[-3].TypeVal);
5314 ;}
5315 break;
5316
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005317 case 265:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005318#line 2679 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005319 {
Reid Spencer14310612006-12-31 05:40:51 +00005320 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005321 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5322 if (!(*(yyvsp[-3].TypeVal))->isInteger()) {
5323 if (Instruction::isShift((yyvsp[-4].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].TypeVal)->get()) ||
5324 !cast<VectorType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00005325 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005326 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005327 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005328 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005329 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005330 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005331 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
5332 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005333 GEN_ERROR("binary operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005334 delete (yyvsp[-3].TypeVal);
5335 ;}
5336 break;
5337
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005338 case 266:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005339#line 2696 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005340 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005341 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005342 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5343 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Chris Lattner32980692007-02-19 07:44:24 +00005344 GEN_ERROR("Vector types not supported by icmp instruction");
Reid Spencer38c91a92007-02-28 02:24:54 +00005345 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005346 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005347 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005348 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005349 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5350 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005351 GEN_ERROR("icmp operator returned null");
Reid Spencer66728ef2007-03-20 01:13:36 +00005352 delete (yyvsp[-3].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005353 ;}
5354 break;
5355
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005356 case 267:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005357#line 2710 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005358 {
Reid Spencer14310612006-12-31 05:40:51 +00005359 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005360 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5361 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Chris Lattner32980692007-02-19 07:44:24 +00005362 GEN_ERROR("Vector types not supported by fcmp instruction");
Reid Spencer38c91a92007-02-28 02:24:54 +00005363 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005364 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005365 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005366 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005367 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5368 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005369 GEN_ERROR("fcmp operator returned null");
Reid Spencer66728ef2007-03-20 01:13:36 +00005370 delete (yyvsp[-3].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005371 ;}
5372 break;
5373
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005374 case 268:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005375#line 2724 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005376 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005377 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005378 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5379 Value* Val = (yyvsp[-2].ValueVal);
5380 const Type* DestTy = (yyvsp[0].TypeVal)->get();
5381 if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005382 GEN_ERROR("invalid cast opcode for cast from '" +
5383 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005384 DestTy->getDescription() + "'");
Reid Spencer38c91a92007-02-28 02:24:54 +00005385 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy);
5386 delete (yyvsp[0].TypeVal);
5387 ;}
5388 break;
5389
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005390 case 269:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005391#line 2736 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005392 {
5393 if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00005394 GEN_ERROR("select condition must be boolean");
Reid Spencer38c91a92007-02-28 02:24:54 +00005395 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00005396 GEN_ERROR("select value types should match");
Reid Spencer38c91a92007-02-28 02:24:54 +00005397 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005398 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005399 ;}
5400 break;
5401
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005402 case 270:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005403#line 2744 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005404 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005405 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005406 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5407 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5408 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005409 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005410 ;}
5411 break;
5412
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005413 case 271:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005414#line 2751 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005415 {
5416 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005417 GEN_ERROR("Invalid extractelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005418 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005419 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005420 ;}
5421 break;
5422
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005423 case 272:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005424#line 2757 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005425 {
5426 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005427 GEN_ERROR("Invalid insertelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005428 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005429 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005430 ;}
5431 break;
5432
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005433 case 273:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005434#line 2763 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005435 {
5436 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005437 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005438 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005439 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005440 ;}
5441 break;
5442
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005443 case 274:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005444#line 2769 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005445 {
5446 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005447 if (!Ty->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00005448 GEN_ERROR("PHI node operands must be of first class type");
Reid Spencer38c91a92007-02-28 02:24:54 +00005449 (yyval.InstVal) = new PHINode(Ty);
5450 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5451 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5452 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00005453 GEN_ERROR("All elements of a PHI node must be of the same type");
Reid Spencer38c91a92007-02-28 02:24:54 +00005454 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5455 (yyvsp[0].PHIList)->pop_front();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005456 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005457 delete (yyvsp[0].PHIList); // Free the list...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005458 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005459 ;}
5460 break;
5461
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005462 case 275:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005463#line 2785 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005464 {
Reid Spencer14310612006-12-31 05:40:51 +00005465
5466 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005467 const PointerType *PFTy = 0;
5468 const FunctionType *Ty = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00005469 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005470 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5471 // Pull out the types of all of the arguments...
5472 std::vector<const Type*> ParamTypes;
Reid Spencer7b5d4662007-04-09 06:16:21 +00005473 ParamAttrsList ParamAttrs;
5474 if ((yyvsp[0].ParamAttrs) != NoAttributeSet)
5475 ParamAttrs.addAttributes(0, (yyvsp[0].ParamAttrs));
5476 unsigned index = 1;
5477 ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end();
5478 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005479 const Type *Ty = I->Val->getType();
5480 if (Ty == Type::VoidTy)
5481 GEN_ERROR("Short call syntax cannot be used with varargs");
5482 ParamTypes.push_back(Ty);
Reid Spencer7b5d4662007-04-09 06:16:21 +00005483 if (I->Attrs != NoAttributeSet)
5484 ParamAttrs.addAttributes(index, I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005485 }
5486
Reid Spencer7b5d4662007-04-09 06:16:21 +00005487 ParamAttrsList *Attrs = 0;
5488 if (!ParamAttrs.empty())
5489 Attrs = new ParamAttrsList(ParamAttrs);
5490
5491 Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005492 PFTy = PointerType::get(Ty);
5493 }
5494
Reid Spencer38c91a92007-02-28 02:24:54 +00005495 Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005496 CHECK_FOR_ERROR
5497
Reid Spencer14310612006-12-31 05:40:51 +00005498 // Check the arguments
5499 ValueList Args;
Reid Spencer38c91a92007-02-28 02:24:54 +00005500 if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005501 // Make sure no arguments is a good thing!
5502 if (Ty->getNumParams() != 0)
5503 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005504 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005505 } else { // Has arguments?
5506 // Loop through FunctionType's arguments and ensure they are specified
5507 // correctly!
5508 //
5509 FunctionType::param_iterator I = Ty->param_begin();
5510 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer38c91a92007-02-28 02:24:54 +00005511 ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005512
Reid Spencer14310612006-12-31 05:40:51 +00005513 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5514 if (ArgI->Val->getType() != *I)
5515 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005516 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005517 Args.push_back(ArgI->Val);
5518 }
5519 if (Ty->isVarArg()) {
5520 if (I == E)
5521 for (; ArgI != ArgE; ++ArgI)
5522 Args.push_back(ArgI->Val); // push the remaining varargs
5523 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005524 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005525 }
Reid Spencer14310612006-12-31 05:40:51 +00005526 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00005527 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencer38c91a92007-02-28 02:24:54 +00005528 CI->setTailCall((yyvsp[-7].BoolVal));
5529 CI->setCallingConv((yyvsp[-6].UIntVal));
5530 (yyval.InstVal) = CI;
5531 delete (yyvsp[-2].ValueRefList);
5532 delete (yyvsp[-5].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005533 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005534 ;}
5535 break;
5536
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005537 case 276:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005538#line 2856 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005539 {
5540 (yyval.InstVal) = (yyvsp[0].InstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005541 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005542 ;}
5543 break;
5544
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005545 case 277:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005546#line 2861 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005547 {
5548 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005549 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005550 ;}
5551 break;
5552
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005553 case 278:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005554#line 2865 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005555 {
5556 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005557 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005558 ;}
5559 break;
5560
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005561 case 279:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005562#line 2872 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005563 {
Reid Spencer6f407902007-01-13 05:00:46 +00005564 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005565 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5566 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5567 delete (yyvsp[-1].TypeVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005568 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005569 ;}
5570 break;
5571
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005572 case 280:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005573#line 2879 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005574 {
Reid Spencer14310612006-12-31 05:40:51 +00005575 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005576 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5577 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005578 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005579 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5580 delete (yyvsp[-4].TypeVal);
5581 ;}
5582 break;
5583
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005584 case 281:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005585#line 2887 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005586 {
Reid Spencer14310612006-12-31 05:40:51 +00005587 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005588 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5589 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5590 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005591 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005592 ;}
5593 break;
5594
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005595 case 282:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005596#line 2894 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005597 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005598 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005599 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5600 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005601 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005602 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5603 delete (yyvsp[-4].TypeVal);
5604 ;}
5605 break;
5606
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005607 case 283:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005608#line 2902 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005609 {
5610 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005611 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005612 (yyvsp[0].ValueVal)->getType()->getDescription() + "");
5613 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005614 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005615 ;}
5616 break;
5617
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005618 case 284:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005619#line 2910 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005620 {
Reid Spencer14310612006-12-31 05:40:51 +00005621 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005622 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5623 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005624 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005625 (*(yyvsp[-1].TypeVal))->getDescription());
5626 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005627 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005628 (*(yyvsp[-1].TypeVal))->getDescription());
5629 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005630 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005631 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5632 delete (yyvsp[-1].TypeVal);
5633 ;}
5634 break;
5635
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005636 case 285:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005637#line 2924 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005638 {
Reid Spencer14310612006-12-31 05:40:51 +00005639 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005640 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5641 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005642 if (!PT)
5643 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005644 (*(yyvsp[-1].TypeVal))->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005645 const Type *ElTy = PT->getElementType();
Reid Spencer38c91a92007-02-28 02:24:54 +00005646 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5647 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencerb5334b02007-02-05 10:18:06 +00005648 "' into space of type '" + ElTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005649
Reid Spencer38c91a92007-02-28 02:24:54 +00005650 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005651 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005652 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5653 delete (yyvsp[-1].TypeVal);
5654 ;}
5655 break;
5656
Reid Spencer3d6b71e2007-04-09 01:56:05 +00005657 case 286:
Reid Spencer7b5d4662007-04-09 06:16:21 +00005658#line 2941 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005659 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005660 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005661 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5662 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005663 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005664
Reid Spencer38c91a92007-02-28 02:24:54 +00005665 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005666 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00005667 (*(yyvsp[-2].TypeVal))->getDescription()+ "'");
5668 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005669 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005670 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size());
5671 delete (yyvsp[-2].TypeVal);
5672 delete (yyvsp[0].ValueList);
5673 ;}
5674 break;
5675
5676
5677 default: break;
5678 }
5679
5680/* Line 1126 of yacc.c. */
Reid Spencer7b5d4662007-04-09 06:16:21 +00005681#line 5682 "llvmAsmParser.tab.c"
Chris Lattner9d2fda62007-02-13 05:53:56 +00005682
5683 yyvsp -= yylen;
5684 yyssp -= yylen;
Reid Spencer5cbf9852007-01-30 20:08:39 +00005685
Reid Spencer38c91a92007-02-28 02:24:54 +00005686
5687 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005688
5689 *++yyvsp = yyval;
5690
5691
Reid Spencer38c91a92007-02-28 02:24:54 +00005692 /* Now `shift' the result of the reduction. Determine what state
5693 that goes to, based on the state we popped back to and the rule
5694 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005695
5696 yyn = yyr1[yyn];
5697
Reid Spencer38c91a92007-02-28 02:24:54 +00005698 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5699 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005700 yystate = yytable[yystate];
5701 else
Reid Spencer38c91a92007-02-28 02:24:54 +00005702 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005703
5704 goto yynewstate;
5705
5706
Reid Spencer38c91a92007-02-28 02:24:54 +00005707/*------------------------------------.
5708| yyerrlab -- here on detecting error |
5709`------------------------------------*/
5710yyerrlab:
5711 /* If not already recovering from an error, report this error. */
5712 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005713 {
5714 ++yynerrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00005715#if YYERROR_VERBOSE
Chris Lattner9d2fda62007-02-13 05:53:56 +00005716 yyn = yypact[yystate];
5717
Reid Spencer38c91a92007-02-28 02:24:54 +00005718 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattner9d2fda62007-02-13 05:53:56 +00005719 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005720 int yytype = YYTRANSLATE (yychar);
5721 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5722 YYSIZE_T yysize = yysize0;
5723 YYSIZE_T yysize1;
5724 int yysize_overflow = 0;
5725 char *yymsg = 0;
5726# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5727 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5728 int yyx;
Chris Lattner9d2fda62007-02-13 05:53:56 +00005729
Reid Spencer38c91a92007-02-28 02:24:54 +00005730#if 0
5731 /* This is so xgettext sees the translatable formats that are
5732 constructed on the fly. */
5733 YY_("syntax error, unexpected %s");
5734 YY_("syntax error, unexpected %s, expecting %s");
5735 YY_("syntax error, unexpected %s, expecting %s or %s");
5736 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5737 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5738#endif
5739 char *yyfmt;
5740 char const *yyf;
5741 static char const yyunexpected[] = "syntax error, unexpected %s";
5742 static char const yyexpecting[] = ", expecting %s";
5743 static char const yyor[] = " or %s";
5744 char yyformat[sizeof yyunexpected
5745 + sizeof yyexpecting - 1
5746 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5747 * (sizeof yyor - 1))];
5748 char const *yyprefix = yyexpecting;
5749
5750 /* Start YYX at -YYN if negative to avoid negative indexes in
5751 YYCHECK. */
5752 int yyxbegin = yyn < 0 ? -yyn : 0;
5753
5754 /* Stay within bounds of both yycheck and yytname. */
5755 int yychecklim = YYLAST - yyn;
5756 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5757 int yycount = 1;
5758
5759 yyarg[0] = yytname[yytype];
5760 yyfmt = yystpcpy (yyformat, yyunexpected);
5761
5762 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5763 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5764 {
5765 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5766 {
5767 yycount = 1;
5768 yysize = yysize0;
5769 yyformat[sizeof yyunexpected - 1] = '\0';
5770 break;
5771 }
5772 yyarg[yycount++] = yytname[yyx];
5773 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5774 yysize_overflow |= yysize1 < yysize;
5775 yysize = yysize1;
5776 yyfmt = yystpcpy (yyfmt, yyprefix);
5777 yyprefix = yyor;
5778 }
5779
5780 yyf = YY_(yyformat);
5781 yysize1 = yysize + yystrlen (yyf);
5782 yysize_overflow |= yysize1 < yysize;
5783 yysize = yysize1;
5784
5785 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5786 yymsg = (char *) YYSTACK_ALLOC (yysize);
5787 if (yymsg)
Chris Lattner9d2fda62007-02-13 05:53:56 +00005788 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005789 /* Avoid sprintf, as that infringes on the user's name space.
5790 Don't have undefined behavior even if the translation
5791 produced a string with the wrong number of "%s"s. */
5792 char *yyp = yymsg;
5793 int yyi = 0;
5794 while ((*yyp = *yyf))
Chris Lattner9d2fda62007-02-13 05:53:56 +00005795 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005796 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5797 {
5798 yyp += yytnamerr (yyp, yyarg[yyi++]);
5799 yyf += 2;
5800 }
5801 else
5802 {
5803 yyp++;
5804 yyf++;
5805 }
Chris Lattner9d2fda62007-02-13 05:53:56 +00005806 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005807 yyerror (yymsg);
5808 YYSTACK_FREE (yymsg);
Chris Lattner9d2fda62007-02-13 05:53:56 +00005809 }
5810 else
Reid Spencer38c91a92007-02-28 02:24:54 +00005811 {
5812 yyerror (YY_("syntax error"));
5813 goto yyexhaustedlab;
5814 }
Chris Lattner9d2fda62007-02-13 05:53:56 +00005815 }
5816 else
5817#endif /* YYERROR_VERBOSE */
Reid Spencer38c91a92007-02-28 02:24:54 +00005818 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005819 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00005820
Reid Spencer38c91a92007-02-28 02:24:54 +00005821
Reid Spencer41dff5e2007-01-26 08:05:27 +00005822
5823 if (yyerrstatus == 3)
5824 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005825 /* If just tried and failed to reuse look-ahead token after an
5826 error, discard it. */
Reid Spencer41dff5e2007-01-26 08:05:27 +00005827
Reid Spencer38c91a92007-02-28 02:24:54 +00005828 if (yychar <= YYEOF)
5829 {
5830 /* Return failure if at end of input. */
5831 if (yychar == YYEOF)
5832 YYABORT;
5833 }
5834 else
5835 {
5836 yydestruct ("Error: discarding", yytoken, &yylval);
5837 yychar = YYEMPTY;
5838 }
5839 }
5840
5841 /* Else will try to reuse look-ahead token after shifting the error
5842 token. */
5843 goto yyerrlab1;
5844
5845
5846/*---------------------------------------------------.
5847| yyerrorlab -- error raised explicitly by YYERROR. |
5848`---------------------------------------------------*/
5849yyerrorlab:
5850
5851 /* Pacify compilers like GCC when the user code never invokes
5852 YYERROR and the label yyerrorlab therefore never appears in user
5853 code. */
5854 if (0)
5855 goto yyerrorlab;
5856
5857yyvsp -= yylen;
5858 yyssp -= yylen;
5859 yystate = *yyssp;
5860 goto yyerrlab1;
5861
5862
5863/*-------------------------------------------------------------.
5864| yyerrlab1 -- common code for both syntax error and YYERROR. |
5865`-------------------------------------------------------------*/
5866yyerrlab1:
5867 yyerrstatus = 3; /* Each real token shifted decrements this. */
5868
5869 for (;;)
5870 {
5871 yyn = yypact[yystate];
5872 if (yyn != YYPACT_NINF)
5873 {
5874 yyn += YYTERROR;
5875 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5876 {
5877 yyn = yytable[yyn];
5878 if (0 < yyn)
5879 break;
5880 }
5881 }
5882
5883 /* Pop the current state because it cannot handle the error token. */
5884 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005885 YYABORT;
5886
Reid Spencere4d87aa2006-12-23 06:05:41 +00005887
Reid Spencer38c91a92007-02-28 02:24:54 +00005888 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5889 YYPOPSTACK;
5890 yystate = *yyssp;
5891 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005892 }
5893
5894 if (yyn == YYFINAL)
5895 YYACCEPT;
5896
Reid Spencer68a24bd2005-08-27 18:50:39 +00005897 *++yyvsp = yylval;
Reid Spencer38c91a92007-02-28 02:24:54 +00005898
5899
5900 /* Shift the error token. */
5901 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer41dff5e2007-01-26 08:05:27 +00005902
Reid Spencer68a24bd2005-08-27 18:50:39 +00005903 yystate = yyn;
5904 goto yynewstate;
5905
Chris Lattner32980692007-02-19 07:44:24 +00005906
Reid Spencer38c91a92007-02-28 02:24:54 +00005907/*-------------------------------------.
5908| yyacceptlab -- YYACCEPT comes here. |
5909`-------------------------------------*/
5910yyacceptlab:
5911 yyresult = 0;
5912 goto yyreturn;
5913
5914/*-----------------------------------.
5915| yyabortlab -- YYABORT comes here. |
5916`-----------------------------------*/
5917yyabortlab:
5918 yyresult = 1;
5919 goto yyreturn;
5920
5921#ifndef yyoverflow
5922/*-------------------------------------------------.
5923| yyexhaustedlab -- memory exhaustion comes here. |
5924`-------------------------------------------------*/
5925yyexhaustedlab:
5926 yyerror (YY_("memory exhausted"));
5927 yyresult = 2;
5928 /* Fall through. */
Chris Lattner32980692007-02-19 07:44:24 +00005929#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00005930
5931yyreturn:
5932 if (yychar != YYEOF && yychar != YYEMPTY)
5933 yydestruct ("Cleanup: discarding lookahead",
5934 yytoken, &yylval);
5935 while (yyssp != yyss)
5936 {
5937 yydestruct ("Cleanup: popping",
5938 yystos[*yyssp], yyvsp);
5939 YYPOPSTACK;
Chris Lattner32980692007-02-19 07:44:24 +00005940 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005941#ifndef yyoverflow
5942 if (yyss != yyssa)
5943 YYSTACK_FREE (yyss);
5944#endif
5945 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005946}
Reid Spencer38c91a92007-02-28 02:24:54 +00005947
5948
Reid Spencer7b5d4662007-04-09 06:16:21 +00005949#line 2958 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005950
5951
Reid Spencer14310612006-12-31 05:40:51 +00005952// common code from the two 'RunVMAsmParser' functions
5953static Module* RunParser(Module * M) {
5954
5955 llvmAsmlineno = 1; // Reset the current line number...
5956 CurModule.CurrentModule = M;
5957#if YYDEBUG
5958 yydebug = Debug;
5959#endif
5960
5961 // Check to make sure the parser succeeded
5962 if (yyparse()) {
5963 if (ParserResult)
5964 delete ParserResult;
5965 return 0;
5966 }
5967
Reid Spencer0d60b5a2007-03-30 01:37:39 +00005968 // Emit an error if there are any unresolved types left.
5969 if (!CurModule.LateResolveTypes.empty()) {
5970 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5971 if (DID.Type == ValID::LocalName) {
5972 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5973 } else {
5974 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5975 }
5976 if (ParserResult)
5977 delete ParserResult;
5978 return 0;
5979 }
5980
5981 // Emit an error if there are any unresolved values left.
5982 if (!CurModule.LateResolveValues.empty()) {
5983 Value *V = CurModule.LateResolveValues.back();
5984 std::map<Value*, std::pair<ValID, int> >::iterator I =
5985 CurModule.PlaceHolderInfo.find(V);
5986
5987 if (I != CurModule.PlaceHolderInfo.end()) {
5988 ValID &DID = I->second.first;
5989 if (DID.Type == ValID::LocalName) {
5990 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5991 } else {
5992 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5993 }
5994 if (ParserResult)
5995 delete ParserResult;
5996 return 0;
5997 }
5998 }
5999
Reid Spencer14310612006-12-31 05:40:51 +00006000 // Check to make sure that parsing produced a result
6001 if (!ParserResult)
6002 return 0;
6003
6004 // Reset ParserResult variable while saving its value for the result.
6005 Module *Result = ParserResult;
6006 ParserResult = 0;
6007
6008 return Result;
6009}
6010
Reid Spencer61c83e02006-08-18 08:43:06 +00006011void llvm::GenerateError(const std::string &message, int LineNo) {
6012 if (LineNo == -1) LineNo = llvmAsmlineno;
6013 // TODO: column number in exception
6014 if (TheParseError)
6015 TheParseError->setError(CurFilename, message, LineNo);
6016 TriggerError = 1;
6017}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006018
6019int yyerror(const char *ErrorMsg) {
6020 std::string where
6021 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6022 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006023 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6024 if (yychar != YYEMPTY && yychar != 0)
6025 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6026 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00006027 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006028 return 0;
6029}
Reid Spencer38c91a92007-02-28 02:24:54 +00006030