blob: 52330541189808112e72ffc388a9294308ed1082 [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 Spencer3025dfd2007-03-29 18:50:01 +000085 IMPLEMENTATION = 276,
Reid Spencer38c91a92007-02-28 02:24:54 +000086 ZEROINITIALIZER = 277,
87 TRUETOK = 278,
88 FALSETOK = 279,
89 BEGINTOK = 280,
90 ENDTOK = 281,
91 DECLARE = 282,
92 DEFINE = 283,
93 GLOBAL = 284,
94 CONSTANT = 285,
95 SECTION = 286,
96 VOLATILE = 287,
97 TO = 288,
98 DOTDOTDOT = 289,
99 NULL_TOK = 290,
100 UNDEF = 291,
101 INTERNAL = 292,
102 LINKONCE = 293,
103 WEAK = 294,
104 APPENDING = 295,
105 DLLIMPORT = 296,
106 DLLEXPORT = 297,
107 EXTERN_WEAK = 298,
108 OPAQUE = 299,
109 EXTERNAL = 300,
110 TARGET = 301,
111 TRIPLE = 302,
112 ALIGN = 303,
113 DEPLIBS = 304,
114 CALL = 305,
115 TAIL = 306,
116 ASM_TOK = 307,
117 MODULE = 308,
118 SIDEEFFECT = 309,
119 CC_TOK = 310,
120 CCC_TOK = 311,
121 FASTCC_TOK = 312,
122 COLDCC_TOK = 313,
123 X86_STDCALLCC_TOK = 314,
124 X86_FASTCALLCC_TOK = 315,
125 DATALAYOUT = 316,
126 RET = 317,
127 BR = 318,
128 SWITCH = 319,
129 INVOKE = 320,
130 UNWIND = 321,
131 UNREACHABLE = 322,
132 ADD = 323,
133 SUB = 324,
134 MUL = 325,
135 UDIV = 326,
136 SDIV = 327,
137 FDIV = 328,
138 UREM = 329,
139 SREM = 330,
140 FREM = 331,
141 AND = 332,
142 OR = 333,
143 XOR = 334,
144 SHL = 335,
145 LSHR = 336,
146 ASHR = 337,
147 ICMP = 338,
148 FCMP = 339,
149 EQ = 340,
150 NE = 341,
151 SLT = 342,
152 SGT = 343,
153 SLE = 344,
154 SGE = 345,
155 ULT = 346,
156 UGT = 347,
157 ULE = 348,
158 UGE = 349,
159 OEQ = 350,
160 ONE = 351,
161 OLT = 352,
162 OGT = 353,
163 OLE = 354,
164 OGE = 355,
165 ORD = 356,
166 UNO = 357,
167 UEQ = 358,
168 UNE = 359,
169 MALLOC = 360,
170 ALLOCA = 361,
171 FREE = 362,
172 LOAD = 363,
173 STORE = 364,
174 GETELEMENTPTR = 365,
175 TRUNC = 366,
176 ZEXT = 367,
177 SEXT = 368,
178 FPTRUNC = 369,
179 FPEXT = 370,
180 BITCAST = 371,
181 UITOFP = 372,
182 SITOFP = 373,
183 FPTOUI = 374,
184 FPTOSI = 375,
185 INTTOPTR = 376,
186 PTRTOINT = 377,
187 PHI_TOK = 378,
188 SELECT = 379,
189 VAARG = 380,
190 EXTRACTELEMENT = 381,
191 INSERTELEMENT = 382,
192 SHUFFLEVECTOR = 383,
193 NORETURN = 384,
194 INREG = 385,
195 SRET = 386,
Reid Spencer67d8ed92007-03-22 02:14:08 +0000196 NOUNWIND = 387,
197 DEFAULT = 388,
198 HIDDEN = 389
Reid Spencer38c91a92007-02-28 02:24:54 +0000199 };
200#endif
201/* Tokens. */
202#define ESINT64VAL 258
203#define EUINT64VAL 259
204#define ESAPINTVAL 260
205#define EUAPINTVAL 261
206#define LOCALVAL_ID 262
207#define GLOBALVAL_ID 263
208#define FPVAL 264
209#define VOID 265
210#define INTTYPE 266
211#define FLOAT 267
212#define DOUBLE 268
213#define LABEL 269
214#define TYPE 270
215#define LOCALVAR 271
216#define GLOBALVAR 272
217#define LABELSTR 273
218#define STRINGCONSTANT 274
219#define ATSTRINGCONSTANT 275
Reid Spencer3025dfd2007-03-29 18:50:01 +0000220#define IMPLEMENTATION 276
Reid Spencer38c91a92007-02-28 02:24:54 +0000221#define ZEROINITIALIZER 277
222#define TRUETOK 278
223#define FALSETOK 279
224#define BEGINTOK 280
225#define ENDTOK 281
226#define DECLARE 282
227#define DEFINE 283
228#define GLOBAL 284
229#define CONSTANT 285
230#define SECTION 286
231#define VOLATILE 287
232#define TO 288
233#define DOTDOTDOT 289
234#define NULL_TOK 290
235#define UNDEF 291
236#define INTERNAL 292
237#define LINKONCE 293
238#define WEAK 294
239#define APPENDING 295
240#define DLLIMPORT 296
241#define DLLEXPORT 297
242#define EXTERN_WEAK 298
243#define OPAQUE 299
244#define EXTERNAL 300
245#define TARGET 301
246#define TRIPLE 302
247#define ALIGN 303
248#define DEPLIBS 304
249#define CALL 305
250#define TAIL 306
251#define ASM_TOK 307
252#define MODULE 308
253#define SIDEEFFECT 309
254#define CC_TOK 310
255#define CCC_TOK 311
256#define FASTCC_TOK 312
257#define COLDCC_TOK 313
258#define X86_STDCALLCC_TOK 314
259#define X86_FASTCALLCC_TOK 315
260#define DATALAYOUT 316
261#define RET 317
262#define BR 318
263#define SWITCH 319
264#define INVOKE 320
265#define UNWIND 321
266#define UNREACHABLE 322
267#define ADD 323
268#define SUB 324
269#define MUL 325
270#define UDIV 326
271#define SDIV 327
272#define FDIV 328
273#define UREM 329
274#define SREM 330
275#define FREM 331
276#define AND 332
277#define OR 333
278#define XOR 334
279#define SHL 335
280#define LSHR 336
281#define ASHR 337
282#define ICMP 338
283#define FCMP 339
284#define EQ 340
285#define NE 341
286#define SLT 342
287#define SGT 343
288#define SLE 344
289#define SGE 345
290#define ULT 346
291#define UGT 347
292#define ULE 348
293#define UGE 349
294#define OEQ 350
295#define ONE 351
296#define OLT 352
297#define OGT 353
298#define OLE 354
299#define OGE 355
300#define ORD 356
301#define UNO 357
302#define UEQ 358
303#define UNE 359
304#define MALLOC 360
305#define ALLOCA 361
306#define FREE 362
307#define LOAD 363
308#define STORE 364
309#define GETELEMENTPTR 365
310#define TRUNC 366
311#define ZEXT 367
312#define SEXT 368
313#define FPTRUNC 369
314#define FPEXT 370
315#define BITCAST 371
316#define UITOFP 372
317#define SITOFP 373
318#define FPTOUI 374
319#define FPTOSI 375
320#define INTTOPTR 376
321#define PTRTOINT 377
322#define PHI_TOK 378
323#define SELECT 379
324#define VAARG 380
325#define EXTRACTELEMENT 381
326#define INSERTELEMENT 382
327#define SHUFFLEVECTOR 383
328#define NORETURN 384
329#define INREG 385
330#define SRET 386
Reid Spencer67d8ed92007-03-22 02:14:08 +0000331#define NOUNWIND 387
332#define DEFAULT 388
333#define HIDDEN 389
Reid Spencer38c91a92007-02-28 02:24:54 +0000334
335
336
337
338/* Copy the first part of user declarations. */
339#line 14 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000340
341#include "ParserInternals.h"
342#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000343#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000344#include "llvm/Instructions.h"
345#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000346#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000347#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000348#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000349#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000350#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000351#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000352#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000353#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000354#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000355#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000356#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000357#ifndef NDEBUG
358#define YYDEBUG 1
359#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000360
Reid Spencere4f47592006-08-18 17:32:55 +0000361// The following is a gross hack. In order to rid the libAsmParser library of
362// exceptions, we have to have a way of getting the yyparse function to go into
363// an error situation. So, whenever we want an error to occur, the GenerateError
364// function (see bottom of file) sets TriggerError. Then, at the end of each
365// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
366// (a goto) to put YACC in error state. Furthermore, several calls to
367// GenerateError are made from inside productions and they must simulate the
368// previous exception behavior by exiting the production immediately. We have
369// replaced these with the GEN_ERROR macro which calls GeneratError and then
370// immediately invokes YYERROR. This would be so much cleaner if it was a
371// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000372static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000373#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000374#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
375
Reid Spencer68a24bd2005-08-27 18:50:39 +0000376int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
377int yylex(); // declaration" of xxx warnings.
378int yyparse();
379
380namespace llvm {
381 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000382#if YYDEBUG
383static cl::opt<bool>
384Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
385 cl::Hidden, cl::init(false));
386#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000387}
388using namespace llvm;
389
390static Module *ParserResult;
391
392// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
393// relating to upreferences in the input stream.
394//
395//#define DEBUG_UPREFS 1
396#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000397#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000398#else
399#define UR_OUT(X)
400#endif
401
402#define YYERROR_VERBOSE 1
403
Chris Lattnerb475c422005-11-12 18:22:38 +0000404static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000405
406
407// This contains info used when building the body of a function. It is
408// destroyed when the function is completed.
409//
410typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000411
Reid Spencer68a24bd2005-08-27 18:50:39 +0000412static void
Reid Spencer93c40032007-03-19 18:40:50 +0000413ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000414
415static struct PerModuleInfo {
416 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000417 ValueList Values; // Module level numbered definitions
418 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000419 std::vector<PATypeHolder> Types;
420 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000421
422 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000423 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000424 /// that we can resolve them later and print error messages as appropriate.
425 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
426
427 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
428 // references to global values. Global values may be referenced before they
429 // are defined, and if so, the temporary object that they represent is held
430 // here. This is used for forward references of GlobalValues.
431 //
432 typedef std::map<std::pair<const PointerType *,
433 ValID>, GlobalValue*> GlobalRefsType;
434 GlobalRefsType GlobalRefs;
435
436 void ModuleDone() {
437 // If we could not resolve some functions at function compilation time
438 // (calls to functions before they are defined), resolve them now... Types
439 // are resolved when the constant pool has been completely parsed.
440 //
441 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000442 if (TriggerError)
443 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000444
445 // Check to make sure that all global value forward references have been
446 // resolved!
447 //
448 if (!GlobalRefs.empty()) {
449 std::string UndefinedReferences = "Unresolved global references exist:\n";
450
451 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
452 I != E; ++I) {
453 UndefinedReferences += " " + I->first.first->getDescription() + " " +
454 I->first.second.getName() + "\n";
455 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000456 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000457 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000458 }
459
460 Values.clear(); // Clear out function local definitions
461 Types.clear();
462 CurrentModule = 0;
463 }
464
Reid Spencer68a24bd2005-08-27 18:50:39 +0000465 // GetForwardRefForGlobal - Check to see if there is a forward reference
466 // for this global. If so, remove it from the GlobalRefs map and return it.
467 // If not, just return null.
468 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
469 // Check to see if there is a forward reference to this global variable...
470 // if there is, eliminate it and patch the reference to use the new def'n.
471 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
472 GlobalValue *Ret = 0;
473 if (I != GlobalRefs.end()) {
474 Ret = I->second;
475 GlobalRefs.erase(I);
476 }
477 return Ret;
478 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000479
480 bool TypeIsUnresolved(PATypeHolder* PATy) {
481 // If it isn't abstract, its resolved
482 const Type* Ty = PATy->get();
483 if (!Ty->isAbstract())
484 return false;
485 // Traverse the type looking for abstract types. If it isn't abstract then
486 // we don't need to traverse that leg of the type.
487 std::vector<const Type*> WorkList, SeenList;
488 WorkList.push_back(Ty);
489 while (!WorkList.empty()) {
490 const Type* Ty = WorkList.back();
491 SeenList.push_back(Ty);
492 WorkList.pop_back();
493 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
494 // Check to see if this is an unresolved type
495 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
496 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
497 for ( ; I != E; ++I) {
498 if (I->second.get() == OpTy)
499 return true;
500 }
501 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
502 const Type* TheTy = SeqTy->getElementType();
503 if (TheTy->isAbstract() && TheTy != Ty) {
504 std::vector<const Type*>::iterator I = SeenList.begin(),
505 E = SeenList.end();
506 for ( ; I != E; ++I)
507 if (*I == TheTy)
508 break;
509 if (I == E)
510 WorkList.push_back(TheTy);
511 }
512 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
513 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
514 const Type* TheTy = StrTy->getElementType(i);
515 if (TheTy->isAbstract() && TheTy != Ty) {
516 std::vector<const Type*>::iterator I = SeenList.begin(),
517 E = SeenList.end();
518 for ( ; I != E; ++I)
519 if (*I == TheTy)
520 break;
521 if (I == E)
522 WorkList.push_back(TheTy);
523 }
524 }
525 }
526 }
527 return false;
528 }
529
530
Reid Spencer68a24bd2005-08-27 18:50:39 +0000531} CurModule;
532
533static struct PerFunctionInfo {
534 Function *CurrentFunction; // Pointer to current function being created
535
Reid Spencer93c40032007-03-19 18:40:50 +0000536 ValueList Values; // Keep track of #'d definitions
537 unsigned NextValNum;
538 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000539 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000540 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000541 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000542
543 /// BBForwardRefs - When we see forward references to basic blocks, keep
544 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000545 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000546
547 inline PerFunctionInfo() {
548 CurrentFunction = 0;
549 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000550 Linkage = GlobalValue::ExternalLinkage;
551 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000552 }
553
554 inline void FunctionStart(Function *M) {
555 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000556 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000557 }
558
559 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000560 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000561 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000562 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000563 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000564 return;
565 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000566
567 // Resolve all forward references now.
568 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
569
570 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000571 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000572 CurrentFunction = 0;
573 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000574 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000575 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000576 }
577} CurFun; // Info for the current function...
578
579static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
580
581
582//===----------------------------------------------------------------------===//
583// Code to handle definitions of all the types
584//===----------------------------------------------------------------------===//
585
Reid Spencer93c40032007-03-19 18:40:50 +0000586static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
587 // Things that have names or are void typed don't get slot numbers
588 if (V->hasName() || (V->getType() == Type::VoidTy))
589 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000590
Reid Spencer93c40032007-03-19 18:40:50 +0000591 // In the case of function values, we have to allow for the forward reference
592 // of basic blocks, which are included in the numbering. Consequently, we keep
593 // track of the next insertion location with NextValNum. When a BB gets
594 // inserted, it could change the size of the CurFun.Values vector.
595 if (&ValueTab == &CurFun.Values) {
596 if (ValueTab.size() <= CurFun.NextValNum)
597 ValueTab.resize(CurFun.NextValNum+1);
598 ValueTab[CurFun.NextValNum++] = V;
599 return;
600 }
601 // For all other lists, its okay to just tack it on the back of the vector.
602 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000603}
604
605static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
606 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000607 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000608 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000609 if (D.Num < CurModule.Types.size())
610 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000611 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000612 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000613 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
614 D.destroy(); // Free old strdup'd memory...
615 return N;
616 }
617 break;
618 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000619 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000620 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000621 }
622
623 // If we reached here, we referenced either a symbol that we don't know about
624 // or an id number that hasn't been read yet. We may be referencing something
625 // forward, so just create an entry to be resolved later and get to it...
626 //
627 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
628
629
630 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000631 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000632 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000633 return 0;
634 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000635 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000636 return 0;
637 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000638 }
639
Reid Spencer861d9d62006-11-28 07:29:44 +0000640 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000641 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000642 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000643
Reid Spencer861d9d62006-11-28 07:29:44 +0000644 Type *Typ = OpaqueType::get();
645 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
646 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000647 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000648
Reid Spencer93c40032007-03-19 18:40:50 +0000649// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000650// the provided ValID. If the value exists and has already been defined, return
651// it. Otherwise return null.
652//
Reid Spencer93c40032007-03-19 18:40:50 +0000653static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000654 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000655 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000656 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000657 return 0;
658 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000659
660 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000661 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000662 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000663 if (D.Num >= CurFun.Values.size())
664 return 0;
665 Value *Result = CurFun.Values[D.Num];
666 if (Ty != Result->getType()) {
667 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
668 Result->getType()->getDescription() + "' does not match "
669 "expected type, '" + Ty->getDescription() + "'");
670 return 0;
671 }
672 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000673 }
674 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000675 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000676 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000677 Value *Result = CurModule.Values[D.Num];
678 if (Ty != Result->getType()) {
679 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
680 Result->getType()->getDescription() + "' does not match "
681 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000682 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000683 }
684 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000685 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000686
687 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000688 if (!inFunctionScope())
689 return 0;
690 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
691 Value *N = SymTab.lookup(D.Name);
692 if (N == 0)
693 return 0;
694 if (N->getType() != Ty)
695 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000696
697 D.destroy(); // Free old strdup'd memory...
698 return N;
699 }
700 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000701 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
702 Value *N = SymTab.lookup(D.Name);
703 if (N == 0)
704 return 0;
705 if (N->getType() != Ty)
706 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000707
708 D.destroy(); // Free old strdup'd memory...
709 return N;
710 }
711
712 // Check to make sure that "Ty" is an integral type, and that our
713 // value will fit into the specified type...
714 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000715 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000716 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000717 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000718 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000719 return 0;
720 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000721 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000722
723 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000724 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
725 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000726 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000727 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000728 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000729 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000730 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000731 }
732 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000733 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000734 }
735
736 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000737 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000738 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000739 return 0;
740 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000741 return ConstantFP::get(Ty, D.ConstPoolFP);
742
743 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000744 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000745 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000746 return 0;
747 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000748 return ConstantPointerNull::get(cast<PointerType>(Ty));
749
750 case ValID::ConstUndefVal: // Is it an undef value?
751 return UndefValue::get(Ty);
752
Chris Lattner7aa61892005-12-21 17:53:23 +0000753 case ValID::ConstZeroVal: // Is it a zero value?
754 return Constant::getNullValue(Ty);
755
Reid Spencer68a24bd2005-08-27 18:50:39 +0000756 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000757 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000758 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000759 return 0;
760 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000761 return D.ConstantValue;
762
Chris Lattner0e9c3762006-01-25 22:27:16 +0000763 case ValID::InlineAsmVal: { // Inline asm expression
764 const PointerType *PTy = dyn_cast<PointerType>(Ty);
765 const FunctionType *FTy =
766 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000768 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000769 return 0;
770 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000771 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
772 D.IAD->HasSideEffects);
773 D.destroy(); // Free InlineAsmDescriptor.
774 return IA;
775 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000776 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000777 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000778 return 0;
779 } // End of switch
780
Reid Spencera9720f52007-02-05 17:04:00 +0000781 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000782 return 0;
783}
784
Reid Spencer93c40032007-03-19 18:40:50 +0000785// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000786// value is not already defined, it "improvises" by creating a placeholder var
787// that looks and acts just like the requested variable. When the value is
788// defined later, all uses of the placeholder variable are replaced with the
789// real thing.
790//
791static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000792 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000793 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000794 return 0;
795 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000796
797 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000798 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000799 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000800 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000801
Reid Spencer5b7e7532006-09-28 19:28:24 +0000802 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000803 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000804 return 0;
805 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000806
807 // If we reached here, we referenced either a symbol that we don't know about
808 // or an id number that hasn't been read yet. We may be referencing something
809 // forward, so just create an entry to be resolved later and get to it...
810 //
811 V = new Argument(Ty);
812
813 // Remember where this forward reference came from. FIXME, shouldn't we try
814 // to recycle these things??
815 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
816 llvmAsmlineno)));
817
818 if (inFunctionScope())
819 InsertValue(V, CurFun.LateResolveValues);
820 else
821 InsertValue(V, CurModule.LateResolveValues);
822 return V;
823}
824
Reid Spencer93c40032007-03-19 18:40:50 +0000825/// defineBBVal - This is a definition of a new basic block with the specified
826/// identifier which must be the same as CurFun.NextValNum, if its numeric.
827static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000828 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000829
Reid Spencer68a24bd2005-08-27 18:50:39 +0000830 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000831
Reid Spencer93c40032007-03-19 18:40:50 +0000832 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000833
Reid Spencer93c40032007-03-19 18:40:50 +0000834 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
835 if (BBI != CurFun.BBForwardRefs.end()) {
836 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000837 // The forward declaration could have been inserted anywhere in the
838 // function: insert it into the correct place now.
839 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
840 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000841
Reid Spencer66728ef2007-03-20 01:13:36 +0000842 // We're about to erase the entry, save the key so we can clean it up.
843 ValID Tmp = BBI->first;
844
Reid Spencer93c40032007-03-19 18:40:50 +0000845 // Erase the forward ref from the map as its no longer "forward"
846 CurFun.BBForwardRefs.erase(ID);
847
Reid Spencer66728ef2007-03-20 01:13:36 +0000848 // The key has been removed from the map but so we don't want to leave
849 // strdup'd memory around so destroy it too.
850 Tmp.destroy();
851
Reid Spencer93c40032007-03-19 18:40:50 +0000852 // If its a numbered definition, bump the number and set the BB value.
853 if (ID.Type == ValID::LocalID) {
854 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
855 InsertValue(BB);
856 }
857
858 ID.destroy();
859 return BB;
860 }
861
862 // We haven't seen this BB before and its first mention is a definition.
863 // Just create it and return it.
864 std::string Name (ID.Type == ValID::LocalName ? ID.Name : "");
865 BB = new BasicBlock(Name, CurFun.CurrentFunction);
866 if (ID.Type == ValID::LocalID) {
867 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
868 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000869 }
Reid Spencer93c40032007-03-19 18:40:50 +0000870
871 ID.destroy(); // Free strdup'd memory
872 return BB;
873}
874
875/// getBBVal - get an existing BB value or create a forward reference for it.
876///
877static BasicBlock *getBBVal(const ValID &ID) {
878 assert(inFunctionScope() && "Can't get basic block at global scope!");
879
880 BasicBlock *BB = 0;
881
882 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
883 if (BBI != CurFun.BBForwardRefs.end()) {
884 BB = BBI->second;
885 } if (ID.Type == ValID::LocalName) {
886 std::string Name = ID.Name;
887 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
888 if (N)
889 if (N->getType()->getTypeID() == Type::LabelTyID)
890 BB = cast<BasicBlock>(N);
891 else
892 GenerateError("Reference to label '" + Name + "' is actually of type '"+
893 N->getType()->getDescription() + "'");
894 } else if (ID.Type == ValID::LocalID) {
895 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
896 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
897 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
898 else
899 GenerateError("Reference to label '%" + utostr(ID.Num) +
900 "' is actually of type '"+
901 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
902 }
903 } else {
904 GenerateError("Illegal label reference " + ID.getName());
905 return 0;
906 }
907
908 // If its already been defined, return it now.
909 if (BB) {
910 ID.destroy(); // Free strdup'd memory.
911 return BB;
912 }
913
914 // Otherwise, this block has not been seen before, create it.
915 std::string Name;
916 if (ID.Type == ValID::LocalName)
917 Name = ID.Name;
918 BB = new BasicBlock(Name, CurFun.CurrentFunction);
919
920 // Insert it in the forward refs map.
921 CurFun.BBForwardRefs[ID] = BB;
922
Reid Spencer68a24bd2005-08-27 18:50:39 +0000923 return BB;
924}
925
926
927//===----------------------------------------------------------------------===//
928// Code to handle forward references in instructions
929//===----------------------------------------------------------------------===//
930//
931// This code handles the late binding needed with statements that reference
932// values not defined yet... for example, a forward branch, or the PHI node for
933// a loop body.
934//
935// This keeps a table (CurFun.LateResolveValues) of all such forward references
936// and back patchs after we are done.
937//
938
939// ResolveDefinitions - If we could not resolve some defs at parsing
940// time (forward branches, phi functions for loops, etc...) resolve the
941// defs now...
942//
943static void
Reid Spencer93c40032007-03-19 18:40:50 +0000944ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000945 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000946 while (!LateResolvers.empty()) {
947 Value *V = LateResolvers.back();
948 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000949
Reid Spencer93c40032007-03-19 18:40:50 +0000950 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
951 CurModule.PlaceHolderInfo.find(V);
952 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000953
Reid Spencer93c40032007-03-19 18:40:50 +0000954 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000955
Reid Spencer93c40032007-03-19 18:40:50 +0000956 Value *TheRealValue = getExistingVal(V->getType(), DID);
957 if (TriggerError)
958 return;
959 if (TheRealValue) {
960 V->replaceAllUsesWith(TheRealValue);
961 delete V;
962 CurModule.PlaceHolderInfo.erase(PHI);
963 } else if (FutureLateResolvers) {
964 // Functions have their unresolved items forwarded to the module late
965 // resolver table
966 InsertValue(V, *FutureLateResolvers);
967 } else {
968 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
969 GenerateError("Reference to an invalid definition: '" +DID.getName()+
970 "' of type '" + V->getType()->getDescription() + "'",
971 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000972 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000973 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000974 GenerateError("Reference to an invalid definition: #" +
975 itostr(DID.Num) + " of type '" +
976 V->getType()->getDescription() + "'",
977 PHI->second.second);
978 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000979 }
980 }
981 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000982 LateResolvers.clear();
983}
984
985// ResolveTypeTo - A brand new type was just declared. This means that (if
986// name is not null) things referencing Name can be resolved. Otherwise, things
987// refering to the number can be resolved. Do this now.
988//
989static void ResolveTypeTo(char *Name, const Type *ToTy) {
990 ValID D;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000991 if (Name) D = ValID::createLocalName(Name);
992 else D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000993
Reid Spencer861d9d62006-11-28 07:29:44 +0000994 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000995 CurModule.LateResolveTypes.find(D);
996 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000997 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000998 CurModule.LateResolveTypes.erase(I);
999 }
1000}
1001
1002// setValueName - Set the specified value to the name given. The name may be
1003// null potentially, in which case this is a noop. The string passed in is
1004// assumed to be a malloc'd string buffer, and is free'd by this function.
1005//
1006static void setValueName(Value *V, char *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001007 if (!NameStr) return;
1008 std::string Name(NameStr); // Copy string
1009 free(NameStr); // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001010
Reid Spencer41dff5e2007-01-26 08:05:27 +00001011 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001012 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001013 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001014 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001015
Reid Spencera9720f52007-02-05 17:04:00 +00001016 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001017 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1018 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001019 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001020 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001021 return;
1022 }
1023
1024 // Set the name.
1025 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001026}
1027
1028/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1029/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001030static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001031ParseGlobalVariable(char *NameStr,
1032 GlobalValue::LinkageTypes Linkage,
1033 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001034 bool isConstantGlobal, const Type *Ty,
1035 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001036 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001037 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001038 return 0;
1039 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001040
1041 const PointerType *PTy = PointerType::get(Ty);
1042
1043 std::string Name;
1044 if (NameStr) {
1045 Name = NameStr; // Copy string
1046 free(NameStr); // Free old string
1047 }
1048
1049 // See if this global value was forward referenced. If so, recycle the
1050 // object.
1051 ValID ID;
1052 if (!Name.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001053 ID = ValID::createGlobalName((char*)Name.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001054 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001055 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001056 }
1057
1058 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1059 // Move the global to the end of the list, from whereever it was
1060 // previously inserted.
1061 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1062 CurModule.CurrentModule->getGlobalList().remove(GV);
1063 CurModule.CurrentModule->getGlobalList().push_back(GV);
1064 GV->setInitializer(Initializer);
1065 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001066 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001067 GV->setConstant(isConstantGlobal);
1068 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001069 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001070 }
1071
Reid Spenceref9b9a72007-02-05 20:47:22 +00001072 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001073 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001074 // if the global we're parsing has an initializer (is a definition) and
1075 // has external linkage.
1076 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1077 // If there is already a global with external linkage with this name
1078 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1079 // If we allow this GVar to get created, it will be renamed in the
1080 // symbol table because it conflicts with an existing GVar. We can't
1081 // allow redefinition of GVars whose linking indicates that their name
1082 // must stay the same. Issue the error.
1083 GenerateError("Redefinition of global variable named '" + Name +
1084 "' of type '" + Ty->getDescription() + "'");
1085 return 0;
1086 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001087 }
1088
1089 // Otherwise there is no existing GV to use, create one now.
1090 GlobalVariable *GV =
1091 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1092 CurModule.CurrentModule);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001093 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001094 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001095 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001096}
1097
1098// setTypeName - Set the specified type to the name given. The name may be
1099// null potentially, in which case this is a noop. The string passed in is
1100// assumed to be a malloc'd string buffer, and is freed by this function.
1101//
1102// This function returns true if the type has already been defined, but is
1103// allowed to be redefined in the specified context. If the name is a new name
1104// for the type plane, it is inserted and false is returned.
1105static bool setTypeName(const Type *T, char *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001106 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001107 if (NameStr == 0) return false;
1108
1109 std::string Name(NameStr); // Copy string
1110 free(NameStr); // Free old string
1111
1112 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001113 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001114 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001115 return false;
1116 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001117
1118 // Set the type name, checking for conflicts as we do so.
1119 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1120
1121 if (AlreadyExists) { // Inserting a name that is already defined???
1122 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001123 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001124
1125 // There is only one case where this is allowed: when we are refining an
1126 // opaque type. In this case, Existing will be an opaque type.
1127 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1128 // We ARE replacing an opaque type!
1129 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1130 return true;
1131 }
1132
1133 // Otherwise, this is an attempt to redefine a type. That's okay if
1134 // the redefinition is identical to the original. This will be so if
1135 // Existing and T point to the same Type object. In this one case we
1136 // allow the equivalent redefinition.
1137 if (Existing == T) return true; // Yes, it's equal.
1138
1139 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001140 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001141 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001142 }
1143
1144 return false;
1145}
1146
1147//===----------------------------------------------------------------------===//
1148// Code for handling upreferences in type names...
1149//
1150
1151// TypeContains - Returns true if Ty directly contains E in it.
1152//
1153static bool TypeContains(const Type *Ty, const Type *E) {
1154 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1155 E) != Ty->subtype_end();
1156}
1157
1158namespace {
1159 struct UpRefRecord {
1160 // NestingLevel - The number of nesting levels that need to be popped before
1161 // this type is resolved.
1162 unsigned NestingLevel;
1163
1164 // LastContainedTy - This is the type at the current binding level for the
1165 // type. Every time we reduce the nesting level, this gets updated.
1166 const Type *LastContainedTy;
1167
1168 // UpRefTy - This is the actual opaque type that the upreference is
1169 // represented with.
1170 OpaqueType *UpRefTy;
1171
1172 UpRefRecord(unsigned NL, OpaqueType *URTy)
1173 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1174 };
1175}
1176
1177// UpRefs - A list of the outstanding upreferences that need to be resolved.
1178static std::vector<UpRefRecord> UpRefs;
1179
1180/// HandleUpRefs - Every time we finish a new layer of types, this function is
1181/// called. It loops through the UpRefs vector, which is a list of the
1182/// currently active types. For each type, if the up reference is contained in
1183/// the newly completed type, we decrement the level count. When the level
1184/// count reaches zero, the upreferenced type is the type that is passed in:
1185/// thus we can complete the cycle.
1186///
1187static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001188 // If Ty isn't abstract, or if there are no up-references in it, then there is
1189 // nothing to resolve here.
1190 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1191
Reid Spencer68a24bd2005-08-27 18:50:39 +00001192 PATypeHolder Ty(ty);
1193 UR_OUT("Type '" << Ty->getDescription() <<
1194 "' newly formed. Resolving upreferences.\n" <<
1195 UpRefs.size() << " upreferences active!\n");
1196
1197 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1198 // to zero), we resolve them all together before we resolve them to Ty. At
1199 // the end of the loop, if there is anything to resolve to Ty, it will be in
1200 // this variable.
1201 OpaqueType *TypeToResolve = 0;
1202
1203 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1204 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1205 << UpRefs[i].second->getDescription() << ") = "
1206 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1207 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1208 // Decrement level of upreference
1209 unsigned Level = --UpRefs[i].NestingLevel;
1210 UpRefs[i].LastContainedTy = Ty;
1211 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1212 if (Level == 0) { // Upreference should be resolved!
1213 if (!TypeToResolve) {
1214 TypeToResolve = UpRefs[i].UpRefTy;
1215 } else {
1216 UR_OUT(" * Resolving upreference for "
1217 << UpRefs[i].second->getDescription() << "\n";
1218 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1219 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1220 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1221 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1222 }
1223 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1224 --i; // Do not skip the next element...
1225 }
1226 }
1227 }
1228
1229 if (TypeToResolve) {
1230 UR_OUT(" * Resolving upreference for "
1231 << UpRefs[i].second->getDescription() << "\n";
1232 std::string OldName = TypeToResolve->getDescription());
1233 TypeToResolve->refineAbstractTypeTo(Ty);
1234 }
1235
1236 return Ty;
1237}
1238
Reid Spencer68a24bd2005-08-27 18:50:39 +00001239//===----------------------------------------------------------------------===//
1240// RunVMAsmParser - Define an interface to this parser
1241//===----------------------------------------------------------------------===//
1242//
Reid Spencer14310612006-12-31 05:40:51 +00001243static Module* RunParser(Module * M);
1244
Reid Spencer68a24bd2005-08-27 18:50:39 +00001245Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1246 set_scan_file(F);
1247
1248 CurFilename = Filename;
1249 return RunParser(new Module(CurFilename));
1250}
1251
1252Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1253 set_scan_string(AsmString);
1254
1255 CurFilename = "from_memory";
1256 if (M == NULL) {
1257 return RunParser(new Module (CurFilename));
1258 } else {
1259 return RunParser(M);
1260 }
1261}
1262
1263
Reid Spencer38c91a92007-02-28 02:24:54 +00001264
1265/* Enabling traces. */
1266#ifndef YYDEBUG
1267# define YYDEBUG 0
1268#endif
1269
1270/* Enabling verbose error messages. */
1271#ifdef YYERROR_VERBOSE
1272# undef YYERROR_VERBOSE
1273# define YYERROR_VERBOSE 1
1274#else
1275# define YYERROR_VERBOSE 0
1276#endif
1277
1278/* Enabling the token table. */
1279#ifndef YYTOKEN_TABLE
1280# define YYTOKEN_TABLE 0
1281#endif
1282
1283#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer66728ef2007-03-20 01:13:36 +00001284#line 939 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00001285typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001286 llvm::Module *ModuleVal;
1287 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001288 llvm::BasicBlock *BasicBlockVal;
1289 llvm::TerminatorInst *TermInstVal;
1290 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001291 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001292
Reid Spencera132e042006-12-03 05:46:11 +00001293 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001294 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001295 llvm::PATypeHolder *TypeVal;
1296 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001297 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001298 llvm::ArgListType *ArgList;
1299 llvm::TypeWithAttrs TypeWithAttrs;
1300 llvm::TypeWithAttrsList *TypeWithAttrsList;
1301 llvm::ValueRefList *ValueRefList;
1302
Reid Spencer68a24bd2005-08-27 18:50:39 +00001303 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001304 std::list<std::pair<llvm::Value*,
1305 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001306 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001307 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001308
1309 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001310 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer14310612006-12-31 05:40:51 +00001311 llvm::FunctionType::ParameterAttributes ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001312 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001313 int64_t SInt64Val;
1314 uint64_t UInt64Val;
1315 int SIntVal;
1316 unsigned UIntVal;
1317 double FPVal;
1318 bool BoolVal;
1319
1320 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001321 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001322
Reid Spencera132e042006-12-03 05:46:11 +00001323 llvm::Instruction::BinaryOps BinaryOpVal;
1324 llvm::Instruction::TermOps TermOpVal;
1325 llvm::Instruction::MemoryOps MemOpVal;
1326 llvm::Instruction::CastOps CastOpVal;
1327 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001328 llvm::ICmpInst::Predicate IPredicate;
1329 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner9d2fda62007-02-13 05:53:56 +00001330} YYSTYPE;
Reid Spencer38c91a92007-02-28 02:24:54 +00001331/* Line 196 of yacc.c. */
Reid Spencer67d8ed92007-03-22 02:14:08 +00001332#line 1333 "llvmAsmParser.tab.c"
Reid Spencer38c91a92007-02-28 02:24:54 +00001333# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1334# define YYSTYPE_IS_DECLARED 1
1335# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001336#endif
1337
Reid Spencer41dff5e2007-01-26 08:05:27 +00001338
Reid Spencer68a24bd2005-08-27 18:50:39 +00001339
Reid Spencer38c91a92007-02-28 02:24:54 +00001340/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001341
1342
Reid Spencer38c91a92007-02-28 02:24:54 +00001343/* Line 219 of yacc.c. */
Reid Spencer67d8ed92007-03-22 02:14:08 +00001344#line 1345 "llvmAsmParser.tab.c"
Reid Spencer41dff5e2007-01-26 08:05:27 +00001345
Reid Spencer38c91a92007-02-28 02:24:54 +00001346#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1347# define YYSIZE_T __SIZE_TYPE__
1348#endif
1349#if ! defined (YYSIZE_T) && defined (size_t)
1350# define YYSIZE_T size_t
1351#endif
1352#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1353# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1354# define YYSIZE_T size_t
1355#endif
1356#if ! defined (YYSIZE_T)
1357# define YYSIZE_T unsigned int
1358#endif
Chris Lattner9d2fda62007-02-13 05:53:56 +00001359
Reid Spencer38c91a92007-02-28 02:24:54 +00001360#ifndef YY_
1361# if YYENABLE_NLS
1362# if ENABLE_NLS
1363# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1364# define YY_(msgid) dgettext ("bison-runtime", msgid)
1365# endif
1366# endif
1367# ifndef YY_
1368# define YY_(msgid) msgid
1369# endif
1370#endif
1371
1372#if ! defined (yyoverflow) || YYERROR_VERBOSE
1373
1374/* The parser invokes alloca or malloc; define the necessary symbols. */
1375
1376# ifdef YYSTACK_USE_ALLOCA
1377# if YYSTACK_USE_ALLOCA
1378# ifdef __GNUC__
1379# define YYSTACK_ALLOC __builtin_alloca
1380# else
1381# define YYSTACK_ALLOC alloca
1382# if defined (__STDC__) || defined (__cplusplus)
1383# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1384# define YYINCLUDED_STDLIB_H
1385# endif
1386# endif
1387# endif
1388# endif
1389
1390# ifdef YYSTACK_ALLOC
1391 /* Pacify GCC's `empty if-body' warning. */
1392# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1393# ifndef YYSTACK_ALLOC_MAXIMUM
1394 /* The OS might guarantee only one guard page at the bottom of the stack,
1395 and a page size can be as small as 4096 bytes. So we cannot safely
1396 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1397 to allow for a few compiler-allocated temporary stack slots. */
1398# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1399# endif
1400# else
1401# define YYSTACK_ALLOC YYMALLOC
1402# define YYSTACK_FREE YYFREE
1403# ifndef YYSTACK_ALLOC_MAXIMUM
1404# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1405# endif
1406# ifdef __cplusplus
1407extern "C" {
1408# endif
1409# ifndef YYMALLOC
1410# define YYMALLOC malloc
1411# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1412 && (defined (__STDC__) || defined (__cplusplus)))
1413void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1414# endif
1415# endif
1416# ifndef YYFREE
1417# define YYFREE free
1418# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1419 && (defined (__STDC__) || defined (__cplusplus)))
1420void free (void *); /* INFRINGES ON USER NAME SPACE */
1421# endif
1422# endif
1423# ifdef __cplusplus
1424}
1425# endif
1426# endif
1427#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1428
1429
1430#if (! defined (yyoverflow) \
1431 && (! defined (__cplusplus) \
1432 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1433
1434/* A type that is properly aligned for any stack member. */
1435union yyalloc
1436{
1437 short int yyss;
1438 YYSTYPE yyvs;
1439 };
1440
1441/* The size of the maximum gap between one aligned stack and the next. */
1442# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1443
1444/* The size of an array large to enough to hold all stacks, each with
1445 N elements. */
1446# define YYSTACK_BYTES(N) \
1447 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1448 + YYSTACK_GAP_MAXIMUM)
1449
1450/* Copy COUNT objects from FROM to TO. The source and destination do
1451 not overlap. */
1452# ifndef YYCOPY
1453# if defined (__GNUC__) && 1 < __GNUC__
1454# define YYCOPY(To, From, Count) \
1455 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1456# else
1457# define YYCOPY(To, From, Count) \
1458 do \
1459 { \
1460 YYSIZE_T yyi; \
1461 for (yyi = 0; yyi < (Count); yyi++) \
1462 (To)[yyi] = (From)[yyi]; \
1463 } \
1464 while (0)
1465# endif
1466# endif
1467
1468/* Relocate STACK from its old location to the new one. The
1469 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1470 elements in the stack, and YYPTR gives the new location of the
1471 stack. Advance YYPTR to a properly aligned location for the next
1472 stack. */
1473# define YYSTACK_RELOCATE(Stack) \
1474 do \
1475 { \
1476 YYSIZE_T yynewbytes; \
1477 YYCOPY (&yyptr->Stack, Stack, yysize); \
1478 Stack = &yyptr->Stack; \
1479 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1480 yyptr += yynewbytes / sizeof (*yyptr); \
1481 } \
1482 while (0)
Chris Lattner9d2fda62007-02-13 05:53:56 +00001483
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001484#endif
1485
Reid Spencer38c91a92007-02-28 02:24:54 +00001486#if defined (__STDC__) || defined (__cplusplus)
1487 typedef signed char yysigned_char;
Reid Spencer5cbf9852007-01-30 20:08:39 +00001488#else
Reid Spencer38c91a92007-02-28 02:24:54 +00001489 typedef short int yysigned_char;
Reid Spencer5cbf9852007-01-30 20:08:39 +00001490#endif
1491
Reid Spencer38c91a92007-02-28 02:24:54 +00001492/* YYFINAL -- State number of the termination state. */
1493#define YYFINAL 40
1494/* YYLAST -- Last index in YYTABLE. */
Reid Spencer67d8ed92007-03-22 02:14:08 +00001495#define YYLAST 1434
Reid Spencer38c91a92007-02-28 02:24:54 +00001496
1497/* YYNTOKENS -- Number of terminals. */
Reid Spencer67d8ed92007-03-22 02:14:08 +00001498#define YYNTOKENS 149
Reid Spencer38c91a92007-02-28 02:24:54 +00001499/* YYNNTS -- Number of nonterminals. */
1500#define YYNNTS 78
1501/* YYNRULES -- Number of rules. */
Reid Spencer67d8ed92007-03-22 02:14:08 +00001502#define YYNRULES 287
Reid Spencer38c91a92007-02-28 02:24:54 +00001503/* YYNRULES -- Number of states. */
Reid Spencer67d8ed92007-03-22 02:14:08 +00001504#define YYNSTATES 560
Reid Spencer38c91a92007-02-28 02:24:54 +00001505
1506/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1507#define YYUNDEFTOK 2
Reid Spencer67d8ed92007-03-22 02:14:08 +00001508#define YYMAXUTOK 389
Reid Spencer38c91a92007-02-28 02:24:54 +00001509
1510#define YYTRANSLATE(YYX) \
1511 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1512
1513/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1514static const unsigned char yytranslate[] =
1515{
1516 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001520 139, 140, 137, 2, 136, 2, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001521 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001522 144, 135, 145, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001525 2, 141, 138, 143, 2, 2, 2, 2, 2, 148,
Reid Spencer38c91a92007-02-28 02:24:54 +00001526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1527 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001528 142, 2, 2, 146, 2, 147, 2, 2, 2, 2,
Reid Spencer38c91a92007-02-28 02:24:54 +00001529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1541 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1542 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1543 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1544 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1545 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1546 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1547 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1548 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1549 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1550 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1551 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1552 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1553 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001554 125, 126, 127, 128, 129, 130, 131, 132, 133, 134
Reid Spencer38c91a92007-02-28 02:24:54 +00001555};
1556
1557#if YYDEBUG
1558/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1559 YYRHS. */
1560static const unsigned short int yyprhs[] =
1561{
1562 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1563 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1564 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1565 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1566 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1567 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1568 119, 121, 122, 125, 126, 128, 130, 133, 134, 136,
1569 138, 140, 142, 144, 146, 148, 150, 151, 153, 154,
1570 156, 158, 159, 161, 163, 165, 167, 168, 170, 172,
1571 174, 176, 178, 181, 183, 185, 187, 189, 190, 193,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001572 195, 197, 199, 200, 203, 204, 207, 208, 212, 215,
1573 216, 218, 219, 223, 225, 228, 230, 232, 234, 236,
1574 238, 240, 243, 245, 248, 254, 260, 266, 272, 276,
1575 279, 285, 290, 293, 295, 297, 299, 303, 305, 309,
1576 311, 312, 314, 318, 323, 327, 331, 336, 341, 345,
1577 352, 358, 361, 364, 367, 370, 373, 376, 379, 382,
1578 385, 388, 391, 394, 401, 407, 416, 423, 430, 438,
1579 446, 453, 462, 471, 475, 477, 479, 481, 483, 484,
1580 486, 489, 490, 494, 495, 499, 503, 505, 509, 513,
1581 514, 521, 522, 530, 531, 539, 542, 546, 548, 552,
1582 556, 560, 564, 566, 567, 573, 577, 579, 583, 585,
1583 586, 596, 598, 600, 605, 607, 609, 612, 616, 617,
1584 619, 621, 623, 625, 627, 629, 631, 633, 635, 639,
1585 641, 647, 649, 651, 653, 655, 657, 659, 662, 665,
1586 668, 672, 675, 676, 678, 681, 684, 688, 698, 708,
1587 717, 732, 734, 736, 743, 749, 752, 759, 767, 771,
1588 777, 778, 779, 783, 786, 788, 794, 800, 807, 814,
1589 819, 826, 831, 836, 843, 850, 853, 862, 864, 866,
1590 867, 871, 878, 882, 889, 892, 897, 904
Reid Spencer38c91a92007-02-28 02:24:54 +00001591};
1592
1593/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1594static const short int yyrhs[] =
1595{
Reid Spencer67d8ed92007-03-22 02:14:08 +00001596 189, 0, -1, 68, -1, 69, -1, 70, -1, 71,
Reid Spencer38c91a92007-02-28 02:24:54 +00001597 -1, 72, -1, 73, -1, 74, -1, 75, -1, 76,
1598 -1, 80, -1, 81, -1, 82, -1, 77, -1, 78,
1599 -1, 79, -1, 111, -1, 112, -1, 113, -1, 114,
1600 -1, 115, -1, 116, -1, 117, -1, 118, -1, 119,
1601 -1, 120, -1, 121, -1, 122, -1, 85, -1, 86,
1602 -1, 87, -1, 88, -1, 89, -1, 90, -1, 91,
1603 -1, 92, -1, 93, -1, 94, -1, 95, -1, 96,
1604 -1, 97, -1, 98, -1, 99, -1, 100, -1, 101,
1605 -1, 102, -1, 103, -1, 104, -1, 91, -1, 92,
1606 -1, 93, -1, 94, -1, 23, -1, 24, -1, 11,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001607 -1, 12, -1, 13, -1, 16, -1, 19, -1, 157,
1608 -1, -1, 157, 135, -1, -1, 17, -1, 20, -1,
1609 160, 135, -1, -1, 37, -1, 39, -1, 38, -1,
Reid Spencer38c91a92007-02-28 02:24:54 +00001610 40, -1, 42, -1, 41, -1, 43, -1, 45, -1,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001611 -1, 134, -1, -1, 41, -1, 43, -1, -1, 37,
Reid Spencer38c91a92007-02-28 02:24:54 +00001612 -1, 38, -1, 39, -1, 42, -1, -1, 56, -1,
1613 57, -1, 58, -1, 59, -1, 60, -1, 55, 4,
1614 -1, 112, -1, 113, -1, 130, -1, 131, -1, -1,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001615 169, 168, -1, 129, -1, 132, -1, 168, -1, -1,
1616 171, 170, -1, -1, 48, 4, -1, -1, 136, 48,
1617 4, -1, 31, 19, -1, -1, 174, -1, -1, 136,
1618 177, 176, -1, 174, -1, 48, 4, -1, 11, -1,
1619 12, -1, 13, -1, 14, -1, 44, -1, 178, -1,
1620 179, 137, -1, 211, -1, 138, 4, -1, 179, 139,
1621 183, 140, 171, -1, 10, 139, 183, 140, 171, -1,
1622 141, 4, 142, 179, 143, -1, 144, 4, 142, 179,
1623 145, -1, 146, 184, 147, -1, 146, 147, -1, 144,
1624 146, 184, 147, 145, -1, 144, 146, 147, 145, -1,
1625 179, 169, -1, 179, -1, 10, -1, 180, -1, 182,
1626 136, 180, -1, 182, -1, 182, 136, 34, -1, 34,
1627 -1, -1, 179, -1, 184, 136, 179, -1, 179, 141,
1628 187, 143, -1, 179, 141, 143, -1, 179, 148, 19,
1629 -1, 179, 144, 187, 145, -1, 179, 146, 187, 147,
1630 -1, 179, 146, 147, -1, 179, 144, 146, 187, 147,
1631 145, -1, 179, 144, 146, 147, 145, -1, 179, 35,
1632 -1, 179, 36, -1, 179, 211, -1, 179, 186, -1,
1633 179, 22, -1, 155, 3, -1, 155, 5, -1, 155,
1634 4, -1, 155, 6, -1, 11, 23, -1, 11, 24,
1635 -1, 156, 9, -1, 152, 139, 185, 33, 179, 140,
1636 -1, 110, 139, 185, 222, 140, -1, 124, 139, 185,
1637 136, 185, 136, 185, 140, -1, 150, 139, 185, 136,
1638 185, 140, -1, 151, 139, 185, 136, 185, 140, -1,
1639 83, 153, 139, 185, 136, 185, 140, -1, 84, 154,
1640 139, 185, 136, 185, 140, -1, 126, 139, 185, 136,
1641 185, 140, -1, 127, 139, 185, 136, 185, 136, 185,
1642 140, -1, 128, 139, 185, 136, 185, 136, 185, 140,
1643 -1, 187, 136, 185, -1, 185, -1, 29, -1, 30,
1644 -1, 190, -1, -1, 191, -1, 190, 191, -1, -1,
1645 28, 192, 207, -1, -1, 27, 193, 208, -1, 53,
1646 52, 197, -1, 21, -1, 159, 15, 179, -1, 159,
1647 15, 10, -1, -1, 161, 164, 188, 185, 194, 176,
1648 -1, -1, 161, 162, 164, 188, 185, 195, 176, -1,
1649 -1, 161, 163, 164, 188, 179, 196, 176, -1, 46,
1650 198, -1, 49, 135, 199, -1, 19, -1, 47, 135,
1651 19, -1, 61, 135, 19, -1, 141, 200, 143, -1,
1652 200, 136, 19, -1, 19, -1, -1, 201, 136, 179,
1653 169, 158, -1, 179, 169, 158, -1, 201, -1, 201,
1654 136, 34, -1, 34, -1, -1, 167, 181, 160, 139,
1655 202, 140, 171, 175, 172, -1, 25, -1, 146, -1,
1656 166, 164, 203, 204, -1, 26, -1, 147, -1, 214,
1657 206, -1, 165, 164, 203, -1, -1, 54, -1, 3,
1658 -1, 4, -1, 9, -1, 23, -1, 24, -1, 35,
1659 -1, 36, -1, 22, -1, 144, 187, 145, -1, 186,
1660 -1, 52, 209, 19, 136, 19, -1, 7, -1, 8,
1661 -1, 157, -1, 160, -1, 211, -1, 210, -1, 179,
1662 212, -1, 214, 215, -1, 205, 215, -1, 216, 159,
1663 217, -1, 216, 219, -1, -1, 18, -1, 62, 213,
1664 -1, 62, 10, -1, 63, 14, 212, -1, 63, 11,
1665 212, 136, 14, 212, 136, 14, 212, -1, 64, 155,
1666 212, 136, 14, 212, 141, 218, 143, -1, 64, 155,
1667 212, 136, 14, 212, 141, 143, -1, 65, 167, 181,
1668 212, 139, 221, 140, 171, 33, 14, 212, 66, 14,
1669 212, -1, 66, -1, 67, -1, 218, 155, 210, 136,
1670 14, 212, -1, 155, 210, 136, 14, 212, -1, 159,
1671 224, -1, 179, 141, 212, 136, 212, 143, -1, 220,
1672 136, 141, 212, 136, 212, 143, -1, 179, 212, 169,
1673 -1, 221, 136, 179, 212, 169, -1, -1, -1, 222,
1674 136, 213, -1, 51, 50, -1, 50, -1, 150, 179,
1675 212, 136, 212, -1, 151, 179, 212, 136, 212, -1,
1676 83, 153, 179, 212, 136, 212, -1, 84, 154, 179,
1677 212, 136, 212, -1, 152, 213, 33, 179, -1, 124,
1678 213, 136, 213, 136, 213, -1, 125, 213, 136, 179,
1679 -1, 126, 213, 136, 213, -1, 127, 213, 136, 213,
1680 136, 213, -1, 128, 213, 136, 213, 136, 213, -1,
1681 123, 220, -1, 223, 167, 181, 212, 139, 221, 140,
1682 171, -1, 226, -1, 32, -1, -1, 105, 179, 173,
1683 -1, 105, 179, 136, 11, 212, 173, -1, 106, 179,
1684 173, -1, 106, 179, 136, 11, 212, 173, -1, 107,
1685 213, -1, 225, 108, 179, 212, -1, 225, 109, 213,
1686 136, 179, 212, -1, 110, 179, 212, 222, -1
Reid Spencer38c91a92007-02-28 02:24:54 +00001687};
1688
1689/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1690static const unsigned short int yyrline[] =
1691{
Reid Spencer66728ef2007-03-20 01:13:36 +00001692 0, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093,
1693 1093, 1094, 1094, 1094, 1094, 1094, 1094, 1095, 1095, 1095,
1694 1095, 1095, 1095, 1096, 1096, 1096, 1096, 1096, 1096, 1099,
1695 1099, 1100, 1100, 1101, 1101, 1102, 1102, 1103, 1103, 1107,
1696 1107, 1108, 1108, 1109, 1109, 1110, 1110, 1111, 1111, 1112,
1697 1112, 1113, 1113, 1114, 1115, 1120, 1121, 1121, 1123, 1123,
1698 1124, 1124, 1128, 1132, 1137, 1137, 1139, 1143, 1149, 1150,
1699 1151, 1152, 1153, 1157, 1158, 1159, 1163, 1164, 1168, 1169,
1700 1170, 1174, 1175, 1176, 1177, 1178, 1181, 1182, 1183, 1184,
1701 1185, 1186, 1187, 1194, 1195, 1196, 1197, 1200, 1201, 1206,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001702 1207, 1208, 1211, 1212, 1219, 1220, 1226, 1227, 1235, 1243,
1703 1244, 1249, 1250, 1251, 1256, 1269, 1269, 1269, 1269, 1272,
1704 1276, 1280, 1287, 1292, 1300, 1319, 1338, 1343, 1355, 1365,
1705 1369, 1379, 1386, 1393, 1400, 1405, 1410, 1417, 1418, 1425,
1706 1432, 1440, 1446, 1458, 1486, 1502, 1531, 1559, 1584, 1603,
1707 1629, 1649, 1661, 1668, 1734, 1744, 1754, 1760, 1770, 1776,
1708 1786, 1791, 1796, 1804, 1816, 1838, 1846, 1852, 1863, 1868,
1709 1873, 1879, 1885, 1894, 1898, 1906, 1906, 1917, 1922, 1930,
1710 1931, 1935, 1935, 1939, 1939, 1942, 1945, 1957, 1981, 1992,
1711 1992, 2002, 2002, 2010, 2010, 2020, 2023, 2029, 2042, 2046,
1712 2051, 2053, 2058, 2063, 2072, 2082, 2093, 2097, 2106, 2115,
1713 2120, 2232, 2232, 2234, 2243, 2243, 2245, 2250, 2262, 2266,
1714 2271, 2275, 2279, 2283, 2287, 2291, 2295, 2299, 2303, 2328,
1715 2332, 2346, 2350, 2354, 2358, 2364, 2364, 2370, 2379, 2383,
1716 2392, 2401, 2410, 2414, 2419, 2423, 2427, 2432, 2442, 2461,
1717 2470, 2539, 2543, 2550, 2561, 2574, 2584, 2595, 2605, 2614,
1718 2623, 2626, 2627, 2634, 2638, 2643, 2664, 2681, 2695, 2709,
1719 2721, 2729, 2736, 2742, 2748, 2754, 2769, 2833, 2838, 2842,
1720 2849, 2856, 2864, 2871, 2879, 2887, 2901, 2918
Reid Spencer38c91a92007-02-28 02:24:54 +00001721};
1722#endif
1723
1724#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1725/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1726 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1727static const char *const yytname[] =
1728{
1729 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1730 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1731 "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
Reid Spencer3025dfd2007-03-29 18:50:01 +00001732 "STRINGCONSTANT", "ATSTRINGCONSTANT", "IMPLEMENTATION",
1733 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1734 "DECLARE", "DEFINE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1735 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1736 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1737 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL",
1738 "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK",
1739 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1740 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1741 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1742 "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT",
1743 "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT",
1744 "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE",
1745 "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC",
1746 "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR",
1747 "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT",
1748 "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET",
1749 "NOUNWIND", "DEFAULT", "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('",
1750 "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept",
1751 "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates", "FPredicates",
1752 "IntType", "FPType", "LocalName", "OptLocalName", "OptLocalAssign",
1753 "GlobalName", "OptGlobalAssign", "GVInternalLinkage",
1754 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
1755 "FunctionDefineLinkage", "OptCallingConv", "ParamAttr", "OptParamAttrs",
1756 "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString",
1757 "OptSection", "GlobalVarAttributes", "GlobalVarAttribute", "PrimType",
1758 "Types", "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI",
1759 "TypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType",
1760 "Module", "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5",
1761 "AsmBlock", "TargetDefinition", "LibrariesDefinition", "LibList",
1762 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
1763 "END", "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
Reid Spencer38c91a92007-02-28 02:24:54 +00001764 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1765 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1766 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1767 "OptVolatile", "MemoryInst", 0
1768};
1769#endif
1770
1771# ifdef YYPRINT
1772/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1773 token YYLEX-NUM. */
1774static const unsigned short int yytoknum[] =
1775{
1776 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1777 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1778 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1779 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1780 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1781 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1782 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1783 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1784 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1785 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1786 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1787 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1788 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001789 385, 386, 387, 388, 389, 61, 44, 42, 92, 40,
1790 41, 91, 120, 93, 60, 62, 123, 125, 99
Reid Spencer38c91a92007-02-28 02:24:54 +00001791};
1792# endif
1793
1794/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1795static const unsigned char yyr1[] =
1796{
Reid Spencer67d8ed92007-03-22 02:14:08 +00001797 0, 149, 150, 150, 150, 150, 150, 150, 150, 150,
1798 150, 151, 151, 151, 151, 151, 151, 152, 152, 152,
Reid Spencer38c91a92007-02-28 02:24:54 +00001799 152, 152, 152, 152, 152, 152, 152, 152, 152, 153,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001800 153, 153, 153, 153, 153, 153, 153, 153, 153, 154,
1801 154, 154, 154, 154, 154, 154, 154, 154, 154, 154,
1802 154, 154, 154, 154, 154, 155, 156, 156, 157, 157,
1803 158, 158, 159, 159, 160, 160, 161, 161, 162, 162,
1804 162, 162, 162, 163, 163, 163, 164, 164, 165, 165,
1805 165, 166, 166, 166, 166, 166, 167, 167, 167, 167,
1806 167, 167, 167, 168, 168, 168, 168, 169, 169, 170,
1807 170, 170, 171, 171, 172, 172, 173, 173, 174, 175,
1808 175, 176, 176, 177, 177, 178, 178, 178, 178, 179,
1809 179, 179, 179, 179, 179, 179, 179, 179, 179, 179,
1810 179, 179, 180, 181, 181, 182, 182, 183, 183, 183,
1811 183, 184, 184, 185, 185, 185, 185, 185, 185, 185,
1812 185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
1813 185, 185, 185, 186, 186, 186, 186, 186, 186, 186,
1814 186, 186, 186, 187, 187, 188, 188, 189, 189, 190,
1815 190, 192, 191, 193, 191, 191, 191, 191, 191, 194,
1816 191, 195, 191, 196, 191, 191, 191, 197, 198, 198,
1817 199, 200, 200, 200, 201, 201, 202, 202, 202, 202,
1818 203, 204, 204, 205, 206, 206, 207, 208, 209, 209,
1819 210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
1820 210, 211, 211, 211, 211, 212, 212, 213, 214, 214,
1821 215, 216, 216, 216, 217, 217, 217, 217, 217, 217,
1822 217, 217, 217, 218, 218, 219, 220, 220, 221, 221,
1823 221, 222, 222, 223, 223, 224, 224, 224, 224, 224,
1824 224, 224, 224, 224, 224, 224, 224, 224, 225, 225,
1825 226, 226, 226, 226, 226, 226, 226, 226
Reid Spencer38c91a92007-02-28 02:24:54 +00001826};
1827
1828/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1829static const unsigned char yyr2[] =
1830{
1831 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1832 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1833 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1834 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1835 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1836 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1837 1, 0, 2, 0, 1, 1, 2, 0, 1, 1,
1838 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
1839 1, 0, 1, 1, 1, 1, 0, 1, 1, 1,
1840 1, 1, 2, 1, 1, 1, 1, 0, 2, 1,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001841 1, 1, 0, 2, 0, 2, 0, 3, 2, 0,
1842 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1843 1, 2, 1, 2, 5, 5, 5, 5, 3, 2,
1844 5, 4, 2, 1, 1, 1, 3, 1, 3, 1,
1845 0, 1, 3, 4, 3, 3, 4, 4, 3, 6,
1846 5, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1847 2, 2, 2, 6, 5, 8, 6, 6, 7, 7,
1848 6, 8, 8, 3, 1, 1, 1, 1, 0, 1,
1849 2, 0, 3, 0, 3, 3, 1, 3, 3, 0,
1850 6, 0, 7, 0, 7, 2, 3, 1, 3, 3,
1851 3, 3, 1, 0, 5, 3, 1, 3, 1, 0,
1852 9, 1, 1, 4, 1, 1, 2, 3, 0, 1,
1853 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
1854 5, 1, 1, 1, 1, 1, 1, 2, 2, 2,
1855 3, 2, 0, 1, 2, 2, 3, 9, 9, 8,
1856 14, 1, 1, 6, 5, 2, 6, 7, 3, 5,
1857 0, 0, 3, 2, 1, 5, 5, 6, 6, 4,
1858 6, 4, 4, 6, 6, 2, 8, 1, 1, 0,
1859 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer38c91a92007-02-28 02:24:54 +00001860};
1861
1862/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1863 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1864 means the default is an error. */
1865static const unsigned short int yydefact[] =
1866{
Reid Spencer67d8ed92007-03-22 02:14:08 +00001867 67, 58, 64, 59, 65, 186, 183, 181, 0, 0,
1868 0, 0, 0, 0, 76, 0, 67, 179, 78, 81,
1869 0, 0, 195, 0, 0, 62, 0, 66, 68, 70,
Reid Spencer38c91a92007-02-28 02:24:54 +00001870 69, 71, 73, 72, 74, 75, 77, 76, 76, 0,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001871 1, 180, 79, 80, 76, 184, 82, 83, 84, 85,
1872 76, 242, 182, 242, 0, 0, 203, 196, 197, 185,
1873 231, 232, 188, 115, 116, 117, 118, 119, 0, 0,
1874 0, 0, 233, 234, 120, 187, 122, 0, 0, 175,
1875 176, 0, 86, 86, 243, 239, 63, 214, 215, 216,
1876 238, 198, 199, 202, 0, 140, 123, 0, 0, 0,
1877 0, 129, 141, 0, 121, 140, 0, 0, 115, 116,
1878 117, 0, 0, 0, 189, 0, 87, 88, 89, 90,
1879 91, 0, 217, 0, 279, 241, 0, 200, 139, 97,
1880 135, 137, 0, 0, 0, 0, 0, 0, 128, 0,
1881 191, 193, 160, 161, 156, 158, 157, 159, 162, 155,
1882 151, 152, 2, 3, 4, 5, 6, 7, 8, 9,
Reid Spencer38c91a92007-02-28 02:24:54 +00001883 10, 14, 15, 16, 11, 12, 13, 0, 0, 0,
1884 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1885 27, 28, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001886 0, 0, 0, 154, 153, 111, 92, 134, 133, 0,
1887 211, 212, 213, 278, 264, 0, 0, 0, 0, 86,
1888 251, 252, 0, 0, 0, 0, 0, 0, 0, 0,
1889 0, 0, 0, 0, 0, 0, 0, 240, 86, 255,
1890 0, 277, 201, 132, 0, 102, 0, 0, 131, 0,
1891 142, 102, 111, 111, 29, 30, 31, 32, 33, 34,
Reid Spencer38c91a92007-02-28 02:24:54 +00001892 35, 36, 37, 38, 0, 53, 54, 49, 50, 51,
1893 52, 39, 40, 41, 42, 43, 44, 45, 46, 47,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001894 48, 0, 0, 0, 0, 0, 0, 144, 174, 0,
1895 0, 0, 148, 0, 145, 0, 0, 0, 0, 190,
1896 0, 263, 245, 0, 244, 0, 0, 55, 0, 0,
1897 0, 0, 106, 106, 284, 0, 0, 275, 0, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00001898 0, 0, 0, 0, 0, 0, 0, 0, 0, 93,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001899 94, 95, 96, 98, 138, 136, 125, 126, 127, 130,
1900 124, 192, 194, 0, 0, 261, 0, 0, 0, 0,
1901 0, 143, 129, 141, 0, 146, 147, 0, 0, 0,
1902 0, 0, 113, 111, 209, 220, 221, 222, 227, 223,
1903 224, 225, 226, 218, 0, 229, 236, 235, 237, 0,
1904 246, 0, 0, 0, 0, 0, 280, 0, 282, 261,
Reid Spencer38c91a92007-02-28 02:24:54 +00001905 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001906 0, 0, 0, 99, 100, 101, 103, 0, 0, 0,
1907 0, 0, 0, 0, 173, 150, 0, 0, 0, 0,
1908 108, 114, 112, 208, 97, 206, 0, 219, 0, 0,
1909 0, 0, 0, 0, 0, 0, 0, 0, 287, 0,
1910 0, 0, 271, 272, 0, 0, 0, 0, 269, 0,
1911 285, 0, 0, 0, 0, 164, 0, 0, 0, 0,
1912 149, 0, 0, 0, 61, 0, 102, 0, 228, 0,
1913 0, 260, 0, 0, 106, 107, 106, 0, 0, 0,
1914 0, 0, 265, 266, 260, 0, 0, 0, 262, 0,
1915 170, 0, 0, 166, 167, 163, 60, 205, 207, 97,
1916 109, 0, 0, 0, 0, 0, 267, 268, 0, 281,
1917 283, 0, 0, 270, 273, 274, 0, 286, 168, 169,
1918 0, 0, 0, 61, 110, 104, 230, 0, 0, 97,
1919 0, 102, 256, 0, 102, 165, 171, 172, 204, 0,
1920 210, 0, 249, 0, 0, 258, 0, 0, 257, 276,
1921 105, 247, 0, 248, 0, 97, 0, 0, 0, 259,
1922 0, 0, 0, 0, 254, 0, 0, 253, 0, 250
Reid Spencer38c91a92007-02-28 02:24:54 +00001923};
1924
1925/* YYDEFGOTO[NTERM-NUM]. */
1926static const short int yydefgoto[] =
1927{
Reid Spencer67d8ed92007-03-22 02:14:08 +00001928 -1, 190, 191, 192, 254, 271, 111, 112, 72, 487,
Reid Spencer38c91a92007-02-28 02:24:54 +00001929 12, 73, 14, 37, 38, 39, 44, 50, 121, 323,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001930 233, 396, 326, 530, 376, 352, 515, 289, 353, 74,
Reid Spencer38c91a92007-02-28 02:24:54 +00001931 113, 130, 199, 131, 132, 103, 278, 365, 279, 81,
1932 15, 16, 17, 19, 18, 195, 242, 243, 59, 22,
Reid Spencer67d8ed92007-03-22 02:14:08 +00001933 57, 94, 415, 416, 122, 202, 51, 89, 52, 45,
1934 418, 366, 76, 368, 294, 53, 85, 86, 227, 534,
1935 125, 307, 495, 399, 228, 229, 230, 231
Reid Spencer38c91a92007-02-28 02:24:54 +00001936};
1937
1938/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1939 STATE-NUM. */
Reid Spencer67d8ed92007-03-22 02:14:08 +00001940#define YYPACT_NINF -472
Reid Spencer38c91a92007-02-28 02:24:54 +00001941static const short int yypact[] =
1942{
Reid Spencer67d8ed92007-03-22 02:14:08 +00001943 44, -472, -472, -472, -472, -472, -472, -472, -9, -93,
1944 25, -40, 89, 40, 303, 124, 406, -472, 137, 199,
1945 48, 73, -472, 72, 147, -472, 1101, -472, -472, -472,
1946 -472, -472, -472, -472, -472, -472, -472, 86, 86, 110,
1947 -472, -472, -472, -472, 86, -472, -472, -472, -472, -472,
1948 86, 215, -472, 9, 216, 228, 233, -472, -472, -472,
1949 -472, -472, 118, -472, -472, -472, -472, -472, 250, 254,
1950 4, 115, -472, -472, -472, 88, -472, 110, 110, -472,
1951 -472, 1115, 310, 310, -472, -472, 31, -472, -472, -472,
1952 -472, -472, -472, -472, -22, 955, -472, 135, 138, 141,
1953 118, -472, 88, -102, -472, 955, 1115, 1153, 52, 251,
1954 269, 239, 272, 739, -472, 280, -472, -472, -472, -472,
1955 -472, 1167, -472, -8, 1306, -472, 270, -472, -472, 88,
1956 -472, 154, 155, 1153, 1153, 156, -55, 1153, -472, 164,
1957 -472, 88, -472, -472, -472, -472, -472, -472, -472, -472,
1958 -472, -472, -472, -472, -472, -472, -472, -472, -472, -472,
1959 -472, -472, -472, -472, -472, -472, -472, 289, 447, 166,
1960 -472, -472, -472, -472, -472, -472, -472, -472, -472, -472,
1961 -472, -472, 168, 169, 170, 171, 995, 1206, 491, 292,
1962 174, 175, 176, -472, -472, 182, -472, 118, 88, 49,
1963 -472, -472, -472, -472, -472, 273, 1221, 122, 313, 310,
1964 -472, -472, 289, 447, 1153, 1153, 1153, 1153, 1153, 1153,
1965 1153, 1153, 1153, 1153, 1153, 1153, 1153, -472, 310, -472,
1966 38, -472, -472, -24, 1010, -472, 34, -26, -472, 180,
1967 88, -472, 182, 182, -472, -472, -472, -472, -472, -472,
1968 -472, -472, -472, -472, 187, -472, -472, -472, -472, -472,
1969 -472, -472, -472, -472, -472, -472, -472, -472, -472, -472,
1970 -472, 188, 1115, 1115, 1115, 1115, 1115, -472, -472, -6,
1971 909, -104, -472, -42, -472, 1115, 1115, 1115, -11, -472,
1972 195, -472, 118, 592, -472, 718, 718, -472, 718, 1167,
1973 1153, 1153, -21, 93, -472, 592, 35, 200, 203, 211,
1974 213, 214, 218, 592, 592, 302, 1167, 1153, 1153, -472,
1975 -472, -472, -472, -472, -472, -472, -29, -472, -472, -472,
1976 -29, -472, -472, 1115, 1115, -472, 219, 235, 255, 256,
1977 1115, -472, 207, 739, -37, -472, -472, 258, 261, 354,
1978 371, 395, -472, 182, 1050, -472, -472, -472, -472, -472,
1979 -472, -472, -472, 346, 1115, -472, -472, -472, -472, 266,
1980 -472, 267, 718, 592, 592, 19, -472, 20, -472, -472,
1981 718, 263, 1153, 1153, 1153, 1153, 1153, 271, 274, 1153,
1982 718, 592, 279, -472, -472, -472, -472, 281, 282, 29,
1983 1115, 1115, 1115, 1115, -472, -472, 284, 1115, 1115, 1153,
1984 -472, -472, -472, -472, 88, 288, 268, -472, 412, -96,
1985 418, 421, 299, 304, 305, 718, 435, 718, 306, 307,
1986 718, 311, 88, -472, 312, 314, 718, 718, 88, 317,
1987 -472, 1153, 1115, 1115, 1153, -472, 315, 318, 324, 325,
1988 -472, 323, 326, 157, 32, 1066, -472, 328, -472, 718,
1989 718, 1153, 718, 718, 329, -472, 329, 718, 331, 1153,
1990 1153, 1153, -472, -472, 1153, 592, 335, 338, -472, 1115,
1991 -472, 1115, 1115, -472, -472, -472, -472, -472, -472, 88,
1992 136, 434, 332, 341, 592, 71, -472, -472, 431, -472,
1993 -472, 340, 718, -472, -472, -472, 74, -472, -472, -472,
1994 345, 347, 348, 32, -472, 438, -472, 455, -2, -472,
1995 1153, -472, -472, 349, -472, -472, -472, -472, -472, 485,
1996 -472, 718, -472, 866, -1, -24, 592, 190, -472, -29,
1997 -472, -472, 357, -472, 866, -472, 480, 482, 361, -24,
1998 718, 718, 486, 440, -472, 718, 495, -472, 718, -472
Reid Spencer38c91a92007-02-28 02:24:54 +00001999};
2000
2001/* YYPGOTO[NTERM-NUM]. */
2002static const short int yypgoto[] =
2003{
Reid Spencer67d8ed92007-03-22 02:14:08 +00002004 -472, 388, 390, 391, 308, 309, -206, -472, 0, 3,
2005 432, 13, -472, -472, -472, 41, -472, -472, -195, -311,
2006 -402, -472, -238, -472, -296, 27, -472, -189, -472, -472,
2007 -25, 285, -273, -472, 416, 424, -70, -109, -182, 173,
2008 -472, -472, 508, -472, -472, -472, -472, -472, -472, -472,
2009 -472, -472, -472, -472, 443, -472, -472, -472, -472, -472,
2010 -472, -471, -74, 100, -198, -472, 475, -472, -472, -472,
2011 -472, -472, 55, 152, -472, -472, -472, -472
Reid Spencer38c91a92007-02-28 02:24:54 +00002012};
2013
2014/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2015 positive, shift that token. If negative, reduce the rule which
2016 number is the opposite. If zero, do what YYDEFACT says.
2017 If YYTABLE_NINF, syntax error. */
Reid Spencer67d8ed92007-03-22 02:14:08 +00002018#define YYTABLE_NINF -179
Reid Spencer38c91a92007-02-28 02:24:54 +00002019static const short int yytable[] =
2020{
Reid Spencer67d8ed92007-03-22 02:14:08 +00002021 11, 75, 298, 330, 193, 281, 283, 378, 98, 297,
2022 297, 114, 454, 13, 299, 395, 11, 200, 304, 395,
2023 350, 308, 309, 310, 311, 312, 372, 84, 315, 13,
2024 425, 427, 340, 316, 137, 87, 140, 351, 20, 194,
2025 340, 345, 23, 390, -178, 138, 102, 1, 1, 458,
2026 3, 3, 21, 331, 332, -55, -55, -55, -55, -63,
2027 1, 2, 542, 3, 4, 5, 2, 426, 426, 4,
2028 129, 6, 7, 548, 102, 142, 143, 24, 77, 78,
2029 129, 137, 141, 319, 320, 82, 11, 513, 319, 320,
2030 8, 83, 239, 9, 340, 25, 198, 10, 344, 340,
2031 393, 321, 322, 394, 26, 346, 321, 322, 236, 237,
2032 406, 104, 240, 105, 126, 375, 104, 535, 105, 328,
2033 392, 127, 60, 61, 40, 100, 63, 64, 65, 66,
2034 340, 1, 2, 295, 3, 4, 296, 341, 201, 79,
2035 80, 532, 543, 549, 319, 320, 317, 318, 60, 61,
2036 99, 100, 63, 64, 65, 66, 88, 1, 2, 67,
2037 3, 4, 321, 322, 412, 444, 58, 350, 499, 445,
2038 500, 104, 104, 105, 105, 27, 380, 327, 42, 395,
2039 43, 293, 419, 54, 431, 67, 433, 434, 435, 302,
Reid Spencer38c91a92007-02-28 02:24:54 +00002040 303, 293, 305, 306, 293, 293, 293, 293, 293, 313,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002041 314, 293, 335, 336, 337, 338, 339, 520, 55, 129,
2042 520, 521, 290, 56, 524, 347, 348, 349, 490, 367,
2043 36, 367, 367, 546, 367, 104, 395, 105, 395, 377,
2044 104, 367, 105, 84, 193, 91, 46, 47, 48, 367,
2045 367, 49, 144, 145, 146, 147, 478, 92, 319, 320,
2046 106, 107, 93, 68, 96, 343, 69, 95, 97, 70,
2047 -56, 71, 101, 397, 398, 393, 321, 322, 394, 194,
2048 404, 503, 504, 505, 198, 373, 374, 133, -57, 68,
2049 134, 148, 69, 537, 196, 70, 539, 71, 135, 232,
2050 234, 198, 391, 293, 104, 235, 105, 485, 367, 367,
2051 367, 238, 319, 320, 241, 272, 367, 273, 274, 275,
2052 276, 284, 533, 285, 286, 287, 367, 367, 288, 393,
2053 321, 322, 394, 291, 297, 329, 333, 334, 544, 414,
2054 446, 447, 448, 449, 354, 389, 381, 451, 452, 382,
2055 28, 29, 30, 31, 32, 33, 34, 383, 35, 384,
2056 385, 367, 405, 367, 386, 400, 367, 293, 432, 293,
2057 293, 293, 367, 367, 438, 115, 116, 117, 118, 119,
2058 120, 401, 476, 477, 244, 245, 246, 247, 248, 249,
2059 250, 251, 252, 253, 453, 367, 367, 409, 367, 367,
2060 410, 402, 403, 367, 407, 369, 370, 408, 371, 411,
2061 417, 367, 420, 421, 430, 379, -177, 436, 456, 510,
2062 437, 511, 512, 387, 388, 441, 475, 442, 443, 293,
2063 367, -63, 1, 2, 455, 3, 4, 5, 367, 450,
2064 489, 457, 459, 6, 7, 460, 494, 36, 461, 465,
2065 462, 463, 444, 467, 293, 293, 293, 469, 470, 494,
2066 471, 479, 8, 516, 486, 9, 474, 367, 480, 10,
2067 481, 482, 367, 483, 491, 498, 484, 502, 517, 531,
2068 255, 256, 422, 423, 424, 508, 367, 367, 509, 426,
2069 429, 367, 518, 522, 367, 525, 529, 526, 527, 540,
2070 439, 440, 538, 547, 550, 536, 551, 552, 60, 61,
2071 555, 100, 108, 109, 110, 66, 556, 1, 2, 558,
2072 3, 4, 224, 486, 225, 226, 528, 514, 124, 325,
2073 300, 139, 301, 136, 41, 464, 123, 466, 90, 506,
2074 468, 428, 0, 0, 0, 67, 472, 473, 257, 258,
2075 259, 260, 261, 262, 263, 264, 265, 266, 267, 268,
2076 269, 270, 0, 0, 0, 0, 0, 0, 0, 492,
2077 493, 0, 496, 497, 0, 0, 0, 501, 0, 0,
2078 0, 0, 0, 0, 0, 507, 0, 0, 0, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00002079 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002080 0, 0, 0, 0, 519, 355, 356, 0, 0, 60,
2081 61, 357, 523, 0, 0, 0, 0, 0, 1, 2,
2082 0, 3, 4, 0, 358, 359, 360, 0, 0, 0,
2083 0, 0, 0, 0, 0, 0, 0, 361, 362, 68,
2084 0, 541, 69, 0, 0, 70, 545, 71, 282, 0,
2085 0, 0, 0, 0, 363, 0, 0, 0, 0, 0,
2086 553, 554, 0, 0, 0, 557, 0, 0, 559, 0,
2087 152, 153, 154, 155, 156, 157, 158, 159, 160, 161,
2088 162, 163, 164, 165, 166, 167, 168, 0, 0, 0,
2089 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2090 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2091 0, 0, 169, 170, 171, 172, 173, 174, 175, 176,
2092 177, 178, 179, 180, 181, 0, 182, 0, 183, 184,
2093 185, 355, 356, 0, 0, 60, 61, 357, 0, 104,
2094 0, 105, 0, 0, 1, 2, 364, 3, 4, 0,
2095 358, 359, 360, 0, 0, 0, 60, 61, 0, 0,
2096 0, 0, 0, 361, 362, 1, 2, 0, 3, 4,
2097 0, 149, 0, 0, 0, 0, 0, 0, 0, 0,
2098 363, 0, 0, 0, 150, 151, 0, 0, 0, 0,
2099 0, 0, 0, 0, 0, 0, 152, 153, 154, 155,
2100 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
2101 166, 167, 168, 0, 0, 0, 0, 152, 153, 154,
2102 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
2103 165, 166, 167, 168, 0, 0, 0, 0, 169, 170,
2104 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
2105 181, 0, 182, 0, 183, 184, 185, 0, 0, 169,
2106 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
2107 180, 181, 364, 182, 0, 183, 184, 185, 0, 355,
2108 356, 0, 0, 0, 0, 357, 104, 0, 105, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00002109 186, 0, 0, 187, 0, 188, 0, 189, 358, 359,
2110 360, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2111 0, 361, 362, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002112 0, 0, 0, 0, 0, 0, 60, 61, 363, 100,
2113 108, 109, 110, 66, 0, 1, 2, 0, 3, 4,
Reid Spencer38c91a92007-02-28 02:24:54 +00002114 0, 0, 0, 0, 152, 153, 154, 155, 156, 157,
2115 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002116 168, 0, 0, 67, 0, 0, 0, 0, 0, 0,
2117 0, 0, 60, 61, 0, 100, 63, 64, 65, 66,
2118 0, 1, 2, 0, 3, 4, 169, 170, 171, 172,
2119 173, 174, 175, 176, 177, 178, 179, 180, 181, 128,
2120 182, 0, 183, 184, 185, 0, 0, 0, 0, 67,
2121 0, 0, 60, 61, 0, 100, 108, 109, 110, 66,
2122 364, 1, 2, 0, 3, 4, 0, 60, 61, 0,
2123 100, 63, 64, 65, 66, 0, 1, 2, 0, 3,
2124 4, 0, 0, 0, 0, 0, 0, 0, 0, 67,
2125 0, 0, 0, 0, 324, 0, 0, 68, 0, 0,
2126 69, 0, 0, 70, 67, 71, 342, 60, 61, 0,
2127 100, 63, 64, 65, 66, 0, 1, 2, 0, 3,
2128 4, 0, 0, 60, 61, 0, 100, 63, 64, 65,
2129 66, 0, 1, 2, 413, 3, 4, 0, 0, 0,
2130 0, 0, 0, 68, 67, 0, 69, 0, 0, 70,
2131 488, 71, 0, 0, 0, 0, 0, 0, 60, 61,
2132 67, 62, 63, 64, 65, 66, 0, 1, 2, 0,
2133 3, 4, 60, 61, 0, 100, 108, 109, 110, 66,
2134 0, 1, 2, 68, 3, 4, 69, 0, 277, 70,
2135 0, 71, 0, 0, 0, 67, 0, 0, 68, 0,
2136 0, 69, 0, 0, 70, 0, 71, 0, 0, 67,
2137 60, 61, 0, 100, 63, 64, 65, 66, 0, 1,
2138 2, 0, 3, 4, 60, 61, 0, 197, 63, 64,
2139 65, 66, 0, 1, 2, 0, 3, 4, 68, 0,
2140 0, 69, 0, 0, 70, 0, 71, 67, 0, 0,
2141 0, 0, 0, 0, 68, 0, 0, 69, 0, 0,
2142 70, 67, 71, 60, 61, 0, 100, 108, 109, 110,
2143 66, 0, 1, 2, 0, 3, 4, 0, 60, 61,
2144 0, 292, 63, 64, 65, 66, 0, 1, 2, 68,
2145 3, 4, 69, 0, 0, 70, 0, 71, 0, 0,
2146 67, 0, 0, 68, 0, 0, 69, 0, 0, 70,
2147 0, 71, 0, 0, 0, 67, 0, 0, 0, 0,
2148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2149 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00002150 0, 68, 0, 0, 69, 0, 0, 70, 0, 71,
Reid Spencer38c91a92007-02-28 02:24:54 +00002151 0, 0, 0, 0, 0, 68, 0, 0, 69, 0,
2152 0, 70, 0, 71, 0, 0, 0, 0, 0, 0,
2153 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002154 0, 0, 0, 0, 0, 0, 0, 0, 203, 0,
2155 0, 0, 0, 0, 68, 0, 0, 69, 0, 0,
2156 70, 0, 280, 0, 0, 0, 204, 205, 0, 68,
2157 0, 0, 69, 0, 0, 70, 0, 71, 206, 207,
2158 208, 209, 210, 211, 152, 153, 154, 155, 156, 157,
2159 158, 159, 160, 161, 162, 163, 164, 165, 166, 212,
2160 213, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer38c91a92007-02-28 02:24:54 +00002161 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002162 0, 214, 215, 216, 0, 0, 217, 170, 171, 172,
2163 173, 174, 175, 176, 177, 178, 179, 180, 181, 218,
2164 219, 220, 221, 222, 223
Reid Spencer38c91a92007-02-28 02:24:54 +00002165};
2166
2167static const short int yycheck[] =
2168{
Reid Spencer67d8ed92007-03-22 02:14:08 +00002169 0, 26, 208, 241, 113, 187, 188, 303, 4, 11,
2170 11, 81, 414, 0, 209, 326, 16, 25, 216, 330,
2171 31, 219, 220, 221, 222, 223, 299, 18, 226, 16,
2172 11, 11, 136, 228, 136, 26, 106, 48, 47, 113,
2173 136, 145, 135, 316, 0, 147, 71, 16, 16, 145,
2174 19, 19, 61, 242, 243, 3, 4, 5, 6, 15,
2175 16, 17, 533, 19, 20, 21, 17, 48, 48, 20,
2176 95, 27, 28, 544, 99, 23, 24, 52, 37, 38,
2177 105, 136, 107, 112, 113, 44, 86, 489, 112, 113,
2178 46, 50, 147, 49, 136, 135, 121, 53, 280, 136,
2179 129, 130, 131, 132, 15, 147, 130, 131, 133, 134,
2180 147, 137, 137, 139, 136, 136, 137, 519, 139, 145,
2181 318, 143, 7, 8, 0, 10, 11, 12, 13, 14,
2182 136, 16, 17, 11, 19, 20, 14, 143, 146, 29,
2183 30, 143, 143, 545, 112, 113, 108, 109, 7, 8,
2184 146, 10, 11, 12, 13, 14, 147, 16, 17, 44,
2185 19, 20, 130, 131, 353, 136, 19, 31, 464, 140,
2186 466, 137, 137, 139, 139, 135, 141, 143, 41, 490,
2187 43, 206, 364, 135, 382, 44, 384, 385, 386, 214,
Reid Spencer38c91a92007-02-28 02:24:54 +00002188 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002189 225, 226, 272, 273, 274, 275, 276, 136, 135, 234,
2190 136, 140, 199, 141, 140, 285, 286, 287, 456, 293,
2191 134, 295, 296, 33, 298, 137, 537, 139, 539, 136,
2192 137, 305, 139, 18, 343, 19, 37, 38, 39, 313,
2193 314, 42, 3, 4, 5, 6, 444, 19, 112, 113,
2194 77, 78, 19, 138, 4, 280, 141, 139, 4, 144,
2195 9, 146, 147, 333, 334, 129, 130, 131, 132, 343,
2196 340, 469, 470, 471, 299, 300, 301, 142, 9, 138,
2197 142, 9, 141, 521, 4, 144, 524, 146, 147, 19,
2198 136, 316, 317, 318, 137, 140, 139, 140, 372, 373,
2199 374, 145, 112, 113, 140, 139, 380, 139, 139, 139,
2200 139, 19, 518, 139, 139, 139, 390, 391, 136, 129,
2201 130, 131, 132, 50, 11, 145, 139, 139, 534, 354,
2202 400, 401, 402, 403, 139, 33, 136, 407, 408, 136,
2203 37, 38, 39, 40, 41, 42, 43, 136, 45, 136,
2204 136, 425, 145, 427, 136, 136, 430, 382, 383, 384,
2205 385, 386, 436, 437, 389, 55, 56, 57, 58, 59,
2206 60, 136, 442, 443, 85, 86, 87, 88, 89, 90,
2207 91, 92, 93, 94, 409, 459, 460, 33, 462, 463,
2208 19, 136, 136, 467, 136, 295, 296, 136, 298, 4,
2209 54, 475, 136, 136, 141, 305, 0, 136, 140, 479,
2210 136, 481, 482, 313, 314, 136, 441, 136, 136, 444,
2211 494, 15, 16, 17, 136, 19, 20, 21, 502, 145,
2212 455, 19, 14, 27, 28, 14, 461, 134, 139, 4,
2213 136, 136, 136, 136, 469, 470, 471, 136, 136, 474,
2214 136, 136, 46, 19, 454, 49, 139, 531, 140, 53,
2215 136, 136, 536, 140, 136, 136, 140, 136, 136, 14,
2216 23, 24, 372, 373, 374, 140, 550, 551, 140, 48,
2217 380, 555, 141, 143, 558, 140, 48, 140, 140, 4,
2218 390, 391, 143, 136, 14, 520, 14, 136, 7, 8,
2219 14, 10, 11, 12, 13, 14, 66, 16, 17, 14,
2220 19, 20, 124, 513, 124, 124, 513, 490, 86, 234,
2221 212, 105, 213, 99, 16, 425, 83, 427, 53, 474,
2222 430, 379, -1, -1, -1, 44, 436, 437, 91, 92,
2223 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
2224 103, 104, -1, -1, -1, -1, -1, -1, -1, 459,
2225 460, -1, 462, 463, -1, -1, -1, 467, -1, -1,
2226 -1, -1, -1, -1, -1, 475, -1, -1, -1, -1,
Reid Spencer38c91a92007-02-28 02:24:54 +00002227 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002228 -1, -1, -1, -1, 494, 3, 4, -1, -1, 7,
2229 8, 9, 502, -1, -1, -1, -1, -1, 16, 17,
2230 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2231 -1, -1, -1, -1, -1, -1, -1, 35, 36, 138,
2232 -1, 531, 141, -1, -1, 144, 536, 146, 147, -1,
2233 -1, -1, -1, -1, 52, -1, -1, -1, -1, -1,
2234 550, 551, -1, -1, -1, 555, -1, -1, 558, -1,
2235 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2236 78, 79, 80, 81, 82, 83, 84, -1, -1, -1,
2237 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2238 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2239 -1, -1, 110, 111, 112, 113, 114, 115, 116, 117,
2240 118, 119, 120, 121, 122, -1, 124, -1, 126, 127,
2241 128, 3, 4, -1, -1, 7, 8, 9, -1, 137,
2242 -1, 139, -1, -1, 16, 17, 144, 19, 20, -1,
2243 22, 23, 24, -1, -1, -1, 7, 8, -1, -1,
2244 -1, -1, -1, 35, 36, 16, 17, -1, 19, 20,
2245 -1, 22, -1, -1, -1, -1, -1, -1, -1, -1,
2246 52, -1, -1, -1, 35, 36, -1, -1, -1, -1,
2247 -1, -1, -1, -1, -1, -1, 68, 69, 70, 71,
2248 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2249 82, 83, 84, -1, -1, -1, -1, 68, 69, 70,
2250 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2251 81, 82, 83, 84, -1, -1, -1, -1, 110, 111,
2252 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2253 122, -1, 124, -1, 126, 127, 128, -1, -1, 110,
2254 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
2255 121, 122, 144, 124, -1, 126, 127, 128, -1, 3,
2256 4, -1, -1, -1, -1, 9, 137, -1, 139, -1,
2257 141, -1, -1, 144, -1, 146, -1, 148, 22, 23,
Reid Spencer38c91a92007-02-28 02:24:54 +00002258 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2259 -1, 35, 36, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002260 -1, -1, -1, -1, -1, -1, 7, 8, 52, 10,
2261 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
Reid Spencer38c91a92007-02-28 02:24:54 +00002262 -1, -1, -1, -1, 68, 69, 70, 71, 72, 73,
2263 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002264 84, -1, -1, 44, -1, -1, -1, -1, -1, -1,
2265 -1, -1, 7, 8, -1, 10, 11, 12, 13, 14,
2266 -1, 16, 17, -1, 19, 20, 110, 111, 112, 113,
2267 114, 115, 116, 117, 118, 119, 120, 121, 122, 34,
2268 124, -1, 126, 127, 128, -1, -1, -1, -1, 44,
2269 -1, -1, 7, 8, -1, 10, 11, 12, 13, 14,
2270 144, 16, 17, -1, 19, 20, -1, 7, 8, -1,
2271 10, 11, 12, 13, 14, -1, 16, 17, -1, 19,
2272 20, -1, -1, -1, -1, -1, -1, -1, -1, 44,
2273 -1, -1, -1, -1, 34, -1, -1, 138, -1, -1,
2274 141, -1, -1, 144, 44, 146, 147, 7, 8, -1,
2275 10, 11, 12, 13, 14, -1, 16, 17, -1, 19,
2276 20, -1, -1, 7, 8, -1, 10, 11, 12, 13,
2277 14, -1, 16, 17, 34, 19, 20, -1, -1, -1,
2278 -1, -1, -1, 138, 44, -1, 141, -1, -1, 144,
2279 34, 146, -1, -1, -1, -1, -1, -1, 7, 8,
2280 44, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2281 19, 20, 7, 8, -1, 10, 11, 12, 13, 14,
2282 -1, 16, 17, 138, 19, 20, 141, -1, 143, 144,
2283 -1, 146, -1, -1, -1, 44, -1, -1, 138, -1,
2284 -1, 141, -1, -1, 144, -1, 146, -1, -1, 44,
2285 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
Reid Spencer38c91a92007-02-28 02:24:54 +00002286 17, -1, 19, 20, 7, 8, -1, 10, 11, 12,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002287 13, 14, -1, 16, 17, -1, 19, 20, 138, -1,
2288 -1, 141, -1, -1, 144, -1, 146, 44, -1, -1,
2289 -1, -1, -1, -1, 138, -1, -1, 141, -1, -1,
2290 144, 44, 146, 7, 8, -1, 10, 11, 12, 13,
2291 14, -1, 16, 17, -1, 19, 20, -1, 7, 8,
2292 -1, 10, 11, 12, 13, 14, -1, 16, 17, 138,
2293 19, 20, 141, -1, -1, 144, -1, 146, -1, -1,
2294 44, -1, -1, 138, -1, -1, 141, -1, -1, 144,
2295 -1, 146, -1, -1, -1, 44, -1, -1, -1, -1,
Reid Spencer38c91a92007-02-28 02:24:54 +00002296 -1, -1, -1, -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 Spencer67d8ed92007-03-22 02:14:08 +00002298 -1, 138, -1, -1, 141, -1, -1, 144, -1, 146,
2299 -1, -1, -1, -1, -1, 138, -1, -1, 141, -1,
2300 -1, 144, -1, 146, -1, -1, -1, -1, -1, -1,
2301 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2302 -1, -1, -1, -1, -1, -1, -1, -1, 32, -1,
2303 -1, -1, -1, -1, 138, -1, -1, 141, -1, -1,
2304 144, -1, 146, -1, -1, -1, 50, 51, -1, 138,
2305 -1, -1, 141, -1, -1, 144, -1, 146, 62, 63,
2306 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
2307 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2308 84, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2309 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2310 -1, 105, 106, 107, -1, -1, 110, 111, 112, 113,
2311 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2312 124, 125, 126, 127, 128
Reid Spencer38c91a92007-02-28 02:24:54 +00002313};
2314
2315/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2316 symbol of state STATE-NUM. */
2317static const unsigned char yystos[] =
2318{
2319 0, 16, 17, 19, 20, 21, 27, 28, 46, 49,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002320 53, 157, 159, 160, 161, 189, 190, 191, 193, 192,
2321 47, 61, 198, 135, 52, 135, 15, 135, 37, 38,
2322 39, 40, 41, 42, 43, 45, 134, 162, 163, 164,
2323 0, 191, 41, 43, 165, 208, 37, 38, 39, 42,
2324 166, 205, 207, 214, 135, 135, 141, 199, 19, 197,
2325 7, 8, 10, 11, 12, 13, 14, 44, 138, 141,
2326 144, 146, 157, 160, 178, 179, 211, 164, 164, 29,
2327 30, 188, 164, 164, 18, 215, 216, 26, 147, 206,
2328 215, 19, 19, 19, 200, 139, 4, 4, 4, 146,
2329 10, 147, 179, 184, 137, 139, 188, 188, 11, 12,
2330 13, 155, 156, 179, 185, 55, 56, 57, 58, 59,
2331 60, 167, 203, 203, 159, 219, 136, 143, 34, 179,
2332 180, 182, 183, 142, 142, 147, 184, 136, 147, 183,
2333 185, 179, 23, 24, 3, 4, 5, 6, 9, 22,
Reid Spencer38c91a92007-02-28 02:24:54 +00002334 35, 36, 68, 69, 70, 71, 72, 73, 74, 75,
2335 76, 77, 78, 79, 80, 81, 82, 83, 84, 110,
2336 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002337 121, 122, 124, 126, 127, 128, 141, 144, 146, 148,
2338 150, 151, 152, 186, 211, 194, 4, 10, 179, 181,
2339 25, 146, 204, 32, 50, 51, 62, 63, 64, 65,
Reid Spencer38c91a92007-02-28 02:24:54 +00002340 66, 67, 83, 84, 105, 106, 107, 110, 123, 124,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002341 125, 126, 127, 128, 150, 151, 152, 217, 223, 224,
2342 225, 226, 19, 169, 136, 140, 179, 179, 145, 147,
2343 179, 140, 195, 196, 85, 86, 87, 88, 89, 90,
2344 91, 92, 93, 94, 153, 23, 24, 91, 92, 93,
Reid Spencer38c91a92007-02-28 02:24:54 +00002345 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
Reid Spencer67d8ed92007-03-22 02:14:08 +00002346 104, 154, 139, 139, 139, 139, 139, 143, 185, 187,
2347 146, 187, 147, 187, 19, 139, 139, 139, 136, 176,
2348 160, 50, 10, 179, 213, 11, 14, 11, 155, 167,
2349 153, 154, 179, 179, 213, 179, 179, 220, 213, 213,
2350 213, 213, 213, 179, 179, 213, 167, 108, 109, 112,
2351 113, 130, 131, 168, 34, 180, 171, 143, 145, 145,
2352 171, 176, 176, 139, 139, 185, 185, 185, 185, 185,
2353 136, 143, 147, 179, 187, 145, 147, 185, 185, 185,
2354 31, 48, 174, 177, 139, 3, 4, 9, 22, 23,
2355 24, 35, 36, 52, 144, 186, 210, 211, 212, 212,
2356 212, 212, 181, 179, 179, 136, 173, 136, 173, 212,
2357 141, 136, 136, 136, 136, 136, 136, 212, 212, 33,
2358 181, 179, 213, 129, 132, 168, 170, 185, 185, 222,
2359 136, 136, 136, 136, 185, 145, 147, 136, 136, 33,
2360 19, 4, 176, 34, 179, 201, 202, 54, 209, 187,
2361 136, 136, 212, 212, 212, 11, 48, 11, 222, 212,
2362 141, 213, 179, 213, 213, 213, 136, 136, 179, 212,
2363 212, 136, 136, 136, 136, 140, 185, 185, 185, 185,
2364 145, 185, 185, 179, 169, 136, 140, 19, 145, 14,
2365 14, 139, 136, 136, 212, 4, 212, 136, 212, 136,
2366 136, 136, 212, 212, 139, 179, 185, 185, 213, 136,
2367 140, 136, 136, 140, 140, 140, 157, 158, 34, 179,
2368 171, 136, 212, 212, 179, 221, 212, 212, 136, 173,
2369 173, 212, 136, 213, 213, 213, 221, 212, 140, 140,
2370 185, 185, 185, 169, 174, 175, 19, 136, 141, 212,
2371 136, 140, 143, 212, 140, 140, 140, 140, 158, 48,
2372 172, 14, 143, 155, 218, 169, 179, 171, 143, 171,
2373 4, 212, 210, 143, 155, 212, 33, 136, 210, 169,
2374 14, 14, 136, 212, 212, 14, 66, 212, 14, 212
Reid Spencer38c91a92007-02-28 02:24:54 +00002375};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002376
2377#define yyerrok (yyerrstatus = 0)
2378#define yyclearin (yychar = YYEMPTY)
Reid Spencer38c91a92007-02-28 02:24:54 +00002379#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002380#define YYEOF 0
Reid Spencer38c91a92007-02-28 02:24:54 +00002381
Reid Spencer68a24bd2005-08-27 18:50:39 +00002382#define YYACCEPT goto yyacceptlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002383#define YYABORT goto yyabortlab
2384#define YYERROR goto yyerrorlab
2385
2386
2387/* Like YYERROR except do call yyerror. This remains here temporarily
2388 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002389 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002390
Reid Spencer68a24bd2005-08-27 18:50:39 +00002391#define YYFAIL goto yyerrlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002392
Reid Spencer68a24bd2005-08-27 18:50:39 +00002393#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002394
2395#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002396do \
2397 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer38c91a92007-02-28 02:24:54 +00002398 { \
2399 yychar = (Token); \
2400 yylval = (Value); \
2401 yytoken = YYTRANSLATE (yychar); \
Chris Lattner9d2fda62007-02-13 05:53:56 +00002402 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002403 goto yybackup; \
2404 } \
2405 else \
Reid Spencer38c91a92007-02-28 02:24:54 +00002406 { \
2407 yyerror (YY_("syntax error: cannot back up")); \
2408 YYERROR; \
2409 } \
Chris Lattner9d2fda62007-02-13 05:53:56 +00002410while (0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002411
Reid Spencer38c91a92007-02-28 02:24:54 +00002412
Reid Spencer68a24bd2005-08-27 18:50:39 +00002413#define YYTERROR 1
2414#define YYERRCODE 256
2415
Reid Spencer38c91a92007-02-28 02:24:54 +00002416
2417/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2418 If N is 0, then set CURRENT to the empty location which ends
2419 the previous symbol: RHS[0] (always defined). */
2420
2421#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2422#ifndef YYLLOC_DEFAULT
2423# define YYLLOC_DEFAULT(Current, Rhs, N) \
2424 do \
2425 if (N) \
2426 { \
2427 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2428 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2429 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2430 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2431 } \
2432 else \
2433 { \
2434 (Current).first_line = (Current).last_line = \
2435 YYRHSLOC (Rhs, 0).last_line; \
2436 (Current).first_column = (Current).last_column = \
2437 YYRHSLOC (Rhs, 0).last_column; \
2438 } \
2439 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002440#endif
2441
Reid Spencer38c91a92007-02-28 02:24:54 +00002442
2443/* YY_LOCATION_PRINT -- Print the location on the stream.
2444 This macro was not mandated originally: define only if we know
2445 we won't break user code: when these are the locations we know. */
2446
2447#ifndef YY_LOCATION_PRINT
2448# if YYLTYPE_IS_TRIVIAL
2449# define YY_LOCATION_PRINT(File, Loc) \
2450 fprintf (File, "%d.%d-%d.%d", \
2451 (Loc).first_line, (Loc).first_column, \
2452 (Loc).last_line, (Loc).last_column)
2453# else
2454# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2455# endif
2456#endif
2457
2458
2459/* YYLEX -- calling `yylex' with the right arguments. */
2460
Reid Spencer41dff5e2007-01-26 08:05:27 +00002461#ifdef YYLEX_PARAM
Reid Spencer38c91a92007-02-28 02:24:54 +00002462# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer41dff5e2007-01-26 08:05:27 +00002463#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002464# define YYLEX yylex ()
Chris Lattner32980692007-02-19 07:44:24 +00002465#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002466
2467/* Enable debugging if requested. */
2468#if YYDEBUG
2469
2470# ifndef YYFPRINTF
2471# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2472# define YYFPRINTF fprintf
2473# endif
2474
2475# define YYDPRINTF(Args) \
2476do { \
2477 if (yydebug) \
2478 YYFPRINTF Args; \
2479} while (0)
2480
2481# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2482do { \
2483 if (yydebug) \
2484 { \
2485 YYFPRINTF (stderr, "%s ", Title); \
2486 yysymprint (stderr, \
2487 Type, Value); \
2488 YYFPRINTF (stderr, "\n"); \
2489 } \
2490} while (0)
2491
2492/*------------------------------------------------------------------.
2493| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2494| TOP (included). |
2495`------------------------------------------------------------------*/
2496
2497#if defined (__STDC__) || defined (__cplusplus)
2498static void
2499yy_stack_print (short int *bottom, short int *top)
Chris Lattner32980692007-02-19 07:44:24 +00002500#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002501static void
2502yy_stack_print (bottom, top)
2503 short int *bottom;
2504 short int *top;
Chris Lattner32980692007-02-19 07:44:24 +00002505#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002506{
2507 YYFPRINTF (stderr, "Stack now");
2508 for (/* Nothing. */; bottom <= top; ++bottom)
2509 YYFPRINTF (stderr, " %d", *bottom);
2510 YYFPRINTF (stderr, "\n");
2511}
2512
2513# define YY_STACK_PRINT(Bottom, Top) \
2514do { \
2515 if (yydebug) \
2516 yy_stack_print ((Bottom), (Top)); \
2517} while (0)
2518
2519
2520/*------------------------------------------------.
2521| Report that the YYRULE is going to be reduced. |
2522`------------------------------------------------*/
2523
2524#if defined (__STDC__) || defined (__cplusplus)
2525static void
2526yy_reduce_print (int yyrule)
2527#else
2528static void
2529yy_reduce_print (yyrule)
2530 int yyrule;
Chris Lattner9d2fda62007-02-13 05:53:56 +00002531#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002532{
2533 int yyi;
2534 unsigned long int yylno = yyrline[yyrule];
2535 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2536 yyrule - 1, yylno);
2537 /* Print the symbols being reduced, and their result. */
2538 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2539 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2540 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2541}
Reid Spencer9d6565a2007-02-15 02:26:10 +00002542
Reid Spencer38c91a92007-02-28 02:24:54 +00002543# define YY_REDUCE_PRINT(Rule) \
2544do { \
2545 if (yydebug) \
2546 yy_reduce_print (Rule); \
2547} while (0)
Reid Spencer9d6565a2007-02-15 02:26:10 +00002548
Reid Spencer38c91a92007-02-28 02:24:54 +00002549/* Nonzero means print parse trace. It is left uninitialized so that
2550 multiple parsers can coexist. */
2551int yydebug;
2552#else /* !YYDEBUG */
2553# define YYDPRINTF(Args)
2554# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2555# define YY_STACK_PRINT(Bottom, Top)
2556# define YY_REDUCE_PRINT(Rule)
2557#endif /* !YYDEBUG */
Reid Spencer9d6565a2007-02-15 02:26:10 +00002558
Reid Spencer9d6565a2007-02-15 02:26:10 +00002559
Reid Spencer38c91a92007-02-28 02:24:54 +00002560/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002561#ifndef YYINITDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002562# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002563#endif
2564
Reid Spencer38c91a92007-02-28 02:24:54 +00002565/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2566 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002567
Reid Spencer38c91a92007-02-28 02:24:54 +00002568 Do not make this value too large; the results are undefined if
2569 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2570 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002571
2572#ifndef YYMAXDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002573# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002574#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002575
Reid Spencer68a24bd2005-08-27 18:50:39 +00002576
2577
Reid Spencer38c91a92007-02-28 02:24:54 +00002578#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002579
Reid Spencer38c91a92007-02-28 02:24:54 +00002580# ifndef yystrlen
2581# if defined (__GLIBC__) && defined (_STRING_H)
2582# define yystrlen strlen
2583# else
2584/* Return the length of YYSTR. */
2585static YYSIZE_T
2586# if defined (__STDC__) || defined (__cplusplus)
2587yystrlen (const char *yystr)
2588# else
2589yystrlen (yystr)
2590 const char *yystr;
2591# endif
Chris Lattner32980692007-02-19 07:44:24 +00002592{
Reid Spencer38c91a92007-02-28 02:24:54 +00002593 const char *yys = yystr;
Chris Lattner32980692007-02-19 07:44:24 +00002594
Reid Spencer38c91a92007-02-28 02:24:54 +00002595 while (*yys++ != '\0')
2596 continue;
2597
2598 return yys - yystr - 1;
Chris Lattner32980692007-02-19 07:44:24 +00002599}
Reid Spencer38c91a92007-02-28 02:24:54 +00002600# endif
2601# endif
Chris Lattner32980692007-02-19 07:44:24 +00002602
Reid Spencer38c91a92007-02-28 02:24:54 +00002603# ifndef yystpcpy
2604# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2605# define yystpcpy stpcpy
2606# else
2607/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2608 YYDEST. */
2609static char *
2610# if defined (__STDC__) || defined (__cplusplus)
2611yystpcpy (char *yydest, const char *yysrc)
2612# else
2613yystpcpy (yydest, yysrc)
2614 char *yydest;
2615 const char *yysrc;
2616# endif
Chris Lattner32980692007-02-19 07:44:24 +00002617{
Reid Spencer38c91a92007-02-28 02:24:54 +00002618 char *yyd = yydest;
2619 const char *yys = yysrc;
Chris Lattner32980692007-02-19 07:44:24 +00002620
Reid Spencer38c91a92007-02-28 02:24:54 +00002621 while ((*yyd++ = *yys++) != '\0')
2622 continue;
2623
2624 return yyd - 1;
Chris Lattner32980692007-02-19 07:44:24 +00002625}
Reid Spencer38c91a92007-02-28 02:24:54 +00002626# endif
2627# endif
Chris Lattner32980692007-02-19 07:44:24 +00002628
Reid Spencer38c91a92007-02-28 02:24:54 +00002629# ifndef yytnamerr
2630/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2631 quotes and backslashes, so that it's suitable for yyerror. The
2632 heuristic is that double-quoting is unnecessary unless the string
2633 contains an apostrophe, a comma, or backslash (other than
2634 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2635 null, do not copy; instead, return the length of what the result
2636 would have been. */
2637static YYSIZE_T
2638yytnamerr (char *yyres, const char *yystr)
2639{
2640 if (*yystr == '"')
2641 {
2642 size_t yyn = 0;
2643 char const *yyp = yystr;
2644
2645 for (;;)
2646 switch (*++yyp)
2647 {
2648 case '\'':
2649 case ',':
2650 goto do_not_strip_quotes;
2651
2652 case '\\':
2653 if (*++yyp != '\\')
2654 goto do_not_strip_quotes;
2655 /* Fall through. */
2656 default:
2657 if (yyres)
2658 yyres[yyn] = *yyp;
2659 yyn++;
2660 break;
2661
2662 case '"':
2663 if (yyres)
2664 yyres[yyn] = '\0';
2665 return yyn;
2666 }
2667 do_not_strip_quotes: ;
2668 }
2669
2670 if (! yyres)
2671 return yystrlen (yystr);
2672
2673 return yystpcpy (yyres, yystr) - yyres;
2674}
2675# endif
2676
2677#endif /* YYERROR_VERBOSE */
2678
Reid Spencer9d6565a2007-02-15 02:26:10 +00002679
2680
Reid Spencer38c91a92007-02-28 02:24:54 +00002681#if YYDEBUG
2682/*--------------------------------.
2683| Print this symbol on YYOUTPUT. |
2684`--------------------------------*/
Reid Spencer9d6565a2007-02-15 02:26:10 +00002685
Reid Spencer38c91a92007-02-28 02:24:54 +00002686#if defined (__STDC__) || defined (__cplusplus)
2687static void
2688yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner32980692007-02-19 07:44:24 +00002689#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002690static void
2691yysymprint (yyoutput, yytype, yyvaluep)
2692 FILE *yyoutput;
2693 int yytype;
2694 YYSTYPE *yyvaluep;
2695#endif
2696{
2697 /* Pacify ``unused variable'' warnings. */
2698 (void) yyvaluep;
2699
2700 if (yytype < YYNTOKENS)
2701 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2702 else
2703 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2704
2705
2706# ifdef YYPRINT
2707 if (yytype < YYNTOKENS)
2708 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2709# endif
2710 switch (yytype)
2711 {
2712 default:
2713 break;
2714 }
2715 YYFPRINTF (yyoutput, ")");
2716}
2717
2718#endif /* ! YYDEBUG */
2719/*-----------------------------------------------.
2720| Release the memory associated to this symbol. |
2721`-----------------------------------------------*/
2722
2723#if defined (__STDC__) || defined (__cplusplus)
2724static void
2725yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2726#else
2727static void
2728yydestruct (yymsg, yytype, yyvaluep)
2729 const char *yymsg;
2730 int yytype;
2731 YYSTYPE *yyvaluep;
2732#endif
2733{
2734 /* Pacify ``unused variable'' warnings. */
2735 (void) yyvaluep;
2736
2737 if (!yymsg)
2738 yymsg = "Deleting";
2739 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2740
2741 switch (yytype)
2742 {
2743
2744 default:
2745 break;
2746 }
2747}
2748
2749
2750/* Prevent warnings from -Wmissing-prototypes. */
2751
2752#ifdef YYPARSE_PARAM
2753# if defined (__STDC__) || defined (__cplusplus)
2754int yyparse (void *YYPARSE_PARAM);
2755# else
2756int yyparse ();
2757# endif
2758#else /* ! YYPARSE_PARAM */
2759#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002760int yyparse (void);
Chris Lattner32980692007-02-19 07:44:24 +00002761#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002762int yyparse ();
2763#endif
2764#endif /* ! YYPARSE_PARAM */
2765
2766
2767
2768/* The look-ahead symbol. */
2769int yychar;
2770
2771/* The semantic value of the look-ahead symbol. */
2772YYSTYPE yylval;
2773
2774/* Number of syntax errors so far. */
2775int yynerrs;
2776
2777
2778
2779/*----------.
2780| yyparse. |
2781`----------*/
2782
2783#ifdef YYPARSE_PARAM
2784# if defined (__STDC__) || defined (__cplusplus)
2785int yyparse (void *YYPARSE_PARAM)
2786# else
2787int yyparse (YYPARSE_PARAM)
2788 void *YYPARSE_PARAM;
2789# endif
2790#else /* ! YYPARSE_PARAM */
2791#if defined (__STDC__) || defined (__cplusplus)
2792int
2793yyparse (void)
2794#else
2795int
2796yyparse ()
2797
2798#endif
2799#endif
2800{
2801
2802 int yystate;
2803 int yyn;
2804 int yyresult;
2805 /* Number of tokens to shift before error messages enabled. */
2806 int yyerrstatus;
2807 /* Look-ahead token as an internal (translated) token number. */
2808 int yytoken = 0;
2809
2810 /* Three stacks and their tools:
2811 `yyss': related to states,
2812 `yyvs': related to semantic values,
2813 `yyls': related to locations.
2814
2815 Refer to the stacks thru separate pointers, to allow yyoverflow
2816 to reallocate them elsewhere. */
2817
2818 /* The state stack. */
2819 short int yyssa[YYINITDEPTH];
2820 short int *yyss = yyssa;
2821 short int *yyssp;
2822
2823 /* The semantic value stack. */
2824 YYSTYPE yyvsa[YYINITDEPTH];
2825 YYSTYPE *yyvs = yyvsa;
2826 YYSTYPE *yyvsp;
2827
2828
2829
Chris Lattner9d2fda62007-02-13 05:53:56 +00002830#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002831
Reid Spencer38c91a92007-02-28 02:24:54 +00002832 YYSIZE_T yystacksize = YYINITDEPTH;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002833
Reid Spencer38c91a92007-02-28 02:24:54 +00002834 /* The variables used to return semantic value and location from the
2835 action routines. */
2836 YYSTYPE yyval;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002837
Chris Lattner7d9801d2007-02-13 00:58:01 +00002838
Reid Spencer38c91a92007-02-28 02:24:54 +00002839 /* When reducing, the number of symbols on the RHS of the reduced
2840 rule. */
Chris Lattner9d2fda62007-02-13 05:53:56 +00002841 int yylen;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002842
Reid Spencer38c91a92007-02-28 02:24:54 +00002843 YYDPRINTF ((stderr, "Starting parse\n"));
Chris Lattner7d9801d2007-02-13 00:58:01 +00002844
Reid Spencer68a24bd2005-08-27 18:50:39 +00002845 yystate = 0;
2846 yyerrstatus = 0;
2847 yynerrs = 0;
2848 yychar = YYEMPTY; /* Cause a token to be read. */
2849
2850 /* Initialize stack pointers.
2851 Waste one element of value and location stack
2852 so that they stay on the same level as the state stack.
2853 The wasted elements are never initialized. */
2854
Reid Spencer38c91a92007-02-28 02:24:54 +00002855 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002856 yyvsp = yyvs;
2857
Reid Spencer38c91a92007-02-28 02:24:54 +00002858 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002859
Reid Spencer38c91a92007-02-28 02:24:54 +00002860/*------------------------------------------------------------.
2861| yynewstate -- Push a new state, which is found in yystate. |
2862`------------------------------------------------------------*/
2863 yynewstate:
2864 /* In all cases, when you get here, the value and location stacks
2865 have just been pushed. so pushing a state here evens the stacks.
2866 */
2867 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002868
Reid Spencer38c91a92007-02-28 02:24:54 +00002869 yysetstate:
2870 *yyssp = yystate;
2871
2872 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002873 {
2874 /* Get the current used size of the three stacks, in elements. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002875 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002876
2877#ifdef yyoverflow
Reid Spencer38c91a92007-02-28 02:24:54 +00002878 {
2879 /* Give user a chance to reallocate the stack. Use copies of
2880 these so that the &'s don't force the real ones into
2881 memory. */
2882 YYSTYPE *yyvs1 = yyvs;
2883 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002884
Reid Spencer38c91a92007-02-28 02:24:54 +00002885
2886 /* Each stack pointer address is followed by the size of the
2887 data in use in that stack, in bytes. This used to be a
2888 conditional around just the two extra args, but that might
2889 be undefined if yyoverflow is a macro. */
2890 yyoverflow (YY_("memory exhausted"),
2891 &yyss1, yysize * sizeof (*yyssp),
2892 &yyvs1, yysize * sizeof (*yyvsp),
2893
2894 &yystacksize);
2895
2896 yyss = yyss1;
2897 yyvs = yyvs1;
2898 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002899#else /* no yyoverflow */
Reid Spencer38c91a92007-02-28 02:24:54 +00002900# ifndef YYSTACK_RELOCATE
2901 goto yyexhaustedlab;
2902# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002903 /* Extend the stack our own way. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002904 if (YYMAXDEPTH <= yystacksize)
2905 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002906 yystacksize *= 2;
Reid Spencer38c91a92007-02-28 02:24:54 +00002907 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002908 yystacksize = YYMAXDEPTH;
Reid Spencer38c91a92007-02-28 02:24:54 +00002909
2910 {
2911 short int *yyss1 = yyss;
2912 union yyalloc *yyptr =
2913 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2914 if (! yyptr)
2915 goto yyexhaustedlab;
2916 YYSTACK_RELOCATE (yyss);
2917 YYSTACK_RELOCATE (yyvs);
2918
2919# undef YYSTACK_RELOCATE
2920 if (yyss1 != yyssa)
2921 YYSTACK_FREE (yyss1);
2922 }
2923# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002924#endif /* no yyoverflow */
2925
Reid Spencer38c91a92007-02-28 02:24:54 +00002926 yyssp = yyss + yysize - 1;
2927 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002928
2929
Reid Spencer38c91a92007-02-28 02:24:54 +00002930 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2931 (unsigned long int) yystacksize));
2932
2933 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002934 YYABORT;
2935 }
2936
Reid Spencer38c91a92007-02-28 02:24:54 +00002937 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002938
2939 goto yybackup;
Reid Spencer38c91a92007-02-28 02:24:54 +00002940
2941/*-----------.
2942| yybackup. |
2943`-----------*/
2944yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002945
Chris Lattner9d2fda62007-02-13 05:53:56 +00002946/* Do appropriate processing given the current state. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002947/* Read a look-ahead token if we need one and don't already have one. */
Chris Lattner9d2fda62007-02-13 05:53:56 +00002948/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002949
Reid Spencer38c91a92007-02-28 02:24:54 +00002950 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer5cbf9852007-01-30 20:08:39 +00002951
Reid Spencer68a24bd2005-08-27 18:50:39 +00002952 yyn = yypact[yystate];
Reid Spencer38c91a92007-02-28 02:24:54 +00002953 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002954 goto yydefault;
2955
Reid Spencer38c91a92007-02-28 02:24:54 +00002956 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002957
Reid Spencer38c91a92007-02-28 02:24:54 +00002958 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002959 if (yychar == YYEMPTY)
2960 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002961 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002962 yychar = YYLEX;
2963 }
2964
Reid Spencer38c91a92007-02-28 02:24:54 +00002965 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002966 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002967 yychar = yytoken = YYEOF;
2968 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002969 }
2970 else
2971 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002972 yytoken = YYTRANSLATE (yychar);
2973 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002974 }
2975
Reid Spencer38c91a92007-02-28 02:24:54 +00002976 /* If the proper action on seeing token YYTOKEN is to reduce or to
2977 detect an error, take that action. */
2978 yyn += yytoken;
2979 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002980 goto yydefault;
2981 yyn = yytable[yyn];
Reid Spencer38c91a92007-02-28 02:24:54 +00002982 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002983 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002984 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002985 goto yyerrlab;
2986 yyn = -yyn;
2987 goto yyreduce;
2988 }
2989
2990 if (yyn == YYFINAL)
2991 YYACCEPT;
2992
Reid Spencer38c91a92007-02-28 02:24:54 +00002993 /* Shift the look-ahead token. */
2994 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer5cbf9852007-01-30 20:08:39 +00002995
Chris Lattner9d2fda62007-02-13 05:53:56 +00002996 /* Discard the token being shifted unless it is eof. */
Reid Spencer5cbf9852007-01-30 20:08:39 +00002997 if (yychar != YYEOF)
2998 yychar = YYEMPTY;
2999
Chris Lattner7d9801d2007-02-13 00:58:01 +00003000 *++yyvsp = yylval;
3001
Reid Spencer38c91a92007-02-28 02:24:54 +00003002
3003 /* Count tokens shifted since error; after three, turn off error
3004 status. */
3005 if (yyerrstatus)
3006 yyerrstatus--;
Chris Lattner9d2fda62007-02-13 05:53:56 +00003007
3008 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003009 goto yynewstate;
3010
Chris Lattner32980692007-02-19 07:44:24 +00003011
Reid Spencer38c91a92007-02-28 02:24:54 +00003012/*-----------------------------------------------------------.
3013| yydefault -- do the default action for the current state. |
3014`-----------------------------------------------------------*/
3015yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003016 yyn = yydefact[yystate];
3017 if (yyn == 0)
3018 goto yyerrlab;
Reid Spencer38c91a92007-02-28 02:24:54 +00003019 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003020
Reid Spencer38c91a92007-02-28 02:24:54 +00003021
3022/*-----------------------------.
3023| yyreduce -- Do a reduction. |
3024`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003025yyreduce:
Reid Spencer38c91a92007-02-28 02:24:54 +00003026 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003027 yylen = yyr2[yyn];
3028
Reid Spencer38c91a92007-02-28 02:24:54 +00003029 /* If YYLEN is nonzero, implement the default value of the action:
3030 `$$ = $1'.
3031
3032 Otherwise, the following line sets YYVAL to garbage.
3033 This behavior is undocumented and Bison
3034 users should not rely upon it. Assigning to YYVAL
3035 unconditionally makes the parser a bit smaller, and it avoids a
3036 GCC warning that YYVAL may be used uninitialized. */
3037 yyval = yyvsp[1-yylen];
3038
3039
3040 YY_REDUCE_PRINT (yyn);
3041 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003042 {
Reid Spencer38c91a92007-02-28 02:24:54 +00003043 case 29:
Reid Spencer66728ef2007-03-20 01:13:36 +00003044#line 1099 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003045 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3046 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003047
Reid Spencer38c91a92007-02-28 02:24:54 +00003048 case 30:
Reid Spencer66728ef2007-03-20 01:13:36 +00003049#line 1099 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003050 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3051 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003052
Reid Spencer38c91a92007-02-28 02:24:54 +00003053 case 31:
Reid Spencer66728ef2007-03-20 01:13:36 +00003054#line 1100 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003055 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3056 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003057
Reid Spencer38c91a92007-02-28 02:24:54 +00003058 case 32:
Reid Spencer66728ef2007-03-20 01:13:36 +00003059#line 1100 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003060 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3061 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003062
Reid Spencer38c91a92007-02-28 02:24:54 +00003063 case 33:
Reid Spencer66728ef2007-03-20 01:13:36 +00003064#line 1101 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003065 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3066 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003067
Reid Spencer38c91a92007-02-28 02:24:54 +00003068 case 34:
Reid Spencer66728ef2007-03-20 01:13:36 +00003069#line 1101 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003070 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3071 break;
3072
3073 case 35:
Reid Spencer66728ef2007-03-20 01:13:36 +00003074#line 1102 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003075 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3076 break;
3077
3078 case 36:
Reid Spencer66728ef2007-03-20 01:13:36 +00003079#line 1102 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003080 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3081 break;
3082
3083 case 37:
Reid Spencer66728ef2007-03-20 01:13:36 +00003084#line 1103 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003085 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3086 break;
3087
3088 case 38:
Reid Spencer66728ef2007-03-20 01:13:36 +00003089#line 1103 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003090 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3091 break;
3092
3093 case 39:
Reid Spencer66728ef2007-03-20 01:13:36 +00003094#line 1107 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003095 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3096 break;
3097
3098 case 40:
Reid Spencer66728ef2007-03-20 01:13:36 +00003099#line 1107 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003100 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3101 break;
3102
3103 case 41:
Reid Spencer66728ef2007-03-20 01:13:36 +00003104#line 1108 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003105 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3106 break;
3107
3108 case 42:
Reid Spencer66728ef2007-03-20 01:13:36 +00003109#line 1108 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003110 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3111 break;
3112
3113 case 43:
Reid Spencer66728ef2007-03-20 01:13:36 +00003114#line 1109 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003115 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3116 break;
3117
3118 case 44:
Reid Spencer66728ef2007-03-20 01:13:36 +00003119#line 1109 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003120 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3121 break;
3122
3123 case 45:
Reid Spencer66728ef2007-03-20 01:13:36 +00003124#line 1110 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003125 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3126 break;
3127
3128 case 46:
Reid Spencer66728ef2007-03-20 01:13:36 +00003129#line 1110 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003130 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3131 break;
3132
3133 case 47:
Reid Spencer66728ef2007-03-20 01:13:36 +00003134#line 1111 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003135 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3136 break;
3137
3138 case 48:
Reid Spencer66728ef2007-03-20 01:13:36 +00003139#line 1111 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003140 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3141 break;
3142
3143 case 49:
Reid Spencer66728ef2007-03-20 01:13:36 +00003144#line 1112 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003145 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3146 break;
3147
3148 case 50:
Reid Spencer66728ef2007-03-20 01:13:36 +00003149#line 1112 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003150 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3151 break;
3152
3153 case 51:
Reid Spencer66728ef2007-03-20 01:13:36 +00003154#line 1113 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003155 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3156 break;
3157
3158 case 52:
Reid Spencer66728ef2007-03-20 01:13:36 +00003159#line 1113 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003160 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3161 break;
3162
3163 case 53:
Reid Spencer66728ef2007-03-20 01:13:36 +00003164#line 1114 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003165 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3166 break;
3167
3168 case 54:
Reid Spencer66728ef2007-03-20 01:13:36 +00003169#line 1115 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003170 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3171 break;
3172
3173 case 61:
Reid Spencer66728ef2007-03-20 01:13:36 +00003174#line 1124 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003175 { (yyval.StrVal) = 0; ;}
3176 break;
3177
3178 case 62:
Reid Spencer66728ef2007-03-20 01:13:36 +00003179#line 1128 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003180 {
3181 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003182 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003183 ;}
3184 break;
3185
3186 case 63:
Reid Spencer66728ef2007-03-20 01:13:36 +00003187#line 1132 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003188 {
3189 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003190 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003191 ;}
3192 break;
3193
3194 case 66:
Reid Spencer66728ef2007-03-20 01:13:36 +00003195#line 1139 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003196 {
3197 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003198 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003199 ;}
3200 break;
3201
3202 case 67:
Reid Spencer66728ef2007-03-20 01:13:36 +00003203#line 1143 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003204 {
3205 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003206 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003207 ;}
3208 break;
3209
3210 case 68:
Reid Spencer66728ef2007-03-20 01:13:36 +00003211#line 1149 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003212 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3213 break;
3214
3215 case 69:
Reid Spencer66728ef2007-03-20 01:13:36 +00003216#line 1150 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003217 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3218 break;
3219
3220 case 70:
Reid Spencer66728ef2007-03-20 01:13:36 +00003221#line 1151 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003222 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3223 break;
3224
3225 case 71:
Reid Spencer66728ef2007-03-20 01:13:36 +00003226#line 1152 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003227 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3228 break;
3229
3230 case 72:
Reid Spencer66728ef2007-03-20 01:13:36 +00003231#line 1153 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003232 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3233 break;
3234
3235 case 73:
Reid Spencer66728ef2007-03-20 01:13:36 +00003236#line 1157 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003237 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3238 break;
3239
3240 case 74:
Reid Spencer66728ef2007-03-20 01:13:36 +00003241#line 1158 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003242 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3243 break;
3244
3245 case 75:
Reid Spencer66728ef2007-03-20 01:13:36 +00003246#line 1159 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003247 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3248 break;
3249
3250 case 76:
Reid Spencer66728ef2007-03-20 01:13:36 +00003251#line 1163 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003252 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3253 break;
3254
3255 case 77:
Reid Spencer66728ef2007-03-20 01:13:36 +00003256#line 1164 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003257 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3258 break;
3259
3260 case 78:
Reid Spencer66728ef2007-03-20 01:13:36 +00003261#line 1168 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003262 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3263 break;
3264
3265 case 79:
Reid Spencer66728ef2007-03-20 01:13:36 +00003266#line 1169 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003267 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3268 break;
3269
3270 case 80:
Reid Spencer66728ef2007-03-20 01:13:36 +00003271#line 1170 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003272 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3273 break;
3274
3275 case 81:
Reid Spencer66728ef2007-03-20 01:13:36 +00003276#line 1174 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003277 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3278 break;
3279
3280 case 82:
Reid Spencer66728ef2007-03-20 01:13:36 +00003281#line 1175 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003282 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3283 break;
3284
3285 case 83:
Reid Spencer66728ef2007-03-20 01:13:36 +00003286#line 1176 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003287 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3288 break;
3289
3290 case 84:
Reid Spencer66728ef2007-03-20 01:13:36 +00003291#line 1177 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003292 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3293 break;
3294
3295 case 85:
Reid Spencer66728ef2007-03-20 01:13:36 +00003296#line 1178 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003297 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3298 break;
3299
3300 case 86:
Reid Spencer66728ef2007-03-20 01:13:36 +00003301#line 1181 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003302 { (yyval.UIntVal) = CallingConv::C; ;}
3303 break;
3304
3305 case 87:
Reid Spencer66728ef2007-03-20 01:13:36 +00003306#line 1182 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003307 { (yyval.UIntVal) = CallingConv::C; ;}
3308 break;
3309
3310 case 88:
Reid Spencer66728ef2007-03-20 01:13:36 +00003311#line 1183 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003312 { (yyval.UIntVal) = CallingConv::Fast; ;}
3313 break;
3314
3315 case 89:
Reid Spencer66728ef2007-03-20 01:13:36 +00003316#line 1184 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003317 { (yyval.UIntVal) = CallingConv::Cold; ;}
3318 break;
3319
3320 case 90:
Reid Spencer66728ef2007-03-20 01:13:36 +00003321#line 1185 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003322 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3323 break;
3324
3325 case 91:
Reid Spencer66728ef2007-03-20 01:13:36 +00003326#line 1186 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003327 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3328 break;
3329
3330 case 92:
Reid Spencer66728ef2007-03-20 01:13:36 +00003331#line 1187 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003332 {
3333 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencerb5334b02007-02-05 10:18:06 +00003334 GEN_ERROR("Calling conv too large");
Reid Spencer38c91a92007-02-28 02:24:54 +00003335 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003336 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003337 ;}
3338 break;
3339
3340 case 93:
Reid Spencer66728ef2007-03-20 01:13:36 +00003341#line 1194 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003342 { (yyval.ParamAttrs) = FunctionType::ZExtAttribute; ;}
3343 break;
3344
3345 case 94:
Reid Spencer66728ef2007-03-20 01:13:36 +00003346#line 1195 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003347 { (yyval.ParamAttrs) = FunctionType::SExtAttribute; ;}
3348 break;
3349
3350 case 95:
Reid Spencer66728ef2007-03-20 01:13:36 +00003351#line 1196 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003352 { (yyval.ParamAttrs) = FunctionType::InRegAttribute; ;}
3353 break;
3354
3355 case 96:
Reid Spencer66728ef2007-03-20 01:13:36 +00003356#line 1197 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003357 { (yyval.ParamAttrs) = FunctionType::StructRetAttribute; ;}
3358 break;
3359
3360 case 97:
Reid Spencer66728ef2007-03-20 01:13:36 +00003361#line 1200 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003362 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3363 break;
3364
3365 case 98:
Reid Spencer66728ef2007-03-20 01:13:36 +00003366#line 1201 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003367 {
3368 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
3369 ;}
3370 break;
3371
3372 case 99:
Reid Spencer66728ef2007-03-20 01:13:36 +00003373#line 1206 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003374 { (yyval.ParamAttrs) = FunctionType::NoReturnAttribute; ;}
3375 break;
3376
Reid Spencer67d8ed92007-03-22 02:14:08 +00003377 case 100:
3378#line 1207 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3379 { (yyval.ParamAttrs) = FunctionType::NoUnwindAttribute; ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003380 break;
3381
3382 case 102:
Reid Spencer66728ef2007-03-20 01:13:36 +00003383#line 1211 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003384 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3385 break;
3386
3387 case 103:
3388#line 1212 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003389 {
3390 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
3391 ;}
3392 break;
3393
Reid Spencer67d8ed92007-03-22 02:14:08 +00003394 case 104:
3395#line 1219 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003396 { (yyval.UIntVal) = 0; ;}
3397 break;
3398
Reid Spencer67d8ed92007-03-22 02:14:08 +00003399 case 105:
3400#line 1220 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003401 {
3402 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3403 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003404 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003405 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003406;}
3407 break;
3408
Reid Spencer66728ef2007-03-20 01:13:36 +00003409 case 106:
3410#line 1226 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003411 { (yyval.UIntVal) = 0; ;}
3412 break;
3413
3414 case 107:
3415#line 1227 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer66728ef2007-03-20 01:13:36 +00003416 {
3417 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3418 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3419 GEN_ERROR("Alignment must be a power of two");
3420 CHECK_FOR_ERROR
3421;}
3422 break;
3423
Reid Spencer67d8ed92007-03-22 02:14:08 +00003424 case 108:
3425#line 1235 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003426 {
3427 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3428 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencerb5334b02007-02-05 10:18:06 +00003429 GEN_ERROR("Invalid character in section name");
Reid Spencer38c91a92007-02-28 02:24:54 +00003430 (yyval.StrVal) = (yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003431 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003432;}
3433 break;
3434
Reid Spencer67d8ed92007-03-22 02:14:08 +00003435 case 109:
3436#line 1243 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003437 { (yyval.StrVal) = 0; ;}
3438 break;
3439
Reid Spencer38c91a92007-02-28 02:24:54 +00003440 case 110:
Reid Spencer67d8ed92007-03-22 02:14:08 +00003441#line 1244 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3442 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00003443 break;
3444
3445 case 111:
Reid Spencer66728ef2007-03-20 01:13:36 +00003446#line 1249 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003447 {;}
3448 break;
3449
3450 case 112:
Reid Spencer66728ef2007-03-20 01:13:36 +00003451#line 1250 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00003452 {;}
3453 break;
3454
3455 case 113:
3456#line 1251 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003457 {
3458 CurGV->setSection((yyvsp[0].StrVal));
3459 free((yyvsp[0].StrVal));
Reid Spencer6f407902007-01-13 05:00:46 +00003460 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003461 ;}
3462 break;
3463
Reid Spencer67d8ed92007-03-22 02:14:08 +00003464 case 114:
3465#line 1256 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003466 {
3467 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003468 GEN_ERROR("Alignment must be a power of two");
Reid Spencer38c91a92007-02-28 02:24:54 +00003469 CurGV->setAlignment((yyvsp[0].UInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003470 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003471 ;}
3472 break;
3473
Reid Spencer67d8ed92007-03-22 02:14:08 +00003474 case 119:
3475#line 1272 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003476 {
3477 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003478 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003479 ;}
3480 break;
3481
Reid Spencer67d8ed92007-03-22 02:14:08 +00003482 case 120:
3483#line 1276 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003484 {
3485 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003486 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003487 ;}
3488 break;
3489
Reid Spencer67d8ed92007-03-22 02:14:08 +00003490 case 121:
3491#line 1280 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003492 { // Pointer type?
3493 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003494 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencer38c91a92007-02-28 02:24:54 +00003495 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3496 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003497 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003498 ;}
3499 break;
3500
Reid Spencer67d8ed92007-03-22 02:14:08 +00003501 case 122:
3502#line 1287 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003503 { // Named types are also simple types...
3504 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003505 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003506 (yyval.TypeVal) = new PATypeHolder(tmp);
3507 ;}
3508 break;
3509
Reid Spencer67d8ed92007-03-22 02:14:08 +00003510 case 123:
3511#line 1292 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003512 { // Type UpReference
3513 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003514 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer38c91a92007-02-28 02:24:54 +00003515 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3516 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003517 UR_OUT("New Upreference!\n");
3518 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003519 ;}
3520 break;
3521
Reid Spencer67d8ed92007-03-22 02:14:08 +00003522 case 124:
3523#line 1300 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003524 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003525 std::vector<const Type*> Params;
3526 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00003527 Attrs.push_back((yyvsp[0].ParamAttrs));
3528 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003529 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003530 Params.push_back(Ty);
3531 if (Ty != Type::VoidTy)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003532 Attrs.push_back(I->Attrs);
3533 }
3534 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3535 if (isVarArg) Params.pop_back();
3536
Reid Spencer38c91a92007-02-28 02:24:54 +00003537 FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, Attrs);
3538 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3539 delete (yyvsp[-4].TypeVal); // Delete the return type handle
3540 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003541 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003542 ;}
3543 break;
3544
Reid Spencer67d8ed92007-03-22 02:14:08 +00003545 case 125:
3546#line 1319 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003547 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003548 std::vector<const Type*> Params;
3549 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00003550 Attrs.push_back((yyvsp[0].ParamAttrs));
3551 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003552 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003553 Params.push_back(Ty);
3554 if (Ty != Type::VoidTy)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003555 Attrs.push_back(I->Attrs);
3556 }
3557 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3558 if (isVarArg) Params.pop_back();
3559
Reid Spencer38c91a92007-02-28 02:24:54 +00003560 FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, Attrs);
3561 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3562 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003563 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003564 ;}
3565 break;
3566
Reid Spencer67d8ed92007-03-22 02:14:08 +00003567 case 126:
3568#line 1338 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003569 { // Sized array type?
3570 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3571 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003572 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003573 ;}
3574 break;
3575
Reid Spencer67d8ed92007-03-22 02:14:08 +00003576 case 127:
3577#line 1343 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003578 { // Vector type?
3579 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3580 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003581 GEN_ERROR("Unsigned result not equal to signed result");
3582 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
Reid Spencer9d6565a2007-02-15 02:26:10 +00003583 GEN_ERROR("Element type of a VectorType must be primitive");
Reid Spencer38c91a92007-02-28 02:24:54 +00003584 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003585 GEN_ERROR("Vector length should be a power of 2");
Reid Spencer38c91a92007-02-28 02:24:54 +00003586 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3587 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003588 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003589 ;}
3590 break;
3591
Reid Spencer67d8ed92007-03-22 02:14:08 +00003592 case 128:
3593#line 1355 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003594 { // Structure type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003595 std::vector<const Type*> Elements;
Reid Spencer38c91a92007-02-28 02:24:54 +00003596 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3597 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003598 Elements.push_back(*I);
3599
Reid Spencer38c91a92007-02-28 02:24:54 +00003600 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3601 delete (yyvsp[-1].TypeList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003602 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003603 ;}
3604 break;
3605
Reid Spencer67d8ed92007-03-22 02:14:08 +00003606 case 129:
3607#line 1365 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003608 { // Empty structure type?
3609 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003610 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003611 ;}
3612 break;
3613
Reid Spencer67d8ed92007-03-22 02:14:08 +00003614 case 130:
3615#line 1369 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003616 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003617 std::vector<const Type*> Elements;
Reid Spencer38c91a92007-02-28 02:24:54 +00003618 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3619 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003620 Elements.push_back(*I);
3621
Reid Spencer38c91a92007-02-28 02:24:54 +00003622 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3623 delete (yyvsp[-2].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003624 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003625 ;}
3626 break;
3627
Reid Spencer67d8ed92007-03-22 02:14:08 +00003628 case 131:
3629#line 1379 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003630 { // Empty structure type?
3631 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003632 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003633 ;}
3634 break;
3635
Reid Spencer67d8ed92007-03-22 02:14:08 +00003636 case 132:
3637#line 1386 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003638 {
3639 (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal);
3640 (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs);
3641 ;}
3642 break;
3643
Reid Spencer67d8ed92007-03-22 02:14:08 +00003644 case 133:
3645#line 1393 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003646 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003647 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003648 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3649 if (!(*(yyvsp[0].TypeVal))->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00003650 GEN_ERROR("LLVM functions cannot return aggregate types");
Reid Spencer38c91a92007-02-28 02:24:54 +00003651 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3652 ;}
3653 break;
3654
Reid Spencer67d8ed92007-03-22 02:14:08 +00003655 case 134:
3656#line 1400 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003657 {
3658 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3659 ;}
3660 break;
3661
Reid Spencer67d8ed92007-03-22 02:14:08 +00003662 case 135:
3663#line 1405 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003664 {
3665 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3666 (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer6f407902007-01-13 05:00:46 +00003667 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003668 ;}
3669 break;
3670
Reid Spencer67d8ed92007-03-22 02:14:08 +00003671 case 136:
3672#line 1410 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003673 {
3674 ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00003675 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003676 ;}
3677 break;
3678
Reid Spencer67d8ed92007-03-22 02:14:08 +00003679 case 138:
3680#line 1418 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003681 {
3682 (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003683 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3684 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003685 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003686 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003687 ;}
3688 break;
3689
Reid Spencer67d8ed92007-03-22 02:14:08 +00003690 case 139:
3691#line 1425 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003692 {
3693 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003694 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3695 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003696 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003697 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003698 ;}
3699 break;
3700
Reid Spencer67d8ed92007-03-22 02:14:08 +00003701 case 140:
3702#line 1432 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003703 {
3704 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003705 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003706 ;}
3707 break;
3708
Reid Spencer67d8ed92007-03-22 02:14:08 +00003709 case 141:
3710#line 1440 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003711 {
3712 (yyval.TypeList) = new std::list<PATypeHolder>();
Reid Spencer66728ef2007-03-20 01:13:36 +00003713 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal));
3714 delete (yyvsp[0].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003715 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003716 ;}
3717 break;
3718
Reid Spencer67d8ed92007-03-22 02:14:08 +00003719 case 142:
3720#line 1446 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003721 {
Reid Spencer66728ef2007-03-20 01:13:36 +00003722 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal));
3723 delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003724 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003725 ;}
3726 break;
3727
Reid Spencer67d8ed92007-03-22 02:14:08 +00003728 case 143:
3729#line 1458 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003730 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003731 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003732 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3733 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003734 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003735 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003736 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003737 const Type *ETy = ATy->getElementType();
3738 int NumElements = ATy->getNumElements();
3739
3740 // Verify that we have the correct size...
Reid Spencer38c91a92007-02-28 02:24:54 +00003741 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003742 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003743 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003744 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003745
3746 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00003747 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3748 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003749 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3750 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer38c91a92007-02-28 02:24:54 +00003751 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003752 }
3753
Reid Spencer38c91a92007-02-28 02:24:54 +00003754 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3755 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003756 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003757 ;}
3758 break;
3759
Reid Spencer67d8ed92007-03-22 02:14:08 +00003760 case 144:
3761#line 1486 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003762 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003763 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003764 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3765 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003766 if (ATy == 0)
3767 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003768 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003769
Andrew Lenharth6353e052006-12-08 18:07:09 +00003770 int NumElements = ATy->getNumElements();
3771 if (NumElements != -1 && NumElements != 0)
3772 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003773 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencer38c91a92007-02-28 02:24:54 +00003774 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3775 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003776 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003777 ;}
3778 break;
3779
Reid Spencer67d8ed92007-03-22 02:14:08 +00003780 case 145:
3781#line 1502 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003782 {
Reid Spencer14310612006-12-31 05:40:51 +00003783 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003784 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3785 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003786 if (ATy == 0)
3787 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003788 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer61c83e02006-08-18 08:43:06 +00003789
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003790 int NumElements = ATy->getNumElements();
3791 const Type *ETy = ATy->getElementType();
Reid Spencer38c91a92007-02-28 02:24:54 +00003792 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3793 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003794 GEN_ERROR("Can't build string constant of size " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003795 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003796 " when array has size " + itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003797 std::vector<Constant*> Vals;
3798 if (ETy == Type::Int8Ty) {
Reid Spencer38c91a92007-02-28 02:24:54 +00003799 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003800 C != (unsigned char*)EndStr; ++C)
3801 Vals.push_back(ConstantInt::get(ETy, *C));
3802 } else {
Reid Spencer38c91a92007-02-28 02:24:54 +00003803 free((yyvsp[0].StrVal));
Reid Spencerb5334b02007-02-05 10:18:06 +00003804 GEN_ERROR("Cannot build string arrays of non byte sized elements");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003805 }
Reid Spencer38c91a92007-02-28 02:24:54 +00003806 free((yyvsp[0].StrVal));
3807 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3808 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003809 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003810 ;}
3811 break;
3812
Reid Spencer67d8ed92007-03-22 02:14:08 +00003813 case 146:
3814#line 1531 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003815 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003816 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003817 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3818 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003819 if (PTy == 0)
3820 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003821 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003822 const Type *ETy = PTy->getElementType();
3823 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003824
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003825 // Verify that we have the correct size...
Reid Spencer38c91a92007-02-28 02:24:54 +00003826 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003827 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003828 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003829 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003830
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003831 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00003832 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3833 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003834 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3835 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer38c91a92007-02-28 02:24:54 +00003836 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003837 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003838
Reid Spencer38c91a92007-02-28 02:24:54 +00003839 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[-1].ConstVector));
3840 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003841 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003842 ;}
3843 break;
3844
Reid Spencer67d8ed92007-03-22 02:14:08 +00003845 case 147:
3846#line 1559 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003847 {
3848 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003849 if (STy == 0)
3850 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003851 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003852
Reid Spencer38c91a92007-02-28 02:24:54 +00003853 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003854 GEN_ERROR("Illegal number of initializers for structure type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003855
3856 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer38c91a92007-02-28 02:24:54 +00003857 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3858 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003859 GEN_ERROR("Expected type '" +
3860 STy->getElementType(i)->getDescription() +
3861 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003862 " of structure initializer");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003863
3864 // Check to ensure that Type is not packed
3865 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003866 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003867
Reid Spencer38c91a92007-02-28 02:24:54 +00003868 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3869 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003870 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003871 ;}
3872 break;
3873
Reid Spencer67d8ed92007-03-22 02:14:08 +00003874 case 148:
3875#line 1584 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003876 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003877 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003878 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3879 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003880 if (STy == 0)
3881 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003882 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003883
3884 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003885 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003886
3887 // Check to ensure that Type is not packed
3888 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003889 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003890
Reid Spencer38c91a92007-02-28 02:24:54 +00003891 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3892 delete (yyvsp[-2].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003893 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003894 ;}
3895 break;
3896
Reid Spencer67d8ed92007-03-22 02:14:08 +00003897 case 149:
3898#line 1603 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003899 {
3900 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003901 if (STy == 0)
3902 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003903 (*(yyvsp[-5].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003904
Reid Spencer38c91a92007-02-28 02:24:54 +00003905 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003906 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003907
3908 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer38c91a92007-02-28 02:24:54 +00003909 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i)
3910 if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003911 GEN_ERROR("Expected type '" +
3912 STy->getElementType(i)->getDescription() +
3913 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003914 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003915
3916 // Check to ensure that Type is packed
3917 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003918 GEN_ERROR("Vector initializer to non-vector type '" +
3919 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003920
Reid Spencer38c91a92007-02-28 02:24:54 +00003921 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector));
3922 delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003923 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003924 ;}
3925 break;
3926
Reid Spencer67d8ed92007-03-22 02:14:08 +00003927 case 150:
3928#line 1629 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003929 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003930 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003931 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
3932 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003933 if (STy == 0)
3934 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003935 (*(yyvsp[-4].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003936
3937 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003938 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003939
3940 // Check to ensure that Type is packed
3941 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003942 GEN_ERROR("Vector initializer to non-vector type '" +
3943 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003944
Reid Spencer38c91a92007-02-28 02:24:54 +00003945 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3946 delete (yyvsp[-4].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003947 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003948 ;}
3949 break;
3950
Reid Spencer67d8ed92007-03-22 02:14:08 +00003951 case 151:
3952#line 1649 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003953 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003954 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003955 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3956 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003957 if (PTy == 0)
3958 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003959 (*(yyvsp[-1].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003960
Reid Spencer38c91a92007-02-28 02:24:54 +00003961 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3962 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003963 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003964 ;}
3965 break;
3966
Reid Spencer67d8ed92007-03-22 02:14:08 +00003967 case 152:
3968#line 1661 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003969 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003970 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003971 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3972 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3973 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003974 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003975 ;}
3976 break;
3977
Reid Spencer67d8ed92007-03-22 02:14:08 +00003978 case 153:
3979#line 1668 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00003980 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003981 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003982 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3983 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003984 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003985 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003986
3987 // ConstExprs can exist in the body of a function, thus creating
3988 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00003989 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00003990 // symbol table instead of the module symbol table for the global symbol,
3991 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00003992 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00003993 //
3994 Function *SavedCurFn = CurFun.CurrentFunction;
3995 CurFun.CurrentFunction = 0;
3996
Reid Spencer93c40032007-03-19 18:40:50 +00003997 Value *V = getExistingVal(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003998 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003999
4000 CurFun.CurrentFunction = SavedCurFn;
4001
4002 // If this is an initializer for a constant pointer, which is referencing a
4003 // (currently) undefined variable, create a stub now that shall be replaced
4004 // in the future with the right type of variable.
4005 //
4006 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004007 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004008 const PointerType *PT = cast<PointerType>(Ty);
4009
4010 // First check to see if the forward references value is already created!
4011 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer38c91a92007-02-28 02:24:54 +00004012 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004013
4014 if (I != CurModule.GlobalRefs.end()) {
4015 V = I->second; // Placeholder already exists, use it...
Reid Spencer38c91a92007-02-28 02:24:54 +00004016 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004017 } else {
4018 std::string Name;
Reid Spencer38c91a92007-02-28 02:24:54 +00004019 if ((yyvsp[0].ValIDVal).Type == ValID::GlobalName)
4020 Name = (yyvsp[0].ValIDVal).Name;
4021 else if ((yyvsp[0].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004022 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004023
4024 // Create the forward referenced global.
4025 GlobalValue *GV;
4026 if (const FunctionType *FTy =
4027 dyn_cast<FunctionType>(PT->getElementType())) {
4028 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4029 CurModule.CurrentModule);
4030 } else {
4031 GV = new GlobalVariable(PT->getElementType(), false,
4032 GlobalValue::ExternalLinkage, 0,
4033 Name, CurModule.CurrentModule);
4034 }
4035
4036 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer38c91a92007-02-28 02:24:54 +00004037 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004038 V = GV;
4039 }
4040 }
4041
Reid Spencer38c91a92007-02-28 02:24:54 +00004042 (yyval.ConstVal) = cast<GlobalValue>(V);
4043 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004044 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004045 ;}
4046 break;
4047
Reid Spencer67d8ed92007-03-22 02:14:08 +00004048 case 154:
4049#line 1734 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004050 {
Reid Spencer14310612006-12-31 05:40:51 +00004051 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004052 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4053 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004054 GEN_ERROR("Mismatched types for constant expression: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00004055 (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription());
4056 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4057 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004058 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004059 ;}
4060 break;
4061
Reid Spencer67d8ed92007-03-22 02:14:08 +00004062 case 155:
4063#line 1744 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004064 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004065 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004066 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4067 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004068 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencerb5334b02007-02-05 10:18:06 +00004069 GEN_ERROR("Cannot create a null initialized value of this type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004070 (yyval.ConstVal) = Constant::getNullValue(Ty);
4071 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004072 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004073 ;}
4074 break;
4075
Reid Spencer67d8ed92007-03-22 02:14:08 +00004076 case 156:
4077#line 1754 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004078 { // integral constants
4079 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004080 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer49d273e2007-03-19 20:40:51 +00004081 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val), true);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004082 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004083 ;}
4084 break;
4085
Reid Spencer67d8ed92007-03-22 02:14:08 +00004086 case 157:
4087#line 1760 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004088 { // arbitrary precision integer constants
4089 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4090 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
4091 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004092 }
4093 (yyvsp[0].APIntVal)->sextOrTrunc(BitWidth);
4094 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004095 delete (yyvsp[0].APIntVal);
4096 CHECK_FOR_ERROR
4097 ;}
4098 break;
4099
Reid Spencer67d8ed92007-03-22 02:14:08 +00004100 case 158:
4101#line 1770 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004102 { // integral constants
4103 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004104 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer49d273e2007-03-19 20:40:51 +00004105 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val), false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004106 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004107 ;}
4108 break;
4109
Reid Spencer67d8ed92007-03-22 02:14:08 +00004110 case 159:
4111#line 1776 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004112 { // arbitrary precision integer constants
4113 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4114 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
4115 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004116 }
4117 (yyvsp[0].APIntVal)->zextOrTrunc(BitWidth);
4118 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004119 delete (yyvsp[0].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004120 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004121 ;}
4122 break;
4123
Reid Spencer67d8ed92007-03-22 02:14:08 +00004124 case 160:
4125#line 1786 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004126 { // Boolean constants
4127 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4128 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004129 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004130 ;}
4131 break;
4132
Reid Spencer67d8ed92007-03-22 02:14:08 +00004133 case 161:
4134#line 1791 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004135 { // Boolean constants
4136 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4137 (yyval.ConstVal) = ConstantInt::getFalse();
4138 CHECK_FOR_ERROR
4139 ;}
4140 break;
4141
Reid Spencer67d8ed92007-03-22 02:14:08 +00004142 case 162:
4143#line 1796 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004144 { // Float & Double constants
4145 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004146 GEN_ERROR("Floating point constant invalid for type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004147 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004148 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004149 ;}
4150 break;
4151
Reid Spencer67d8ed92007-03-22 02:14:08 +00004152 case 163:
4153#line 1804 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004154 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004155 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004156 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4157 Constant *Val = (yyvsp[-3].ConstVal);
4158 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4159 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004160 GEN_ERROR("invalid cast opcode for cast from '" +
4161 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004162 DestTy->getDescription() + "'");
Reid Spencer38c91a92007-02-28 02:24:54 +00004163 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
4164 delete (yyvsp[-1].TypeVal);
4165 ;}
4166 break;
4167
Reid Spencer67d8ed92007-03-22 02:14:08 +00004168 case 164:
4169#line 1816 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004170 {
4171 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004172 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004173
4174 const Type *IdxTy =
Reid Spencer38c91a92007-02-28 02:24:54 +00004175 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), &(*(yyvsp[-1].ValueList))[0], (yyvsp[-1].ValueList)->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004176 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004177 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004178 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004179
Chris Lattnerf7469af2007-01-31 04:44:08 +00004180 SmallVector<Constant*, 8> IdxVec;
Reid Spencer38c91a92007-02-28 02:24:54 +00004181 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
4182 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004183 IdxVec.push_back(C);
4184 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004185 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004186
Reid Spencer38c91a92007-02-28 02:24:54 +00004187 delete (yyvsp[-1].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004188
Reid Spencer38c91a92007-02-28 02:24:54 +00004189 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004190 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004191 ;}
4192 break;
4193
Reid Spencer67d8ed92007-03-22 02:14:08 +00004194 case 165:
4195#line 1838 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004196 {
4197 if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00004198 GEN_ERROR("Select condition must be of boolean type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004199 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004200 GEN_ERROR("Select operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004201 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004202 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004203 ;}
4204 break;
4205
Reid Spencer67d8ed92007-03-22 02:14:08 +00004206 case 166:
4207#line 1846 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004208 {
4209 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004210 GEN_ERROR("Binary operator types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004211 CHECK_FOR_ERROR;
Reid Spencer38c91a92007-02-28 02:24:54 +00004212 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4213 ;}
4214 break;
4215
Reid Spencer67d8ed92007-03-22 02:14:08 +00004216 case 167:
4217#line 1852 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004218 {
4219 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004220 GEN_ERROR("Logical operator types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004221 if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) {
4222 if (Instruction::isShift((yyvsp[-5].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].ConstVal)->getType()) ||
4223 !cast<VectorType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00004224 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004225 }
Reid Spencer38c91a92007-02-28 02:24:54 +00004226 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004227 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004228 ;}
4229 break;
4230
Reid Spencer67d8ed92007-03-22 02:14:08 +00004231 case 168:
4232#line 1863 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004233 {
4234 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004235 GEN_ERROR("icmp operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004236 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4237 ;}
4238 break;
4239
Reid Spencer67d8ed92007-03-22 02:14:08 +00004240 case 169:
4241#line 1868 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004242 {
4243 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004244 GEN_ERROR("fcmp operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004245 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4246 ;}
4247 break;
4248
Reid Spencer67d8ed92007-03-22 02:14:08 +00004249 case 170:
4250#line 1873 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004251 {
4252 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004253 GEN_ERROR("Invalid extractelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004254 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004255 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004256 ;}
4257 break;
4258
Reid Spencer67d8ed92007-03-22 02:14:08 +00004259 case 171:
4260#line 1879 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004261 {
4262 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004263 GEN_ERROR("Invalid insertelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004264 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004265 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004266 ;}
4267 break;
4268
Reid Spencer67d8ed92007-03-22 02:14:08 +00004269 case 172:
4270#line 1885 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004271 {
4272 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004273 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004274 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004275 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004276 ;}
4277 break;
4278
Reid Spencer67d8ed92007-03-22 02:14:08 +00004279 case 173:
4280#line 1894 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004281 {
4282 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004283 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004284 ;}
4285 break;
4286
Reid Spencer67d8ed92007-03-22 02:14:08 +00004287 case 174:
4288#line 1898 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004289 {
4290 (yyval.ConstVector) = new std::vector<Constant*>();
4291 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004292 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004293 ;}
4294 break;
4295
Reid Spencer67d8ed92007-03-22 02:14:08 +00004296 case 175:
4297#line 1906 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004298 { (yyval.BoolVal) = false; ;}
4299 break;
4300
Reid Spencer67d8ed92007-03-22 02:14:08 +00004301 case 176:
4302#line 1906 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004303 { (yyval.BoolVal) = true; ;}
4304 break;
4305
Reid Spencer38c91a92007-02-28 02:24:54 +00004306 case 177:
Reid Spencer67d8ed92007-03-22 02:14:08 +00004307#line 1917 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004308 {
4309 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004310 CurModule.ModuleDone();
4311 CHECK_FOR_ERROR;
Reid Spencer38c91a92007-02-28 02:24:54 +00004312 ;}
4313 break;
4314
Reid Spencer67d8ed92007-03-22 02:14:08 +00004315 case 178:
4316#line 1922 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4317 {
4318 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
4319 CurModule.ModuleDone();
4320 CHECK_FOR_ERROR;
4321 ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00004322 break;
4323
4324 case 181:
Reid Spencer67d8ed92007-03-22 02:14:08 +00004325#line 1935 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4326 { CurFun.isDeclare = false; ;}
4327 break;
4328
4329 case 182:
4330#line 1935 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004331 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004332 CurFun.FunctionDone();
4333 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004334 ;}
4335 break;
4336
Reid Spencer67d8ed92007-03-22 02:14:08 +00004337 case 183:
4338#line 1939 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004339 { CurFun.isDeclare = true; ;}
4340 break;
4341
Reid Spencer38c91a92007-02-28 02:24:54 +00004342 case 184:
Reid Spencer67d8ed92007-03-22 02:14:08 +00004343#line 1939 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004344 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004345 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004346 ;}
4347 break;
4348
4349 case 185:
Reid Spencer67d8ed92007-03-22 02:14:08 +00004350#line 1942 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4351 {
4352 CHECK_FOR_ERROR
4353 ;}
4354 break;
4355
4356 case 186:
4357#line 1945 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004358 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004359 // Emit an error if there are any unresolved types left.
4360 if (!CurModule.LateResolveTypes.empty()) {
4361 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004362 if (DID.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +00004363 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
4364 } else {
4365 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
4366 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004367 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004368 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004369 ;}
4370 break;
4371
Reid Spencer67d8ed92007-03-22 02:14:08 +00004372 case 187:
4373#line 1957 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004374 {
Reid Spencer14310612006-12-31 05:40:51 +00004375 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004376 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004377 // Eagerly resolve types. This is not an optimization, this is a
4378 // requirement that is due to the fact that we could have this:
4379 //
4380 // %list = type { %list * }
4381 // %list = type { %list * } ; repeated type decl
4382 //
4383 // If types are not resolved eagerly, then the two types will not be
4384 // determined to be the same type!
4385 //
Reid Spencer38c91a92007-02-28 02:24:54 +00004386 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004387
Reid Spencer38c91a92007-02-28 02:24:54 +00004388 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004389 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004390 // If this is a named type that is not a redefinition, add it to the slot
4391 // table.
Reid Spencer38c91a92007-02-28 02:24:54 +00004392 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004393 }
Reid Spencera132e042006-12-03 05:46:11 +00004394
Reid Spencer38c91a92007-02-28 02:24:54 +00004395 delete (yyvsp[0].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004396 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004397 ;}
4398 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004399
Reid Spencer67d8ed92007-03-22 02:14:08 +00004400 case 188:
4401#line 1981 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004402 {
4403 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType));
4404
4405 if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004406 CHECK_FOR_ERROR
4407 // If this is a named type that is not a redefinition, add it to the slot
4408 // table.
Reid Spencer38c91a92007-02-28 02:24:54 +00004409 CurModule.Types.push_back((yyvsp[0].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004410 }
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004411 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004412 ;}
4413 break;
4414
Reid Spencer67d8ed92007-03-22 02:14:08 +00004415 case 189:
4416#line 1992 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004417 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004418 /* "Externally Visible" Linkage */
Reid Spencer38c91a92007-02-28 02:24:54 +00004419 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004420 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer38c91a92007-02-28 02:24:54 +00004421 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage,
4422 (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004423 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004424 ;}
4425 break;
4426
Reid Spencer67d8ed92007-03-22 02:14:08 +00004427 case 190:
4428#line 1999 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004429 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004430 CurGV = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00004431 ;}
4432 break;
4433
Reid Spencer67d8ed92007-03-22 02:14:08 +00004434 case 191:
4435#line 2002 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004436 {
4437 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004438 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer38c91a92007-02-28 02:24:54 +00004439 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 +00004440 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004441 ;}
4442 break;
4443
Reid Spencer67d8ed92007-03-22 02:14:08 +00004444 case 192:
4445#line 2007 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004446 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004447 CurGV = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00004448 ;}
4449 break;
4450
Reid Spencer67d8ed92007-03-22 02:14:08 +00004451 case 193:
4452#line 2010 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004453 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004454 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004455 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
4456 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 +00004457 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004458 delete (yyvsp[0].TypeVal);
4459 ;}
4460 break;
4461
Reid Spencer67d8ed92007-03-22 02:14:08 +00004462 case 194:
4463#line 2016 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004464 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004465 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004466 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004467 ;}
4468 break;
4469
Reid Spencer67d8ed92007-03-22 02:14:08 +00004470 case 195:
4471#line 2020 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004472 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004473 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004474 ;}
4475 break;
4476
Reid Spencer67d8ed92007-03-22 02:14:08 +00004477 case 196:
4478#line 2023 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004479 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004480 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004481 ;}
4482 break;
4483
Reid Spencer67d8ed92007-03-22 02:14:08 +00004484 case 197:
4485#line 2029 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004486 {
Chris Lattner66316012006-01-24 04:14:29 +00004487 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer38c91a92007-02-28 02:24:54 +00004488 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4489 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4490 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004491
4492 if (AsmSoFar.empty())
4493 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4494 else
4495 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004496 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004497;}
4498 break;
4499
Reid Spencer67d8ed92007-03-22 02:14:08 +00004500 case 198:
4501#line 2042 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004502 {
4503 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4504 free((yyvsp[0].StrVal));
4505 ;}
4506 break;
4507
Reid Spencer67d8ed92007-03-22 02:14:08 +00004508 case 199:
4509#line 2046 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004510 {
4511 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4512 free((yyvsp[0].StrVal));
4513 ;}
4514 break;
4515
Reid Spencer38c91a92007-02-28 02:24:54 +00004516 case 201:
Reid Spencer67d8ed92007-03-22 02:14:08 +00004517#line 2053 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004518 {
4519 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4520 free((yyvsp[0].StrVal));
Reid Spencera54b7cb2007-01-12 07:05:14 +00004521 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004522 ;}
4523 break;
4524
4525 case 202:
Reid Spencer67d8ed92007-03-22 02:14:08 +00004526#line 2058 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004527 {
Reid Spencer67d8ed92007-03-22 02:14:08 +00004528 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4529 free((yyvsp[0].StrVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004530 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004531 ;}
4532 break;
4533
4534 case 203:
Reid Spencer67d8ed92007-03-22 02:14:08 +00004535#line 2063 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4536 {
4537 CHECK_FOR_ERROR
4538 ;}
4539 break;
4540
4541 case 204:
4542#line 2072 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004543 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004544 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004545 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4546 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004547 GEN_ERROR("void typed arguments are invalid");
Reid Spencer38c91a92007-02-28 02:24:54 +00004548 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4549 (yyval.ArgList) = (yyvsp[-4].ArgList);
4550 (yyvsp[-4].ArgList)->push_back(E);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004551 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004552 ;}
4553 break;
4554
Reid Spencer67d8ed92007-03-22 02:14:08 +00004555 case 205:
4556#line 2082 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004557 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004558 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004559 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4560 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004561 GEN_ERROR("void typed arguments are invalid");
Reid Spencer38c91a92007-02-28 02:24:54 +00004562 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4563 (yyval.ArgList) = new ArgListType;
4564 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004565 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004566 ;}
4567 break;
4568
Reid Spencer67d8ed92007-03-22 02:14:08 +00004569 case 206:
4570#line 2093 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004571 {
4572 (yyval.ArgList) = (yyvsp[0].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004573 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004574 ;}
4575 break;
4576
Reid Spencer67d8ed92007-03-22 02:14:08 +00004577 case 207:
4578#line 2097 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004579 {
4580 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004581 struct ArgListEntry E;
4582 E.Ty = new PATypeHolder(Type::VoidTy);
4583 E.Name = 0;
4584 E.Attrs = FunctionType::NoAttributeSet;
Reid Spencer38c91a92007-02-28 02:24:54 +00004585 (yyval.ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004586 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004587 ;}
4588 break;
4589
Reid Spencer67d8ed92007-03-22 02:14:08 +00004590 case 208:
4591#line 2106 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004592 {
4593 (yyval.ArgList) = new ArgListType;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004594 struct ArgListEntry E;
4595 E.Ty = new PATypeHolder(Type::VoidTy);
4596 E.Name = 0;
4597 E.Attrs = FunctionType::NoAttributeSet;
Reid Spencer38c91a92007-02-28 02:24:54 +00004598 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004599 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004600 ;}
4601 break;
4602
Reid Spencer67d8ed92007-03-22 02:14:08 +00004603 case 209:
4604#line 2115 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004605 {
4606 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004607 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004608 ;}
4609 break;
4610
Reid Spencer67d8ed92007-03-22 02:14:08 +00004611 case 210:
4612#line 2121 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004613 {
4614 UnEscapeLexed((yyvsp[-6].StrVal));
4615 std::string FunctionName((yyvsp[-6].StrVal));
4616 free((yyvsp[-6].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004617
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004618 // Check the function result for abstractness if this is a define. We should
4619 // have no abstract types at this point
Reid Spencer38c91a92007-02-28 02:24:54 +00004620 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal)))
4621 GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004622
Reid Spencer68a24bd2005-08-27 18:50:39 +00004623 std::vector<const Type*> ParamTypeList;
Reid Spencer14310612006-12-31 05:40:51 +00004624 std::vector<FunctionType::ParameterAttributes> ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00004625 ParamAttrs.push_back((yyvsp[-2].ParamAttrs));
4626 if ((yyvsp[-4].ArgList)) { // If there are arguments...
4627 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004628 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004629 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4630 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004631 ParamTypeList.push_back(Ty);
4632 if (Ty != Type::VoidTy)
4633 ParamAttrs.push_back(I->Attrs);
4634 }
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 Spencer38c91a92007-02-28 02:24:54 +00004640 FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg,
Reid Spencer14310612006-12-31 05:40:51 +00004641 ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004642 const PointerType *PFT = PointerType::get(FT);
Reid Spencer38c91a92007-02-28 02:24:54 +00004643 delete (yyvsp[-7].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004644
4645 ValID ID;
4646 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004647 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004648 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004649 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004650 }
4651
4652 Function *Fn = 0;
4653 // See if this function was forward referenced. If so, recycle the object.
4654 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4655 // Move the function to the end of the list, from whereever it was
4656 // previously inserted.
4657 Fn = cast<Function>(FWRef);
4658 CurModule.CurrentModule->getFunctionList().remove(Fn);
4659 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4660 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004661 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
4662 if (Fn->getFunctionType() != FT ) {
4663 // The existing function doesn't have the same type. This is an overload
4664 // error.
4665 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4666 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
4667 // Neither the existing or the current function is a declaration and they
4668 // have the same name and same type. Clearly this is a redefinition.
Reid Spencerb5334b02007-02-05 10:18:06 +00004669 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004670 } if (Fn->isDeclaration()) {
4671 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004672 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4673 AI != AE; ++AI)
4674 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004675 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004676 } else { // Not already defined?
4677 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4678 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004679
Reid Spencer68a24bd2005-08-27 18:50:39 +00004680 InsertValue(Fn, CurModule.Values);
4681 }
4682
4683 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004684
4685 if (CurFun.isDeclare) {
4686 // If we have declaration, always overwrite linkage. This will allow us to
4687 // correctly handle cases, when pointer to function is passed as argument to
4688 // another function.
4689 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004690 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004691 }
Reid Spencer38c91a92007-02-28 02:24:54 +00004692 Fn->setCallingConv((yyvsp[-8].UIntVal));
4693 Fn->setAlignment((yyvsp[0].UIntVal));
4694 if ((yyvsp[-1].StrVal)) {
4695 Fn->setSection((yyvsp[-1].StrVal));
4696 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004697 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004698
4699 // Add all of the arguments we parsed to the function...
Reid Spencer38c91a92007-02-28 02:24:54 +00004700 if ((yyvsp[-4].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004701 if (isVarArg) { // Nuke the last entry
Reid Spencer38c91a92007-02-28 02:24:54 +00004702 assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004703 "Not a varargs marker!");
Reid Spencer38c91a92007-02-28 02:24:54 +00004704 delete (yyvsp[-4].ArgList)->back().Ty;
4705 (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004706 }
4707 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004708 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004709 unsigned Idx = 1;
Reid Spencer38c91a92007-02-28 02:24:54 +00004710 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin();
4711 I != (yyvsp[-4].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004712 delete I->Ty; // Delete the typeholder...
Reid Spenceref9b9a72007-02-05 20:47:22 +00004713 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004714 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004715 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004716 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004717 }
Reid Spencera132e042006-12-03 05:46:11 +00004718
Reid Spencer38c91a92007-02-28 02:24:54 +00004719 delete (yyvsp[-4].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004720 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004721 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004722;}
4723 break;
4724
Reid Spencer67d8ed92007-03-22 02:14:08 +00004725 case 213:
4726#line 2234 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004727 {
4728 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004729
4730 // Make sure that we keep track of the linkage type even if there was a
4731 // previous "declare".
Reid Spencer38c91a92007-02-28 02:24:54 +00004732 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
4733 (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility));
4734;}
4735 break;
4736
Reid Spencer67d8ed92007-03-22 02:14:08 +00004737 case 216:
4738#line 2245 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004739 {
4740 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004741 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004742;}
4743 break;
4744
Reid Spencer67d8ed92007-03-22 02:14:08 +00004745 case 217:
4746#line 2250 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004747 {
4748 CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage));
4749 CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility));
4750 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004751 CurFun.FunctionDone();
4752 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004753 ;}
4754 break;
4755
Reid Spencer67d8ed92007-03-22 02:14:08 +00004756 case 218:
4757#line 2262 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004758 {
4759 (yyval.BoolVal) = false;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004760 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004761 ;}
4762 break;
4763
Reid Spencer67d8ed92007-03-22 02:14:08 +00004764 case 219:
4765#line 2266 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004766 {
4767 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004768 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004769 ;}
4770 break;
4771
Reid Spencer67d8ed92007-03-22 02:14:08 +00004772 case 220:
4773#line 2271 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004774 { // A reference to a direct constant
4775 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004776 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004777 ;}
4778 break;
4779
Reid Spencer67d8ed92007-03-22 02:14:08 +00004780 case 221:
4781#line 2275 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004782 {
4783 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Reid Spencer6f407902007-01-13 05:00:46 +00004784 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004785 ;}
4786 break;
4787
Reid Spencer67d8ed92007-03-22 02:14:08 +00004788 case 222:
4789#line 2279 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004790 { // Perhaps it's an FP constant?
4791 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004792 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004793 ;}
4794 break;
4795
Reid Spencer67d8ed92007-03-22 02:14:08 +00004796 case 223:
4797#line 2283 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004798 {
4799 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004800 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004801 ;}
4802 break;
4803
Reid Spencer67d8ed92007-03-22 02:14:08 +00004804 case 224:
4805#line 2287 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004806 {
4807 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004808 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004809 ;}
4810 break;
4811
Reid Spencer67d8ed92007-03-22 02:14:08 +00004812 case 225:
4813#line 2291 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004814 {
4815 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004816 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004817 ;}
4818 break;
4819
Reid Spencer67d8ed92007-03-22 02:14:08 +00004820 case 226:
4821#line 2295 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004822 {
4823 (yyval.ValIDVal) = ValID::createUndef();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004824 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004825 ;}
4826 break;
4827
Reid Spencer67d8ed92007-03-22 02:14:08 +00004828 case 227:
4829#line 2299 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004830 { // A vector zero constant.
4831 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00004832 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004833 ;}
4834 break;
4835
Reid Spencer67d8ed92007-03-22 02:14:08 +00004836 case 228:
4837#line 2303 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004838 { // Nonempty unsized packed vector
4839 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4840 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004841
Reid Spencer9d6565a2007-02-15 02:26:10 +00004842 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004843 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004844 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004845 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004846 ETy,
4847 NumElements)
4848 )
4849 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004850
4851 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00004852 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4853 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004854 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004855 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00004856 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004857 }
4858
Reid Spencer38c91a92007-02-28 02:24:54 +00004859 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[-1].ConstVector)));
4860 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004861 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004862 ;}
4863 break;
4864
Reid Spencer67d8ed92007-03-22 02:14:08 +00004865 case 229:
4866#line 2328 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004867 {
4868 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004869 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004870 ;}
4871 break;
4872
Reid Spencer67d8ed92007-03-22 02:14:08 +00004873 case 230:
4874#line 2332 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004875 {
4876 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4877 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4878 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4879 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4880 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4881 free((yyvsp[-2].StrVal));
4882 free((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004883 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004884 ;}
4885 break;
4886
Reid Spencer67d8ed92007-03-22 02:14:08 +00004887 case 231:
4888#line 2346 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004889 { // Is it an integer reference...?
4890 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004891 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004892 ;}
4893 break;
4894
Reid Spencer67d8ed92007-03-22 02:14:08 +00004895 case 232:
4896#line 2350 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004897 {
4898 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004899 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004900 ;}
4901 break;
4902
Reid Spencer67d8ed92007-03-22 02:14:08 +00004903 case 233:
4904#line 2354 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004905 { // Is it a named reference...?
4906 (yyval.ValIDVal) = ValID::createLocalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004907 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004908 ;}
4909 break;
4910
Reid Spencer67d8ed92007-03-22 02:14:08 +00004911 case 234:
4912#line 2358 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004913 { // Is it a named reference...?
4914 (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004915 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004916 ;}
4917 break;
4918
Reid Spencer67d8ed92007-03-22 02:14:08 +00004919 case 237:
4920#line 2370 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004921 {
Reid Spencer832254e2007-02-02 02:16:23 +00004922 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004923 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4924 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
4925 delete (yyvsp[-1].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004926 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004927 ;}
4928 break;
4929
Reid Spencer67d8ed92007-03-22 02:14:08 +00004930 case 238:
4931#line 2379 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004932 {
4933 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004934 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004935 ;}
4936 break;
4937
Reid Spencer67d8ed92007-03-22 02:14:08 +00004938 case 239:
4939#line 2383 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004940 { // Do not allow functions with 0 basic blocks
4941 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004942 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004943 ;}
4944 break;
4945
Reid Spencer67d8ed92007-03-22 02:14:08 +00004946 case 240:
4947#line 2392 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004948 {
4949 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004950 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004951 InsertValue((yyvsp[0].TermInstVal));
4952 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004953 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004954 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004955 ;}
4956 break;
4957
Reid Spencer67d8ed92007-03-22 02:14:08 +00004958 case 241:
4959#line 2401 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004960 {
4961 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004962 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4963 if (CI2->getParent() == 0)
Reid Spencer38c91a92007-02-28 02:24:54 +00004964 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
4965 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4966 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004967 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004968 ;}
4969 break;
4970
Reid Spencer67d8ed92007-03-22 02:14:08 +00004971 case 242:
4972#line 2410 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004973 { // Empty space between instruction lists
4974 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004975 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004976 ;}
4977 break;
4978
Reid Spencer67d8ed92007-03-22 02:14:08 +00004979 case 243:
4980#line 2414 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004981 { // Labelled (named) basic block
4982 (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName((yyvsp[0].StrVal)));
Reid Spencer3822ff52006-11-08 06:47:33 +00004983 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004984 ;}
4985 break;
Reid Spencer3822ff52006-11-08 06:47:33 +00004986
Reid Spencer67d8ed92007-03-22 02:14:08 +00004987 case 244:
4988#line 2419 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004989 { // Return with a result...
4990 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
4991 CHECK_FOR_ERROR
4992 ;}
4993 break;
4994
Reid Spencer67d8ed92007-03-22 02:14:08 +00004995 case 245:
4996#line 2423 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00004997 { // Return with no result...
Reid Spencer38c91a92007-02-28 02:24:54 +00004998 (yyval.TermInstVal) = new ReturnInst();
4999 CHECK_FOR_ERROR
5000 ;}
5001 break;
5002
Reid Spencer67d8ed92007-03-22 02:14:08 +00005003 case 246:
5004#line 2427 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer93c40032007-03-19 18:40:50 +00005005 { // Unconditional Branch...
Reid Spencer38c91a92007-02-28 02:24:54 +00005006 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
5007 CHECK_FOR_ERROR
5008 (yyval.TermInstVal) = new BranchInst(tmpBB);
5009 ;}
5010 break;
5011
Reid Spencer67d8ed92007-03-22 02:14:08 +00005012 case 247:
5013#line 2432 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005014 {
5015 assert(cast<IntegerType>((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?");
5016 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
5017 CHECK_FOR_ERROR
5018 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
5019 CHECK_FOR_ERROR
5020 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
5021 CHECK_FOR_ERROR
5022 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5023 ;}
5024 break;
5025
Reid Spencer67d8ed92007-03-22 02:14:08 +00005026 case 248:
5027#line 2442 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005028 {
5029 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
5030 CHECK_FOR_ERROR
5031 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5032 CHECK_FOR_ERROR
5033 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
5034 (yyval.TermInstVal) = S;
5035
5036 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5037 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005038 for (; I != E; ++I) {
5039 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5040 S->addCase(CI, I->second);
5041 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005042 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005043 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005044 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005045 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005046 ;}
5047 break;
5048
Reid Spencer67d8ed92007-03-22 02:14:08 +00005049 case 249:
5050#line 2461 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005051 {
5052 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005053 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005054 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005055 CHECK_FOR_ERROR
5056 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencer38c91a92007-02-28 02:24:54 +00005057 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00005058 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005059 ;}
5060 break;
5061
Reid Spencer67d8ed92007-03-22 02:14:08 +00005062 case 250:
5063#line 2471 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005064 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005065
Reid Spencer14310612006-12-31 05:40:51 +00005066 // Handle the short syntax
5067 const PointerType *PFTy = 0;
5068 const FunctionType *Ty = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00005069 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005070 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5071 // Pull out the types of all of the arguments...
5072 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005073 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00005074 ParamAttrs.push_back((yyvsp[-6].ParamAttrs));
5075 for (ValueRefList::iterator I = (yyvsp[-8].ValueRefList)->begin(), E = (yyvsp[-8].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005076 const Type *Ty = I->Val->getType();
5077 if (Ty == Type::VoidTy)
5078 GEN_ERROR("Short call syntax cannot be used with varargs");
5079 ParamTypes.push_back(Ty);
5080 ParamAttrs.push_back(I->Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005081 }
5082
Reid Spencer38c91a92007-02-28 02:24:54 +00005083 Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005084 PFTy = PointerType::get(Ty);
5085 }
5086
Reid Spencer66728ef2007-03-20 01:13:36 +00005087 delete (yyvsp[-11].TypeVal);
5088
Reid Spencer38c91a92007-02-28 02:24:54 +00005089 Value *V = getVal(PFTy, (yyvsp[-10].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005090 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005091 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005092 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005093 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005094 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005095
Reid Spencer14310612006-12-31 05:40:51 +00005096 // Check the arguments
5097 ValueList Args;
Reid Spencer38c91a92007-02-28 02:24:54 +00005098 if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005099 // Make sure no arguments is a good thing!
5100 if (Ty->getNumParams() != 0)
5101 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005102 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005103 } else { // Has arguments?
5104 // Loop through FunctionType's arguments and ensure they are specified
5105 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005106 FunctionType::param_iterator I = Ty->param_begin();
5107 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer38c91a92007-02-28 02:24:54 +00005108 ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005109
Reid Spencer14310612006-12-31 05:40:51 +00005110 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5111 if (ArgI->Val->getType() != *I)
5112 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005113 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005114 Args.push_back(ArgI->Val);
5115 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005116
Reid Spencer14310612006-12-31 05:40:51 +00005117 if (Ty->isVarArg()) {
5118 if (I == E)
5119 for (; ArgI != ArgE; ++ArgI)
5120 Args.push_back(ArgI->Val); // push the remaining varargs
5121 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005122 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005123 }
Reid Spencer14310612006-12-31 05:40:51 +00005124
5125 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005126 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencer38c91a92007-02-28 02:24:54 +00005127 II->setCallingConv((yyvsp[-12].UIntVal));
5128 (yyval.TermInstVal) = II;
5129 delete (yyvsp[-8].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005130 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005131 ;}
5132 break;
5133
Reid Spencer67d8ed92007-03-22 02:14:08 +00005134 case 251:
5135#line 2539 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005136 {
5137 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005138 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005139 ;}
5140 break;
5141
Reid Spencer67d8ed92007-03-22 02:14:08 +00005142 case 252:
5143#line 2543 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005144 {
5145 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005146 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005147 ;}
5148 break;
5149
Reid Spencer67d8ed92007-03-22 02:14:08 +00005150 case 253:
5151#line 2550 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005152 {
5153 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
Reid Spencer93c40032007-03-19 18:40:50 +00005154 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005155 CHECK_FOR_ERROR
5156 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005157 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005158
Reid Spencer38c91a92007-02-28 02:24:54 +00005159 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005160 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005161 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5162 ;}
5163 break;
5164
Reid Spencer67d8ed92007-03-22 02:14:08 +00005165 case 254:
5166#line 2561 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005167 {
5168 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencer93c40032007-03-19 18:40:50 +00005169 Constant *V = cast<Constant>(getExistingVal((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005170 CHECK_FOR_ERROR
5171
5172 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005173 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005174
Reid Spencer38c91a92007-02-28 02:24:54 +00005175 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005176 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005177 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5178 ;}
5179 break;
5180
Reid Spencer67d8ed92007-03-22 02:14:08 +00005181 case 255:
5182#line 2574 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005183 {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005184 // Is this definition named?? if so, assign the name...
Reid Spencer38c91a92007-02-28 02:24:54 +00005185 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Reid Spenceref9b9a72007-02-05 20:47:22 +00005186 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005187 InsertValue((yyvsp[0].InstVal));
5188 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005189 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005190 ;}
5191 break;
5192
Reid Spencer67d8ed92007-03-22 02:14:08 +00005193 case 256:
5194#line 2584 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005195 { // Used for PHI nodes
Reid Spencer14310612006-12-31 05:40:51 +00005196 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005197 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription());
5198 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5199 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005200 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005201 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005202 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005203 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5204 delete (yyvsp[-5].TypeVal);
5205 ;}
5206 break;
5207
Reid Spencer67d8ed92007-03-22 02:14:08 +00005208 case 257:
5209#line 2595 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005210 {
5211 (yyval.PHIList) = (yyvsp[-6].PHIList);
5212 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005213 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005214 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005215 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005216 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5217 ;}
5218 break;
5219
Reid Spencer67d8ed92007-03-22 02:14:08 +00005220 case 258:
5221#line 2605 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005222 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005223 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005224 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005225 // Used for call and invoke instructions
Reid Spencer38c91a92007-02-28 02:24:54 +00005226 (yyval.ValueRefList) = new ValueRefList();
5227 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5228 (yyval.ValueRefList)->push_back(E);
Reid Spencer66728ef2007-03-20 01:13:36 +00005229 delete (yyvsp[-2].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005230 ;}
5231 break;
5232
Reid Spencer67d8ed92007-03-22 02:14:08 +00005233 case 259:
5234#line 2614 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005235 {
Reid Spencer14310612006-12-31 05:40:51 +00005236 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005237 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5238 (yyval.ValueRefList) = (yyvsp[-4].ValueRefList);
5239 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5240 (yyval.ValueRefList)->push_back(E);
Reid Spencer66728ef2007-03-20 01:13:36 +00005241 delete (yyvsp[-2].TypeVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005242 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005243 ;}
5244 break;
5245
Reid Spencer38c91a92007-02-28 02:24:54 +00005246 case 260:
Reid Spencer67d8ed92007-03-22 02:14:08 +00005247#line 2623 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
5248 { (yyval.ValueRefList) = new ValueRefList(); ;}
Reid Spencer38c91a92007-02-28 02:24:54 +00005249 break;
5250
5251 case 261:
Reid Spencer9eba7a22007-03-20 17:19:31 +00005252#line 2626 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer67d8ed92007-03-22 02:14:08 +00005253 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5254 break;
5255
5256 case 262:
5257#line 2627 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005258 {
5259 (yyval.ValueList) = (yyvsp[-2].ValueList);
5260 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer14310612006-12-31 05:40:51 +00005261 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005262 ;}
5263 break;
5264
Reid Spencer67d8ed92007-03-22 02:14:08 +00005265 case 263:
5266#line 2634 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005267 {
5268 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005269 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005270 ;}
5271 break;
5272
Reid Spencer67d8ed92007-03-22 02:14:08 +00005273 case 264:
5274#line 2638 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005275 {
5276 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005277 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005278 ;}
5279 break;
5280
Reid Spencer67d8ed92007-03-22 02:14:08 +00005281 case 265:
5282#line 2643 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005283 {
Reid Spencer14310612006-12-31 05:40:51 +00005284 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005285 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5286 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
5287 !isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005288 GEN_ERROR(
Reid Spencerb5334b02007-02-05 10:18:06 +00005289 "Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005290 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()) &&
5291 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
5292 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
5293 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
Chris Lattner32980692007-02-19 07:44:24 +00005294 GEN_ERROR("Remainder not supported on vector types");
Reid Spencer38c91a92007-02-28 02:24:54 +00005295 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005296 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005297 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005298 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005299 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
5300 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005301 GEN_ERROR("binary operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005302 delete (yyvsp[-3].TypeVal);
5303 ;}
5304 break;
5305
Reid Spencer67d8ed92007-03-22 02:14:08 +00005306 case 266:
5307#line 2664 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005308 {
Reid Spencer14310612006-12-31 05:40:51 +00005309 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005310 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5311 if (!(*(yyvsp[-3].TypeVal))->isInteger()) {
5312 if (Instruction::isShift((yyvsp[-4].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].TypeVal)->get()) ||
5313 !cast<VectorType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00005314 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005315 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005316 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005317 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005318 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005319 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005320 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
5321 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005322 GEN_ERROR("binary operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005323 delete (yyvsp[-3].TypeVal);
5324 ;}
5325 break;
5326
Reid Spencer67d8ed92007-03-22 02:14:08 +00005327 case 267:
5328#line 2681 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005329 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005330 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005331 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5332 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Chris Lattner32980692007-02-19 07:44:24 +00005333 GEN_ERROR("Vector types not supported by icmp instruction");
Reid Spencer38c91a92007-02-28 02:24:54 +00005334 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005335 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005336 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005337 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005338 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5339 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005340 GEN_ERROR("icmp operator returned null");
Reid Spencer66728ef2007-03-20 01:13:36 +00005341 delete (yyvsp[-3].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005342 ;}
5343 break;
5344
Reid Spencer67d8ed92007-03-22 02:14:08 +00005345 case 268:
5346#line 2695 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005347 {
Reid Spencer14310612006-12-31 05:40:51 +00005348 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005349 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5350 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Chris Lattner32980692007-02-19 07:44:24 +00005351 GEN_ERROR("Vector types not supported by fcmp instruction");
Reid Spencer38c91a92007-02-28 02:24:54 +00005352 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005353 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005354 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005355 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005356 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5357 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005358 GEN_ERROR("fcmp operator returned null");
Reid Spencer66728ef2007-03-20 01:13:36 +00005359 delete (yyvsp[-3].TypeVal);
Reid Spencer38c91a92007-02-28 02:24:54 +00005360 ;}
5361 break;
5362
Reid Spencer67d8ed92007-03-22 02:14:08 +00005363 case 269:
5364#line 2709 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005365 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005366 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005367 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5368 Value* Val = (yyvsp[-2].ValueVal);
5369 const Type* DestTy = (yyvsp[0].TypeVal)->get();
5370 if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005371 GEN_ERROR("invalid cast opcode for cast from '" +
5372 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005373 DestTy->getDescription() + "'");
Reid Spencer38c91a92007-02-28 02:24:54 +00005374 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy);
5375 delete (yyvsp[0].TypeVal);
5376 ;}
5377 break;
5378
Reid Spencer67d8ed92007-03-22 02:14:08 +00005379 case 270:
5380#line 2721 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005381 {
5382 if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00005383 GEN_ERROR("select condition must be boolean");
Reid Spencer38c91a92007-02-28 02:24:54 +00005384 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00005385 GEN_ERROR("select value types should match");
Reid Spencer38c91a92007-02-28 02:24:54 +00005386 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005387 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005388 ;}
5389 break;
5390
Reid Spencer67d8ed92007-03-22 02:14:08 +00005391 case 271:
5392#line 2729 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005393 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005394 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005395 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5396 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5397 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005398 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005399 ;}
5400 break;
5401
Reid Spencer67d8ed92007-03-22 02:14:08 +00005402 case 272:
5403#line 2736 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005404 {
5405 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005406 GEN_ERROR("Invalid extractelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005407 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005408 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005409 ;}
5410 break;
5411
Reid Spencer67d8ed92007-03-22 02:14:08 +00005412 case 273:
5413#line 2742 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005414 {
5415 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005416 GEN_ERROR("Invalid insertelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005417 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005418 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005419 ;}
5420 break;
5421
Reid Spencer67d8ed92007-03-22 02:14:08 +00005422 case 274:
5423#line 2748 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005424 {
5425 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005426 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005427 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005428 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005429 ;}
5430 break;
5431
Reid Spencer67d8ed92007-03-22 02:14:08 +00005432 case 275:
5433#line 2754 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005434 {
5435 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005436 if (!Ty->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00005437 GEN_ERROR("PHI node operands must be of first class type");
Reid Spencer38c91a92007-02-28 02:24:54 +00005438 (yyval.InstVal) = new PHINode(Ty);
5439 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5440 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5441 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00005442 GEN_ERROR("All elements of a PHI node must be of the same type");
Reid Spencer38c91a92007-02-28 02:24:54 +00005443 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5444 (yyvsp[0].PHIList)->pop_front();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005445 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005446 delete (yyvsp[0].PHIList); // Free the list...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005447 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005448 ;}
5449 break;
5450
Reid Spencer67d8ed92007-03-22 02:14:08 +00005451 case 276:
5452#line 2770 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005453 {
Reid Spencer14310612006-12-31 05:40:51 +00005454
5455 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005456 const PointerType *PFTy = 0;
5457 const FunctionType *Ty = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00005458 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005459 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5460 // Pull out the types of all of the arguments...
5461 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005462 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00005463 ParamAttrs.push_back((yyvsp[0].ParamAttrs));
5464 for (ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005465 const Type *Ty = I->Val->getType();
5466 if (Ty == Type::VoidTy)
5467 GEN_ERROR("Short call syntax cannot be used with varargs");
5468 ParamTypes.push_back(Ty);
5469 ParamAttrs.push_back(I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005470 }
5471
Reid Spencer38c91a92007-02-28 02:24:54 +00005472 Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005473 PFTy = PointerType::get(Ty);
5474 }
5475
Reid Spencer38c91a92007-02-28 02:24:54 +00005476 Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005477 CHECK_FOR_ERROR
5478
Reid Spencer14310612006-12-31 05:40:51 +00005479 // Check the arguments
5480 ValueList Args;
Reid Spencer38c91a92007-02-28 02:24:54 +00005481 if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005482 // Make sure no arguments is a good thing!
5483 if (Ty->getNumParams() != 0)
5484 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005485 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005486 } else { // Has arguments?
5487 // Loop through FunctionType's arguments and ensure they are specified
5488 // correctly!
5489 //
5490 FunctionType::param_iterator I = Ty->param_begin();
5491 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer38c91a92007-02-28 02:24:54 +00005492 ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005493
Reid Spencer14310612006-12-31 05:40:51 +00005494 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5495 if (ArgI->Val->getType() != *I)
5496 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005497 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005498 Args.push_back(ArgI->Val);
5499 }
5500 if (Ty->isVarArg()) {
5501 if (I == E)
5502 for (; ArgI != ArgE; ++ArgI)
5503 Args.push_back(ArgI->Val); // push the remaining varargs
5504 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005505 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005506 }
Reid Spencer14310612006-12-31 05:40:51 +00005507 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00005508 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencer38c91a92007-02-28 02:24:54 +00005509 CI->setTailCall((yyvsp[-7].BoolVal));
5510 CI->setCallingConv((yyvsp[-6].UIntVal));
5511 (yyval.InstVal) = CI;
5512 delete (yyvsp[-2].ValueRefList);
5513 delete (yyvsp[-5].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005514 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005515 ;}
5516 break;
5517
Reid Spencer67d8ed92007-03-22 02:14:08 +00005518 case 277:
5519#line 2833 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005520 {
5521 (yyval.InstVal) = (yyvsp[0].InstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005522 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005523 ;}
5524 break;
5525
Reid Spencer67d8ed92007-03-22 02:14:08 +00005526 case 278:
5527#line 2838 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005528 {
5529 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005530 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005531 ;}
5532 break;
5533
Reid Spencer67d8ed92007-03-22 02:14:08 +00005534 case 279:
5535#line 2842 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005536 {
5537 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005538 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005539 ;}
5540 break;
5541
Reid Spencer67d8ed92007-03-22 02:14:08 +00005542 case 280:
5543#line 2849 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005544 {
Reid Spencer6f407902007-01-13 05:00:46 +00005545 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005546 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5547 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5548 delete (yyvsp[-1].TypeVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005549 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005550 ;}
5551 break;
5552
Reid Spencer67d8ed92007-03-22 02:14:08 +00005553 case 281:
5554#line 2856 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005555 {
Reid Spencer14310612006-12-31 05:40:51 +00005556 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005557 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5558 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005559 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005560 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5561 delete (yyvsp[-4].TypeVal);
5562 ;}
5563 break;
5564
Reid Spencer67d8ed92007-03-22 02:14:08 +00005565 case 282:
5566#line 2864 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005567 {
Reid Spencer14310612006-12-31 05:40:51 +00005568 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005569 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5570 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5571 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005572 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005573 ;}
5574 break;
5575
Reid Spencer67d8ed92007-03-22 02:14:08 +00005576 case 283:
5577#line 2871 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005578 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005579 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005580 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5581 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005582 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005583 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5584 delete (yyvsp[-4].TypeVal);
5585 ;}
5586 break;
5587
Reid Spencer67d8ed92007-03-22 02:14:08 +00005588 case 284:
5589#line 2879 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005590 {
5591 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005592 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005593 (yyvsp[0].ValueVal)->getType()->getDescription() + "");
5594 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005595 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005596 ;}
5597 break;
5598
Reid Spencer67d8ed92007-03-22 02:14:08 +00005599 case 285:
5600#line 2887 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005601 {
Reid Spencer14310612006-12-31 05:40:51 +00005602 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005603 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5604 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005605 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005606 (*(yyvsp[-1].TypeVal))->getDescription());
5607 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005608 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005609 (*(yyvsp[-1].TypeVal))->getDescription());
5610 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005611 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005612 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5613 delete (yyvsp[-1].TypeVal);
5614 ;}
5615 break;
5616
Reid Spencer67d8ed92007-03-22 02:14:08 +00005617 case 286:
5618#line 2901 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005619 {
Reid Spencer14310612006-12-31 05:40:51 +00005620 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005621 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5622 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005623 if (!PT)
5624 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005625 (*(yyvsp[-1].TypeVal))->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005626 const Type *ElTy = PT->getElementType();
Reid Spencer38c91a92007-02-28 02:24:54 +00005627 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5628 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencerb5334b02007-02-05 10:18:06 +00005629 "' into space of type '" + ElTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005630
Reid Spencer38c91a92007-02-28 02:24:54 +00005631 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005632 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005633 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5634 delete (yyvsp[-1].TypeVal);
5635 ;}
5636 break;
5637
Reid Spencer67d8ed92007-03-22 02:14:08 +00005638 case 287:
5639#line 2918 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005640 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005641 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005642 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5643 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005644 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005645
Reid Spencer38c91a92007-02-28 02:24:54 +00005646 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005647 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00005648 (*(yyvsp[-2].TypeVal))->getDescription()+ "'");
5649 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005650 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005651 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size());
5652 delete (yyvsp[-2].TypeVal);
5653 delete (yyvsp[0].ValueList);
5654 ;}
5655 break;
5656
5657
5658 default: break;
5659 }
5660
5661/* Line 1126 of yacc.c. */
Reid Spencer67d8ed92007-03-22 02:14:08 +00005662#line 5663 "llvmAsmParser.tab.c"
Chris Lattner9d2fda62007-02-13 05:53:56 +00005663
5664 yyvsp -= yylen;
5665 yyssp -= yylen;
Reid Spencer5cbf9852007-01-30 20:08:39 +00005666
Reid Spencer38c91a92007-02-28 02:24:54 +00005667
5668 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005669
5670 *++yyvsp = yyval;
5671
5672
Reid Spencer38c91a92007-02-28 02:24:54 +00005673 /* Now `shift' the result of the reduction. Determine what state
5674 that goes to, based on the state we popped back to and the rule
5675 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005676
5677 yyn = yyr1[yyn];
5678
Reid Spencer38c91a92007-02-28 02:24:54 +00005679 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5680 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005681 yystate = yytable[yystate];
5682 else
Reid Spencer38c91a92007-02-28 02:24:54 +00005683 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005684
5685 goto yynewstate;
5686
5687
Reid Spencer38c91a92007-02-28 02:24:54 +00005688/*------------------------------------.
5689| yyerrlab -- here on detecting error |
5690`------------------------------------*/
5691yyerrlab:
5692 /* If not already recovering from an error, report this error. */
5693 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005694 {
5695 ++yynerrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00005696#if YYERROR_VERBOSE
Chris Lattner9d2fda62007-02-13 05:53:56 +00005697 yyn = yypact[yystate];
5698
Reid Spencer38c91a92007-02-28 02:24:54 +00005699 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattner9d2fda62007-02-13 05:53:56 +00005700 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005701 int yytype = YYTRANSLATE (yychar);
5702 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5703 YYSIZE_T yysize = yysize0;
5704 YYSIZE_T yysize1;
5705 int yysize_overflow = 0;
5706 char *yymsg = 0;
5707# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5708 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5709 int yyx;
Chris Lattner9d2fda62007-02-13 05:53:56 +00005710
Reid Spencer38c91a92007-02-28 02:24:54 +00005711#if 0
5712 /* This is so xgettext sees the translatable formats that are
5713 constructed on the fly. */
5714 YY_("syntax error, unexpected %s");
5715 YY_("syntax error, unexpected %s, expecting %s");
5716 YY_("syntax error, unexpected %s, expecting %s or %s");
5717 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5718 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5719#endif
5720 char *yyfmt;
5721 char const *yyf;
5722 static char const yyunexpected[] = "syntax error, unexpected %s";
5723 static char const yyexpecting[] = ", expecting %s";
5724 static char const yyor[] = " or %s";
5725 char yyformat[sizeof yyunexpected
5726 + sizeof yyexpecting - 1
5727 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5728 * (sizeof yyor - 1))];
5729 char const *yyprefix = yyexpecting;
5730
5731 /* Start YYX at -YYN if negative to avoid negative indexes in
5732 YYCHECK. */
5733 int yyxbegin = yyn < 0 ? -yyn : 0;
5734
5735 /* Stay within bounds of both yycheck and yytname. */
5736 int yychecklim = YYLAST - yyn;
5737 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5738 int yycount = 1;
5739
5740 yyarg[0] = yytname[yytype];
5741 yyfmt = yystpcpy (yyformat, yyunexpected);
5742
5743 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5744 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5745 {
5746 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5747 {
5748 yycount = 1;
5749 yysize = yysize0;
5750 yyformat[sizeof yyunexpected - 1] = '\0';
5751 break;
5752 }
5753 yyarg[yycount++] = yytname[yyx];
5754 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5755 yysize_overflow |= yysize1 < yysize;
5756 yysize = yysize1;
5757 yyfmt = yystpcpy (yyfmt, yyprefix);
5758 yyprefix = yyor;
5759 }
5760
5761 yyf = YY_(yyformat);
5762 yysize1 = yysize + yystrlen (yyf);
5763 yysize_overflow |= yysize1 < yysize;
5764 yysize = yysize1;
5765
5766 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5767 yymsg = (char *) YYSTACK_ALLOC (yysize);
5768 if (yymsg)
Chris Lattner9d2fda62007-02-13 05:53:56 +00005769 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005770 /* Avoid sprintf, as that infringes on the user's name space.
5771 Don't have undefined behavior even if the translation
5772 produced a string with the wrong number of "%s"s. */
5773 char *yyp = yymsg;
5774 int yyi = 0;
5775 while ((*yyp = *yyf))
Chris Lattner9d2fda62007-02-13 05:53:56 +00005776 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005777 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5778 {
5779 yyp += yytnamerr (yyp, yyarg[yyi++]);
5780 yyf += 2;
5781 }
5782 else
5783 {
5784 yyp++;
5785 yyf++;
5786 }
Chris Lattner9d2fda62007-02-13 05:53:56 +00005787 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005788 yyerror (yymsg);
5789 YYSTACK_FREE (yymsg);
Chris Lattner9d2fda62007-02-13 05:53:56 +00005790 }
5791 else
Reid Spencer38c91a92007-02-28 02:24:54 +00005792 {
5793 yyerror (YY_("syntax error"));
5794 goto yyexhaustedlab;
5795 }
Chris Lattner9d2fda62007-02-13 05:53:56 +00005796 }
5797 else
5798#endif /* YYERROR_VERBOSE */
Reid Spencer38c91a92007-02-28 02:24:54 +00005799 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005800 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00005801
Reid Spencer38c91a92007-02-28 02:24:54 +00005802
Reid Spencer41dff5e2007-01-26 08:05:27 +00005803
5804 if (yyerrstatus == 3)
5805 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005806 /* If just tried and failed to reuse look-ahead token after an
5807 error, discard it. */
Reid Spencer41dff5e2007-01-26 08:05:27 +00005808
Reid Spencer38c91a92007-02-28 02:24:54 +00005809 if (yychar <= YYEOF)
5810 {
5811 /* Return failure if at end of input. */
5812 if (yychar == YYEOF)
5813 YYABORT;
5814 }
5815 else
5816 {
5817 yydestruct ("Error: discarding", yytoken, &yylval);
5818 yychar = YYEMPTY;
5819 }
5820 }
5821
5822 /* Else will try to reuse look-ahead token after shifting the error
5823 token. */
5824 goto yyerrlab1;
5825
5826
5827/*---------------------------------------------------.
5828| yyerrorlab -- error raised explicitly by YYERROR. |
5829`---------------------------------------------------*/
5830yyerrorlab:
5831
5832 /* Pacify compilers like GCC when the user code never invokes
5833 YYERROR and the label yyerrorlab therefore never appears in user
5834 code. */
5835 if (0)
5836 goto yyerrorlab;
5837
5838yyvsp -= yylen;
5839 yyssp -= yylen;
5840 yystate = *yyssp;
5841 goto yyerrlab1;
5842
5843
5844/*-------------------------------------------------------------.
5845| yyerrlab1 -- common code for both syntax error and YYERROR. |
5846`-------------------------------------------------------------*/
5847yyerrlab1:
5848 yyerrstatus = 3; /* Each real token shifted decrements this. */
5849
5850 for (;;)
5851 {
5852 yyn = yypact[yystate];
5853 if (yyn != YYPACT_NINF)
5854 {
5855 yyn += YYTERROR;
5856 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5857 {
5858 yyn = yytable[yyn];
5859 if (0 < yyn)
5860 break;
5861 }
5862 }
5863
5864 /* Pop the current state because it cannot handle the error token. */
5865 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005866 YYABORT;
5867
Reid Spencere4d87aa2006-12-23 06:05:41 +00005868
Reid Spencer38c91a92007-02-28 02:24:54 +00005869 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5870 YYPOPSTACK;
5871 yystate = *yyssp;
5872 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005873 }
5874
5875 if (yyn == YYFINAL)
5876 YYACCEPT;
5877
Reid Spencer68a24bd2005-08-27 18:50:39 +00005878 *++yyvsp = yylval;
Reid Spencer38c91a92007-02-28 02:24:54 +00005879
5880
5881 /* Shift the error token. */
5882 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer41dff5e2007-01-26 08:05:27 +00005883
Reid Spencer68a24bd2005-08-27 18:50:39 +00005884 yystate = yyn;
5885 goto yynewstate;
5886
Chris Lattner32980692007-02-19 07:44:24 +00005887
Reid Spencer38c91a92007-02-28 02:24:54 +00005888/*-------------------------------------.
5889| yyacceptlab -- YYACCEPT comes here. |
5890`-------------------------------------*/
5891yyacceptlab:
5892 yyresult = 0;
5893 goto yyreturn;
5894
5895/*-----------------------------------.
5896| yyabortlab -- YYABORT comes here. |
5897`-----------------------------------*/
5898yyabortlab:
5899 yyresult = 1;
5900 goto yyreturn;
5901
5902#ifndef yyoverflow
5903/*-------------------------------------------------.
5904| yyexhaustedlab -- memory exhaustion comes here. |
5905`-------------------------------------------------*/
5906yyexhaustedlab:
5907 yyerror (YY_("memory exhausted"));
5908 yyresult = 2;
5909 /* Fall through. */
Chris Lattner32980692007-02-19 07:44:24 +00005910#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00005911
5912yyreturn:
5913 if (yychar != YYEOF && yychar != YYEMPTY)
5914 yydestruct ("Cleanup: discarding lookahead",
5915 yytoken, &yylval);
5916 while (yyssp != yyss)
5917 {
5918 yydestruct ("Cleanup: popping",
5919 yystos[*yyssp], yyvsp);
5920 YYPOPSTACK;
Chris Lattner32980692007-02-19 07:44:24 +00005921 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005922#ifndef yyoverflow
5923 if (yyss != yyssa)
5924 YYSTACK_FREE (yyss);
5925#endif
5926 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005927}
Reid Spencer38c91a92007-02-28 02:24:54 +00005928
5929
Reid Spencer67d8ed92007-03-22 02:14:08 +00005930#line 2935 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005931
5932
Reid Spencer14310612006-12-31 05:40:51 +00005933// common code from the two 'RunVMAsmParser' functions
5934static Module* RunParser(Module * M) {
5935
5936 llvmAsmlineno = 1; // Reset the current line number...
5937 CurModule.CurrentModule = M;
5938#if YYDEBUG
5939 yydebug = Debug;
5940#endif
5941
5942 // Check to make sure the parser succeeded
5943 if (yyparse()) {
5944 if (ParserResult)
5945 delete ParserResult;
5946 return 0;
5947 }
5948
Reid Spencer0d60b5a2007-03-30 01:37:39 +00005949 // Emit an error if there are any unresolved types left.
5950 if (!CurModule.LateResolveTypes.empty()) {
5951 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5952 if (DID.Type == ValID::LocalName) {
5953 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5954 } else {
5955 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5956 }
5957 if (ParserResult)
5958 delete ParserResult;
5959 return 0;
5960 }
5961
5962 // Emit an error if there are any unresolved values left.
5963 if (!CurModule.LateResolveValues.empty()) {
5964 Value *V = CurModule.LateResolveValues.back();
5965 std::map<Value*, std::pair<ValID, int> >::iterator I =
5966 CurModule.PlaceHolderInfo.find(V);
5967
5968 if (I != CurModule.PlaceHolderInfo.end()) {
5969 ValID &DID = I->second.first;
5970 if (DID.Type == ValID::LocalName) {
5971 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5972 } else {
5973 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5974 }
5975 if (ParserResult)
5976 delete ParserResult;
5977 return 0;
5978 }
5979 }
5980
Reid Spencer14310612006-12-31 05:40:51 +00005981 // Check to make sure that parsing produced a result
5982 if (!ParserResult)
5983 return 0;
5984
5985 // Reset ParserResult variable while saving its value for the result.
5986 Module *Result = ParserResult;
5987 ParserResult = 0;
5988
5989 return Result;
5990}
5991
Reid Spencer61c83e02006-08-18 08:43:06 +00005992void llvm::GenerateError(const std::string &message, int LineNo) {
5993 if (LineNo == -1) LineNo = llvmAsmlineno;
5994 // TODO: column number in exception
5995 if (TheParseError)
5996 TheParseError->setError(CurFilename, message, LineNo);
5997 TriggerError = 1;
5998}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005999
6000int yyerror(const char *ErrorMsg) {
6001 std::string where
6002 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6003 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006004 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6005 if (yychar != YYEMPTY && yychar != 0)
6006 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6007 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00006008 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006009 return 0;
6010}
Reid Spencer38c91a92007-02-28 02:24:54 +00006011