blob: 0f9f160b886debacb13f4ced8ccb5a16fdee2c02 [file] [log] [blame]
David Greene5fd22a82007-09-04 18:46:50 +00001/* A Bison parser, made by GNU Bison 1.875c. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
David Greene5fd22a82007-09-04 18:46:50 +00003/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005
David Greene5fd22a82007-09-04 18:46:50 +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
David Greene5fd22a82007-09-04 18:46:50 +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., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, 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/* Skeleton name. */
40#define YYSKELETON_NAME "yacc.c"
41
42/* Pure parsers. */
43#define YYPURE 0
44
45/* Using locations. */
46#define YYLSP_NEEDED 0
47
48/* If NAME_PREFIX is specified substitute the variables and functions
49 names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000050#define yyparse llvmAsmparse
David Greene5fd22a82007-09-04 18:46:50 +000051#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000052#define yyerror llvmAsmerror
David Greene5fd22a82007-09-04 18:46:50 +000053#define yylval llvmAsmlval
54#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000055#define yydebug llvmAsmdebug
56#define yynerrs llvmAsmnerrs
57
David Greene5fd22a82007-09-04 18:46:50 +000058
59/* Tokens. */
60#ifndef YYTOKENTYPE
61# define YYTOKENTYPE
62 /* Put the tokens into the symbol table, so that GDB and other debuggers
63 know about them. */
64 enum yytokentype {
65 ESINT64VAL = 258,
66 EUINT64VAL = 259,
67 ESAPINTVAL = 260,
68 EUAPINTVAL = 261,
69 LOCALVAL_ID = 262,
70 GLOBALVAL_ID = 263,
71 FPVAL = 264,
72 VOID = 265,
73 INTTYPE = 266,
74 FLOAT = 267,
75 DOUBLE = 268,
76 X86_FP80 = 269,
77 FP128 = 270,
78 PPC_FP128 = 271,
79 LABEL = 272,
80 TYPE = 273,
81 LOCALVAR = 274,
82 GLOBALVAR = 275,
83 LABELSTR = 276,
84 STRINGCONSTANT = 277,
85 ATSTRINGCONSTANT = 278,
86 PCTSTRINGCONSTANT = 279,
87 ZEROINITIALIZER = 280,
88 TRUETOK = 281,
89 FALSETOK = 282,
90 BEGINTOK = 283,
91 ENDTOK = 284,
92 DECLARE = 285,
93 DEFINE = 286,
94 GLOBAL = 287,
95 CONSTANT = 288,
96 SECTION = 289,
97 ALIAS = 290,
98 VOLATILE = 291,
99 THREAD_LOCAL = 292,
100 TO = 293,
101 DOTDOTDOT = 294,
102 NULL_TOK = 295,
103 UNDEF = 296,
104 INTERNAL = 297,
105 LINKONCE = 298,
106 WEAK = 299,
107 APPENDING = 300,
108 DLLIMPORT = 301,
109 DLLEXPORT = 302,
110 EXTERN_WEAK = 303,
111 OPAQUE = 304,
112 EXTERNAL = 305,
113 TARGET = 306,
114 TRIPLE = 307,
115 ALIGN = 308,
116 DEPLIBS = 309,
117 CALL = 310,
118 TAIL = 311,
119 ASM_TOK = 312,
120 MODULE = 313,
121 SIDEEFFECT = 314,
122 CC_TOK = 315,
123 CCC_TOK = 316,
124 FASTCC_TOK = 317,
125 COLDCC_TOK = 318,
126 X86_STDCALLCC_TOK = 319,
127 X86_FASTCALLCC_TOK = 320,
128 DATALAYOUT = 321,
129 RET = 322,
130 BR = 323,
131 SWITCH = 324,
132 INVOKE = 325,
133 UNWIND = 326,
134 UNREACHABLE = 327,
135 ADD = 328,
136 SUB = 329,
137 MUL = 330,
138 UDIV = 331,
139 SDIV = 332,
140 FDIV = 333,
141 UREM = 334,
142 SREM = 335,
143 FREM = 336,
144 AND = 337,
145 OR = 338,
146 XOR = 339,
147 SHL = 340,
148 LSHR = 341,
149 ASHR = 342,
150 ICMP = 343,
151 FCMP = 344,
152 EQ = 345,
153 NE = 346,
154 SLT = 347,
155 SGT = 348,
156 SLE = 349,
157 SGE = 350,
158 ULT = 351,
159 UGT = 352,
160 ULE = 353,
161 UGE = 354,
162 OEQ = 355,
163 ONE = 356,
164 OLT = 357,
165 OGT = 358,
166 OLE = 359,
167 OGE = 360,
168 ORD = 361,
169 UNO = 362,
170 UEQ = 363,
171 UNE = 364,
172 MALLOC = 365,
173 ALLOCA = 366,
174 FREE = 367,
175 LOAD = 368,
176 STORE = 369,
177 GETELEMENTPTR = 370,
178 TRUNC = 371,
179 ZEXT = 372,
180 SEXT = 373,
181 FPTRUNC = 374,
182 FPEXT = 375,
183 BITCAST = 376,
184 UITOFP = 377,
185 SITOFP = 378,
186 FPTOUI = 379,
187 FPTOSI = 380,
188 INTTOPTR = 381,
189 PTRTOINT = 382,
190 PHI_TOK = 383,
191 SELECT = 384,
192 VAARG = 385,
193 EXTRACTELEMENT = 386,
194 INSERTELEMENT = 387,
195 SHUFFLEVECTOR = 388,
196 SIGNEXT = 389,
197 ZEROEXT = 390,
198 NORETURN = 391,
199 INREG = 392,
200 SRET = 393,
201 NOUNWIND = 394,
202 NOALIAS = 395,
203 BYVAL = 396,
204 NEST = 397,
205 DEFAULT = 398,
206 HIDDEN = 399,
207 PROTECTED = 400
208 };
209#endif
210#define ESINT64VAL 258
211#define EUINT64VAL 259
212#define ESAPINTVAL 260
213#define EUAPINTVAL 261
214#define LOCALVAL_ID 262
215#define GLOBALVAL_ID 263
216#define FPVAL 264
217#define VOID 265
218#define INTTYPE 266
219#define FLOAT 267
220#define DOUBLE 268
221#define X86_FP80 269
222#define FP128 270
223#define PPC_FP128 271
224#define LABEL 272
225#define TYPE 273
226#define LOCALVAR 274
227#define GLOBALVAR 275
228#define LABELSTR 276
229#define STRINGCONSTANT 277
230#define ATSTRINGCONSTANT 278
231#define PCTSTRINGCONSTANT 279
232#define ZEROINITIALIZER 280
233#define TRUETOK 281
234#define FALSETOK 282
235#define BEGINTOK 283
236#define ENDTOK 284
237#define DECLARE 285
238#define DEFINE 286
239#define GLOBAL 287
240#define CONSTANT 288
241#define SECTION 289
242#define ALIAS 290
243#define VOLATILE 291
244#define THREAD_LOCAL 292
245#define TO 293
246#define DOTDOTDOT 294
247#define NULL_TOK 295
248#define UNDEF 296
249#define INTERNAL 297
250#define LINKONCE 298
251#define WEAK 299
252#define APPENDING 300
253#define DLLIMPORT 301
254#define DLLEXPORT 302
255#define EXTERN_WEAK 303
256#define OPAQUE 304
257#define EXTERNAL 305
258#define TARGET 306
259#define TRIPLE 307
260#define ALIGN 308
261#define DEPLIBS 309
262#define CALL 310
263#define TAIL 311
264#define ASM_TOK 312
265#define MODULE 313
266#define SIDEEFFECT 314
267#define CC_TOK 315
268#define CCC_TOK 316
269#define FASTCC_TOK 317
270#define COLDCC_TOK 318
271#define X86_STDCALLCC_TOK 319
272#define X86_FASTCALLCC_TOK 320
273#define DATALAYOUT 321
274#define RET 322
275#define BR 323
276#define SWITCH 324
277#define INVOKE 325
278#define UNWIND 326
279#define UNREACHABLE 327
280#define ADD 328
281#define SUB 329
282#define MUL 330
283#define UDIV 331
284#define SDIV 332
285#define FDIV 333
286#define UREM 334
287#define SREM 335
288#define FREM 336
289#define AND 337
290#define OR 338
291#define XOR 339
292#define SHL 340
293#define LSHR 341
294#define ASHR 342
295#define ICMP 343
296#define FCMP 344
297#define EQ 345
298#define NE 346
299#define SLT 347
300#define SGT 348
301#define SLE 349
302#define SGE 350
303#define ULT 351
304#define UGT 352
305#define ULE 353
306#define UGE 354
307#define OEQ 355
308#define ONE 356
309#define OLT 357
310#define OGT 358
311#define OLE 359
312#define OGE 360
313#define ORD 361
314#define UNO 362
315#define UEQ 363
316#define UNE 364
317#define MALLOC 365
318#define ALLOCA 366
319#define FREE 367
320#define LOAD 368
321#define STORE 369
322#define GETELEMENTPTR 370
323#define TRUNC 371
324#define ZEXT 372
325#define SEXT 373
326#define FPTRUNC 374
327#define FPEXT 375
328#define BITCAST 376
329#define UITOFP 377
330#define SITOFP 378
331#define FPTOUI 379
332#define FPTOSI 380
333#define INTTOPTR 381
334#define PTRTOINT 382
335#define PHI_TOK 383
336#define SELECT 384
337#define VAARG 385
338#define EXTRACTELEMENT 386
339#define INSERTELEMENT 387
340#define SHUFFLEVECTOR 388
341#define SIGNEXT 389
342#define ZEROEXT 390
343#define NORETURN 391
344#define INREG 392
345#define SRET 393
346#define NOUNWIND 394
347#define NOALIAS 395
348#define BYVAL 396
349#define NEST 397
350#define DEFAULT 398
351#define HIDDEN 399
352#define PROTECTED 400
353
354
355
356
357/* Copy the first part of user declarations. */
358#line 14 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000359
360#include "ParserInternals.h"
361#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000362#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000363#include "llvm/Instructions.h"
364#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000365#include "llvm/ValueSymbolTable.h"
Chandler Carruth02202192007-08-04 01:56:21 +0000366#include "llvm/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000367#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000368#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000369#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000370#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000371#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000372#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000373#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000374#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000375#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000376#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000377#ifndef NDEBUG
378#define YYDEBUG 1
379#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000380
Reid Spencere4f47592006-08-18 17:32:55 +0000381// The following is a gross hack. In order to rid the libAsmParser library of
382// exceptions, we have to have a way of getting the yyparse function to go into
383// an error situation. So, whenever we want an error to occur, the GenerateError
384// function (see bottom of file) sets TriggerError. Then, at the end of each
385// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
386// (a goto) to put YACC in error state. Furthermore, several calls to
387// GenerateError are made from inside productions and they must simulate the
388// previous exception behavior by exiting the production immediately. We have
389// replaced these with the GEN_ERROR macro which calls GeneratError and then
390// immediately invokes YYERROR. This would be so much cleaner if it was a
391// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000392static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000393#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000394#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
395
Reid Spencer68a24bd2005-08-27 18:50:39 +0000396int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
397int yylex(); // declaration" of xxx warnings.
398int yyparse();
399
400namespace llvm {
401 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000402#if YYDEBUG
403static cl::opt<bool>
404Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
405 cl::Hidden, cl::init(false));
406#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000407}
408using namespace llvm;
409
410static Module *ParserResult;
411
412// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
413// relating to upreferences in the input stream.
414//
415//#define DEBUG_UPREFS 1
416#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000417#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000418#else
419#define UR_OUT(X)
420#endif
421
422#define YYERROR_VERBOSE 1
423
Chris Lattnerb475c422005-11-12 18:22:38 +0000424static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000425
426
427// This contains info used when building the body of a function. It is
428// destroyed when the function is completed.
429//
430typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000431
Reid Spencer68a24bd2005-08-27 18:50:39 +0000432static void
Reid Spencer93c40032007-03-19 18:40:50 +0000433ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000434
435static struct PerModuleInfo {
436 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000437 ValueList Values; // Module level numbered definitions
438 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000439 std::vector<PATypeHolder> Types;
440 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000441
442 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000443 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000444 /// that we can resolve them later and print error messages as appropriate.
445 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
446
447 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
448 // references to global values. Global values may be referenced before they
449 // are defined, and if so, the temporary object that they represent is held
450 // here. This is used for forward references of GlobalValues.
451 //
452 typedef std::map<std::pair<const PointerType *,
453 ValID>, GlobalValue*> GlobalRefsType;
454 GlobalRefsType GlobalRefs;
455
456 void ModuleDone() {
457 // If we could not resolve some functions at function compilation time
458 // (calls to functions before they are defined), resolve them now... Types
459 // are resolved when the constant pool has been completely parsed.
460 //
461 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000462 if (TriggerError)
463 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000464
465 // Check to make sure that all global value forward references have been
466 // resolved!
467 //
468 if (!GlobalRefs.empty()) {
469 std::string UndefinedReferences = "Unresolved global references exist:\n";
470
471 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
472 I != E; ++I) {
473 UndefinedReferences += " " + I->first.first->getDescription() + " " +
474 I->first.second.getName() + "\n";
475 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000476 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000477 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000478 }
479
Chandler Carruth02202192007-08-04 01:56:21 +0000480 // Look for intrinsic functions and CallInst that need to be upgraded
481 for (Module::iterator FI = CurrentModule->begin(),
482 FE = CurrentModule->end(); FI != FE; )
483 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
484
Reid Spencer68a24bd2005-08-27 18:50:39 +0000485 Values.clear(); // Clear out function local definitions
486 Types.clear();
487 CurrentModule = 0;
488 }
489
Reid Spencer68a24bd2005-08-27 18:50:39 +0000490 // GetForwardRefForGlobal - Check to see if there is a forward reference
491 // for this global. If so, remove it from the GlobalRefs map and return it.
492 // If not, just return null.
493 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
494 // Check to see if there is a forward reference to this global variable...
495 // if there is, eliminate it and patch the reference to use the new def'n.
496 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
497 GlobalValue *Ret = 0;
498 if (I != GlobalRefs.end()) {
499 Ret = I->second;
500 GlobalRefs.erase(I);
501 }
502 return Ret;
503 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000504
505 bool TypeIsUnresolved(PATypeHolder* PATy) {
506 // If it isn't abstract, its resolved
507 const Type* Ty = PATy->get();
508 if (!Ty->isAbstract())
509 return false;
510 // Traverse the type looking for abstract types. If it isn't abstract then
511 // we don't need to traverse that leg of the type.
512 std::vector<const Type*> WorkList, SeenList;
513 WorkList.push_back(Ty);
514 while (!WorkList.empty()) {
515 const Type* Ty = WorkList.back();
516 SeenList.push_back(Ty);
517 WorkList.pop_back();
518 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
519 // Check to see if this is an unresolved type
520 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
521 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
522 for ( ; I != E; ++I) {
523 if (I->second.get() == OpTy)
524 return true;
525 }
526 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
527 const Type* TheTy = SeqTy->getElementType();
528 if (TheTy->isAbstract() && TheTy != Ty) {
529 std::vector<const Type*>::iterator I = SeenList.begin(),
530 E = SeenList.end();
531 for ( ; I != E; ++I)
532 if (*I == TheTy)
533 break;
534 if (I == E)
535 WorkList.push_back(TheTy);
536 }
537 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
538 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
539 const Type* TheTy = StrTy->getElementType(i);
540 if (TheTy->isAbstract() && TheTy != Ty) {
541 std::vector<const Type*>::iterator I = SeenList.begin(),
542 E = SeenList.end();
543 for ( ; I != E; ++I)
544 if (*I == TheTy)
545 break;
546 if (I == E)
547 WorkList.push_back(TheTy);
548 }
549 }
550 }
551 }
552 return false;
553 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000554} CurModule;
555
556static struct PerFunctionInfo {
557 Function *CurrentFunction; // Pointer to current function being created
558
Reid Spencer93c40032007-03-19 18:40:50 +0000559 ValueList Values; // Keep track of #'d definitions
560 unsigned NextValNum;
561 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000562 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000563 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000564 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000565
566 /// BBForwardRefs - When we see forward references to basic blocks, keep
567 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000568 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000569
570 inline PerFunctionInfo() {
571 CurrentFunction = 0;
572 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000573 Linkage = GlobalValue::ExternalLinkage;
574 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000575 }
576
577 inline void FunctionStart(Function *M) {
578 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000579 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000580 }
581
582 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000583 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000584 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000585 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000586 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000587 return;
588 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000589
590 // Resolve all forward references now.
591 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
592
593 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000594 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000595 CurrentFunction = 0;
596 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000597 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000598 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000599 }
600} CurFun; // Info for the current function...
601
602static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
603
604
605//===----------------------------------------------------------------------===//
606// Code to handle definitions of all the types
607//===----------------------------------------------------------------------===//
608
Reid Spencer93c40032007-03-19 18:40:50 +0000609static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
610 // Things that have names or are void typed don't get slot numbers
611 if (V->hasName() || (V->getType() == Type::VoidTy))
612 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000613
Reid Spencer93c40032007-03-19 18:40:50 +0000614 // In the case of function values, we have to allow for the forward reference
615 // of basic blocks, which are included in the numbering. Consequently, we keep
616 // track of the next insertion location with NextValNum. When a BB gets
617 // inserted, it could change the size of the CurFun.Values vector.
618 if (&ValueTab == &CurFun.Values) {
619 if (ValueTab.size() <= CurFun.NextValNum)
620 ValueTab.resize(CurFun.NextValNum+1);
621 ValueTab[CurFun.NextValNum++] = V;
622 return;
623 }
624 // For all other lists, its okay to just tack it on the back of the vector.
625 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000626}
627
628static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
629 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000630 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000631 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000632 if (D.Num < CurModule.Types.size())
633 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000634 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000635 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000636 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000637 D.destroy(); // Free old strdup'd memory...
638 return N;
639 }
640 break;
641 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000642 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000643 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000644 }
645
646 // If we reached here, we referenced either a symbol that we don't know about
647 // or an id number that hasn't been read yet. We may be referencing something
648 // forward, so just create an entry to be resolved later and get to it...
649 //
650 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
651
652
653 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000654 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000655 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000656 return 0;
657 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000658 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000659 return 0;
660 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000661 }
662
Reid Spencer861d9d62006-11-28 07:29:44 +0000663 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000664 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000665 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000666
Reid Spencer861d9d62006-11-28 07:29:44 +0000667 Type *Typ = OpaqueType::get();
668 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
669 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000670 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000671
Reid Spencer93c40032007-03-19 18:40:50 +0000672// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000673// the provided ValID. If the value exists and has already been defined, return
674// it. Otherwise return null.
675//
Reid Spencer93c40032007-03-19 18:40:50 +0000676static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000677 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000678 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000679 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000680 return 0;
681 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000682
683 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000684 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000685 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000686 if (D.Num >= CurFun.Values.size())
687 return 0;
688 Value *Result = CurFun.Values[D.Num];
689 if (Ty != Result->getType()) {
690 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
691 Result->getType()->getDescription() + "' does not match "
692 "expected type, '" + Ty->getDescription() + "'");
693 return 0;
694 }
695 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000696 }
697 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000698 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000699 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000700 Value *Result = CurModule.Values[D.Num];
701 if (Ty != Result->getType()) {
702 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
703 Result->getType()->getDescription() + "' does not match "
704 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000705 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000706 }
707 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000708 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000709
710 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000711 if (!inFunctionScope())
712 return 0;
713 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000714 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000715 if (N == 0)
716 return 0;
717 if (N->getType() != Ty)
718 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000719
720 D.destroy(); // Free old strdup'd memory...
721 return N;
722 }
723 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000724 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000725 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000726 if (N == 0)
727 return 0;
728 if (N->getType() != Ty)
729 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000730
731 D.destroy(); // Free old strdup'd memory...
732 return N;
733 }
734
735 // Check to make sure that "Ty" is an integral type, and that our
736 // value will fit into the specified type...
737 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000738 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000739 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000740 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000741 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000742 return 0;
743 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000744 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000745
746 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000747 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
748 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000749 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000750 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000751 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000752 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000753 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000754 }
755 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000756 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000757 }
758
759 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000760 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000761 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000762 return 0;
763 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000764 return ConstantFP::get(Ty, D.ConstPoolFP);
765
766 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000768 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000769 return 0;
770 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000771 return ConstantPointerNull::get(cast<PointerType>(Ty));
772
773 case ValID::ConstUndefVal: // Is it an undef value?
774 return UndefValue::get(Ty);
775
Chris Lattner7aa61892005-12-21 17:53:23 +0000776 case ValID::ConstZeroVal: // Is it a zero value?
777 return Constant::getNullValue(Ty);
778
Reid Spencer68a24bd2005-08-27 18:50:39 +0000779 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000780 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000781 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000782 return 0;
783 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000784 return D.ConstantValue;
785
Chris Lattner0e9c3762006-01-25 22:27:16 +0000786 case ValID::InlineAsmVal: { // Inline asm expression
787 const PointerType *PTy = dyn_cast<PointerType>(Ty);
788 const FunctionType *FTy =
789 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000790 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000791 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000792 return 0;
793 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000794 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
795 D.IAD->HasSideEffects);
796 D.destroy(); // Free InlineAsmDescriptor.
797 return IA;
798 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000799 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000800 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000801 return 0;
802 } // End of switch
803
Reid Spencera9720f52007-02-05 17:04:00 +0000804 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000805 return 0;
806}
807
Reid Spencer93c40032007-03-19 18:40:50 +0000808// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000809// value is not already defined, it "improvises" by creating a placeholder var
810// that looks and acts just like the requested variable. When the value is
811// defined later, all uses of the placeholder variable are replaced with the
812// real thing.
813//
814static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000815 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000816 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000817 return 0;
818 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000819
820 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000821 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000822 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000823 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000824
Reid Spencer5b7e7532006-09-28 19:28:24 +0000825 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000826 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000827 return 0;
828 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000829
830 // If we reached here, we referenced either a symbol that we don't know about
831 // or an id number that hasn't been read yet. We may be referencing something
832 // forward, so just create an entry to be resolved later and get to it...
833 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000834 switch (ID.Type) {
835 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000836 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000837 const PointerType *PTy = dyn_cast<PointerType>(Ty);
838 if (!PTy) {
839 GenerateError("Invalid type for reference to global" );
840 return 0;
841 }
842 const Type* ElTy = PTy->getElementType();
843 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
844 V = new Function(FTy, GlobalValue::ExternalLinkage);
845 else
846 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
847 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000848 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000849 default:
850 V = new Argument(Ty);
851 }
852
Reid Spencer68a24bd2005-08-27 18:50:39 +0000853 // Remember where this forward reference came from. FIXME, shouldn't we try
854 // to recycle these things??
855 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
856 llvmAsmlineno)));
857
858 if (inFunctionScope())
859 InsertValue(V, CurFun.LateResolveValues);
860 else
861 InsertValue(V, CurModule.LateResolveValues);
862 return V;
863}
864
Reid Spencer93c40032007-03-19 18:40:50 +0000865/// defineBBVal - This is a definition of a new basic block with the specified
866/// identifier which must be the same as CurFun.NextValNum, if its numeric.
867static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000868 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000869
Reid Spencer68a24bd2005-08-27 18:50:39 +0000870 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000871
Reid Spencer93c40032007-03-19 18:40:50 +0000872 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000873
Reid Spencer93c40032007-03-19 18:40:50 +0000874 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
875 if (BBI != CurFun.BBForwardRefs.end()) {
876 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000877 // The forward declaration could have been inserted anywhere in the
878 // function: insert it into the correct place now.
879 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
880 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000881
Reid Spencer66728ef2007-03-20 01:13:36 +0000882 // We're about to erase the entry, save the key so we can clean it up.
883 ValID Tmp = BBI->first;
884
Reid Spencer93c40032007-03-19 18:40:50 +0000885 // Erase the forward ref from the map as its no longer "forward"
886 CurFun.BBForwardRefs.erase(ID);
887
Reid Spencer66728ef2007-03-20 01:13:36 +0000888 // The key has been removed from the map but so we don't want to leave
889 // strdup'd memory around so destroy it too.
890 Tmp.destroy();
891
Reid Spencer93c40032007-03-19 18:40:50 +0000892 // If its a numbered definition, bump the number and set the BB value.
893 if (ID.Type == ValID::LocalID) {
894 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
895 InsertValue(BB);
896 }
897
898 ID.destroy();
899 return BB;
900 }
901
902 // We haven't seen this BB before and its first mention is a definition.
903 // Just create it and return it.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000904 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Reid Spencer93c40032007-03-19 18:40:50 +0000905 BB = new BasicBlock(Name, CurFun.CurrentFunction);
906 if (ID.Type == ValID::LocalID) {
907 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
908 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000909 }
Reid Spencer93c40032007-03-19 18:40:50 +0000910
911 ID.destroy(); // Free strdup'd memory
912 return BB;
913}
914
915/// getBBVal - get an existing BB value or create a forward reference for it.
916///
917static BasicBlock *getBBVal(const ValID &ID) {
918 assert(inFunctionScope() && "Can't get basic block at global scope!");
919
920 BasicBlock *BB = 0;
921
922 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
923 if (BBI != CurFun.BBForwardRefs.end()) {
924 BB = BBI->second;
925 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000926 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000927 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
928 if (N)
929 if (N->getType()->getTypeID() == Type::LabelTyID)
930 BB = cast<BasicBlock>(N);
931 else
932 GenerateError("Reference to label '" + Name + "' is actually of type '"+
933 N->getType()->getDescription() + "'");
934 } else if (ID.Type == ValID::LocalID) {
935 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
936 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
937 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
938 else
939 GenerateError("Reference to label '%" + utostr(ID.Num) +
940 "' is actually of type '"+
941 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
942 }
943 } else {
944 GenerateError("Illegal label reference " + ID.getName());
945 return 0;
946 }
947
948 // If its already been defined, return it now.
949 if (BB) {
950 ID.destroy(); // Free strdup'd memory.
951 return BB;
952 }
953
954 // Otherwise, this block has not been seen before, create it.
955 std::string Name;
956 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000957 Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000958 BB = new BasicBlock(Name, CurFun.CurrentFunction);
959
960 // Insert it in the forward refs map.
961 CurFun.BBForwardRefs[ID] = BB;
962
Reid Spencer68a24bd2005-08-27 18:50:39 +0000963 return BB;
964}
965
966
967//===----------------------------------------------------------------------===//
968// Code to handle forward references in instructions
969//===----------------------------------------------------------------------===//
970//
971// This code handles the late binding needed with statements that reference
972// values not defined yet... for example, a forward branch, or the PHI node for
973// a loop body.
974//
975// This keeps a table (CurFun.LateResolveValues) of all such forward references
976// and back patchs after we are done.
977//
978
979// ResolveDefinitions - If we could not resolve some defs at parsing
980// time (forward branches, phi functions for loops, etc...) resolve the
981// defs now...
982//
983static void
Reid Spencer93c40032007-03-19 18:40:50 +0000984ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000985 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000986 while (!LateResolvers.empty()) {
987 Value *V = LateResolvers.back();
988 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000989
Reid Spencer93c40032007-03-19 18:40:50 +0000990 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
991 CurModule.PlaceHolderInfo.find(V);
992 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000993
Reid Spencer93c40032007-03-19 18:40:50 +0000994 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000995
Reid Spencer93c40032007-03-19 18:40:50 +0000996 Value *TheRealValue = getExistingVal(V->getType(), DID);
997 if (TriggerError)
998 return;
999 if (TheRealValue) {
1000 V->replaceAllUsesWith(TheRealValue);
1001 delete V;
1002 CurModule.PlaceHolderInfo.erase(PHI);
1003 } else if (FutureLateResolvers) {
1004 // Functions have their unresolved items forwarded to the module late
1005 // resolver table
1006 InsertValue(V, *FutureLateResolvers);
1007 } else {
1008 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
1009 GenerateError("Reference to an invalid definition: '" +DID.getName()+
1010 "' of type '" + V->getType()->getDescription() + "'",
1011 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +00001012 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001013 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001014 GenerateError("Reference to an invalid definition: #" +
1015 itostr(DID.Num) + " of type '" +
1016 V->getType()->getDescription() + "'",
1017 PHI->second.second);
1018 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001019 }
1020 }
1021 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001022 LateResolvers.clear();
1023}
1024
1025// ResolveTypeTo - A brand new type was just declared. This means that (if
1026// name is not null) things referencing Name can be resolved. Otherwise, things
1027// refering to the number can be resolved. Do this now.
1028//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001029static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001030 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001031 if (Name)
1032 D = ValID::createLocalName(*Name);
1033 else
1034 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001035
Reid Spencer861d9d62006-11-28 07:29:44 +00001036 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001037 CurModule.LateResolveTypes.find(D);
1038 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +00001039 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001040 CurModule.LateResolveTypes.erase(I);
1041 }
1042}
1043
1044// setValueName - Set the specified value to the name given. The name may be
1045// null potentially, in which case this is a noop. The string passed in is
1046// assumed to be a malloc'd string buffer, and is free'd by this function.
1047//
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001048static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001049 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001050 std::string Name(*NameStr); // Copy string
1051 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001052
Reid Spencer41dff5e2007-01-26 08:05:27 +00001053 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001054 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001055 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001056 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00001057
Reid Spencera9720f52007-02-05 17:04:00 +00001058 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +00001059 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1060 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001061 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001062 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00001063 return;
1064 }
1065
1066 // Set the name.
1067 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001068}
1069
1070/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
1071/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +00001072static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001073ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001074 GlobalValue::LinkageTypes Linkage,
1075 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +00001076 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001077 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001078 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001079 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001080 return 0;
1081 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001082
1083 const PointerType *PTy = PointerType::get(Ty);
1084
1085 std::string Name;
1086 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001087 Name = *NameStr; // Copy string
1088 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001089 }
1090
1091 // See if this global value was forward referenced. If so, recycle the
1092 // object.
1093 ValID ID;
1094 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001095 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001096 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00001097 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001098 }
1099
1100 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1101 // Move the global to the end of the list, from whereever it was
1102 // previously inserted.
1103 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1104 CurModule.CurrentModule->getGlobalList().remove(GV);
1105 CurModule.CurrentModule->getGlobalList().push_back(GV);
1106 GV->setInitializer(Initializer);
1107 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001108 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001109 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001110 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001111 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001112 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001113 }
1114
Reid Spenceref9b9a72007-02-05 20:47:22 +00001115 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001116 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001117 // if the global we're parsing has an initializer (is a definition) and
1118 // has external linkage.
1119 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1120 // If there is already a global with external linkage with this name
1121 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1122 // If we allow this GVar to get created, it will be renamed in the
1123 // symbol table because it conflicts with an existing GVar. We can't
1124 // allow redefinition of GVars whose linking indicates that their name
1125 // must stay the same. Issue the error.
1126 GenerateError("Redefinition of global variable named '" + Name +
1127 "' of type '" + Ty->getDescription() + "'");
1128 return 0;
1129 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001130 }
1131
1132 // Otherwise there is no existing GV to use, create one now.
1133 GlobalVariable *GV =
1134 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00001135 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001136 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001137 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001138 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001139}
1140
1141// setTypeName - Set the specified type to the name given. The name may be
1142// null potentially, in which case this is a noop. The string passed in is
1143// assumed to be a malloc'd string buffer, and is freed by this function.
1144//
1145// This function returns true if the type has already been defined, but is
1146// allowed to be redefined in the specified context. If the name is a new name
1147// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001148static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001149 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001150 if (NameStr == 0) return false;
1151
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001152 std::string Name(*NameStr); // Copy string
1153 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +00001154
1155 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001156 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001157 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001158 return false;
1159 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001160
1161 // Set the type name, checking for conflicts as we do so.
1162 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1163
1164 if (AlreadyExists) { // Inserting a name that is already defined???
1165 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001166 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001167
1168 // There is only one case where this is allowed: when we are refining an
1169 // opaque type. In this case, Existing will be an opaque type.
1170 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1171 // We ARE replacing an opaque type!
1172 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1173 return true;
1174 }
1175
1176 // Otherwise, this is an attempt to redefine a type. That's okay if
1177 // the redefinition is identical to the original. This will be so if
1178 // Existing and T point to the same Type object. In this one case we
1179 // allow the equivalent redefinition.
1180 if (Existing == T) return true; // Yes, it's equal.
1181
1182 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001183 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001184 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001185 }
1186
1187 return false;
1188}
1189
1190//===----------------------------------------------------------------------===//
1191// Code for handling upreferences in type names...
1192//
1193
1194// TypeContains - Returns true if Ty directly contains E in it.
1195//
1196static bool TypeContains(const Type *Ty, const Type *E) {
1197 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1198 E) != Ty->subtype_end();
1199}
1200
1201namespace {
1202 struct UpRefRecord {
1203 // NestingLevel - The number of nesting levels that need to be popped before
1204 // this type is resolved.
1205 unsigned NestingLevel;
1206
1207 // LastContainedTy - This is the type at the current binding level for the
1208 // type. Every time we reduce the nesting level, this gets updated.
1209 const Type *LastContainedTy;
1210
1211 // UpRefTy - This is the actual opaque type that the upreference is
1212 // represented with.
1213 OpaqueType *UpRefTy;
1214
1215 UpRefRecord(unsigned NL, OpaqueType *URTy)
1216 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1217 };
1218}
1219
1220// UpRefs - A list of the outstanding upreferences that need to be resolved.
1221static std::vector<UpRefRecord> UpRefs;
1222
1223/// HandleUpRefs - Every time we finish a new layer of types, this function is
1224/// called. It loops through the UpRefs vector, which is a list of the
1225/// currently active types. For each type, if the up reference is contained in
1226/// the newly completed type, we decrement the level count. When the level
1227/// count reaches zero, the upreferenced type is the type that is passed in:
1228/// thus we can complete the cycle.
1229///
1230static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001231 // If Ty isn't abstract, or if there are no up-references in it, then there is
1232 // nothing to resolve here.
1233 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1234
Reid Spencer68a24bd2005-08-27 18:50:39 +00001235 PATypeHolder Ty(ty);
1236 UR_OUT("Type '" << Ty->getDescription() <<
1237 "' newly formed. Resolving upreferences.\n" <<
1238 UpRefs.size() << " upreferences active!\n");
1239
1240 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1241 // to zero), we resolve them all together before we resolve them to Ty. At
1242 // the end of the loop, if there is anything to resolve to Ty, it will be in
1243 // this variable.
1244 OpaqueType *TypeToResolve = 0;
1245
1246 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1247 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1248 << UpRefs[i].second->getDescription() << ") = "
1249 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1250 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1251 // Decrement level of upreference
1252 unsigned Level = --UpRefs[i].NestingLevel;
1253 UpRefs[i].LastContainedTy = Ty;
1254 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1255 if (Level == 0) { // Upreference should be resolved!
1256 if (!TypeToResolve) {
1257 TypeToResolve = UpRefs[i].UpRefTy;
1258 } else {
1259 UR_OUT(" * Resolving upreference for "
1260 << UpRefs[i].second->getDescription() << "\n";
1261 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1262 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1263 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1264 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1265 }
1266 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1267 --i; // Do not skip the next element...
1268 }
1269 }
1270 }
1271
1272 if (TypeToResolve) {
1273 UR_OUT(" * Resolving upreference for "
1274 << UpRefs[i].second->getDescription() << "\n";
1275 std::string OldName = TypeToResolve->getDescription());
1276 TypeToResolve->refineAbstractTypeTo(Ty);
1277 }
1278
1279 return Ty;
1280}
1281
Reid Spencer68a24bd2005-08-27 18:50:39 +00001282//===----------------------------------------------------------------------===//
1283// RunVMAsmParser - Define an interface to this parser
1284//===----------------------------------------------------------------------===//
1285//
Reid Spencer14310612006-12-31 05:40:51 +00001286static Module* RunParser(Module * M);
1287
Reid Spencer68a24bd2005-08-27 18:50:39 +00001288Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1289 set_scan_file(F);
1290
1291 CurFilename = Filename;
1292 return RunParser(new Module(CurFilename));
1293}
1294
1295Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1296 set_scan_string(AsmString);
1297
1298 CurFilename = "from_memory";
1299 if (M == NULL) {
1300 return RunParser(new Module (CurFilename));
1301 } else {
1302 return RunParser(M);
1303 }
1304}
1305
1306
David Greene5fd22a82007-09-04 18:46:50 +00001307
1308/* Enabling traces. */
1309#ifndef YYDEBUG
1310# define YYDEBUG 0
1311#endif
1312
1313/* Enabling verbose error messages. */
1314#ifdef YYERROR_VERBOSE
1315# undef YYERROR_VERBOSE
1316# define YYERROR_VERBOSE 1
1317#else
1318# define YYERROR_VERBOSE 0
1319#endif
1320
1321#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1322#line 963 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
1323typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001324 llvm::Module *ModuleVal;
1325 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001326 llvm::BasicBlock *BasicBlockVal;
1327 llvm::TerminatorInst *TermInstVal;
1328 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001329 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001330
Reid Spencera132e042006-12-03 05:46:11 +00001331 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001332 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001333 llvm::PATypeHolder *TypeVal;
1334 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001335 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001336 llvm::ArgListType *ArgList;
1337 llvm::TypeWithAttrs TypeWithAttrs;
1338 llvm::TypeWithAttrsList *TypeWithAttrsList;
1339 llvm::ValueRefList *ValueRefList;
1340
Reid Spencer68a24bd2005-08-27 18:50:39 +00001341 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001342 std::list<std::pair<llvm::Value*,
1343 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001344 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001345 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001346
1347 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001348 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001349 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001350 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001351 int64_t SInt64Val;
1352 uint64_t UInt64Val;
1353 int SIntVal;
1354 unsigned UIntVal;
1355 double FPVal;
1356 bool BoolVal;
1357
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001358 std::string *StrVal; // This memory must be deleted
1359 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001360
Reid Spencera132e042006-12-03 05:46:11 +00001361 llvm::Instruction::BinaryOps BinaryOpVal;
1362 llvm::Instruction::TermOps TermOpVal;
1363 llvm::Instruction::MemoryOps MemOpVal;
1364 llvm::Instruction::CastOps CastOpVal;
1365 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001366 llvm::ICmpInst::Predicate IPredicate;
1367 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner0275cff2007-08-06 21:00:46 +00001368} YYSTYPE;
David Greene5fd22a82007-09-04 18:46:50 +00001369/* Line 191 of yacc.c. */
1370#line 1371 "llvmAsmParser.tab.c"
1371# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1372# define YYSTYPE_IS_DECLARED 1
1373# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001374#endif
1375
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001376
Reid Spencer68a24bd2005-08-27 18:50:39 +00001377
David Greene5fd22a82007-09-04 18:46:50 +00001378/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001379
1380
David Greene5fd22a82007-09-04 18:46:50 +00001381/* Line 214 of yacc.c. */
1382#line 1383 "llvmAsmParser.tab.c"
Reid Spencerb8f85052007-07-31 03:50:36 +00001383
David Greene5fd22a82007-09-04 18:46:50 +00001384#if ! defined (yyoverflow) || YYERROR_VERBOSE
Chris Lattner0275cff2007-08-06 21:00:46 +00001385
David Greene5fd22a82007-09-04 18:46:50 +00001386/* The parser invokes alloca or malloc; define the necessary symbols. */
1387
1388# ifdef YYSTACK_USE_ALLOCA
1389# if YYSTACK_USE_ALLOCA
1390# define YYSTACK_ALLOC alloca
1391# endif
1392# else
1393# if defined (alloca) || defined (_ALLOCA_H)
1394# define YYSTACK_ALLOC alloca
1395# else
1396# ifdef __GNUC__
1397# define YYSTACK_ALLOC __builtin_alloca
1398# endif
1399# endif
1400# endif
1401
1402# ifdef YYSTACK_ALLOC
1403 /* Pacify GCC's `empty if-body' warning. */
1404# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1405# else
1406# if defined (__STDC__) || defined (__cplusplus)
1407# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1408# define YYSIZE_T size_t
1409# endif
1410# define YYSTACK_ALLOC malloc
1411# define YYSTACK_FREE free
1412# endif
1413#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1414
1415
1416#if (! defined (yyoverflow) \
1417 && (! defined (__cplusplus) \
1418 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1419
1420/* A type that is properly aligned for any stack member. */
1421union yyalloc
1422{
1423 short yyss;
1424 YYSTYPE yyvs;
1425 };
1426
1427/* The size of the maximum gap between one aligned stack and the next. */
1428# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1429
1430/* The size of an array large to enough to hold all stacks, each with
1431 N elements. */
1432# define YYSTACK_BYTES(N) \
1433 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
1434 + YYSTACK_GAP_MAXIMUM)
1435
1436/* Copy COUNT objects from FROM to TO. The source and destination do
1437 not overlap. */
1438# ifndef YYCOPY
1439# if defined (__GNUC__) && 1 < __GNUC__
1440# define YYCOPY(To, From, Count) \
1441 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1442# else
1443# define YYCOPY(To, From, Count) \
1444 do \
1445 { \
1446 register YYSIZE_T yyi; \
1447 for (yyi = 0; yyi < (Count); yyi++) \
1448 (To)[yyi] = (From)[yyi]; \
1449 } \
1450 while (0)
1451# endif
1452# endif
1453
1454/* Relocate STACK from its old location to the new one. The
1455 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1456 elements in the stack, and YYPTR gives the new location of the
1457 stack. Advance YYPTR to a properly aligned location for the next
1458 stack. */
1459# define YYSTACK_RELOCATE(Stack) \
1460 do \
1461 { \
1462 YYSIZE_T yynewbytes; \
1463 YYCOPY (&yyptr->Stack, Stack, yysize); \
1464 Stack = &yyptr->Stack; \
1465 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1466 yyptr += yynewbytes / sizeof (*yyptr); \
1467 } \
1468 while (0)
Chris Lattner0275cff2007-08-06 21:00:46 +00001469
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001470#endif
1471
David Greene5fd22a82007-09-04 18:46:50 +00001472#if defined (__STDC__) || defined (__cplusplus)
1473 typedef signed char yysigned_char;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001474#else
David Greene5fd22a82007-09-04 18:46:50 +00001475 typedef short yysigned_char;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001476#endif
1477
David Greene5fd22a82007-09-04 18:46:50 +00001478/* YYFINAL -- State number of the termination state. */
1479#define YYFINAL 43
1480/* YYLAST -- Last index in YYTABLE. */
1481#define YYLAST 1685
1482
1483/* YYNTOKENS -- Number of terminals. */
1484#define YYNTOKENS 160
1485/* YYNNTS -- Number of nonterminals. */
1486#define YYNNTS 82
1487/* YYNRULES -- Number of rules. */
1488#define YYNRULES 310
1489/* YYNRULES -- Number of states. */
1490#define YYNSTATES 594
1491
1492/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1493#define YYUNDEFTOK 2
1494#define YYMAXUTOK 400
1495
1496#define YYTRANSLATE(YYX) \
1497 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1498
1499/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1500static const unsigned char yytranslate[] =
1501{
1502 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1505 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1506 150, 151, 148, 2, 147, 2, 2, 2, 2, 2,
1507 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1508 155, 146, 156, 2, 2, 2, 2, 2, 2, 2,
1509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1511 2, 152, 149, 154, 2, 2, 2, 2, 2, 159,
1512 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1514 153, 2, 2, 157, 2, 158, 2, 2, 2, 2,
1515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1516 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1520 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1521 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1522 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1527 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1528 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1529 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1530 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1531 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1532 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1533 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1534 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1535 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1536 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1537 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1538 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1539 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1540 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1541 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
1542 145
1543};
1544
1545#if YYDEBUG
1546/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1547 YYRHS. */
1548static const unsigned short yyprhs[] =
1549{
1550 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1551 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1552 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1553 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1554 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1555 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1556 119, 121, 123, 125, 127, 129, 130, 133, 134, 136,
1557 138, 140, 141, 144, 146, 148, 150, 152, 154, 156,
1558 158, 160, 161, 163, 165, 167, 168, 170, 172, 173,
1559 175, 177, 179, 181, 182, 184, 186, 187, 189, 191,
1560 193, 195, 197, 200, 202, 204, 206, 208, 210, 212,
1561 214, 216, 218, 219, 222, 224, 226, 228, 230, 231,
1562 234, 235, 238, 239, 243, 246, 247, 249, 250, 254,
1563 256, 259, 261, 263, 265, 267, 269, 271, 273, 275,
1564 277, 280, 282, 285, 291, 297, 303, 309, 313, 316,
1565 322, 327, 330, 332, 334, 336, 340, 342, 346, 348,
1566 349, 351, 355, 360, 364, 368, 373, 378, 382, 389,
1567 395, 398, 401, 404, 407, 410, 413, 416, 419, 422,
1568 425, 428, 431, 438, 444, 453, 460, 467, 475, 483,
1569 490, 499, 508, 512, 514, 516, 518, 520, 521, 524,
1570 531, 533, 534, 536, 539, 540, 544, 545, 549, 553,
1571 557, 561, 562, 570, 571, 580, 581, 590, 596, 599,
1572 603, 605, 609, 613, 617, 621, 623, 624, 630, 634,
1573 636, 640, 642, 643, 653, 655, 657, 662, 664, 666,
1574 669, 673, 674, 676, 678, 680, 682, 684, 686, 688,
1575 690, 692, 696, 698, 704, 706, 708, 710, 712, 714,
1576 716, 719, 722, 725, 729, 732, 733, 735, 738, 741,
1577 745, 755, 765, 774, 789, 791, 793, 800, 806, 809,
1578 816, 824, 828, 834, 835, 836, 840, 843, 845, 851,
1579 857, 864, 871, 876, 883, 888, 893, 900, 907, 910,
1580 919, 921, 923, 924, 928, 935, 939, 946, 949, 955,
1581 963
1582};
1583
1584/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1585static const short yyrhs[] =
1586{
1587 204, 0, -1, 73, -1, 74, -1, 75, -1, 76,
1588 -1, 77, -1, 78, -1, 79, -1, 80, -1, 81,
1589 -1, 85, -1, 86, -1, 87, -1, 82, -1, 83,
1590 -1, 84, -1, 116, -1, 117, -1, 118, -1, 119,
1591 -1, 120, -1, 121, -1, 122, -1, 123, -1, 124,
1592 -1, 125, -1, 126, -1, 127, -1, 90, -1, 91,
1593 -1, 92, -1, 93, -1, 94, -1, 95, -1, 96,
1594 -1, 97, -1, 98, -1, 99, -1, 100, -1, 101,
1595 -1, 102, -1, 103, -1, 104, -1, 105, -1, 106,
1596 -1, 107, -1, 108, -1, 109, -1, 96, -1, 97,
1597 -1, 98, -1, 99, -1, 26, -1, 27, -1, 11,
1598 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
1599 -1, 19, -1, 22, -1, 24, -1, 168, -1, -1,
1600 168, 146, -1, -1, 20, -1, 23, -1, 173, -1,
1601 -1, 171, 146, -1, 42, -1, 44, -1, 43, -1,
1602 45, -1, 47, -1, 46, -1, 48, -1, 50, -1,
1603 -1, 143, -1, 144, -1, 145, -1, -1, 46, -1,
1604 48, -1, -1, 42, -1, 43, -1, 44, -1, 47,
1605 -1, -1, 44, -1, 42, -1, -1, 61, -1, 62,
1606 -1, 63, -1, 64, -1, 65, -1, 60, 4, -1,
1607 135, -1, 117, -1, 134, -1, 118, -1, 137, -1,
1608 138, -1, 140, -1, 141, -1, 142, -1, -1, 182,
1609 181, -1, 136, -1, 139, -1, 135, -1, 134, -1,
1610 -1, 184, 183, -1, -1, 53, 4, -1, -1, 147,
1611 53, 4, -1, 34, 22, -1, -1, 187, -1, -1,
1612 147, 190, 189, -1, 187, -1, 53, 4, -1, 11,
1613 -1, 12, -1, 13, -1, 16, -1, 15, -1, 14,
1614 -1, 17, -1, 49, -1, 191, -1, 192, 148, -1,
1615 226, -1, 149, 4, -1, 192, 150, 196, 151, 184,
1616 -1, 10, 150, 196, 151, 184, -1, 152, 4, 153,
1617 192, 154, -1, 155, 4, 153, 192, 156, -1, 157,
1618 197, 158, -1, 157, 158, -1, 155, 157, 197, 158,
1619 156, -1, 155, 157, 158, 156, -1, 192, 182, -1,
1620 192, -1, 10, -1, 193, -1, 195, 147, 193, -1,
1621 195, -1, 195, 147, 39, -1, 39, -1, -1, 192,
1622 -1, 197, 147, 192, -1, 192, 152, 200, 154, -1,
1623 192, 152, 154, -1, 192, 159, 22, -1, 192, 155,
1624 200, 156, -1, 192, 157, 200, 158, -1, 192, 157,
1625 158, -1, 192, 155, 157, 200, 158, 156, -1, 192,
1626 155, 157, 158, 156, -1, 192, 40, -1, 192, 41,
1627 -1, 192, 226, -1, 192, 199, -1, 192, 25, -1,
1628 166, 3, -1, 166, 5, -1, 166, 4, -1, 166,
1629 6, -1, 11, 26, -1, 11, 27, -1, 167, 9,
1630 -1, 163, 150, 198, 38, 192, 151, -1, 115, 150,
1631 198, 237, 151, -1, 129, 150, 198, 147, 198, 147,
1632 198, 151, -1, 161, 150, 198, 147, 198, 151, -1,
1633 162, 150, 198, 147, 198, 151, -1, 88, 164, 150,
1634 198, 147, 198, 151, -1, 89, 165, 150, 198, 147,
1635 198, 151, -1, 131, 150, 198, 147, 198, 151, -1,
1636 132, 150, 198, 147, 198, 147, 198, 151, -1, 133,
1637 150, 198, 147, 198, 147, 198, 151, -1, 200, 147,
1638 198, -1, 198, -1, 32, -1, 33, -1, 37, -1,
1639 -1, 194, 226, -1, 121, 150, 203, 38, 192, 151,
1640 -1, 205, -1, -1, 206, -1, 205, 206, -1, -1,
1641 31, 207, 222, -1, -1, 30, 208, 223, -1, 58,
1642 57, 212, -1, 170, 18, 192, -1, 170, 18, 10,
1643 -1, -1, 172, 176, 202, 201, 198, 209, 189, -1,
1644 -1, 172, 174, 176, 202, 201, 198, 210, 189, -1,
1645 -1, 172, 175, 176, 202, 201, 192, 211, 189, -1,
1646 172, 176, 35, 179, 203, -1, 51, 213, -1, 54,
1647 146, 214, -1, 22, -1, 52, 146, 22, -1, 66,
1648 146, 22, -1, 152, 215, 154, -1, 215, 147, 22,
1649 -1, 22, -1, -1, 216, 147, 192, 182, 169, -1,
1650 192, 182, 169, -1, 216, -1, 216, 147, 39, -1,
1651 39, -1, -1, 180, 194, 171, 150, 217, 151, 184,
1652 188, 185, -1, 28, -1, 157, -1, 178, 176, 218,
1653 219, -1, 29, -1, 158, -1, 229, 221, -1, 177,
1654 176, 218, -1, -1, 59, -1, 3, -1, 4, -1,
1655 9, -1, 26, -1, 27, -1, 40, -1, 41, -1,
1656 25, -1, 155, 200, 156, -1, 199, -1, 57, 224,
1657 22, 147, 22, -1, 7, -1, 8, -1, 168, -1,
1658 171, -1, 226, -1, 225, -1, 192, 227, -1, 229,
1659 230, -1, 220, 230, -1, 231, 170, 232, -1, 231,
1660 234, -1, -1, 21, -1, 67, 228, -1, 67, 10,
1661 -1, 68, 17, 227, -1, 68, 11, 227, 147, 17,
1662 227, 147, 17, 227, -1, 69, 166, 227, 147, 17,
1663 227, 152, 233, 154, -1, 69, 166, 227, 147, 17,
1664 227, 152, 154, -1, 70, 180, 194, 227, 150, 236,
1665 151, 184, 38, 17, 227, 71, 17, 227, -1, 71,
1666 -1, 72, -1, 233, 166, 225, 147, 17, 227, -1,
1667 166, 225, 147, 17, 227, -1, 170, 239, -1, 192,
1668 152, 227, 147, 227, 154, -1, 235, 147, 152, 227,
1669 147, 227, 154, -1, 192, 227, 182, -1, 236, 147,
1670 192, 227, 182, -1, -1, -1, 237, 147, 228, -1,
1671 56, 55, -1, 55, -1, 161, 192, 227, 147, 227,
1672 -1, 162, 192, 227, 147, 227, -1, 88, 164, 192,
1673 227, 147, 227, -1, 89, 165, 192, 227, 147, 227,
1674 -1, 163, 228, 38, 192, -1, 129, 228, 147, 228,
1675 147, 228, -1, 130, 228, 147, 192, -1, 131, 228,
1676 147, 228, -1, 132, 228, 147, 228, 147, 228, -1,
1677 133, 228, 147, 228, 147, 228, -1, 128, 235, -1,
1678 238, 180, 194, 227, 150, 236, 151, 184, -1, 241,
1679 -1, 36, -1, -1, 110, 192, 186, -1, 110, 192,
1680 147, 11, 227, 186, -1, 111, 192, 186, -1, 111,
1681 192, 147, 11, 227, 186, -1, 112, 228, -1, 240,
1682 113, 192, 227, 186, -1, 240, 114, 228, 147, 192,
1683 227, 186, -1, 115, 192, 227, 237, -1
1684};
1685
1686/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1687static const unsigned short yyrline[] =
1688{
1689 0, 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1122,
1690 1122, 1123, 1123, 1123, 1123, 1123, 1123, 1124, 1124, 1124,
1691 1124, 1124, 1124, 1125, 1125, 1125, 1125, 1125, 1125, 1128,
1692 1128, 1129, 1129, 1130, 1130, 1131, 1131, 1132, 1132, 1136,
1693 1136, 1137, 1137, 1138, 1138, 1139, 1139, 1140, 1140, 1141,
1694 1141, 1142, 1142, 1143, 1144, 1149, 1150, 1150, 1150, 1150,
1695 1150, 1152, 1152, 1152, 1153, 1153, 1157, 1161, 1166, 1166,
1696 1168, 1169, 1174, 1180, 1181, 1182, 1183, 1184, 1188, 1189,
1697 1190, 1194, 1195, 1196, 1197, 1201, 1202, 1203, 1207, 1208,
1698 1209, 1210, 1211, 1215, 1216, 1217, 1220, 1221, 1222, 1223,
1699 1224, 1225, 1226, 1233, 1234, 1235, 1236, 1237, 1238, 1239,
1700 1240, 1241, 1244, 1245, 1250, 1251, 1252, 1253, 1256, 1257,
1701 1264, 1265, 1271, 1272, 1280, 1288, 1289, 1294, 1295, 1296,
1702 1301, 1314, 1314, 1314, 1314, 1314, 1314, 1314, 1317, 1321,
1703 1325, 1332, 1337, 1345, 1375, 1406, 1411, 1423, 1433, 1437,
1704 1447, 1454, 1461, 1468, 1473, 1478, 1485, 1486, 1493, 1500,
1705 1508, 1514, 1526, 1554, 1570, 1597, 1625, 1651, 1671, 1697,
1706 1717, 1729, 1736, 1802, 1812, 1822, 1828, 1838, 1844, 1854,
1707 1859, 1864, 1872, 1884, 1906, 1914, 1920, 1931, 1936, 1941,
1708 1947, 1953, 1962, 1966, 1974, 1974, 1977, 1977, 1980, 1992,
1709 2013, 2018, 2026, 2027, 2031, 2031, 2035, 2035, 2038, 2041,
1710 2065, 2076, 2076, 2087, 2086, 2096, 2095, 2106, 2125, 2128,
1711 2134, 2144, 2148, 2153, 2155, 2160, 2165, 2174, 2184, 2195,
1712 2199, 2208, 2217, 2222, 2343, 2343, 2345, 2354, 2354, 2356,
1713 2361, 2373, 2377, 2382, 2386, 2390, 2394, 2398, 2402, 2406,
1714 2410, 2414, 2439, 2443, 2453, 2457, 2461, 2466, 2473, 2473,
1715 2479, 2488, 2492, 2501, 2510, 2519, 2523, 2530, 2534, 2538,
1716 2543, 2553, 2572, 2581, 2661, 2665, 2672, 2683, 2696, 2706,
1717 2717, 2727, 2736, 2745, 2748, 2749, 2756, 2760, 2765, 2786,
1718 2803, 2817, 2831, 2843, 2851, 2858, 2864, 2870, 2876, 2891,
1719 2976, 2981, 2985, 2992, 2999, 3007, 3014, 3022, 3030, 3044,
1720 3061
1721};
1722#endif
1723
1724#if YYDEBUG || YYERROR_VERBOSE
1725/* YYTNME[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", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE",
1732 "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT",
1733 "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK",
1734 "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL",
1735 "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO",
1736 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1737 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1738 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL",
1739 "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK",
1740 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1741 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1742 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1743 "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT",
1744 "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT",
1745 "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE",
1746 "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC",
1747 "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR",
1748 "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT",
1749 "INSERTELEMENT", "SHUFFLEVECTOR", "SIGNEXT", "ZEROEXT", "NORETURN",
1750 "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST", "DEFAULT",
1751 "HIDDEN", "PROTECTED", "'='", "','", "'*'", "'\\\\'", "'('", "')'",
1752 "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept",
1753 "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates", "FPredicates",
1754 "IntType", "FPType", "LocalName", "OptLocalName", "OptLocalAssign",
1755 "GlobalName", "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage",
1756 "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage",
1757 "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr",
1758 "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign",
1759 "SectionString", "OptSection", "GlobalVarAttributes",
1760 "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes",
1761 "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr",
1762 "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module",
1763 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1764 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1765 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1766 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1767 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1768 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1769 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1770 "OptVolatile", "MemoryInst", 0
1771};
1772#endif
1773
1774# ifdef YYPRINT
1775/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1776 token YYLEX-NUM. */
1777static const unsigned short yytoknum[] =
1778{
1779 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1780 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1781 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1782 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1783 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1784 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1785 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1786 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1787 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1788 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1789 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1790 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1791 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1792 385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1793 395, 396, 397, 398, 399, 400, 61, 44, 42, 92,
1794 40, 41, 91, 120, 93, 60, 62, 123, 125, 99
1795};
1796# endif
1797
1798/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1799static const unsigned char yyr1[] =
1800{
1801 0, 160, 161, 161, 161, 161, 161, 161, 161, 161,
1802 161, 162, 162, 162, 162, 162, 162, 163, 163, 163,
1803 163, 163, 163, 163, 163, 163, 163, 163, 163, 164,
1804 164, 164, 164, 164, 164, 164, 164, 164, 164, 165,
1805 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
1806 165, 165, 165, 165, 165, 166, 167, 167, 167, 167,
1807 167, 168, 168, 168, 169, 169, 170, 170, 171, 171,
1808 172, 172, 173, 174, 174, 174, 174, 174, 175, 175,
1809 175, 176, 176, 176, 176, 177, 177, 177, 178, 178,
1810 178, 178, 178, 179, 179, 179, 180, 180, 180, 180,
1811 180, 180, 180, 181, 181, 181, 181, 181, 181, 181,
1812 181, 181, 182, 182, 183, 183, 183, 183, 184, 184,
1813 185, 185, 186, 186, 187, 188, 188, 189, 189, 190,
1814 190, 191, 191, 191, 191, 191, 191, 191, 192, 192,
1815 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
1816 192, 193, 194, 194, 195, 195, 196, 196, 196, 196,
1817 197, 197, 198, 198, 198, 198, 198, 198, 198, 198,
1818 198, 198, 198, 198, 198, 198, 198, 198, 198, 198,
1819 198, 198, 199, 199, 199, 199, 199, 199, 199, 199,
1820 199, 199, 200, 200, 201, 201, 202, 202, 203, 203,
1821 204, 204, 205, 205, 207, 206, 208, 206, 206, 206,
1822 206, 209, 206, 210, 206, 211, 206, 206, 206, 206,
1823 212, 213, 213, 214, 215, 215, 215, 216, 216, 217,
1824 217, 217, 217, 218, 219, 219, 220, 221, 221, 222,
1825 223, 224, 224, 225, 225, 225, 225, 225, 225, 225,
1826 225, 225, 225, 225, 226, 226, 226, 226, 227, 227,
1827 228, 229, 229, 230, 231, 231, 231, 232, 232, 232,
1828 232, 232, 232, 232, 232, 232, 233, 233, 234, 235,
1829 235, 236, 236, 236, 237, 237, 238, 238, 239, 239,
1830 239, 239, 239, 239, 239, 239, 239, 239, 239, 239,
1831 239, 240, 240, 241, 241, 241, 241, 241, 241, 241,
1832 241
1833};
1834
1835/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1836static const unsigned char yyr2[] =
1837{
1838 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1839 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1840 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1841 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1842 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1843 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1844 1, 1, 1, 1, 1, 0, 2, 0, 1, 1,
1845 1, 0, 2, 1, 1, 1, 1, 1, 1, 1,
1846 1, 0, 1, 1, 1, 0, 1, 1, 0, 1,
1847 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
1848 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1849 1, 1, 0, 2, 1, 1, 1, 1, 0, 2,
1850 0, 2, 0, 3, 2, 0, 1, 0, 3, 1,
1851 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1852 2, 1, 2, 5, 5, 5, 5, 3, 2, 5,
1853 4, 2, 1, 1, 1, 3, 1, 3, 1, 0,
1854 1, 3, 4, 3, 3, 4, 4, 3, 6, 5,
1855 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1856 2, 2, 6, 5, 8, 6, 6, 7, 7, 6,
1857 8, 8, 3, 1, 1, 1, 1, 0, 2, 6,
1858 1, 0, 1, 2, 0, 3, 0, 3, 3, 3,
1859 3, 0, 7, 0, 8, 0, 8, 5, 2, 3,
1860 1, 3, 3, 3, 3, 1, 0, 5, 3, 1,
1861 3, 1, 0, 9, 1, 1, 4, 1, 1, 2,
1862 3, 0, 1, 1, 1, 1, 1, 1, 1, 1,
1863 1, 3, 1, 5, 1, 1, 1, 1, 1, 1,
1864 2, 2, 2, 3, 2, 0, 1, 2, 2, 3,
1865 9, 9, 8, 14, 1, 1, 6, 5, 2, 6,
1866 7, 3, 5, 0, 0, 3, 2, 1, 5, 5,
1867 6, 6, 4, 6, 4, 4, 6, 6, 2, 8,
1868 1, 1, 0, 3, 6, 3, 6, 2, 5, 7,
1869 4
1870};
1871
1872/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1873 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1874 means the default is an error. */
1875static const unsigned short yydefact[] =
1876{
1877 71, 61, 68, 62, 69, 63, 206, 204, 0, 0,
1878 0, 0, 0, 0, 81, 70, 0, 71, 202, 85,
1879 88, 0, 0, 218, 0, 0, 66, 0, 72, 73,
1880 75, 74, 76, 78, 77, 79, 80, 82, 83, 84,
1881 81, 81, 197, 1, 203, 86, 87, 81, 207, 89,
1882 90, 91, 92, 81, 265, 205, 265, 0, 0, 226,
1883 219, 220, 208, 254, 255, 210, 131, 132, 133, 136,
1884 135, 134, 137, 138, 0, 0, 0, 0, 256, 257,
1885 139, 209, 141, 197, 197, 93, 196, 0, 96, 96,
1886 266, 262, 67, 237, 238, 239, 261, 221, 222, 225,
1887 0, 159, 142, 0, 0, 0, 0, 148, 160, 0,
1888 140, 159, 0, 0, 95, 94, 0, 194, 195, 0,
1889 0, 97, 98, 99, 100, 101, 0, 240, 0, 302,
1890 264, 0, 223, 158, 112, 154, 156, 0, 0, 0,
1891 0, 0, 0, 147, 0, 0, 0, 153, 0, 152,
1892 0, 217, 131, 132, 133, 136, 135, 134, 0, 0,
1893 0, 211, 102, 0, 234, 235, 236, 301, 287, 0,
1894 0, 0, 0, 96, 274, 275, 2, 3, 4, 5,
1895 6, 7, 8, 9, 10, 14, 15, 16, 11, 12,
1896 13, 0, 0, 0, 0, 0, 0, 17, 18, 19,
1897 20, 21, 22, 23, 24, 25, 26, 27, 28, 0,
1898 0, 0, 0, 0, 0, 0, 0, 0, 263, 96,
1899 278, 0, 300, 224, 151, 0, 118, 0, 0, 150,
1900 0, 161, 118, 213, 215, 0, 198, 179, 180, 175,
1901 177, 176, 178, 181, 174, 170, 171, 0, 0, 0,
1902 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1903 0, 173, 172, 127, 0, 286, 268, 0, 267, 0,
1904 0, 55, 0, 0, 29, 30, 31, 32, 33, 34,
1905 35, 36, 37, 38, 0, 53, 54, 49, 50, 51,
1906 52, 39, 40, 41, 42, 43, 44, 45, 46, 47,
1907 48, 0, 122, 122, 307, 0, 0, 298, 0, 0,
1908 0, 0, 0, 0, 0, 0, 0, 0, 0, 104,
1909 106, 105, 103, 107, 108, 109, 110, 111, 113, 157,
1910 155, 144, 145, 146, 149, 143, 127, 127, 0, 0,
1911 0, 0, 0, 0, 0, 0, 163, 193, 0, 0,
1912 0, 167, 0, 164, 0, 0, 0, 0, 212, 232,
1913 243, 244, 245, 250, 246, 247, 248, 249, 241, 0,
1914 252, 259, 258, 260, 0, 269, 0, 0, 0, 0,
1915 0, 303, 0, 305, 284, 0, 0, 0, 0, 0,
1916 0, 0, 0, 0, 0, 0, 0, 0, 117, 116,
1917 114, 115, 119, 214, 216, 0, 0, 0, 284, 0,
1918 0, 0, 0, 0, 162, 148, 160, 0, 165, 166,
1919 0, 0, 0, 0, 0, 129, 127, 231, 112, 229,
1920 0, 242, 0, 0, 0, 0, 0, 0, 0, 0,
1921 0, 0, 310, 0, 0, 0, 294, 295, 0, 0,
1922 0, 0, 292, 0, 122, 0, 0, 0, 0, 0,
1923 0, 0, 0, 0, 192, 169, 0, 0, 0, 0,
1924 124, 130, 128, 65, 0, 118, 0, 251, 0, 0,
1925 283, 0, 0, 122, 123, 122, 0, 0, 0, 0,
1926 0, 0, 288, 289, 283, 0, 308, 0, 199, 0,
1927 0, 183, 0, 0, 0, 0, 168, 0, 0, 0,
1928 64, 228, 230, 112, 125, 0, 0, 0, 0, 0,
1929 290, 291, 304, 306, 285, 0, 0, 293, 296, 297,
1930 0, 122, 0, 0, 0, 189, 0, 0, 185, 186,
1931 182, 65, 126, 120, 253, 0, 0, 112, 0, 118,
1932 279, 0, 118, 309, 187, 188, 0, 0, 0, 227,
1933 0, 233, 0, 272, 0, 0, 281, 0, 0, 280,
1934 299, 184, 190, 191, 121, 270, 0, 271, 0, 112,
1935 0, 0, 0, 282, 0, 0, 0, 0, 277, 0,
1936 0, 276, 0, 273
1937};
1938
1939/* YYDEFGOTO[NTERM-NUM]. */
1940static const short yydefgoto[] =
1941{
1942 -1, 258, 259, 260, 284, 301, 158, 159, 78, 511,
1943 12, 79, 14, 15, 40, 41, 42, 47, 53, 116,
1944 126, 328, 224, 402, 331, 561, 381, 425, 543, 358,
1945 426, 80, 160, 135, 150, 136, 137, 109, 347, 370,
1946 348, 119, 87, 151, 16, 17, 18, 20, 19, 263,
1947 336, 337, 62, 23, 60, 100, 429, 430, 127, 166,
1948 54, 95, 55, 48, 432, 371, 82, 373, 268, 56,
1949 91, 92, 218, 565, 130, 307, 519, 442, 219, 220,
1950 221, 222
1951};
1952
1953/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1954 STATE-NUM. */
1955#define YYPACT_NINF -529
1956static const short yypact[] =
1957{
1958 40, -529, -529, -529, -529, -529, -529, -529, -17, -107,
1959 12, -64, 78, -40, 183, -529, 150, 370, -529, 147,
1960 115, -5, 26, -529, 14, 132, -529, 1319, -529, -529,
1961 -529, -529, -529, -529, -529, -529, -529, -529, -529, -529,
1962 -90, -90, 173, -529, -529, -529, -529, -90, -529, -529,
1963 -529, -529, -529, -90, 154, -529, -7, 179, 197, 214,
1964 -529, -529, -529, -529, -529, 96, -529, -529, -529, -529,
1965 -529, -529, -529, -529, 253, 258, 3, 791, -529, -529,
1966 -529, 145, -529, 228, 228, 287, -529, 191, 189, 189,
1967 -529, -529, 109, -529, -529, -529, -529, -529, -529, -529,
1968 -66, 1052, -529, 125, 135, 835, 96, -529, 145, -110,
1969 -529, 1052, 191, 191, -529, -529, 1092, -529, -529, 1359,
1970 285, -529, -529, -529, -529, -529, 1377, -529, -12, 1525,
1971 -529, 272, -529, -529, 145, -529, 153, 152, 1430, 1430,
1972 168, -106, 1430, -529, 157, 1359, 1430, 96, 159, 145,
1973 102, -529, 39, 321, 323, 325, 326, 327, 266, 328,
1974 750, -529, -529, 141, -529, -529, -529, -529, -529, 288,
1975 1470, 94, 329, 189, -529, -529, -529, -529, -529, -529,
1976 -529, -529, -529, -529, -529, -529, -529, -529, -529, -529,
1977 -529, 222, 625, 1430, 1430, 1430, 1430, -529, -529, -529,
1978 -529, -529, -529, -529, -529, -529, -529, -529, -529, 1430,
1979 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, -529, 189,
1980 -529, 128, -529, -529, 126, 1110, -529, -53, -72, -529,
1981 188, 145, -529, -529, 145, 1092, -529, -529, -529, -529,
1982 -529, -529, -529, -529, -529, -529, -529, 222, 625, 195,
1983 196, 200, 201, 202, 1204, 1528, 1012, 331, 204, 206,
1984 208, -529, -529, 212, 210, -529, 96, 486, -529, 623,
1985 623, -529, 623, 1377, -529, -529, -529, -529, -529, -529,
1986 -529, -529, -529, -529, 1430, -529, -529, -529, -529, -529,
1987 -529, -529, -529, -529, -529, -529, -529, -529, -529, -529,
1988 -529, 1430, -1, 32, -529, 486, 52, 219, 220, 224,
1989 227, 230, 233, 486, 486, 343, 1377, 1430, 1430, -529,
1990 -529, -529, -529, -529, -529, -529, -529, -529, -529, -529,
1991 -529, 77, -529, -529, -529, 77, 212, 212, 344, 234,
1992 235, 1359, 1359, 1359, 1359, 1359, -529, -529, -61, 1031,
1993 -100, -529, -101, -529, 1359, 1359, 1359, -19, -529, 1261,
1994 -529, -529, -529, -529, -529, -529, -529, -529, 310, 1359,
1995 -529, -529, -529, -529, 236, -529, 240, 623, 486, 486,
1996 20, -529, 21, -529, -529, 623, 239, 1430, 1430, 1430,
1997 1430, 1430, 249, 250, 1430, 623, 486, 251, -529, -529,
1998 -529, -529, -529, -529, -529, 1430, 1359, 1359, -529, 252,
1999 259, 260, 264, 1359, -529, 256, 750, -75, -529, -529,
2000 267, 268, 375, 396, 415, -529, 212, -529, 145, 273,
2001 274, -529, 401, -79, 409, 413, 281, 286, 289, 623,
2002 428, 623, 290, 291, 623, 292, 145, -529, 293, 299,
2003 623, 623, 145, 284, 300, 1430, 84, 303, 304, -44,
2004 1359, 1359, 1359, 1359, -529, -529, 279, 1359, 1359, 1430,
2005 -529, -529, -529, 80, 1279, -529, 306, -529, 623, 623,
2006 1430, 623, 623, 300, -529, 300, 1430, 623, 308, 1430,
2007 1430, 1430, -529, -529, 1430, 403, -529, 486, -529, 1359,
2008 1359, -529, 311, 315, 312, 314, -529, 316, 318, 129,
2009 -529, -529, -529, 145, 4, 435, 324, 320, 486, -33,
2010 -529, -529, -529, -529, -529, 330, 623, -529, -529, -529,
2011 -32, 300, 319, 332, 1359, -529, 1359, 1359, -529, -529,
2012 -529, 80, -529, 421, -529, 445, -2, -529, 1430, -529,
2013 -529, 333, -529, -529, -529, -529, 334, 335, 340, -529,
2014 471, -529, 623, -529, 885, 2, 126, 486, 42, -529,
2015 77, -529, -529, -529, -529, -529, 345, -529, 885, -529,
2016 460, 479, 350, 126, 623, 623, 483, 430, -529, 623,
2017 485, -529, 623, -529
2018};
2019
2020/* YYPGOTO[NTERM-NUM]. */
2021static const short yypgoto[] =
2022{
2023 -529, 374, 378, 385, 257, 269, -170, -529, 0, -25,
2024 423, 8, -529, -529, -529, -529, 95, -529, -529, -529,
2025 -152, -529, -424, -529, -227, -529, -291, 5, -529, -318,
2026 -529, -529, -26, 295, -120, -529, 407, 416, -58, -157,
2027 -232, 161, 198, 294, -529, -529, 506, -529, -529, -529,
2028 -529, -529, -529, -529, -529, -529, -529, -529, 436, -529,
2029 -529, -529, -529, -529, -529, -528, -140, 103, -184, -529,
2030 468, -529, -529, -529, -529, -529, 34, 122, -529, -529,
2031 -529, -529
2032};
2033
2034/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2035 positive, shift that token. If negative, reduce the rule which
2036 number is the opposite. If zero, do what YYDEFACT says.
2037 If YYTABLE_NINF, syntax error. */
2038#define YYTABLE_NINF -202
2039static const short yytable[] =
2040{
2041 11, 81, 272, 261, 473, 335, 163, 104, 13, 271,
2042 236, 304, 383, 271, 90, 423, 164, 11, 403, 404,
2043 262, 273, 93, 350, 352, 13, 308, 309, 310, 311,
2044 312, 439, 441, 315, 424, 21, 576, 142, 423, 24,
2045 -201, 142, -55, -55, -55, -55, 413, 413, 143, 22,
2046 582, 108, 230, 37, 38, 39, 418, 419, -67, 1,
2047 2, 161, 3, 4, 5, 237, 238, 316, 413, 25,
2048 6, 7, 413, 440, 440, 134, 110, 477, 111, 108,
2049 580, 131, 26, 466, 333, 134, 413, 233, 132, 541,
2050 149, 8, 11, 414, 9, 110, 27, 111, 10, 1,
2051 149, 332, 3, 486, 5, 269, 28, 501, 472, 63,
2052 64, 270, 227, 228, 548, 548, 231, 417, 549, 552,
2053 234, 1, 2, 566, 3, 4, 5, 372, 1, 372,
2054 372, 3, 372, 5, 397, 83, 84, 433, 398, 399,
2055 400, 57, 88, 401, 267, 165, 380, 110, 89, 111,
2056 43, 94, 563, 377, 61, 583, 577, 49, 50, 51,
2057 105, 2, 52, 496, 4, 372, 59, 302, 303, 267,
2058 305, 264, 58, 372, 372, 90, 398, 399, 400, 382,
2059 110, 401, 111, 306, 267, 267, 267, 267, 267, 313,
2060 314, 267, 522, 45, 523, 46, 395, 319, 320, 134,
2061 110, 97, 111, 445, 385, 447, 448, 449, 85, 149,
2062 86, 398, 399, 400, 321, 322, 401, 323, 324, 98,
2063 325, 326, 327, 117, 118, 29, 30, 31, 32, 33,
2064 34, 35, 110, 36, 111, 498, 99, 372, 372, 372,
2065 553, 317, 318, 319, 320, 372, 101, 149, 514, 120,
2066 121, 122, 123, 124, 125, 372, 372, 102, 378, 261,
2067 321, 322, 103, 323, 324, 86, 325, 326, 327, 239,
2068 240, 241, 242, 145, 146, 379, 262, 110, 138, 111,
2069 540, 112, 113, 408, 409, 410, 411, 412, 139, 162,
2070 149, 396, 267, 110, 223, 111, 420, 421, 422, 372,
2071 225, 372, 524, 226, 372, 527, 528, 529, 232, 235,
2072 372, 372, 274, 275, 276, 277, 278, 279, 280, 281,
2073 282, 283, 568, 416, 229, 570, 37, 38, 39, 114,
2074 -56, 115, -57, 428, -60, -59, -58, 243, 372, 372,
2075 271, 372, 372, 265, 334, 341, 342, 372, 457, 458,
2076 343, 344, 345, 353, 354, 464, 355, 372, 356, 357,
2077 359, 267, 446, 267, 267, 267, 386, 387, 452, 431,
2078 -200, 388, 374, 375, 389, 376, 564, 390, 372, 456,
2079 391, 394, 405, 434, 406, 407, 372, 435, -67, 1,
2080 2, 444, 3, 4, 5, 578, 450, 451, 455, 460,
2081 6, 7, 502, 503, 504, 505, 461, 462, 384, 507,
2082 508, 463, 465, 469, 467, 468, 392, 393, 470, 471,
2083 474, 8, 372, 476, 9, 475, 478, 372, 10, 497,
2084 479, 480, 484, 481, 494, 506, 482, 486, 487, 489,
2085 490, 532, 533, 509, 372, 372, 491, 495, 513, 372,
2086 499, 500, 372, 515, 518, 526, 440, 544, 534, 536,
2087 267, 537, 562, 267, 267, 267, 535, 538, 518, 539,
2088 554, 545, 546, 510, 560, 574, 556, 584, 557, 558,
2089 436, 437, 438, 555, 550, 571, 572, 569, 443, 360,
2090 361, 573, 581, 63, 64, 362, 585, 586, 453, 454,
2091 589, 590, 592, 215, 339, 1, 2, 216, 3, 4,
2092 5, 363, 364, 365, 217, 129, 559, 340, 144, 542,
2093 330, 141, 567, 44, 96, 128, 366, 367, 530, 338,
2094 459, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2095 0, 510, 483, 368, 485, 0, 0, 488, 0, 0,
2096 0, 0, 0, 492, 493, 0, 0, 0, 0, 176,
2097 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
2098 187, 188, 189, 190, 247, 248, 0, 0, 0, 0,
2099 0, 516, 517, 0, 520, 521, 0, 0, 0, 0,
2100 525, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2101 531, 249, 197, 198, 199, 200, 201, 202, 203, 204,
2102 205, 206, 207, 208, 0, 250, 0, 251, 252, 253,
2103 0, 547, 0, 0, 0, 0, 360, 361, 0, 551,
2104 63, 64, 362, 0, 110, 0, 111, 0, 0, 0,
2105 0, 369, 1, 2, 0, 3, 4, 5, 363, 364,
2106 365, 285, 286, 0, 0, 0, 0, 0, 0, 0,
2107 0, 0, 0, 366, 367, 575, 0, 0, 0, 0,
2108 579, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2109 368, 0, 0, 0, 0, 0, 0, 587, 588, 0,
2110 0, 0, 591, 0, 0, 593, 176, 177, 178, 179,
2111 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
2112 190, 247, 248, 0, 0, 0, 0, 0, 0, 0,
2113 0, 287, 288, 289, 290, 291, 292, 293, 294, 295,
2114 296, 297, 298, 299, 300, 0, 0, 0, 249, 197,
2115 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
2116 208, 0, 250, 0, 251, 252, 253, 63, 64, 0,
2117 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
2118 2, 0, 3, 4, 5, 244, 0, 0, 369, 0,
2119 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2120 245, 246, 0, 0, 0, 0, 0, 0, 63, 64,
2121 0, 106, 66, 67, 68, 69, 70, 71, 72, 0,
2122 1, 2, 0, 3, 4, 5, 0, 0, 0, 0,
2123 0, 0, 0, 176, 177, 178, 179, 180, 181, 182,
2124 183, 184, 185, 186, 187, 188, 189, 190, 247, 248,
2125 73, 0, 63, 64, 0, 106, 66, 67, 68, 69,
2126 70, 71, 72, 0, 1, 2, 0, 3, 4, 5,
2127 0, 0, 0, 0, 0, 249, 197, 198, 199, 200,
2128 201, 202, 203, 204, 205, 206, 207, 208, 0, 250,
2129 0, 251, 252, 253, 73, 0, 0, 0, 360, 361,
2130 0, 0, 0, 0, 362, 0, 0, 0, 110, 0,
2131 111, 0, 254, 0, 0, 255, 0, 256, 0, 257,
2132 363, 364, 365, 0, 0, 0, 0, 0, 0, 0,
2133 0, 0, 0, 0, 0, 366, 367, 0, 0, 0,
2134 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2135 74, 0, 368, 75, 0, 0, 76, 0, 77, 107,
2136 0, 0, 0, 0, 0, 0, 0, 0, 176, 177,
2137 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
2138 188, 189, 190, 247, 248, 0, 0, 0, 0, 0,
2139 0, 0, 0, 0, 74, 0, 0, 75, 0, 0,
2140 76, 0, 77, 140, 0, 0, 0, 0, 0, 0,
2141 249, 197, 198, 199, 200, 201, 202, 203, 204, 205,
2142 206, 207, 208, 0, 250, 0, 251, 252, 253, 63,
2143 64, 0, 106, 152, 153, 154, 155, 156, 157, 72,
2144 0, 1, 2, 0, 3, 4, 5, 0, 63, 64,
2145 369, 106, 152, 153, 154, 155, 156, 157, 72, 0,
2146 1, 2, 0, 3, 4, 5, 0, 0, 0, 63,
2147 64, 73, 106, 66, 67, 68, 69, 70, 71, 72,
2148 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
2149 73, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2150 0, 133, 0, 0, 0, 0, 0, 0, 0, 63,
2151 64, 73, 147, 66, 67, 68, 69, 70, 71, 72,
2152 0, 1, 2, 0, 3, 4, 5, 63, 64, 0,
2153 106, 66, 67, 68, 69, 70, 71, 72, 0, 1,
2154 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2155 0, 73, 0, 0, 0, 0, 0, 0, 0, 329,
2156 0, 0, 0, 0, 0, 0, 0, 0, 0, 73,
2157 0, 74, 0, 0, 75, 0, 0, 76, 0, 77,
2158 351, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2159 74, 0, 0, 75, 0, 0, 76, 0, 77, 415,
2160 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2161 0, 74, 0, 0, 75, 0, 0, 76, 0, 77,
2162 0, 63, 64, 148, 106, 152, 153, 154, 155, 156,
2163 157, 72, 0, 1, 2, 0, 3, 4, 5, 0,
2164 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2165 0, 74, 0, 0, 75, 0, 0, 76, 0, 77,
2166 0, 0, 0, 73, 0, 0, 0, 0, 0, 74,
2167 0, 0, 75, 0, 0, 76, 0, 77, 63, 64,
2168 0, 106, 66, 67, 68, 69, 70, 71, 72, 0,
2169 1, 2, 0, 3, 4, 5, 63, 64, 0, 106,
2170 66, 67, 68, 69, 70, 71, 72, 0, 1, 2,
2171 427, 3, 4, 5, 0, 0, 0, 0, 0, 0,
2172 73, 0, 0, 0, 0, 0, 0, 0, 512, 0,
2173 0, 0, 0, 0, 0, 0, 63, 64, 73, 65,
2174 66, 67, 68, 69, 70, 71, 72, 0, 1, 2,
2175 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
2176 0, 0, 0, 74, 0, 0, 75, 0, 346, 76,
2177 0, 77, 0, 0, 0, 0, 63, 64, 73, 106,
2178 152, 153, 154, 155, 156, 157, 72, 0, 1, 2,
2179 0, 3, 4, 5, 63, 64, 0, 147, 66, 67,
2180 68, 69, 70, 71, 72, 0, 1, 2, 0, 3,
2181 4, 5, 0, 0, 0, 0, 0, 0, 73, 0,
2182 74, 0, 0, 75, 0, 0, 76, 0, 77, 0,
2183 0, 0, 0, 0, 0, 0, 73, 0, 74, 0,
2184 0, 75, 0, 0, 76, 0, 77, 63, 64, 0,
2185 106, 66, 67, 68, 69, 70, 71, 72, 0, 1,
2186 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2187 0, 0, 0, 0, 0, 0, 0, 0, 74, 0,
2188 0, 75, 0, 0, 76, 0, 77, 63, 64, 73,
2189 266, 66, 67, 68, 69, 70, 71, 72, 0, 1,
2190 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
2191 0, 0, 0, 0, 0, 0, 0, 0, 74, 0,
2192 0, 75, 0, 0, 76, 0, 77, 0, 0, 73,
2193 0, 0, 0, 0, 0, 0, 74, 0, 0, 75,
2194 0, 0, 76, 0, 77, 63, 64, 0, 106, 152,
2195 153, 154, 155, 156, 157, 72, 0, 1, 2, 0,
2196 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
2197 0, 167, 0, 0, 0, 0, 0, 0, 0, 0,
2198 0, 0, 0, 0, 0, 0, 0, 73, 0, 74,
2199 168, 169, 75, 0, 0, 76, 0, 77, 0, 0,
2200 0, 0, 170, 171, 172, 173, 174, 175, 176, 177,
2201 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
2202 188, 189, 190, 191, 192, 0, 0, 0, 0, 74,
2203 0, 0, 75, 0, 0, 76, 0, 77, 0, 0,
2204 0, 0, 0, 0, 0, 193, 194, 195, 0, 0,
2205 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
2206 206, 207, 208, 209, 210, 211, 212, 213, 214, 0,
2207 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2208 0, 0, 0, 0, 0, 0, 0, 74, 0, 0,
2209 75, 0, 0, 76, 0, 349
2210};
2211
2212static const short yycheck[] =
2213{
2214 0, 27, 172, 160, 428, 232, 126, 4, 0, 11,
2215 150, 195, 303, 11, 21, 34, 28, 17, 336, 337,
2216 160, 173, 29, 255, 256, 17, 210, 211, 212, 213,
2217 214, 11, 11, 217, 53, 52, 564, 147, 34, 146,
2218 0, 147, 3, 4, 5, 6, 147, 147, 158, 66,
2219 578, 77, 158, 143, 144, 145, 156, 158, 18, 19,
2220 20, 119, 22, 23, 24, 26, 27, 219, 147, 57,
2221 30, 31, 147, 53, 53, 101, 148, 156, 150, 105,
2222 38, 147, 146, 158, 156, 111, 147, 145, 154, 513,
2223 116, 51, 92, 154, 54, 148, 18, 150, 58, 19,
2224 126, 154, 22, 147, 24, 11, 146, 151, 426, 7,
2225 8, 17, 138, 139, 147, 147, 142, 349, 151, 151,
2226 146, 19, 20, 547, 22, 23, 24, 267, 19, 269,
2227 270, 22, 272, 24, 318, 40, 41, 369, 134, 135,
2228 136, 146, 47, 139, 170, 157, 147, 148, 53, 150,
2229 0, 158, 154, 273, 22, 579, 154, 42, 43, 44,
2230 157, 20, 47, 454, 23, 305, 152, 193, 194, 195,
2231 196, 163, 146, 313, 314, 21, 134, 135, 136, 147,
2232 148, 139, 150, 209, 210, 211, 212, 213, 214, 215,
2233 216, 217, 483, 46, 485, 48, 316, 117, 118, 225,
2234 148, 22, 150, 387, 152, 389, 390, 391, 35, 235,
2235 37, 134, 135, 136, 134, 135, 139, 137, 138, 22,
2236 140, 141, 142, 32, 33, 42, 43, 44, 45, 46,
2237 47, 48, 148, 50, 150, 151, 22, 377, 378, 379,
2238 531, 113, 114, 117, 118, 385, 150, 273, 475, 60,
2239 61, 62, 63, 64, 65, 395, 396, 4, 284, 416,
2240 134, 135, 4, 137, 138, 37, 140, 141, 142, 3,
2241 4, 5, 6, 112, 113, 301, 416, 148, 153, 150,
2242 151, 83, 84, 341, 342, 343, 344, 345, 153, 4,
2243 316, 317, 318, 148, 22, 150, 354, 355, 356, 439,
2244 147, 441, 486, 151, 444, 489, 490, 491, 151, 150,
2245 450, 451, 90, 91, 92, 93, 94, 95, 96, 97,
2246 98, 99, 549, 349, 156, 552, 143, 144, 145, 42,
2247 9, 44, 9, 359, 9, 9, 9, 9, 478, 479,
2248 11, 481, 482, 55, 156, 150, 150, 487, 406, 407,
2249 150, 150, 150, 22, 150, 413, 150, 497, 150, 147,
2250 150, 387, 388, 389, 390, 391, 147, 147, 394, 59,
2251 0, 147, 269, 270, 147, 272, 546, 147, 518, 405,
2252 147, 38, 38, 147, 150, 150, 526, 147, 18, 19,
2253 20, 152, 22, 23, 24, 565, 147, 147, 147, 147,
2254 30, 31, 460, 461, 462, 463, 147, 147, 305, 467,
2255 468, 147, 156, 38, 147, 147, 313, 314, 22, 4,
2256 147, 51, 562, 22, 54, 151, 17, 567, 58, 455,
2257 17, 150, 4, 147, 150, 156, 147, 147, 147, 147,
2258 147, 499, 500, 469, 584, 585, 147, 147, 474, 589,
2259 147, 147, 592, 147, 480, 147, 53, 22, 147, 147,
2260 486, 147, 17, 489, 490, 491, 151, 151, 494, 151,
2261 151, 147, 152, 473, 53, 4, 534, 17, 536, 537,
2262 377, 378, 379, 151, 154, 151, 151, 154, 385, 3,
2263 4, 151, 147, 7, 8, 9, 17, 147, 395, 396,
2264 17, 71, 17, 129, 247, 19, 20, 129, 22, 23,
2265 24, 25, 26, 27, 129, 92, 541, 248, 111, 514,
2266 225, 105, 548, 17, 56, 89, 40, 41, 494, 235,
2267 408, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2268 -1, 541, 439, 57, 441, -1, -1, 444, -1, -1,
2269 -1, -1, -1, 450, 451, -1, -1, -1, -1, 73,
2270 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2271 84, 85, 86, 87, 88, 89, -1, -1, -1, -1,
2272 -1, 478, 479, -1, 481, 482, -1, -1, -1, -1,
2273 487, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2274 497, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2275 124, 125, 126, 127, -1, 129, -1, 131, 132, 133,
2276 -1, 518, -1, -1, -1, -1, 3, 4, -1, 526,
2277 7, 8, 9, -1, 148, -1, 150, -1, -1, -1,
2278 -1, 155, 19, 20, -1, 22, 23, 24, 25, 26,
2279 27, 26, 27, -1, -1, -1, -1, -1, -1, -1,
2280 -1, -1, -1, 40, 41, 562, -1, -1, -1, -1,
2281 567, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2282 57, -1, -1, -1, -1, -1, -1, 584, 585, -1,
2283 -1, -1, 589, -1, -1, 592, 73, 74, 75, 76,
2284 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2285 87, 88, 89, -1, -1, -1, -1, -1, -1, -1,
2286 -1, 96, 97, 98, 99, 100, 101, 102, 103, 104,
2287 105, 106, 107, 108, 109, -1, -1, -1, 115, 116,
2288 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
2289 127, -1, 129, -1, 131, 132, 133, 7, 8, -1,
2290 -1, -1, -1, -1, -1, -1, -1, -1, -1, 19,
2291 20, -1, 22, 23, 24, 25, -1, -1, 155, -1,
2292 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2293 40, 41, -1, -1, -1, -1, -1, -1, 7, 8,
2294 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2295 19, 20, -1, 22, 23, 24, -1, -1, -1, -1,
2296 -1, -1, -1, 73, 74, 75, 76, 77, 78, 79,
2297 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2298 49, -1, 7, 8, -1, 10, 11, 12, 13, 14,
2299 15, 16, 17, -1, 19, 20, -1, 22, 23, 24,
2300 -1, -1, -1, -1, -1, 115, 116, 117, 118, 119,
2301 120, 121, 122, 123, 124, 125, 126, 127, -1, 129,
2302 -1, 131, 132, 133, 49, -1, -1, -1, 3, 4,
2303 -1, -1, -1, -1, 9, -1, -1, -1, 148, -1,
2304 150, -1, 152, -1, -1, 155, -1, 157, -1, 159,
2305 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
2306 -1, -1, -1, -1, -1, 40, 41, -1, -1, -1,
2307 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2308 149, -1, 57, 152, -1, -1, 155, -1, 157, 158,
2309 -1, -1, -1, -1, -1, -1, -1, -1, 73, 74,
2310 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2311 85, 86, 87, 88, 89, -1, -1, -1, -1, -1,
2312 -1, -1, -1, -1, 149, -1, -1, 152, -1, -1,
2313 155, -1, 157, 158, -1, -1, -1, -1, -1, -1,
2314 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2315 125, 126, 127, -1, 129, -1, 131, 132, 133, 7,
2316 8, -1, 10, 11, 12, 13, 14, 15, 16, 17,
2317 -1, 19, 20, -1, 22, 23, 24, -1, 7, 8,
2318 155, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2319 19, 20, -1, 22, 23, 24, -1, -1, -1, 7,
2320 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2321 -1, 19, 20, -1, 22, 23, 24, -1, -1, -1,
2322 49, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2323 -1, 39, -1, -1, -1, -1, -1, -1, -1, 7,
2324 8, 49, 10, 11, 12, 13, 14, 15, 16, 17,
2325 -1, 19, 20, -1, 22, 23, 24, 7, 8, -1,
2326 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2327 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2328 -1, 49, -1, -1, -1, -1, -1, -1, -1, 39,
2329 -1, -1, -1, -1, -1, -1, -1, -1, -1, 49,
2330 -1, 149, -1, -1, 152, -1, -1, 155, -1, 157,
2331 158, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2332 149, -1, -1, 152, -1, -1, 155, -1, 157, 158,
2333 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2334 -1, 149, -1, -1, 152, -1, -1, 155, -1, 157,
2335 -1, 7, 8, 121, 10, 11, 12, 13, 14, 15,
2336 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
2337 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2338 -1, 149, -1, -1, 152, -1, -1, 155, -1, 157,
2339 -1, -1, -1, 49, -1, -1, -1, -1, -1, 149,
2340 -1, -1, 152, -1, -1, 155, -1, 157, 7, 8,
2341 -1, 10, 11, 12, 13, 14, 15, 16, 17, -1,
2342 19, 20, -1, 22, 23, 24, 7, 8, -1, 10,
2343 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2344 39, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2345 49, -1, -1, -1, -1, -1, -1, -1, 39, -1,
2346 -1, -1, -1, -1, -1, -1, 7, 8, 49, 10,
2347 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2348 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
2349 -1, -1, -1, 149, -1, -1, 152, -1, 154, 155,
2350 -1, 157, -1, -1, -1, -1, 7, 8, 49, 10,
2351 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
2352 -1, 22, 23, 24, 7, 8, -1, 10, 11, 12,
2353 13, 14, 15, 16, 17, -1, 19, 20, -1, 22,
2354 23, 24, -1, -1, -1, -1, -1, -1, 49, -1,
2355 149, -1, -1, 152, -1, -1, 155, -1, 157, -1,
2356 -1, -1, -1, -1, -1, -1, 49, -1, 149, -1,
2357 -1, 152, -1, -1, 155, -1, 157, 7, 8, -1,
2358 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2359 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2360 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
2361 -1, 152, -1, -1, 155, -1, 157, 7, 8, 49,
2362 10, 11, 12, 13, 14, 15, 16, 17, -1, 19,
2363 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
2364 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
2365 -1, 152, -1, -1, 155, -1, 157, -1, -1, 49,
2366 -1, -1, -1, -1, -1, -1, 149, -1, -1, 152,
2367 -1, -1, 155, -1, 157, 7, 8, -1, 10, 11,
2368 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
2369 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2370 -1, 36, -1, -1, -1, -1, -1, -1, -1, -1,
2371 -1, -1, -1, -1, -1, -1, -1, 49, -1, 149,
2372 55, 56, 152, -1, -1, 155, -1, 157, -1, -1,
2373 -1, -1, 67, 68, 69, 70, 71, 72, 73, 74,
2374 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2375 85, 86, 87, 88, 89, -1, -1, -1, -1, 149,
2376 -1, -1, 152, -1, -1, 155, -1, 157, -1, -1,
2377 -1, -1, -1, -1, -1, 110, 111, 112, -1, -1,
2378 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
2379 125, 126, 127, 128, 129, 130, 131, 132, 133, -1,
2380 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2381 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
2382 152, -1, -1, 155, -1, 157
2383};
2384
2385/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2386 symbol of state STATE-NUM. */
2387static const unsigned char yystos[] =
2388{
2389 0, 19, 20, 22, 23, 24, 30, 31, 51, 54,
2390 58, 168, 170, 171, 172, 173, 204, 205, 206, 208,
2391 207, 52, 66, 213, 146, 57, 146, 18, 146, 42,
2392 43, 44, 45, 46, 47, 48, 50, 143, 144, 145,
2393 174, 175, 176, 0, 206, 46, 48, 177, 223, 42,
2394 43, 44, 47, 178, 220, 222, 229, 146, 146, 152,
2395 214, 22, 212, 7, 8, 10, 11, 12, 13, 14,
2396 15, 16, 17, 49, 149, 152, 155, 157, 168, 171,
2397 191, 192, 226, 176, 176, 35, 37, 202, 176, 176,
2398 21, 230, 231, 29, 158, 221, 230, 22, 22, 22,
2399 215, 150, 4, 4, 4, 157, 10, 158, 192, 197,
2400 148, 150, 202, 202, 42, 44, 179, 32, 33, 201,
2401 60, 61, 62, 63, 64, 65, 180, 218, 218, 170,
2402 234, 147, 154, 39, 192, 193, 195, 196, 153, 153,
2403 158, 197, 147, 158, 196, 201, 201, 10, 121, 192,
2404 194, 203, 11, 12, 13, 14, 15, 16, 166, 167,
2405 192, 198, 4, 194, 28, 157, 219, 36, 55, 56,
2406 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2407 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2408 87, 88, 89, 110, 111, 112, 115, 116, 117, 118,
2409 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
2410 129, 130, 131, 132, 133, 161, 162, 163, 232, 238,
2411 239, 240, 241, 22, 182, 147, 151, 192, 192, 156,
2412 158, 192, 151, 198, 192, 150, 226, 26, 27, 3,
2413 4, 5, 6, 9, 25, 40, 41, 88, 89, 115,
2414 129, 131, 132, 133, 152, 155, 157, 159, 161, 162,
2415 163, 199, 226, 209, 171, 55, 10, 192, 228, 11,
2416 17, 11, 166, 180, 90, 91, 92, 93, 94, 95,
2417 96, 97, 98, 99, 164, 26, 27, 96, 97, 98,
2418 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
2419 109, 165, 192, 192, 228, 192, 192, 235, 228, 228,
2420 228, 228, 228, 192, 192, 228, 180, 113, 114, 117,
2421 118, 134, 135, 137, 138, 140, 141, 142, 181, 39,
2422 193, 184, 154, 156, 156, 184, 210, 211, 203, 164,
2423 165, 150, 150, 150, 150, 150, 154, 198, 200, 157,
2424 200, 158, 200, 22, 150, 150, 150, 147, 189, 150,
2425 3, 4, 9, 25, 26, 27, 40, 41, 57, 155,
2426 199, 225, 226, 227, 227, 227, 227, 194, 192, 192,
2427 147, 186, 147, 186, 227, 152, 147, 147, 147, 147,
2428 147, 147, 227, 227, 38, 194, 192, 228, 134, 135,
2429 136, 139, 183, 189, 189, 38, 150, 150, 198, 198,
2430 198, 198, 198, 147, 154, 158, 192, 200, 156, 158,
2431 198, 198, 198, 34, 53, 187, 190, 39, 192, 216,
2432 217, 59, 224, 200, 147, 147, 227, 227, 227, 11,
2433 53, 11, 237, 227, 152, 228, 192, 228, 228, 228,
2434 147, 147, 192, 227, 227, 147, 192, 198, 198, 237,
2435 147, 147, 147, 147, 198, 156, 158, 147, 147, 38,
2436 22, 4, 189, 182, 147, 151, 22, 156, 17, 17,
2437 150, 147, 147, 227, 4, 227, 147, 147, 227, 147,
2438 147, 147, 227, 227, 150, 147, 186, 192, 151, 147,
2439 147, 151, 198, 198, 198, 198, 156, 198, 198, 192,
2440 168, 169, 39, 192, 184, 147, 227, 227, 192, 236,
2441 227, 227, 186, 186, 228, 227, 147, 228, 228, 228,
2442 236, 227, 198, 198, 147, 151, 147, 147, 151, 151,
2443 151, 182, 187, 188, 22, 147, 152, 227, 147, 151,
2444 154, 227, 151, 186, 151, 151, 198, 198, 198, 169,
2445 53, 185, 17, 154, 166, 233, 182, 192, 184, 154,
2446 184, 151, 151, 151, 4, 227, 225, 154, 166, 227,
2447 38, 147, 225, 182, 17, 17, 147, 227, 227, 17,
2448 71, 227, 17, 227
2449};
2450
2451#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
2452# define YYSIZE_T __SIZE_TYPE__
2453#endif
2454#if ! defined (YYSIZE_T) && defined (size_t)
2455# define YYSIZE_T size_t
2456#endif
2457#if ! defined (YYSIZE_T)
2458# if defined (__STDC__) || defined (__cplusplus)
2459# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
2460# define YYSIZE_T size_t
2461# endif
2462#endif
2463#if ! defined (YYSIZE_T)
2464# define YYSIZE_T unsigned int
2465#endif
David Greene718fda32007-08-01 03:59:32 +00002466
Reid Spencer68a24bd2005-08-27 18:50:39 +00002467#define yyerrok (yyerrstatus = 0)
2468#define yyclearin (yychar = YYEMPTY)
David Greene5fd22a82007-09-04 18:46:50 +00002469#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002470#define YYEOF 0
David Greene5fd22a82007-09-04 18:46:50 +00002471
Reid Spencer68a24bd2005-08-27 18:50:39 +00002472#define YYACCEPT goto yyacceptlab
David Greene5fd22a82007-09-04 18:46:50 +00002473#define YYABORT goto yyabortlab
2474#define YYERROR goto yyerrorlab
2475
2476
2477/* Like YYERROR except do call yyerror. This remains here temporarily
2478 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002479 Once GCC version 2 has supplanted version 1, this can go. */
David Greene5fd22a82007-09-04 18:46:50 +00002480
Reid Spencer68a24bd2005-08-27 18:50:39 +00002481#define YYFAIL goto yyerrlab
David Greene5fd22a82007-09-04 18:46:50 +00002482
Reid Spencer68a24bd2005-08-27 18:50:39 +00002483#define YYRECOVERING() (!!yyerrstatus)
David Greene5fd22a82007-09-04 18:46:50 +00002484
2485#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002486do \
2487 if (yychar == YYEMPTY && yylen == 1) \
David Greene5fd22a82007-09-04 18:46:50 +00002488 { \
2489 yychar = (Token); \
2490 yylval = (Value); \
2491 yytoken = YYTRANSLATE (yychar); \
Chris Lattner0275cff2007-08-06 21:00:46 +00002492 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002493 goto yybackup; \
2494 } \
2495 else \
David Greene5fd22a82007-09-04 18:46:50 +00002496 { \
2497 yyerror ("syntax error: cannot back up");\
2498 YYERROR; \
2499 } \
Chris Lattner0275cff2007-08-06 21:00:46 +00002500while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002501
Reid Spencer68a24bd2005-08-27 18:50:39 +00002502#define YYTERROR 1
2503#define YYERRCODE 256
2504
David Greene5fd22a82007-09-04 18:46:50 +00002505/* YYLLOC_DEFAULT -- Compute the default location (before the actions
2506 are run). */
2507
2508#ifndef YYLLOC_DEFAULT
2509# define YYLLOC_DEFAULT(Current, Rhs, N) \
2510 ((Current).first_line = (Rhs)[1].first_line, \
2511 (Current).first_column = (Rhs)[1].first_column, \
2512 (Current).last_line = (Rhs)[N].last_line, \
2513 (Current).last_column = (Rhs)[N].last_column)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002514#endif
2515
David Greene5fd22a82007-09-04 18:46:50 +00002516/* YYLEX -- calling `yylex' with the right arguments. */
2517
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002518#ifdef YYLEX_PARAM
David Greene5fd22a82007-09-04 18:46:50 +00002519# define YYLEX yylex (YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002520#else
David Greene5fd22a82007-09-04 18:46:50 +00002521# define YYLEX yylex ()
Chris Lattner0275cff2007-08-06 21:00:46 +00002522#endif
David Greene5fd22a82007-09-04 18:46:50 +00002523
2524/* Enable debugging if requested. */
2525#if YYDEBUG
2526
2527# ifndef YYFPRINTF
2528# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2529# define YYFPRINTF fprintf
2530# endif
2531
2532# define YYDPRINTF(Args) \
2533do { \
2534 if (yydebug) \
2535 YYFPRINTF Args; \
2536} while (0)
2537
2538# define YYDSYMPRINT(Args) \
2539do { \
2540 if (yydebug) \
2541 yysymprint Args; \
2542} while (0)
2543
2544# define YYDSYMPRINTF(Title, Token, Value, Location) \
2545do { \
2546 if (yydebug) \
2547 { \
2548 YYFPRINTF (stderr, "%s ", Title); \
2549 yysymprint (stderr, \
2550 Token, Value); \
2551 YYFPRINTF (stderr, "\n"); \
2552 } \
2553} while (0)
2554
2555/*------------------------------------------------------------------.
2556| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2557| TOP (included). |
2558`------------------------------------------------------------------*/
2559
2560#if defined (__STDC__) || defined (__cplusplus)
2561static void
2562yy_stack_print (short *bottom, short *top)
Chris Lattner0275cff2007-08-06 21:00:46 +00002563#else
David Greene5fd22a82007-09-04 18:46:50 +00002564static void
2565yy_stack_print (bottom, top)
2566 short *bottom;
2567 short *top;
Chris Lattner0275cff2007-08-06 21:00:46 +00002568#endif
David Greene5fd22a82007-09-04 18:46:50 +00002569{
2570 YYFPRINTF (stderr, "Stack now");
2571 for (/* Nothing. */; bottom <= top; ++bottom)
2572 YYFPRINTF (stderr, " %d", *bottom);
2573 YYFPRINTF (stderr, "\n");
2574}
2575
2576# define YY_STACK_PRINT(Bottom, Top) \
2577do { \
2578 if (yydebug) \
2579 yy_stack_print ((Bottom), (Top)); \
2580} while (0)
2581
2582
2583/*------------------------------------------------.
2584| Report that the YYRULE is going to be reduced. |
2585`------------------------------------------------*/
2586
2587#if defined (__STDC__) || defined (__cplusplus)
2588static void
2589yy_reduce_print (int yyrule)
2590#else
2591static void
2592yy_reduce_print (yyrule)
2593 int yyrule;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002594#endif
David Greene5fd22a82007-09-04 18:46:50 +00002595{
2596 int yyi;
2597 unsigned int yylno = yyrline[yyrule];
2598 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
2599 yyrule - 1, yylno);
2600 /* Print the symbols being reduced, and their result. */
2601 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2602 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
2603 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
2604}
Chandler Carruth02202192007-08-04 01:56:21 +00002605
David Greene5fd22a82007-09-04 18:46:50 +00002606# define YY_REDUCE_PRINT(Rule) \
2607do { \
2608 if (yydebug) \
2609 yy_reduce_print (Rule); \
2610} while (0)
Chandler Carruth02202192007-08-04 01:56:21 +00002611
David Greene5fd22a82007-09-04 18:46:50 +00002612/* Nonzero means print parse trace. It is left uninitialized so that
2613 multiple parsers can coexist. */
2614int yydebug;
2615#else /* !YYDEBUG */
2616# define YYDPRINTF(Args)
2617# define YYDSYMPRINT(Args)
2618# define YYDSYMPRINTF(Title, Token, Value, Location)
2619# define YY_STACK_PRINT(Bottom, Top)
2620# define YY_REDUCE_PRINT(Rule)
2621#endif /* !YYDEBUG */
Chandler Carruth02202192007-08-04 01:56:21 +00002622
Chandler Carruth02202192007-08-04 01:56:21 +00002623
David Greene5fd22a82007-09-04 18:46:50 +00002624/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002625#ifndef YYINITDEPTH
David Greene5fd22a82007-09-04 18:46:50 +00002626# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002627#endif
2628
David Greene5fd22a82007-09-04 18:46:50 +00002629/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2630 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002631
David Greene5fd22a82007-09-04 18:46:50 +00002632 Do not make this value too large; the results are undefined if
2633 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
2634 evaluated with infinite-precision integer arithmetic. */
2635
2636#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
2637# undef YYMAXDEPTH
Chris Lattner0275cff2007-08-06 21:00:46 +00002638#endif
David Greene718fda32007-08-01 03:59:32 +00002639
Reid Spencer68a24bd2005-08-27 18:50:39 +00002640#ifndef YYMAXDEPTH
David Greene5fd22a82007-09-04 18:46:50 +00002641# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002642#endif
David Greene5fd22a82007-09-04 18:46:50 +00002643
Reid Spencer68a24bd2005-08-27 18:50:39 +00002644
2645
David Greene5fd22a82007-09-04 18:46:50 +00002646#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002647
David Greene5fd22a82007-09-04 18:46:50 +00002648# ifndef yystrlen
2649# if defined (__GLIBC__) && defined (_STRING_H)
2650# define yystrlen strlen
2651# else
2652/* Return the length of YYSTR. */
2653static YYSIZE_T
2654# if defined (__STDC__) || defined (__cplusplus)
2655yystrlen (const char *yystr)
2656# else
2657yystrlen (yystr)
2658 const char *yystr;
2659# endif
Chandler Carruth02202192007-08-04 01:56:21 +00002660{
David Greene5fd22a82007-09-04 18:46:50 +00002661 register const char *yys = yystr;
Chandler Carruth02202192007-08-04 01:56:21 +00002662
David Greene5fd22a82007-09-04 18:46:50 +00002663 while (*yys++ != '\0')
2664 continue;
2665
2666 return yys - yystr - 1;
Chandler Carruth02202192007-08-04 01:56:21 +00002667}
David Greene5fd22a82007-09-04 18:46:50 +00002668# endif
2669# endif
Chandler Carruth02202192007-08-04 01:56:21 +00002670
David Greene5fd22a82007-09-04 18:46:50 +00002671# ifndef yystpcpy
2672# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2673# define yystpcpy stpcpy
2674# else
2675/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2676 YYDEST. */
2677static char *
2678# if defined (__STDC__) || defined (__cplusplus)
2679yystpcpy (char *yydest, const char *yysrc)
2680# else
2681yystpcpy (yydest, yysrc)
2682 char *yydest;
2683 const char *yysrc;
2684# endif
Chris Lattner0275cff2007-08-06 21:00:46 +00002685{
David Greene5fd22a82007-09-04 18:46:50 +00002686 register char *yyd = yydest;
2687 register const char *yys = yysrc;
Chris Lattner0275cff2007-08-06 21:00:46 +00002688
David Greene5fd22a82007-09-04 18:46:50 +00002689 while ((*yyd++ = *yys++) != '\0')
2690 continue;
2691
2692 return yyd - 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00002693}
David Greene5fd22a82007-09-04 18:46:50 +00002694# endif
2695# endif
Chris Lattner0275cff2007-08-06 21:00:46 +00002696
David Greene5fd22a82007-09-04 18:46:50 +00002697#endif /* !YYERROR_VERBOSE */
2698
Chris Lattner0275cff2007-08-06 21:00:46 +00002699
Chris Lattner0275cff2007-08-06 21:00:46 +00002700
David Greene5fd22a82007-09-04 18:46:50 +00002701#if YYDEBUG
2702/*--------------------------------.
2703| Print this symbol on YYOUTPUT. |
2704`--------------------------------*/
Chandler Carruth02202192007-08-04 01:56:21 +00002705
David Greene5fd22a82007-09-04 18:46:50 +00002706#if defined (__STDC__) || defined (__cplusplus)
2707static void
2708yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chandler Carruth02202192007-08-04 01:56:21 +00002709#else
David Greene5fd22a82007-09-04 18:46:50 +00002710static void
2711yysymprint (yyoutput, yytype, yyvaluep)
2712 FILE *yyoutput;
2713 int yytype;
2714 YYSTYPE *yyvaluep;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002715#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002716{
David Greene5fd22a82007-09-04 18:46:50 +00002717 /* Pacify ``unused variable'' warnings. */
2718 (void) yyvaluep;
2719
2720 if (yytype < YYNTOKENS)
2721 {
2722 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2723# ifdef YYPRINT
2724 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2725# endif
2726 }
2727 else
2728 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2729
2730 switch (yytype)
2731 {
2732 default:
2733 break;
2734 }
2735 YYFPRINTF (yyoutput, ")");
2736}
2737
2738#endif /* ! YYDEBUG */
2739/*-----------------------------------------------.
2740| Release the memory associated to this symbol. |
2741`-----------------------------------------------*/
2742
2743#if defined (__STDC__) || defined (__cplusplus)
2744static void
2745yydestruct (int yytype, YYSTYPE *yyvaluep)
2746#else
2747static void
2748yydestruct (yytype, yyvaluep)
2749 int yytype;
2750 YYSTYPE *yyvaluep;
2751#endif
2752{
2753 /* Pacify ``unused variable'' warnings. */
2754 (void) yyvaluep;
2755
2756 switch (yytype)
2757 {
2758
2759 default:
2760 break;
2761 }
2762}
2763
2764
2765/* Prevent warnings from -Wmissing-prototypes. */
2766
2767#ifdef YYPARSE_PARAM
2768# if defined (__STDC__) || defined (__cplusplus)
2769int yyparse (void *YYPARSE_PARAM);
2770# else
2771int yyparse ();
2772# endif
2773#else /* ! YYPARSE_PARAM */
2774#if defined (__STDC__) || defined (__cplusplus)
2775int yyparse (void);
2776#else
2777int yyparse ();
2778#endif
2779#endif /* ! YYPARSE_PARAM */
2780
2781
2782
2783/* The lookahead symbol. */
2784int yychar;
2785
2786/* The semantic value of the lookahead symbol. */
2787YYSTYPE yylval;
2788
2789/* Number of syntax errors so far. */
2790int yynerrs;
2791
2792
2793
2794/*----------.
2795| yyparse. |
2796`----------*/
2797
2798#ifdef YYPARSE_PARAM
2799# if defined (__STDC__) || defined (__cplusplus)
2800int yyparse (void *YYPARSE_PARAM)
2801# else
2802int yyparse (YYPARSE_PARAM)
2803 void *YYPARSE_PARAM;
2804# endif
2805#else /* ! YYPARSE_PARAM */
2806#if defined (__STDC__) || defined (__cplusplus)
2807int
2808yyparse (void)
2809#else
2810int
2811yyparse ()
2812
2813#endif
2814#endif
2815{
2816
Chris Lattner0275cff2007-08-06 21:00:46 +00002817 register int yystate;
2818 register int yyn;
David Greene5fd22a82007-09-04 18:46:50 +00002819 int yyresult;
2820 /* Number of tokens to shift before error messages enabled. */
2821 int yyerrstatus;
2822 /* Lookahead token as an internal (translated) token number. */
2823 int yytoken = 0;
2824
2825 /* Three stacks and their tools:
2826 `yyss': related to states,
2827 `yyvs': related to semantic values,
2828 `yyls': related to locations.
2829
2830 Refer to the stacks thru separate pointers, to allow yyoverflow
2831 to reallocate them elsewhere. */
2832
2833 /* The state stack. */
2834 short yyssa[YYINITDEPTH];
2835 short *yyss = yyssa;
Chris Lattner0275cff2007-08-06 21:00:46 +00002836 register short *yyssp;
David Greene5fd22a82007-09-04 18:46:50 +00002837
2838 /* The semantic value stack. */
2839 YYSTYPE yyvsa[YYINITDEPTH];
2840 YYSTYPE *yyvs = yyvsa;
Chris Lattner0275cff2007-08-06 21:00:46 +00002841 register YYSTYPE *yyvsp;
Chris Lattner0275cff2007-08-06 21:00:46 +00002842
Chris Lattner0275cff2007-08-06 21:00:46 +00002843
Chris Lattner0275cff2007-08-06 21:00:46 +00002844
Chris Lattner0275cff2007-08-06 21:00:46 +00002845#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002846
David Greene5fd22a82007-09-04 18:46:50 +00002847 YYSIZE_T yystacksize = YYINITDEPTH;
Chandler Carruth02202192007-08-04 01:56:21 +00002848
David Greene5fd22a82007-09-04 18:46:50 +00002849 /* The variables used to return semantic value and location from the
2850 action routines. */
2851 YYSTYPE yyval;
Chandler Carruth02202192007-08-04 01:56:21 +00002852
Chandler Carruth02202192007-08-04 01:56:21 +00002853
David Greene5fd22a82007-09-04 18:46:50 +00002854 /* When reducing, the number of symbols on the RHS of the reduced
2855 rule. */
Chris Lattner0275cff2007-08-06 21:00:46 +00002856 int yylen;
Chandler Carruth02202192007-08-04 01:56:21 +00002857
David Greene5fd22a82007-09-04 18:46:50 +00002858 YYDPRINTF ((stderr, "Starting parse\n"));
Chandler Carruth02202192007-08-04 01:56:21 +00002859
Reid Spencer68a24bd2005-08-27 18:50:39 +00002860 yystate = 0;
2861 yyerrstatus = 0;
2862 yynerrs = 0;
2863 yychar = YYEMPTY; /* Cause a token to be read. */
2864
2865 /* Initialize stack pointers.
2866 Waste one element of value and location stack
2867 so that they stay on the same level as the state stack.
2868 The wasted elements are never initialized. */
2869
David Greene5fd22a82007-09-04 18:46:50 +00002870 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002871 yyvsp = yyvs;
2872
David Greene5fd22a82007-09-04 18:46:50 +00002873 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002874
David Greene5fd22a82007-09-04 18:46:50 +00002875/*------------------------------------------------------------.
2876| yynewstate -- Push a new state, which is found in yystate. |
2877`------------------------------------------------------------*/
2878 yynewstate:
2879 /* In all cases, when you get here, the value and location stacks
2880 have just been pushed. so pushing a state here evens the stacks.
2881 */
2882 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002883
David Greene5fd22a82007-09-04 18:46:50 +00002884 yysetstate:
2885 *yyssp = yystate;
2886
2887 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002888 {
2889 /* Get the current used size of the three stacks, in elements. */
David Greene5fd22a82007-09-04 18:46:50 +00002890 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002891
2892#ifdef yyoverflow
David Greene5fd22a82007-09-04 18:46:50 +00002893 {
2894 /* Give user a chance to reallocate the stack. Use copies of
2895 these so that the &'s don't force the real ones into
2896 memory. */
2897 YYSTYPE *yyvs1 = yyvs;
2898 short *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002899
David Greene5fd22a82007-09-04 18:46:50 +00002900
2901 /* Each stack pointer address is followed by the size of the
2902 data in use in that stack, in bytes. This used to be a
2903 conditional around just the two extra args, but that might
2904 be undefined if yyoverflow is a macro. */
2905 yyoverflow ("parser stack overflow",
2906 &yyss1, yysize * sizeof (*yyssp),
2907 &yyvs1, yysize * sizeof (*yyvsp),
2908
2909 &yystacksize);
2910
2911 yyss = yyss1;
2912 yyvs = yyvs1;
2913 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002914#else /* no yyoverflow */
David Greene5fd22a82007-09-04 18:46:50 +00002915# ifndef YYSTACK_RELOCATE
2916 goto yyoverflowlab;
2917# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002918 /* Extend the stack our own way. */
David Greene5fd22a82007-09-04 18:46:50 +00002919 if (YYMAXDEPTH <= yystacksize)
2920 goto yyoverflowlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002921 yystacksize *= 2;
David Greene5fd22a82007-09-04 18:46:50 +00002922 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002923 yystacksize = YYMAXDEPTH;
David Greene5fd22a82007-09-04 18:46:50 +00002924
2925 {
2926 short *yyss1 = yyss;
2927 union yyalloc *yyptr =
2928 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2929 if (! yyptr)
2930 goto yyoverflowlab;
2931 YYSTACK_RELOCATE (yyss);
2932 YYSTACK_RELOCATE (yyvs);
2933
2934# undef YYSTACK_RELOCATE
2935 if (yyss1 != yyssa)
2936 YYSTACK_FREE (yyss1);
2937 }
2938# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002939#endif /* no yyoverflow */
2940
David Greene5fd22a82007-09-04 18:46:50 +00002941 yyssp = yyss + yysize - 1;
2942 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002943
2944
David Greene5fd22a82007-09-04 18:46:50 +00002945 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2946 (unsigned long int) yystacksize));
2947
2948 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002949 YYABORT;
2950 }
2951
David Greene5fd22a82007-09-04 18:46:50 +00002952 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002953
2954 goto yybackup;
David Greene5fd22a82007-09-04 18:46:50 +00002955
2956/*-----------.
2957| yybackup. |
2958`-----------*/
2959yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002960
Chris Lattner0275cff2007-08-06 21:00:46 +00002961/* Do appropriate processing given the current state. */
2962/* Read a lookahead token if we need one and don't already have one. */
2963/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002964
Chris Lattner0275cff2007-08-06 21:00:46 +00002965 /* First try to decide what to do without reference to lookahead token. */
Reid Spencer7780acb2007-04-16 06:56:07 +00002966
Reid Spencer68a24bd2005-08-27 18:50:39 +00002967 yyn = yypact[yystate];
David Greene5fd22a82007-09-04 18:46:50 +00002968 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002969 goto yydefault;
2970
Chris Lattner0275cff2007-08-06 21:00:46 +00002971 /* Not known => get a lookahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002972
David Greene5fd22a82007-09-04 18:46:50 +00002973 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002974 if (yychar == YYEMPTY)
2975 {
David Greene5fd22a82007-09-04 18:46:50 +00002976 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002977 yychar = YYLEX;
2978 }
2979
David Greene5fd22a82007-09-04 18:46:50 +00002980 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002981 {
David Greene5fd22a82007-09-04 18:46:50 +00002982 yychar = yytoken = YYEOF;
2983 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002984 }
2985 else
2986 {
David Greene5fd22a82007-09-04 18:46:50 +00002987 yytoken = YYTRANSLATE (yychar);
2988 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002989 }
2990
David Greene5fd22a82007-09-04 18:46:50 +00002991 /* If the proper action on seeing token YYTOKEN is to reduce or to
2992 detect an error, take that action. */
2993 yyn += yytoken;
2994 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002995 goto yydefault;
2996 yyn = yytable[yyn];
David Greene5fd22a82007-09-04 18:46:50 +00002997 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002998 {
David Greene5fd22a82007-09-04 18:46:50 +00002999 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003000 goto yyerrlab;
3001 yyn = -yyn;
3002 goto yyreduce;
3003 }
3004
3005 if (yyn == YYFINAL)
3006 YYACCEPT;
3007
Chris Lattner0275cff2007-08-06 21:00:46 +00003008 /* Shift the lookahead token. */
David Greene5fd22a82007-09-04 18:46:50 +00003009 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003010
Chris Lattner0275cff2007-08-06 21:00:46 +00003011 /* Discard the token being shifted unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003012 if (yychar != YYEOF)
3013 yychar = YYEMPTY;
3014
Chandler Carruth02202192007-08-04 01:56:21 +00003015 *++yyvsp = yylval;
3016
David Greene5fd22a82007-09-04 18:46:50 +00003017
3018 /* Count tokens shifted since error; after three, turn off error
3019 status. */
3020 if (yyerrstatus)
3021 yyerrstatus--;
Chris Lattner0275cff2007-08-06 21:00:46 +00003022
3023 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003024 goto yynewstate;
3025
Chris Lattner0275cff2007-08-06 21:00:46 +00003026
David Greene5fd22a82007-09-04 18:46:50 +00003027/*-----------------------------------------------------------.
3028| yydefault -- do the default action for the current state. |
3029`-----------------------------------------------------------*/
3030yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003031 yyn = yydefact[yystate];
3032 if (yyn == 0)
3033 goto yyerrlab;
David Greene5fd22a82007-09-04 18:46:50 +00003034 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003035
David Greene5fd22a82007-09-04 18:46:50 +00003036
3037/*-----------------------------.
3038| yyreduce -- Do a reduction. |
3039`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003040yyreduce:
David Greene5fd22a82007-09-04 18:46:50 +00003041 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003042 yylen = yyr2[yyn];
3043
David Greene5fd22a82007-09-04 18:46:50 +00003044 /* If YYLEN is nonzero, implement the default value of the action:
3045 `$$ = $1'.
3046
3047 Otherwise, the following line sets YYVAL to garbage.
3048 This behavior is undocumented and Bison
3049 users should not rely upon it. Assigning to YYVAL
3050 unconditionally makes the parser a bit smaller, and it avoids a
3051 GCC warning that YYVAL may be used uninitialized. */
3052 yyval = yyvsp[1-yylen];
3053
3054
3055 YY_REDUCE_PRINT (yyn);
3056 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003057 {
David Greene5fd22a82007-09-04 18:46:50 +00003058 case 29:
3059#line 1128 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3060 { yyval.IPredicate = ICmpInst::ICMP_EQ; ;}
3061 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003062
David Greene5fd22a82007-09-04 18:46:50 +00003063 case 30:
3064#line 1128 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3065 { yyval.IPredicate = ICmpInst::ICMP_NE; ;}
3066 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003067
David Greene5fd22a82007-09-04 18:46:50 +00003068 case 31:
3069#line 1129 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3070 { yyval.IPredicate = ICmpInst::ICMP_SLT; ;}
3071 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003072
David Greene5fd22a82007-09-04 18:46:50 +00003073 case 32:
3074#line 1129 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3075 { yyval.IPredicate = ICmpInst::ICMP_SGT; ;}
3076 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003077
David Greene5fd22a82007-09-04 18:46:50 +00003078 case 33:
3079#line 1130 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3080 { yyval.IPredicate = ICmpInst::ICMP_SLE; ;}
3081 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003082
David Greene5fd22a82007-09-04 18:46:50 +00003083 case 34:
3084#line 1130 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3085 { yyval.IPredicate = ICmpInst::ICMP_SGE; ;}
3086 break;
3087
3088 case 35:
3089#line 1131 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3090 { yyval.IPredicate = ICmpInst::ICMP_ULT; ;}
3091 break;
3092
3093 case 36:
3094#line 1131 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3095 { yyval.IPredicate = ICmpInst::ICMP_UGT; ;}
3096 break;
3097
3098 case 37:
3099#line 1132 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3100 { yyval.IPredicate = ICmpInst::ICMP_ULE; ;}
3101 break;
3102
3103 case 38:
3104#line 1132 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3105 { yyval.IPredicate = ICmpInst::ICMP_UGE; ;}
3106 break;
3107
3108 case 39:
3109#line 1136 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3110 { yyval.FPredicate = FCmpInst::FCMP_OEQ; ;}
3111 break;
3112
3113 case 40:
3114#line 1136 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3115 { yyval.FPredicate = FCmpInst::FCMP_ONE; ;}
3116 break;
3117
3118 case 41:
3119#line 1137 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3120 { yyval.FPredicate = FCmpInst::FCMP_OLT; ;}
3121 break;
3122
3123 case 42:
3124#line 1137 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3125 { yyval.FPredicate = FCmpInst::FCMP_OGT; ;}
3126 break;
3127
3128 case 43:
3129#line 1138 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3130 { yyval.FPredicate = FCmpInst::FCMP_OLE; ;}
3131 break;
3132
3133 case 44:
3134#line 1138 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3135 { yyval.FPredicate = FCmpInst::FCMP_OGE; ;}
3136 break;
3137
3138 case 45:
3139#line 1139 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3140 { yyval.FPredicate = FCmpInst::FCMP_ORD; ;}
3141 break;
3142
3143 case 46:
3144#line 1139 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3145 { yyval.FPredicate = FCmpInst::FCMP_UNO; ;}
3146 break;
3147
3148 case 47:
3149#line 1140 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3150 { yyval.FPredicate = FCmpInst::FCMP_UEQ; ;}
3151 break;
3152
3153 case 48:
3154#line 1140 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3155 { yyval.FPredicate = FCmpInst::FCMP_UNE; ;}
3156 break;
3157
3158 case 49:
3159#line 1141 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3160 { yyval.FPredicate = FCmpInst::FCMP_ULT; ;}
3161 break;
3162
3163 case 50:
3164#line 1141 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3165 { yyval.FPredicate = FCmpInst::FCMP_UGT; ;}
3166 break;
3167
3168 case 51:
3169#line 1142 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3170 { yyval.FPredicate = FCmpInst::FCMP_ULE; ;}
3171 break;
3172
3173 case 52:
3174#line 1142 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3175 { yyval.FPredicate = FCmpInst::FCMP_UGE; ;}
3176 break;
3177
3178 case 53:
3179#line 1143 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3180 { yyval.FPredicate = FCmpInst::FCMP_TRUE; ;}
3181 break;
3182
3183 case 54:
3184#line 1144 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3185 { yyval.FPredicate = FCmpInst::FCMP_FALSE; ;}
3186 break;
3187
3188 case 65:
3189#line 1153 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3190 { yyval.StrVal = 0; ;}
3191 break;
3192
3193 case 66:
3194#line 1157 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3195 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003196 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003197 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003198 ;}
3199 break;
3200
3201 case 67:
3202#line 1161 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3203 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003204 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003205 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003206 ;}
3207 break;
3208
3209 case 71:
3210#line 1169 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3211 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003212 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003213 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003214 ;}
3215 break;
3216
3217 case 72:
3218#line 1174 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3219 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003220 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003221 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003222 ;}
3223 break;
3224
3225 case 73:
3226#line 1180 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3227 { yyval.Linkage = GlobalValue::InternalLinkage; ;}
3228 break;
3229
3230 case 74:
3231#line 1181 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3232 { yyval.Linkage = GlobalValue::WeakLinkage; ;}
3233 break;
3234
3235 case 75:
3236#line 1182 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3237 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;}
3238 break;
3239
3240 case 76:
3241#line 1183 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3242 { yyval.Linkage = GlobalValue::AppendingLinkage; ;}
3243 break;
3244
3245 case 77:
3246#line 1184 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3247 { yyval.Linkage = GlobalValue::DLLExportLinkage; ;}
3248 break;
3249
3250 case 78:
3251#line 1188 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3252 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;}
3253 break;
3254
3255 case 79:
3256#line 1189 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3257 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;}
3258 break;
3259
3260 case 80:
3261#line 1190 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3262 { yyval.Linkage = GlobalValue::ExternalLinkage; ;}
3263 break;
3264
3265 case 81:
3266#line 1194 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3267 { yyval.Visibility = GlobalValue::DefaultVisibility; ;}
3268 break;
3269
3270 case 82:
3271#line 1195 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3272 { yyval.Visibility = GlobalValue::DefaultVisibility; ;}
3273 break;
3274
3275 case 83:
3276#line 1196 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3277 { yyval.Visibility = GlobalValue::HiddenVisibility; ;}
3278 break;
3279
3280 case 84:
3281#line 1197 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3282 { yyval.Visibility = GlobalValue::ProtectedVisibility; ;}
3283 break;
3284
3285 case 85:
3286#line 1201 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3287 { yyval.Linkage = GlobalValue::ExternalLinkage; ;}
3288 break;
3289
3290 case 86:
3291#line 1202 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3292 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;}
3293 break;
3294
3295 case 87:
3296#line 1203 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3297 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;}
3298 break;
3299
3300 case 88:
3301#line 1207 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3302 { yyval.Linkage = GlobalValue::ExternalLinkage; ;}
3303 break;
3304
3305 case 89:
3306#line 1208 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3307 { yyval.Linkage = GlobalValue::InternalLinkage; ;}
3308 break;
3309
3310 case 90:
3311#line 1209 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3312 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;}
3313 break;
3314
3315 case 91:
3316#line 1210 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3317 { yyval.Linkage = GlobalValue::WeakLinkage; ;}
3318 break;
3319
3320 case 92:
3321#line 1211 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3322 { yyval.Linkage = GlobalValue::DLLExportLinkage; ;}
3323 break;
3324
3325 case 93:
3326#line 1215 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3327 { yyval.Linkage = GlobalValue::ExternalLinkage; ;}
3328 break;
3329
3330 case 94:
3331#line 1216 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3332 { yyval.Linkage = GlobalValue::WeakLinkage; ;}
3333 break;
3334
3335 case 95:
3336#line 1217 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3337 { yyval.Linkage = GlobalValue::InternalLinkage; ;}
3338 break;
3339
3340 case 96:
3341#line 1220 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3342 { yyval.UIntVal = CallingConv::C; ;}
3343 break;
3344
3345 case 97:
3346#line 1221 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3347 { yyval.UIntVal = CallingConv::C; ;}
3348 break;
3349
3350 case 98:
3351#line 1222 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3352 { yyval.UIntVal = CallingConv::Fast; ;}
3353 break;
3354
3355 case 99:
3356#line 1223 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3357 { yyval.UIntVal = CallingConv::Cold; ;}
3358 break;
3359
3360 case 100:
3361#line 1224 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3362 { yyval.UIntVal = CallingConv::X86_StdCall; ;}
3363 break;
3364
3365 case 101:
3366#line 1225 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3367 { yyval.UIntVal = CallingConv::X86_FastCall; ;}
3368 break;
3369
3370 case 102:
3371#line 1226 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3372 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003373 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003374 GEN_ERROR("Calling conv too large");
Chris Lattner0275cff2007-08-06 21:00:46 +00003375 yyval.UIntVal = yyvsp[0].UInt64Val;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003376 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003377 ;}
3378 break;
3379
3380 case 103:
3381#line 1233 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3382 { yyval.ParamAttrs = ParamAttr::ZExt; ;}
3383 break;
3384
3385 case 104:
3386#line 1234 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3387 { yyval.ParamAttrs = ParamAttr::ZExt; ;}
3388 break;
3389
3390 case 105:
3391#line 1235 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3392 { yyval.ParamAttrs = ParamAttr::SExt; ;}
3393 break;
3394
3395 case 106:
3396#line 1236 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3397 { yyval.ParamAttrs = ParamAttr::SExt; ;}
3398 break;
3399
3400 case 107:
3401#line 1237 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3402 { yyval.ParamAttrs = ParamAttr::InReg; ;}
3403 break;
3404
3405 case 108:
3406#line 1238 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3407 { yyval.ParamAttrs = ParamAttr::StructRet; ;}
3408 break;
3409
3410 case 109:
3411#line 1239 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3412 { yyval.ParamAttrs = ParamAttr::NoAlias; ;}
3413 break;
3414
3415 case 110:
3416#line 1240 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3417 { yyval.ParamAttrs = ParamAttr::ByVal; ;}
3418 break;
3419
3420 case 111:
3421#line 1241 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3422 { yyval.ParamAttrs = ParamAttr::Nest; ;}
3423 break;
3424
3425 case 112:
3426#line 1244 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3427 { yyval.ParamAttrs = ParamAttr::None; ;}
3428 break;
3429
3430 case 113:
3431#line 1245 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3432 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003433 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
David Greene5fd22a82007-09-04 18:46:50 +00003434 ;}
3435 break;
3436
3437 case 114:
3438#line 1250 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3439 { yyval.ParamAttrs = ParamAttr::NoReturn; ;}
3440 break;
3441
3442 case 115:
3443#line 1251 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3444 { yyval.ParamAttrs = ParamAttr::NoUnwind; ;}
3445 break;
3446
3447 case 116:
3448#line 1252 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3449 { yyval.ParamAttrs = ParamAttr::ZExt; ;}
3450 break;
3451
3452 case 117:
3453#line 1253 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3454 { yyval.ParamAttrs = ParamAttr::SExt; ;}
3455 break;
3456
3457 case 118:
3458#line 1256 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3459 { yyval.ParamAttrs = ParamAttr::None; ;}
3460 break;
3461
3462 case 119:
3463#line 1257 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3464 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003465 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
David Greene5fd22a82007-09-04 18:46:50 +00003466 ;}
3467 break;
3468
3469 case 120:
3470#line 1264 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3471 { yyval.UIntVal = 0; ;}
3472 break;
3473
3474 case 121:
3475#line 1265 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3476 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003477 yyval.UIntVal = yyvsp[0].UInt64Val;
3478 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003479 GEN_ERROR("Alignment must be a power of two");
3480 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003481;}
3482 break;
3483
3484 case 122:
3485#line 1271 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3486 { yyval.UIntVal = 0; ;}
3487 break;
3488
3489 case 123:
3490#line 1272 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3491 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003492 yyval.UIntVal = yyvsp[0].UInt64Val;
3493 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003494 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003495 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003496;}
3497 break;
3498
3499 case 124:
3500#line 1280 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3501 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003502 for (unsigned i = 0, e = yyvsp[0].StrVal->length(); i != e; ++i)
3503 if ((*yyvsp[0].StrVal)[i] == '"' || (*yyvsp[0].StrVal)[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003504 GEN_ERROR("Invalid character in section name");
Chris Lattner0275cff2007-08-06 21:00:46 +00003505 yyval.StrVal = yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003506 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003507;}
3508 break;
3509
3510 case 125:
3511#line 1288 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3512 { yyval.StrVal = 0; ;}
3513 break;
3514
3515 case 126:
3516#line 1289 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3517 { yyval.StrVal = yyvsp[0].StrVal; ;}
3518 break;
3519
3520 case 127:
3521#line 1294 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3522 {;}
3523 break;
3524
3525 case 128:
3526#line 1295 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3527 {;}
3528 break;
3529
3530 case 129:
3531#line 1296 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3532 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003533 CurGV->setSection(*yyvsp[0].StrVal);
3534 delete yyvsp[0].StrVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003535 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003536 ;}
3537 break;
3538
3539 case 130:
3540#line 1301 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3541 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003542 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003543 GEN_ERROR("Alignment must be a power of two");
Chris Lattner0275cff2007-08-06 21:00:46 +00003544 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003545 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003546 ;}
3547 break;
3548
3549 case 138:
3550#line 1317 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3551 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003552 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003553 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003554 ;}
3555 break;
3556
3557 case 139:
3558#line 1321 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3559 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003560 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003561 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003562 ;}
3563 break;
3564
3565 case 140:
3566#line 1325 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3567 { // Pointer type?
Chris Lattner0275cff2007-08-06 21:00:46 +00003568 if (*yyvsp[-1].TypeVal == Type::LabelTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003569 GEN_ERROR("Cannot form a pointer to a basic block");
Chris Lattner0275cff2007-08-06 21:00:46 +00003570 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
3571 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003572 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003573 ;}
3574 break;
3575
3576 case 141:
3577#line 1332 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3578 { // Named types are also simple types...
Chris Lattner0275cff2007-08-06 21:00:46 +00003579 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003580 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003581 yyval.TypeVal = new PATypeHolder(tmp);
David Greene5fd22a82007-09-04 18:46:50 +00003582 ;}
3583 break;
3584
3585 case 142:
3586#line 1337 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3587 { // Type UpReference
Chris Lattner0275cff2007-08-06 21:00:46 +00003588 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003589 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chris Lattner0275cff2007-08-06 21:00:46 +00003590 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
3591 yyval.TypeVal = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003592 UR_OUT("New Upreference!\n");
3593 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003594 ;}
3595 break;
3596
3597 case 143:
3598#line 1345 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3599 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003600 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003601 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00003602 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
3603 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00003604 Attrs.push_back(X);
3605 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00003606 unsigned index = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00003607 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003608 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003609 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003610 Params.push_back(Ty);
3611 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003612 if (I->Attrs != ParamAttr::None) {
3613 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3614 Attrs.push_back(X);
3615 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003616 }
3617 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3618 if (isVarArg) Params.pop_back();
3619
Reid Spencer7b5d4662007-04-09 06:16:21 +00003620 ParamAttrsList *ActualAttrs = 0;
3621 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003622 ActualAttrs = ParamAttrsList::get(Attrs);
Chris Lattner0275cff2007-08-06 21:00:46 +00003623 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs);
3624 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3625 delete yyvsp[-4].TypeVal; // Delete the return type handle
3626 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003627 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003628 ;}
3629 break;
3630
3631 case 144:
3632#line 1375 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3633 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003634 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003635 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00003636 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
3637 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00003638 Attrs.push_back(X);
3639 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003640 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003641 unsigned index = 1;
3642 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003643 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003644 Params.push_back(Ty);
3645 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003646 if (I->Attrs != ParamAttr::None) {
3647 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3648 Attrs.push_back(X);
3649 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003650 }
3651 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3652 if (isVarArg) Params.pop_back();
3653
Reid Spencer7b5d4662007-04-09 06:16:21 +00003654 ParamAttrsList *ActualAttrs = 0;
3655 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003656 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00003657
Chris Lattner0275cff2007-08-06 21:00:46 +00003658 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs);
3659 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3660 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003661 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003662 ;}
3663 break;
3664
3665 case 145:
3666#line 1406 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3667 { // Sized array type?
Chris Lattner0275cff2007-08-06 21:00:46 +00003668 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3669 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003670 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003671 ;}
3672 break;
3673
3674 case 146:
3675#line 1411 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3676 { // Vector type?
Chris Lattner0275cff2007-08-06 21:00:46 +00003677 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
3678 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003679 GEN_ERROR("Unsigned result not equal to signed result");
3680 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3681 GEN_ERROR("Element type of a VectorType must be primitive");
Chris Lattner0275cff2007-08-06 21:00:46 +00003682 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003683 GEN_ERROR("Vector length should be a power of 2");
Chris Lattner0275cff2007-08-06 21:00:46 +00003684 yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3685 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003686 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003687 ;}
3688 break;
3689
3690 case 147:
3691#line 1423 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3692 { // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003693 std::vector<const Type*> Elements;
Chris Lattner0275cff2007-08-06 21:00:46 +00003694 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
3695 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003696 Elements.push_back(*I);
3697
Chris Lattner0275cff2007-08-06 21:00:46 +00003698 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3699 delete yyvsp[-1].TypeList;
Reid Spencer14310612006-12-31 05:40:51 +00003700 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003701 ;}
3702 break;
3703
3704 case 148:
3705#line 1433 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3706 { // Empty structure type?
Chris Lattner0275cff2007-08-06 21:00:46 +00003707 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003708 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003709 ;}
3710 break;
3711
3712 case 149:
3713#line 1437 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3714 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003715 std::vector<const Type*> Elements;
Chris Lattner0275cff2007-08-06 21:00:46 +00003716 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
3717 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003718 Elements.push_back(*I);
3719
Chris Lattner0275cff2007-08-06 21:00:46 +00003720 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3721 delete yyvsp[-2].TypeList;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003722 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003723 ;}
3724 break;
3725
3726 case 150:
3727#line 1447 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3728 { // Empty structure type?
Chris Lattner0275cff2007-08-06 21:00:46 +00003729 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003730 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003731 ;}
3732 break;
3733
3734 case 151:
3735#line 1454 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3736 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003737 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
3738 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
David Greene5fd22a82007-09-04 18:46:50 +00003739 ;}
3740 break;
3741
3742 case 152:
3743#line 1461 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3744 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003745 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003746 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3747 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003748 GEN_ERROR("LLVM functions cannot return aggregate types");
Chris Lattner0275cff2007-08-06 21:00:46 +00003749 yyval.TypeVal = yyvsp[0].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00003750 ;}
3751 break;
3752
3753 case 153:
3754#line 1468 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3755 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003756 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
David Greene5fd22a82007-09-04 18:46:50 +00003757 ;}
3758 break;
3759
3760 case 154:
3761#line 1473 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3762 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003763 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3764 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer3da59db2006-11-27 01:05:10 +00003765 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003766 ;}
3767 break;
3768
3769 case 155:
3770#line 1478 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3771 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003772 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003773 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003774 ;}
3775 break;
3776
3777 case 157:
3778#line 1486 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3779 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003780 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Reid Spencer18da0722007-04-11 02:44:20 +00003781 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003782 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner0275cff2007-08-06 21:00:46 +00003783 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003784 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003785 ;}
3786 break;
3787
3788 case 158:
3789#line 1493 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3790 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003791 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003792 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3793 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner0275cff2007-08-06 21:00:46 +00003794 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003795 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003796 ;}
3797 break;
3798
3799 case 159:
3800#line 1500 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3801 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003802 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003803 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003804 ;}
3805 break;
3806
3807 case 160:
3808#line 1508 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3809 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003810 yyval.TypeList = new std::list<PATypeHolder>();
3811 yyval.TypeList->push_back(*yyvsp[0].TypeVal);
3812 delete yyvsp[0].TypeVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00003813 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003814 ;}
3815 break;
3816
3817 case 161:
3818#line 1514 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3819 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003820 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal);
3821 delete yyvsp[0].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003822 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003823 ;}
3824 break;
3825
3826 case 162:
3827#line 1526 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3828 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003829 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003830 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3831 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003832 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003833 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003834 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003835 const Type *ETy = ATy->getElementType();
3836 int NumElements = ATy->getNumElements();
3837
3838 // Verify that we have the correct size...
Chris Lattner0275cff2007-08-06 21:00:46 +00003839 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003840 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003841 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003842 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003843
3844 // Verify all elements are correct type!
Chris Lattner0275cff2007-08-06 21:00:46 +00003845 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3846 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003847 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3848 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner0275cff2007-08-06 21:00:46 +00003849 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003850 }
3851
Chris Lattner0275cff2007-08-06 21:00:46 +00003852 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
3853 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003854 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003855 ;}
3856 break;
3857
3858 case 163:
3859#line 1554 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3860 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003861 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003862 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3863 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003864 if (ATy == 0)
3865 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003866 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003867
Andrew Lenharth6353e052006-12-08 18:07:09 +00003868 int NumElements = ATy->getNumElements();
3869 if (NumElements != -1 && NumElements != 0)
3870 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003871 " arguments, but has size of " + itostr(NumElements) +"");
Chris Lattner0275cff2007-08-06 21:00:46 +00003872 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3873 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003874 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003875 ;}
3876 break;
3877
3878 case 164:
3879#line 1570 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3880 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003881 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003882 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3883 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003884 if (ATy == 0)
3885 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003886 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003887
3888 int NumElements = ATy->getNumElements();
3889 const Type *ETy = ATy->getElementType();
Chris Lattner0275cff2007-08-06 21:00:46 +00003890 if (NumElements != -1 && NumElements != int(yyvsp[0].StrVal->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003891 GEN_ERROR("Can't build string constant of size " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003892 itostr((int)(yyvsp[0].StrVal->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003893 " when array has size " + itostr(NumElements) + "");
3894 std::vector<Constant*> Vals;
3895 if (ETy == Type::Int8Ty) {
Chris Lattner0275cff2007-08-06 21:00:46 +00003896 for (unsigned i = 0; i < yyvsp[0].StrVal->length(); ++i)
3897 Vals.push_back(ConstantInt::get(ETy, (*yyvsp[0].StrVal)[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003898 } else {
Chris Lattner0275cff2007-08-06 21:00:46 +00003899 delete yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003900 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3901 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003902 delete yyvsp[0].StrVal;
3903 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3904 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003905 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003906 ;}
3907 break;
3908
3909 case 165:
3910#line 1597 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3911 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003912 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003913 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3914 const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003915 if (PTy == 0)
3916 GEN_ERROR("Cannot make packed constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003917 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003918 const Type *ETy = PTy->getElementType();
3919 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003920
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003921 // Verify that we have the correct size...
Chris Lattner0275cff2007-08-06 21:00:46 +00003922 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003923 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003924 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003925 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003926
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003927 // Verify all elements are correct type!
Chris Lattner0275cff2007-08-06 21:00:46 +00003928 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3929 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003930 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3931 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner0275cff2007-08-06 21:00:46 +00003932 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003933 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003934
Chris Lattner0275cff2007-08-06 21:00:46 +00003935 yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector);
3936 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003937 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003938 ;}
3939 break;
3940
3941 case 166:
3942#line 1625 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3943 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003944 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003945 if (STy == 0)
3946 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003947 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003948
Chris Lattner0275cff2007-08-06 21:00:46 +00003949 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003950 GEN_ERROR("Illegal number of initializers for structure type");
3951
3952 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner0275cff2007-08-06 21:00:46 +00003953 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3954 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003955 GEN_ERROR("Expected type '" +
3956 STy->getElementType(i)->getDescription() +
3957 "' for element #" + utostr(i) +
3958 " of structure initializer");
3959
3960 // Check to ensure that Type is not packed
3961 if (STy->isPacked())
3962 GEN_ERROR("Unpacked Initializer to vector type '" +
3963 STy->getDescription() + "'");
3964
Chris Lattner0275cff2007-08-06 21:00:46 +00003965 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3966 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003967 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003968 ;}
3969 break;
3970
3971 case 167:
3972#line 1651 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3973 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003974 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003975 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3976 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003977 if (STy == 0)
3978 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003979 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003980
3981 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003982 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003983
3984 // Check to ensure that Type is not packed
3985 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00003986 GEN_ERROR("Unpacked Initializer to vector type '" +
3987 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003988
Chris Lattner0275cff2007-08-06 21:00:46 +00003989 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3990 delete yyvsp[-2].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003991 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00003992 ;}
3993 break;
3994
3995 case 168:
3996#line 1671 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
3997 {
Chris Lattner0275cff2007-08-06 21:00:46 +00003998 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003999 if (STy == 0)
4000 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00004001 (*yyvsp[-5].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004002
Chris Lattner0275cff2007-08-06 21:00:46 +00004003 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00004004 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004005
4006 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner0275cff2007-08-06 21:00:46 +00004007 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
4008 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00004009 GEN_ERROR("Expected type '" +
4010 STy->getElementType(i)->getDescription() +
4011 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00004012 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004013
4014 // Check to ensure that Type is packed
4015 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004016 GEN_ERROR("Vector initializer to non-vector type '" +
4017 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004018
Chris Lattner0275cff2007-08-06 21:00:46 +00004019 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
4020 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004021 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004022 ;}
4023 break;
4024
4025 case 169:
4026#line 1697 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4027 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004028 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004029 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4030 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00004031 if (STy == 0)
4032 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00004033 (*yyvsp[-4].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004034
4035 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004036 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004037
4038 // Check to ensure that Type is packed
4039 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00004040 GEN_ERROR("Vector initializer to non-vector type '" +
4041 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00004042
Chris Lattner0275cff2007-08-06 21:00:46 +00004043 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
4044 delete yyvsp[-4].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004045 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004046 ;}
4047 break;
4048
4049 case 170:
4050#line 1717 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4051 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004052 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004053 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4054 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004055 if (PTy == 0)
4056 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00004057 (*yyvsp[-1].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004058
Chris Lattner0275cff2007-08-06 21:00:46 +00004059 yyval.ConstVal = ConstantPointerNull::get(PTy);
4060 delete yyvsp[-1].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004061 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004062 ;}
4063 break;
4064
4065 case 171:
4066#line 1729 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4067 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004068 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004069 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4070 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
4071 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004072 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004073 ;}
4074 break;
4075
4076 case 172:
4077#line 1736 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4078 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004079 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004080 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4081 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004082 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004083 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004084
4085 // ConstExprs can exist in the body of a function, thus creating
4086 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00004087 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00004088 // symbol table instead of the module symbol table for the global symbol,
4089 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00004090 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004091 //
4092 Function *SavedCurFn = CurFun.CurrentFunction;
4093 CurFun.CurrentFunction = 0;
4094
Chris Lattner0275cff2007-08-06 21:00:46 +00004095 Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004096 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004097
4098 CurFun.CurrentFunction = SavedCurFn;
4099
4100 // If this is an initializer for a constant pointer, which is referencing a
4101 // (currently) undefined variable, create a stub now that shall be replaced
4102 // in the future with the right type of variable.
4103 //
4104 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00004105 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004106 const PointerType *PT = cast<PointerType>(Ty);
4107
4108 // First check to see if the forward references value is already created!
4109 PerModuleInfo::GlobalRefsType::iterator I =
Chris Lattner0275cff2007-08-06 21:00:46 +00004110 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004111
4112 if (I != CurModule.GlobalRefs.end()) {
4113 V = I->second; // Placeholder already exists, use it...
Chris Lattner0275cff2007-08-06 21:00:46 +00004114 yyvsp[0].ValIDVal.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004115 } else {
4116 std::string Name;
Chris Lattner0275cff2007-08-06 21:00:46 +00004117 if (yyvsp[0].ValIDVal.Type == ValID::GlobalName)
4118 Name = yyvsp[0].ValIDVal.getName();
4119 else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00004120 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004121
4122 // Create the forward referenced global.
4123 GlobalValue *GV;
4124 if (const FunctionType *FTy =
4125 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004126 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004127 CurModule.CurrentModule);
4128 } else {
4129 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00004130 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004131 Name, CurModule.CurrentModule);
4132 }
4133
4134 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattner0275cff2007-08-06 21:00:46 +00004135 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004136 V = GV;
4137 }
4138 }
4139
Chris Lattner0275cff2007-08-06 21:00:46 +00004140 yyval.ConstVal = cast<GlobalValue>(V);
4141 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00004142 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004143 ;}
4144 break;
4145
4146 case 173:
4147#line 1802 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4148 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004149 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004150 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4151 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004152 GEN_ERROR("Mismatched types for constant expression: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00004153 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
4154 yyval.ConstVal = yyvsp[0].ConstVal;
4155 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004156 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004157 ;}
4158 break;
4159
4160 case 174:
4161#line 1812 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4162 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004163 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004164 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4165 const Type *Ty = yyvsp[-1].TypeVal->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004166 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4167 GEN_ERROR("Cannot create a null initialized value of this type");
Chris Lattner0275cff2007-08-06 21:00:46 +00004168 yyval.ConstVal = Constant::getNullValue(Ty);
4169 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004170 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004171 ;}
4172 break;
4173
4174 case 175:
4175#line 1822 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4176 { // integral constants
Chris Lattner0275cff2007-08-06 21:00:46 +00004177 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004178 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattner0275cff2007-08-06 21:00:46 +00004179 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true);
Reid Spencer38c91a92007-02-28 02:24:54 +00004180 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004181 ;}
4182 break;
4183
4184 case 176:
4185#line 1828 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4186 { // arbitrary precision integer constants
Chris Lattner0275cff2007-08-06 21:00:46 +00004187 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
4188 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004189 GEN_ERROR("Constant value does not fit in type");
4190 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004191 yyvsp[0].APIntVal->sextOrTrunc(BitWidth);
4192 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
4193 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004194 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004195 ;}
4196 break;
4197
4198 case 177:
4199#line 1838 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4200 { // integral constants
Chris Lattner0275cff2007-08-06 21:00:46 +00004201 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004202 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattner0275cff2007-08-06 21:00:46 +00004203 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004204 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004205 ;}
4206 break;
4207
4208 case 178:
4209#line 1844 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4210 { // arbitrary precision integer constants
Chris Lattner0275cff2007-08-06 21:00:46 +00004211 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
4212 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004213 GEN_ERROR("Constant value does not fit in type");
4214 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004215 yyvsp[0].APIntVal->zextOrTrunc(BitWidth);
4216 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
4217 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004218 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004219 ;}
4220 break;
4221
4222 case 179:
4223#line 1854 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4224 { // Boolean constants
Chris Lattner0275cff2007-08-06 21:00:46 +00004225 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
4226 yyval.ConstVal = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00004227 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004228 ;}
4229 break;
4230
4231 case 180:
4232#line 1859 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4233 { // Boolean constants
Chris Lattner0275cff2007-08-06 21:00:46 +00004234 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
4235 yyval.ConstVal = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00004236 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004237 ;}
4238 break;
4239
4240 case 181:
4241#line 1864 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4242 { // Float & Double constants
Chris Lattner0275cff2007-08-06 21:00:46 +00004243 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004244 GEN_ERROR("Floating point constant invalid for type");
Chris Lattner0275cff2007-08-06 21:00:46 +00004245 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004246 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004247 ;}
4248 break;
4249
4250 case 182:
4251#line 1872 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4252 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004253 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004254 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4255 Constant *Val = yyvsp[-3].ConstVal;
4256 const Type *DestTy = yyvsp[-1].TypeVal->get();
4257 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004258 GEN_ERROR("invalid cast opcode for cast from '" +
4259 Val->getType()->getDescription() + "' to '" +
4260 DestTy->getDescription() + "'");
Chris Lattner0275cff2007-08-06 21:00:46 +00004261 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
4262 delete yyvsp[-1].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00004263 ;}
4264 break;
4265
4266 case 183:
4267#line 1884 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4268 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004269 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004270 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004271
4272 const Type *IdxTy =
David Greene5fd22a82007-09-04 18:46:50 +00004273 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004274 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004275 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004276 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004277
Chris Lattnerf7469af2007-01-31 04:44:08 +00004278 SmallVector<Constant*, 8> IdxVec;
Chris Lattner0275cff2007-08-06 21:00:46 +00004279 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
4280 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004281 IdxVec.push_back(C);
4282 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004283 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004284
Chris Lattner0275cff2007-08-06 21:00:46 +00004285 delete yyvsp[-1].ValueList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004286
Chris Lattner0275cff2007-08-06 21:00:46 +00004287 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004288 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004289 ;}
4290 break;
4291
4292 case 184:
4293#line 1906 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4294 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004295 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004296 GEN_ERROR("Select condition must be of boolean type");
Chris Lattner0275cff2007-08-06 21:00:46 +00004297 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004298 GEN_ERROR("Select operand types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00004299 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004300 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004301 ;}
4302 break;
4303
4304 case 185:
4305#line 1914 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4306 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004307 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004308 GEN_ERROR("Binary operator types must match");
4309 CHECK_FOR_ERROR;
Chris Lattner0275cff2007-08-06 21:00:46 +00004310 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
David Greene5fd22a82007-09-04 18:46:50 +00004311 ;}
4312 break;
4313
4314 case 186:
4315#line 1920 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4316 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004317 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004318 GEN_ERROR("Logical operator types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00004319 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
4320 if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) ||
4321 !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004322 GEN_ERROR("Logical operator requires integral operands");
4323 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004324 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004325 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004326 ;}
4327 break;
4328
4329 case 187:
4330#line 1931 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4331 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004332 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004333 GEN_ERROR("icmp operand types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00004334 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
David Greene5fd22a82007-09-04 18:46:50 +00004335 ;}
4336 break;
4337
4338 case 188:
4339#line 1936 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4340 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004341 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004342 GEN_ERROR("fcmp operand types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00004343 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
David Greene5fd22a82007-09-04 18:46:50 +00004344 ;}
4345 break;
4346
4347 case 189:
4348#line 1941 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4349 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004350 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004351 GEN_ERROR("Invalid extractelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004352 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004353 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004354 ;}
4355 break;
4356
4357 case 190:
4358#line 1947 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4359 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004360 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004361 GEN_ERROR("Invalid insertelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004362 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004363 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004364 ;}
4365 break;
4366
4367 case 191:
4368#line 1953 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4369 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004370 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004371 GEN_ERROR("Invalid shufflevector operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004372 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004373 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004374 ;}
4375 break;
4376
4377 case 192:
4378#line 1962 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4379 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004380 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004381 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004382 ;}
4383 break;
4384
4385 case 193:
4386#line 1966 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4387 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004388 yyval.ConstVector = new std::vector<Constant*>();
4389 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004390 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004391 ;}
4392 break;
4393
4394 case 194:
4395#line 1974 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4396 { yyval.BoolVal = false; ;}
4397 break;
4398
4399 case 195:
4400#line 1974 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4401 { yyval.BoolVal = true; ;}
4402 break;
4403
4404 case 196:
4405#line 1977 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4406 { yyval.BoolVal = true; ;}
4407 break;
4408
4409 case 197:
4410#line 1977 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4411 { yyval.BoolVal = false; ;}
4412 break;
4413
4414 case 198:
4415#line 1980 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4416 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004417 const Type* VTy = yyvsp[-1].TypeVal->get();
4418 Value *V = getVal(VTy, yyvsp[0].ValIDVal);
4419 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004420 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
4421 if (!Aliasee)
4422 GEN_ERROR("Aliases can be created only to global values");
4423
Chris Lattner0275cff2007-08-06 21:00:46 +00004424 yyval.ConstVal = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004425 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004426 delete yyvsp[-1].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00004427 ;}
4428 break;
4429
4430 case 199:
4431#line 1992 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4432 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004433 Constant *Val = yyvsp[-3].ConstVal;
4434 const Type *DestTy = yyvsp[-1].TypeVal->get();
4435 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004436 GEN_ERROR("invalid cast opcode for cast from '" +
4437 Val->getType()->getDescription() + "' to '" +
4438 DestTy->getDescription() + "'");
4439
Chris Lattner0275cff2007-08-06 21:00:46 +00004440 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004441 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004442 delete yyvsp[-1].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00004443 ;}
4444 break;
4445
4446 case 200:
4447#line 2013 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4448 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004449 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Reid Spencer1013b4d2007-07-31 14:41:17 +00004450 CurModule.ModuleDone();
4451 CHECK_FOR_ERROR;
David Greene5fd22a82007-09-04 18:46:50 +00004452 ;}
4453 break;
4454
4455 case 201:
4456#line 2018 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4457 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004458 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004459 CurModule.ModuleDone();
4460 CHECK_FOR_ERROR;
David Greene5fd22a82007-09-04 18:46:50 +00004461 ;}
4462 break;
4463
4464 case 204:
4465#line 2031 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4466 { CurFun.isDeclare = false; ;}
4467 break;
4468
4469 case 205:
4470#line 2031 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4471 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004472 CurFun.FunctionDone();
4473 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004474 ;}
4475 break;
4476
4477 case 206:
4478#line 2035 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4479 { CurFun.isDeclare = true; ;}
4480 break;
4481
4482 case 207:
4483#line 2035 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4484 {
Reid Spencer1013b4d2007-07-31 14:41:17 +00004485 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004486 ;}
4487 break;
4488
4489 case 208:
4490#line 2038 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4491 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004492 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004493 ;}
4494 break;
4495
4496 case 209:
4497#line 2041 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4498 {
Reid Spencer14310612006-12-31 05:40:51 +00004499 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004500 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004501 // Eagerly resolve types. This is not an optimization, this is a
4502 // requirement that is due to the fact that we could have this:
4503 //
4504 // %list = type { %list * }
4505 // %list = type { %list * } ; repeated type decl
4506 //
4507 // If types are not resolved eagerly, then the two types will not be
4508 // determined to be the same type!
4509 //
Chris Lattner0275cff2007-08-06 21:00:46 +00004510 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004511
Chris Lattner0275cff2007-08-06 21:00:46 +00004512 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004513 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004514 // If this is a named type that is not a redefinition, add it to the slot
4515 // table.
Chris Lattner0275cff2007-08-06 21:00:46 +00004516 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004517 }
Reid Spencera132e042006-12-03 05:46:11 +00004518
Chris Lattner0275cff2007-08-06 21:00:46 +00004519 delete yyvsp[0].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004520 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004521 ;}
4522 break;
4523
4524 case 210:
4525#line 2065 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4526 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004527 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Reid Spencerb8f85052007-07-31 03:50:36 +00004528
Chris Lattner0275cff2007-08-06 21:00:46 +00004529 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004530 CHECK_FOR_ERROR
4531 // If this is a named type that is not a redefinition, add it to the slot
4532 // table.
Chris Lattner0275cff2007-08-06 21:00:46 +00004533 CurModule.Types.push_back(yyvsp[0].PrimType);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004534 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004535 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004536 ;}
4537 break;
4538
4539 case 211:
4540#line 2076 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4541 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004542 /* "Externally Visible" Linkage */
Chris Lattner0275cff2007-08-06 21:00:46 +00004543 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004544 GEN_ERROR("Global value initializer is not a constant");
Chris Lattner0275cff2007-08-06 21:00:46 +00004545 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage,
4546 yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004547 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004548 ;}
4549 break;
4550
4551 case 212:
4552#line 2083 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4553 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004554 CurGV = 0;
David Greene5fd22a82007-09-04 18:46:50 +00004555 ;}
4556 break;
4557
4558 case 213:
4559#line 2087 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4560 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004561 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004562 GEN_ERROR("Global value initializer is not a constant");
Chris Lattner0275cff2007-08-06 21:00:46 +00004563 CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004564 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004565 ;}
4566 break;
4567
4568 case 214:
4569#line 2092 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4570 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004571 CurGV = 0;
David Greene5fd22a82007-09-04 18:46:50 +00004572 ;}
4573 break;
4574
4575 case 215:
4576#line 2096 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4577 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004578 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004579 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4580 CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0, yyvsp[-2].BoolVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004581 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004582 delete yyvsp[0].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00004583 ;}
4584 break;
4585
4586 case 216:
4587#line 2102 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4588 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004589 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004590 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004591 ;}
4592 break;
4593
4594 case 217:
4595#line 2106 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4596 {
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004597 std::string Name;
Chris Lattner0275cff2007-08-06 21:00:46 +00004598 if (yyvsp[-4].StrVal) {
4599 Name = *yyvsp[-4].StrVal;
4600 delete yyvsp[-4].StrVal;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004601 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004602 if (Name.empty())
4603 GEN_ERROR("Alias name cannot be empty");
4604
Chris Lattner0275cff2007-08-06 21:00:46 +00004605 Constant* Aliasee = yyvsp[0].ConstVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004606 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004607 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004608
Chris Lattner0275cff2007-08-06 21:00:46 +00004609 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004610 CurModule.CurrentModule);
Chris Lattner0275cff2007-08-06 21:00:46 +00004611 GA->setVisibility(yyvsp[-3].Visibility);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004612 InsertValue(GA, CurModule.Values);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004613 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004614 ;}
4615 break;
4616
4617 case 218:
4618#line 2125 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4619 {
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00004620 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004621 ;}
4622 break;
4623
4624 case 219:
4625#line 2128 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4626 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004627 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004628 ;}
4629 break;
4630
4631 case 220:
4632#line 2134 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4633 {
Chris Lattner66316012006-01-24 04:14:29 +00004634 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00004635 if (AsmSoFar.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004636 CurModule.CurrentModule->setModuleInlineAsm(*yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00004637 else
Chris Lattner0275cff2007-08-06 21:00:46 +00004638 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*yyvsp[0].StrVal);
4639 delete yyvsp[0].StrVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004640 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004641;}
4642 break;
4643
4644 case 221:
4645#line 2144 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4646 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004647 CurModule.CurrentModule->setTargetTriple(*yyvsp[0].StrVal);
4648 delete yyvsp[0].StrVal;
David Greene5fd22a82007-09-04 18:46:50 +00004649 ;}
4650 break;
4651
4652 case 222:
4653#line 2148 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4654 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004655 CurModule.CurrentModule->setDataLayout(*yyvsp[0].StrVal);
4656 delete yyvsp[0].StrVal;
David Greene5fd22a82007-09-04 18:46:50 +00004657 ;}
4658 break;
4659
4660 case 224:
4661#line 2155 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4662 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004663 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
4664 delete yyvsp[0].StrVal;
Reid Spencer1013b4d2007-07-31 14:41:17 +00004665 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004666 ;}
4667 break;
4668
4669 case 225:
4670#line 2160 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4671 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004672 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
4673 delete yyvsp[0].StrVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004674 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004675 ;}
4676 break;
4677
4678 case 226:
4679#line 2165 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4680 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004681 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004682 ;}
4683 break;
4684
4685 case 227:
4686#line 2174 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4687 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004688 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004689 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4690 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004691 GEN_ERROR("void typed arguments are invalid");
Chris Lattner0275cff2007-08-06 21:00:46 +00004692 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4693 yyval.ArgList = yyvsp[-4].ArgList;
4694 yyvsp[-4].ArgList->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004695 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004696 ;}
4697 break;
4698
4699 case 228:
4700#line 2184 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4701 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004702 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004703 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4704 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004705 GEN_ERROR("void typed arguments are invalid");
Chris Lattner0275cff2007-08-06 21:00:46 +00004706 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4707 yyval.ArgList = new ArgListType;
4708 yyval.ArgList->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004709 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004710 ;}
4711 break;
4712
4713 case 229:
4714#line 2195 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4715 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004716 yyval.ArgList = yyvsp[0].ArgList;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004717 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004718 ;}
4719 break;
4720
4721 case 230:
4722#line 2199 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4723 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004724 yyval.ArgList = yyvsp[-2].ArgList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004725 struct ArgListEntry E;
4726 E.Ty = new PATypeHolder(Type::VoidTy);
4727 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004728 E.Attrs = ParamAttr::None;
Chris Lattner0275cff2007-08-06 21:00:46 +00004729 yyval.ArgList->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004730 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004731 ;}
4732 break;
4733
4734 case 231:
4735#line 2208 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4736 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004737 yyval.ArgList = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004738 struct ArgListEntry E;
4739 E.Ty = new PATypeHolder(Type::VoidTy);
4740 E.Name = 0;
4741 E.Attrs = ParamAttr::None;
Chris Lattner0275cff2007-08-06 21:00:46 +00004742 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004743 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004744 ;}
4745 break;
4746
4747 case 232:
4748#line 2217 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4749 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004750 yyval.ArgList = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004751 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004752 ;}
4753 break;
4754
4755 case 233:
4756#line 2223 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4757 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004758 std::string FunctionName(*yyvsp[-6].StrVal);
4759 delete yyvsp[-6].StrVal; // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004760
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004761 // Check the function result for abstractness if this is a define. We should
4762 // have no abstract types at this point
Chris Lattner0275cff2007-08-06 21:00:46 +00004763 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
4764 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004765
Reid Spencer68a24bd2005-08-27 18:50:39 +00004766 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00004767 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00004768 if (yyvsp[-2].ParamAttrs != ParamAttr::None) {
4769 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004770 Attrs.push_back(PAWI);
4771 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004772 if (yyvsp[-4].ArgList) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004773 unsigned index = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00004774 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004775 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004776 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4777 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004778 ParamTypeList.push_back(Ty);
4779 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00004780 if (I->Attrs != ParamAttr::None) {
4781 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4782 Attrs.push_back(PAWI);
4783 }
Reid Spencer14310612006-12-31 05:40:51 +00004784 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004785 }
4786
4787 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4788 if (isVarArg) ParamTypeList.pop_back();
4789
Christopher Lamb5c104242007-04-22 20:09:11 +00004790 ParamAttrsList *PAL = 0;
4791 if (!Attrs.empty())
4792 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004793
Chris Lattner0275cff2007-08-06 21:00:46 +00004794 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004795 const PointerType *PFT = PointerType::get(FT);
Chris Lattner0275cff2007-08-06 21:00:46 +00004796 delete yyvsp[-7].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004797
4798 ValID ID;
4799 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004800 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004801 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004802 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004803 }
4804
4805 Function *Fn = 0;
4806 // See if this function was forward referenced. If so, recycle the object.
4807 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4808 // Move the function to the end of the list, from whereever it was
4809 // previously inserted.
4810 Fn = cast<Function>(FWRef);
4811 CurModule.CurrentModule->getFunctionList().remove(Fn);
4812 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4813 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004814 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004815 if (Fn->getFunctionType() != FT) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00004816 // The existing function doesn't have the same type. This is an overload
4817 // error.
4818 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4819 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004820 // Neither the existing or the current function is a declaration and they
4821 // have the same name and same type. Clearly this is a redefinition.
4822 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004823 } if (Fn->isDeclaration()) {
4824 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004825 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4826 AI != AE; ++AI)
4827 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004828 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004829 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00004830 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004831 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004832
Reid Spencer68a24bd2005-08-27 18:50:39 +00004833 InsertValue(Fn, CurModule.Values);
4834 }
4835
4836 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004837
4838 if (CurFun.isDeclare) {
4839 // If we have declaration, always overwrite linkage. This will allow us to
4840 // correctly handle cases, when pointer to function is passed as argument to
4841 // another function.
4842 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004843 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004844 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004845 Fn->setCallingConv(yyvsp[-8].UIntVal);
4846 Fn->setAlignment(yyvsp[0].UIntVal);
4847 if (yyvsp[-1].StrVal) {
4848 Fn->setSection(*yyvsp[-1].StrVal);
4849 delete yyvsp[-1].StrVal;
Chris Lattnere869eef2005-11-12 00:11:49 +00004850 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004851
4852 // Add all of the arguments we parsed to the function...
Chris Lattner0275cff2007-08-06 21:00:46 +00004853 if (yyvsp[-4].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004854 if (isVarArg) { // Nuke the last entry
Chris Lattner0275cff2007-08-06 21:00:46 +00004855 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004856 "Not a varargs marker!");
Chris Lattner0275cff2007-08-06 21:00:46 +00004857 delete yyvsp[-4].ArgList->back().Ty;
4858 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004859 }
4860 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004861 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004862 unsigned Idx = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00004863 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin();
4864 I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004865 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004866 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004867 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004868 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004869 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004870 }
Reid Spencera132e042006-12-03 05:46:11 +00004871
Chris Lattner0275cff2007-08-06 21:00:46 +00004872 delete yyvsp[-4].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004873 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004874 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004875;}
4876 break;
4877
4878 case 236:
4879#line 2345 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4880 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004881 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004882
4883 // Make sure that we keep track of the linkage type even if there was a
4884 // previous "declare".
Chris Lattner0275cff2007-08-06 21:00:46 +00004885 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4886 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
David Greene5fd22a82007-09-04 18:46:50 +00004887;}
4888 break;
4889
4890 case 239:
4891#line 2356 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4892 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004893 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004894 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004895;}
4896 break;
4897
4898 case 240:
4899#line 2361 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4900 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004901 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
4902 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
4903 yyval.FunctionVal = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004904 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004905 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004906 ;}
4907 break;
4908
4909 case 241:
4910#line 2373 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4911 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004912 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004913 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004914 ;}
4915 break;
4916
4917 case 242:
4918#line 2377 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4919 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004920 yyval.BoolVal = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004921 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004922 ;}
4923 break;
4924
4925 case 243:
4926#line 2382 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4927 { // A reference to a direct constant
Chris Lattner0275cff2007-08-06 21:00:46 +00004928 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004929 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004930 ;}
4931 break;
4932
4933 case 244:
4934#line 2386 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4935 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004936 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004937 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004938 ;}
4939 break;
4940
4941 case 245:
4942#line 2390 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4943 { // Perhaps it's an FP constant?
Chris Lattner0275cff2007-08-06 21:00:46 +00004944 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004945 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004946 ;}
4947 break;
4948
4949 case 246:
4950#line 2394 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4951 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004952 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004953 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004954 ;}
4955 break;
4956
4957 case 247:
4958#line 2398 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4959 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004960 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004961 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004962 ;}
4963 break;
4964
4965 case 248:
4966#line 2402 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4967 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004968 yyval.ValIDVal = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004969 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004970 ;}
4971 break;
4972
4973 case 249:
4974#line 2406 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4975 {
Chris Lattner0275cff2007-08-06 21:00:46 +00004976 yyval.ValIDVal = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004977 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004978 ;}
4979 break;
4980
4981 case 250:
4982#line 2410 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4983 { // A vector zero constant.
Chris Lattner0275cff2007-08-06 21:00:46 +00004984 yyval.ValIDVal = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004985 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00004986 ;}
4987 break;
4988
4989 case 251:
4990#line 2414 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
4991 { // Nonempty unsized packed vector
Chris Lattner0275cff2007-08-06 21:00:46 +00004992 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
4993 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004994
Reid Spencer9d6565a2007-02-15 02:26:10 +00004995 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004996 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004997 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004998 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004999 ETy,
5000 NumElements)
5001 )
5002 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00005003
5004 // Verify all elements are correct type!
Chris Lattner0275cff2007-08-06 21:00:46 +00005005 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
5006 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005007 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005008 ETy->getDescription() +"' as required!\nIt is of type '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00005009 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005010 }
5011
Chris Lattner0275cff2007-08-06 21:00:46 +00005012 yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector));
5013 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencer832254e2007-02-02 02:16:23 +00005014 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005015 ;}
5016 break;
5017
5018 case 252:
5019#line 2439 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5020 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005021 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005022 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005023 ;}
5024 break;
5025
5026 case 253:
5027#line 2443 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5028 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005029 yyval.ValIDVal = ValID::createInlineAsm(*yyvsp[-2].StrVal, *yyvsp[0].StrVal, yyvsp[-3].BoolVal);
5030 delete yyvsp[-2].StrVal;
5031 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00005032 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005033 ;}
5034 break;
5035
5036 case 254:
5037#line 2453 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5038 { // Is it an integer reference...?
Chris Lattner0275cff2007-08-06 21:00:46 +00005039 yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005040 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005041 ;}
5042 break;
5043
5044 case 255:
5045#line 2457 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5046 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005047 yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal);
Reid Spencer832254e2007-02-02 02:16:23 +00005048 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005049 ;}
5050 break;
5051
5052 case 256:
5053#line 2461 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5054 { // Is it a named reference...?
Chris Lattner0275cff2007-08-06 21:00:46 +00005055 yyval.ValIDVal = ValID::createLocalName(*yyvsp[0].StrVal);
5056 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00005057 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005058 ;}
5059 break;
5060
5061 case 257:
5062#line 2466 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5063 { // Is it a named reference...?
Chris Lattner0275cff2007-08-06 21:00:46 +00005064 yyval.ValIDVal = ValID::createGlobalName(*yyvsp[0].StrVal);
5065 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00005066 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005067 ;}
5068 break;
5069
5070 case 260:
5071#line 2479 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5072 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005073 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005074 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5075 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
5076 delete yyvsp[-1].TypeVal;
Reid Spencer832254e2007-02-02 02:16:23 +00005077 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005078 ;}
5079 break;
5080
5081 case 261:
5082#line 2488 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5083 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005084 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005085 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005086 ;}
5087 break;
5088
5089 case 262:
5090#line 2492 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5091 { // Do not allow functions with 0 basic blocks
Chris Lattner0275cff2007-08-06 21:00:46 +00005092 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005093 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005094 ;}
5095 break;
5096
5097 case 263:
5098#line 2501 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5099 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005100 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005101 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005102 InsertValue(yyvsp[0].TermInstVal);
5103 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
5104 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005105 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005106 ;}
5107 break;
5108
5109 case 264:
5110#line 2510 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5111 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005112 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005113 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
5114 if (CI2->getParent() == 0)
Chris Lattner0275cff2007-08-06 21:00:46 +00005115 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
5116 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
5117 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00005118 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005119 ;}
5120 break;
5121
5122 case 265:
5123#line 2519 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5124 { // Empty space between instruction lists
Chris Lattner0275cff2007-08-06 21:00:46 +00005125 yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencered951ea2007-05-19 07:22:10 +00005126 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005127 ;}
5128 break;
5129
5130 case 266:
5131#line 2523 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5132 { // Labelled (named) basic block
Chris Lattner0275cff2007-08-06 21:00:46 +00005133 yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[0].StrVal));
5134 delete yyvsp[0].StrVal;
Reid Spencered951ea2007-05-19 07:22:10 +00005135 CHECK_FOR_ERROR
Reid Spencer0a8a16b2007-05-22 18:52:55 +00005136
David Greene5fd22a82007-09-04 18:46:50 +00005137 ;}
5138 break;
5139
5140 case 267:
5141#line 2530 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5142 { // Return with a result...
Chris Lattner0275cff2007-08-06 21:00:46 +00005143 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
5144 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005145 ;}
5146 break;
5147
5148 case 268:
5149#line 2534 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5150 { // Return with no result...
Chris Lattner0275cff2007-08-06 21:00:46 +00005151 yyval.TermInstVal = new ReturnInst();
5152 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005153 ;}
5154 break;
5155
5156 case 269:
5157#line 2538 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5158 { // Unconditional Branch...
Chris Lattner0275cff2007-08-06 21:00:46 +00005159 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
5160 CHECK_FOR_ERROR
5161 yyval.TermInstVal = new BranchInst(tmpBB);
David Greene5fd22a82007-09-04 18:46:50 +00005162 ;}
5163 break;
5164
5165 case 270:
5166#line 2543 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5167 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005168 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
5169 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
5170 CHECK_FOR_ERROR
5171 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
5172 CHECK_FOR_ERROR
5173 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
5174 CHECK_FOR_ERROR
5175 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
David Greene5fd22a82007-09-04 18:46:50 +00005176 ;}
5177 break;
5178
5179 case 271:
5180#line 2553 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5181 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005182 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
5183 CHECK_FOR_ERROR
5184 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
5185 CHECK_FOR_ERROR
5186 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
5187 yyval.TermInstVal = S;
Reid Spencerb8f85052007-07-31 03:50:36 +00005188
Chris Lattner0275cff2007-08-06 21:00:46 +00005189 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
5190 E = yyvsp[-1].JumpTable->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005191 for (; I != E; ++I) {
5192 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5193 S->addCase(CI, I->second);
5194 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005195 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005196 }
Chris Lattner0275cff2007-08-06 21:00:46 +00005197 delete yyvsp[-1].JumpTable;
Reid Spencer61c83e02006-08-18 08:43:06 +00005198 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005199 ;}
5200 break;
5201
5202 case 272:
5203#line 2572 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5204 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005205 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005206 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005207 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005208 CHECK_FOR_ERROR
5209 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chris Lattner0275cff2007-08-06 21:00:46 +00005210 yyval.TermInstVal = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005211 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005212 ;}
5213 break;
5214
5215 case 273:
5216#line 2582 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5217 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005218
Reid Spencer14310612006-12-31 05:40:51 +00005219 // Handle the short syntax
5220 const PointerType *PFTy = 0;
5221 const FunctionType *Ty = 0;
Chris Lattner0275cff2007-08-06 21:00:46 +00005222 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005223 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5224 // Pull out the types of all of the arguments...
5225 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005226 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00005227 if (yyvsp[-6].ParamAttrs != ParamAttr::None) {
5228 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00005229 Attrs.push_back(PAWI);
5230 }
Chris Lattner0275cff2007-08-06 21:00:46 +00005231 ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005232 unsigned index = 1;
5233 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005234 const Type *Ty = I->Val->getType();
5235 if (Ty == Type::VoidTy)
5236 GEN_ERROR("Short call syntax cannot be used with varargs");
5237 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005238 if (I->Attrs != ParamAttr::None) {
5239 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5240 Attrs.push_back(PAWI);
5241 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005242 }
5243
Christopher Lamb5c104242007-04-22 20:09:11 +00005244 ParamAttrsList *PAL = 0;
5245 if (!Attrs.empty())
5246 PAL = ParamAttrsList::get(Attrs);
Chris Lattner0275cff2007-08-06 21:00:46 +00005247 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005248 PFTy = PointerType::get(Ty);
5249 }
5250
Chris Lattner0275cff2007-08-06 21:00:46 +00005251 delete yyvsp[-11].TypeVal;
Reid Spencer66728ef2007-03-20 01:13:36 +00005252
Chris Lattner0275cff2007-08-06 21:00:46 +00005253 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005254 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005255 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005256 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005257 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00005258 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005259
Reid Spencer14310612006-12-31 05:40:51 +00005260 // Check the arguments
5261 ValueList Args;
Chris Lattner0275cff2007-08-06 21:00:46 +00005262 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005263 // Make sure no arguments is a good thing!
5264 if (Ty->getNumParams() != 0)
5265 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005266 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005267 } else { // Has arguments?
5268 // Loop through FunctionType's arguments and ensure they are specified
5269 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005270 FunctionType::param_iterator I = Ty->param_begin();
5271 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner0275cff2007-08-06 21:00:46 +00005272 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005273
Reid Spencer14310612006-12-31 05:40:51 +00005274 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5275 if (ArgI->Val->getType() != *I)
5276 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005277 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005278 Args.push_back(ArgI->Val);
5279 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005280
Reid Spencer14310612006-12-31 05:40:51 +00005281 if (Ty->isVarArg()) {
5282 if (I == E)
5283 for (; ArgI != ArgE; ++ArgI)
5284 Args.push_back(ArgI->Val); // push the remaining varargs
5285 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005286 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005287 }
Reid Spencer14310612006-12-31 05:40:51 +00005288
5289 // Create the InvokeInst
Chris Lattnerd80fb8b2007-08-29 16:15:23 +00005290 InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
Chris Lattner0275cff2007-08-06 21:00:46 +00005291 II->setCallingConv(yyvsp[-12].UIntVal);
5292 yyval.TermInstVal = II;
5293 delete yyvsp[-8].ValueRefList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005294 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005295 ;}
5296 break;
5297
5298 case 274:
5299#line 2661 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5300 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005301 yyval.TermInstVal = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005302 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005303 ;}
5304 break;
5305
5306 case 275:
5307#line 2665 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5308 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005309 yyval.TermInstVal = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005310 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005311 ;}
5312 break;
5313
5314 case 276:
5315#line 2672 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5316 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005317 yyval.JumpTable = yyvsp[-5].JumpTable;
5318 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005319 CHECK_FOR_ERROR
5320 if (V == 0)
5321 GEN_ERROR("May only switch on a constant pool value");
5322
Chris Lattner0275cff2007-08-06 21:00:46 +00005323 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005324 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005325 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
David Greene5fd22a82007-09-04 18:46:50 +00005326 ;}
5327 break;
5328
5329 case 277:
5330#line 2683 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5331 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005332 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
5333 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005334 CHECK_FOR_ERROR
5335
5336 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005337 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005338
Chris Lattner0275cff2007-08-06 21:00:46 +00005339 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005340 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005341 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
David Greene5fd22a82007-09-04 18:46:50 +00005342 ;}
5343 break;
5344
5345 case 278:
5346#line 2696 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5347 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005348 // Is this definition named?? if so, assign the name...
Chris Lattner0275cff2007-08-06 21:00:46 +00005349 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005350 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005351 InsertValue(yyvsp[0].InstVal);
5352 yyval.InstVal = yyvsp[0].InstVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005353 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005354 ;}
5355 break;
5356
5357 case 279:
5358#line 2706 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5359 { // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005360 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005361 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
5362 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
5363 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005364 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005365 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005366 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005367 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
5368 delete yyvsp[-5].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00005369 ;}
5370 break;
5371
5372 case 280:
5373#line 2717 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5374 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005375 yyval.PHIList = yyvsp[-6].PHIList;
5376 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005377 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005378 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005379 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005380 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
David Greene5fd22a82007-09-04 18:46:50 +00005381 ;}
5382 break;
5383
5384 case 281:
5385#line 2727 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5386 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005387 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005388 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005389 // Used for call and invoke instructions
Chris Lattner0275cff2007-08-06 21:00:46 +00005390 yyval.ValueRefList = new ValueRefList();
5391 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
5392 yyval.ValueRefList->push_back(E);
5393 delete yyvsp[-2].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00005394 ;}
5395 break;
5396
5397 case 282:
5398#line 2736 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5399 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005400 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005401 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5402 yyval.ValueRefList = yyvsp[-4].ValueRefList;
5403 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
5404 yyval.ValueRefList->push_back(E);
5405 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005406 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005407 ;}
5408 break;
5409
5410 case 283:
5411#line 2745 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5412 { yyval.ValueRefList = new ValueRefList(); ;}
5413 break;
5414
5415 case 284:
5416#line 2748 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5417 { yyval.ValueList = new std::vector<Value*>(); ;}
5418 break;
5419
5420 case 285:
5421#line 2749 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5422 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005423 yyval.ValueList = yyvsp[-2].ValueList;
5424 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005425 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005426 ;}
5427 break;
5428
5429 case 286:
5430#line 2756 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5431 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005432 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005433 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005434 ;}
5435 break;
5436
5437 case 287:
5438#line 2760 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5439 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005440 yyval.BoolVal = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00005441 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005442 ;}
5443 break;
5444
5445 case 288:
5446#line 2765 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5447 {
Reid Spencer14310612006-12-31 05:40:51 +00005448 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005449 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
5450 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
5451 !isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005452 GEN_ERROR(
5453 "Arithmetic operator requires integer, FP, or packed operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00005454 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) &&
5455 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
5456 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
5457 yyvsp[-4].BinaryOpVal == Instruction::FRem))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005458 GEN_ERROR("Remainder not supported on vector types");
Chris Lattner0275cff2007-08-06 21:00:46 +00005459 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005460 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005461 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005462 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005463 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
5464 if (yyval.InstVal == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005465 GEN_ERROR("binary operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00005466 delete yyvsp[-3].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00005467 ;}
5468 break;
5469
5470 case 289:
5471#line 2786 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5472 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005473 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005474 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
5475 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
5476 if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) ||
5477 !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005478 GEN_ERROR("Logical operator requires integral operands");
5479 }
Chris Lattner0275cff2007-08-06 21:00:46 +00005480 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005481 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005482 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005483 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005484 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
5485 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005486 GEN_ERROR("binary operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00005487 delete yyvsp[-3].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00005488 ;}
5489 break;
5490
5491 case 290:
5492#line 2803 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5493 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005494 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005495 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
5496 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005497 GEN_ERROR("Vector types not supported by icmp instruction");
Chris Lattner0275cff2007-08-06 21:00:46 +00005498 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005499 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005500 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005501 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005502 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
5503 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005504 GEN_ERROR("icmp operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00005505 delete yyvsp[-3].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00005506 ;}
5507 break;
5508
5509 case 291:
5510#line 2817 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5511 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005512 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005513 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
5514 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005515 GEN_ERROR("Vector types not supported by fcmp instruction");
Chris Lattner0275cff2007-08-06 21:00:46 +00005516 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005517 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005518 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005519 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005520 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
5521 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005522 GEN_ERROR("fcmp operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00005523 delete yyvsp[-3].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00005524 ;}
5525 break;
5526
5527 case 292:
5528#line 2831 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5529 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005530 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005531 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
5532 Value* Val = yyvsp[-2].ValueVal;
5533 const Type* DestTy = yyvsp[0].TypeVal->get();
5534 if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005535 GEN_ERROR("invalid cast opcode for cast from '" +
5536 Val->getType()->getDescription() + "' to '" +
5537 DestTy->getDescription() + "'");
Chris Lattner0275cff2007-08-06 21:00:46 +00005538 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy);
5539 delete yyvsp[0].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00005540 ;}
5541 break;
5542
5543 case 293:
5544#line 2843 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5545 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005546 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005547 GEN_ERROR("select condition must be boolean");
Chris Lattner0275cff2007-08-06 21:00:46 +00005548 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005549 GEN_ERROR("select value types should match");
Chris Lattner0275cff2007-08-06 21:00:46 +00005550 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005551 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005552 ;}
5553 break;
5554
5555 case 294:
5556#line 2851 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5557 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005558 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005559 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
5560 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
5561 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00005562 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005563 ;}
5564 break;
5565
5566 case 295:
5567#line 2858 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5568 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005569 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005570 GEN_ERROR("Invalid extractelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00005571 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005572 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005573 ;}
5574 break;
5575
5576 case 296:
5577#line 2864 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5578 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005579 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005580 GEN_ERROR("Invalid insertelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00005581 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005582 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005583 ;}
5584 break;
5585
5586 case 297:
5587#line 2870 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5588 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005589 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005590 GEN_ERROR("Invalid shufflevector operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00005591 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005592 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005593 ;}
5594 break;
5595
5596 case 298:
5597#line 2876 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5598 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005599 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005600 if (!Ty->isFirstClassType())
5601 GEN_ERROR("PHI node operands must be of first class type");
Chris Lattner0275cff2007-08-06 21:00:46 +00005602 yyval.InstVal = new PHINode(Ty);
5603 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
5604 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
5605 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005606 GEN_ERROR("All elements of a PHI node must be of the same type");
Chris Lattner0275cff2007-08-06 21:00:46 +00005607 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
5608 yyvsp[0].PHIList->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005609 }
Chris Lattner0275cff2007-08-06 21:00:46 +00005610 delete yyvsp[0].PHIList; // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005611 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005612 ;}
5613 break;
5614
5615 case 299:
5616#line 2892 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5617 {
Reid Spencer14310612006-12-31 05:40:51 +00005618
5619 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005620 const PointerType *PFTy = 0;
5621 const FunctionType *Ty = 0;
Chris Lattner0275cff2007-08-06 21:00:46 +00005622 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005623 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5624 // Pull out the types of all of the arguments...
5625 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00005626 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00005627 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
5628 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00005629 Attrs.push_back(PAWI);
5630 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00005631 unsigned index = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00005632 ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00005633 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00005634 const Type *Ty = I->Val->getType();
5635 if (Ty == Type::VoidTy)
5636 GEN_ERROR("Short call syntax cannot be used with varargs");
5637 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00005638 if (I->Attrs != ParamAttr::None) {
5639 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
5640 Attrs.push_back(PAWI);
5641 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00005642 }
5643
Christopher Lamb5c104242007-04-22 20:09:11 +00005644 ParamAttrsList *PAL = 0;
5645 if (!Attrs.empty())
5646 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00005647
Chris Lattner0275cff2007-08-06 21:00:46 +00005648 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005649 PFTy = PointerType::get(Ty);
5650 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00005651
Chris Lattner0275cff2007-08-06 21:00:46 +00005652 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005653 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00005654
Reid Spencer7780acb2007-04-16 06:56:07 +00005655 // Check for call to invalid intrinsic to avoid crashing later.
5656 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00005657 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00005658 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
5659 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00005660 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
5661 theF->getName() + "'");
5662 }
5663
Reid Spencer14310612006-12-31 05:40:51 +00005664 // Check the arguments
5665 ValueList Args;
Chris Lattner0275cff2007-08-06 21:00:46 +00005666 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005667 // Make sure no arguments is a good thing!
5668 if (Ty->getNumParams() != 0)
5669 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005670 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005671 } else { // Has arguments?
5672 // Loop through FunctionType's arguments and ensure they are specified
5673 // correctly!
5674 //
5675 FunctionType::param_iterator I = Ty->param_begin();
5676 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner0275cff2007-08-06 21:00:46 +00005677 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005678
Reid Spencer14310612006-12-31 05:40:51 +00005679 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5680 if (ArgI->Val->getType() != *I)
5681 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005682 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005683 Args.push_back(ArgI->Val);
5684 }
5685 if (Ty->isVarArg()) {
5686 if (I == E)
5687 for (; ArgI != ArgE; ++ArgI)
5688 Args.push_back(ArgI->Val); // push the remaining varargs
5689 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005690 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005691 }
Reid Spencer14310612006-12-31 05:40:51 +00005692 // Create the call node
David Greene718fda32007-08-01 03:59:32 +00005693 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Chris Lattner0275cff2007-08-06 21:00:46 +00005694 CI->setTailCall(yyvsp[-7].BoolVal);
5695 CI->setCallingConv(yyvsp[-6].UIntVal);
5696 yyval.InstVal = CI;
5697 delete yyvsp[-2].ValueRefList;
5698 delete yyvsp[-5].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005699 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005700 ;}
5701 break;
5702
5703 case 300:
5704#line 2976 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5705 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005706 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005707 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005708 ;}
5709 break;
5710
5711 case 301:
5712#line 2981 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5713 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005714 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005715 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005716 ;}
5717 break;
5718
5719 case 302:
5720#line 2985 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5721 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005722 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005723 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005724 ;}
5725 break;
5726
5727 case 303:
5728#line 2992 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5729 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005730 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005731 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5732 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5733 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00005734 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005735 ;}
5736 break;
5737
5738 case 304:
5739#line 2999 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5740 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005741 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005742 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5743 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005744 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005745 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5746 delete yyvsp[-4].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00005747 ;}
5748 break;
5749
5750 case 305:
5751#line 3007 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5752 {
Reid Spencer14310612006-12-31 05:40:51 +00005753 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005754 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
5755 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
5756 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00005757 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005758 ;}
5759 break;
5760
5761 case 306:
5762#line 3014 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5763 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005764 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005765 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
5766 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005767 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005768 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
5769 delete yyvsp[-4].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00005770 ;}
5771 break;
5772
5773 case 307:
5774#line 3022 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5775 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005776 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005777 GEN_ERROR("Trying to free nonpointer type " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005778 yyvsp[0].ValueVal->getType()->getDescription() + "");
5779 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005780 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005781 ;}
5782 break;
5783
5784 case 308:
5785#line 3030 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5786 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005787 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005788 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5789 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005790 GEN_ERROR("Can't load from nonpointer type: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005791 (*yyvsp[-2].TypeVal)->getDescription());
5792 if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005793 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005794 (*yyvsp[-2].TypeVal)->getDescription());
5795 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005796 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005797 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal);
5798 delete yyvsp[-2].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00005799 ;}
5800 break;
5801
5802 case 309:
5803#line 3044 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5804 {
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005805 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005806 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5807 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005808 if (!PT)
5809 GEN_ERROR("Can't store to a nonpointer type: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005810 (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005811 const Type *ElTy = PT->getElementType();
Chris Lattner0275cff2007-08-06 21:00:46 +00005812 if (ElTy != yyvsp[-4].ValueVal->getType())
5813 GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005814 "' into space of type '" + ElTy->getDescription() + "'");
5815
Chris Lattner0275cff2007-08-06 21:00:46 +00005816 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005817 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005818 yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal);
5819 delete yyvsp[-2].TypeVal;
David Greene5fd22a82007-09-04 18:46:50 +00005820 ;}
5821 break;
5822
5823 case 310:
5824#line 3061 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
5825 {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005826 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005827 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5828 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005829 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005830
David Greene5fd22a82007-09-04 18:46:50 +00005831 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005832 GEN_ERROR("Invalid getelementptr indices for type '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00005833 (*yyvsp[-2].TypeVal)->getDescription()+ "'");
5834 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005835 CHECK_FOR_ERROR
David Greene5fd22a82007-09-04 18:46:50 +00005836 yyval.InstVal = new GetElementPtrInst(tmpVal, yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
Chris Lattner0275cff2007-08-06 21:00:46 +00005837 delete yyvsp[-2].TypeVal;
5838 delete yyvsp[0].ValueList;
David Greene5fd22a82007-09-04 18:46:50 +00005839 ;}
5840 break;
5841
5842
5843 }
5844
5845/* Line 993 of yacc.c. */
5846#line 5847 "llvmAsmParser.tab.c"
Chris Lattner0275cff2007-08-06 21:00:46 +00005847
5848 yyvsp -= yylen;
5849 yyssp -= yylen;
Reid Spencer7780acb2007-04-16 06:56:07 +00005850
David Greene5fd22a82007-09-04 18:46:50 +00005851
5852 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005853
5854 *++yyvsp = yyval;
5855
5856
David Greene5fd22a82007-09-04 18:46:50 +00005857 /* Now `shift' the result of the reduction. Determine what state
5858 that goes to, based on the state we popped back to and the rule
5859 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005860
5861 yyn = yyr1[yyn];
5862
David Greene5fd22a82007-09-04 18:46:50 +00005863 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5864 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005865 yystate = yytable[yystate];
5866 else
David Greene5fd22a82007-09-04 18:46:50 +00005867 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005868
5869 goto yynewstate;
5870
5871
David Greene5fd22a82007-09-04 18:46:50 +00005872/*------------------------------------.
5873| yyerrlab -- here on detecting error |
5874`------------------------------------*/
5875yyerrlab:
5876 /* If not already recovering from an error, report this error. */
5877 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005878 {
5879 ++yynerrs;
David Greene5fd22a82007-09-04 18:46:50 +00005880#if YYERROR_VERBOSE
Chris Lattner0275cff2007-08-06 21:00:46 +00005881 yyn = yypact[yystate];
5882
David Greene5fd22a82007-09-04 18:46:50 +00005883 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattner0275cff2007-08-06 21:00:46 +00005884 {
David Greene5fd22a82007-09-04 18:46:50 +00005885 YYSIZE_T yysize = 0;
5886 int yytype = YYTRANSLATE (yychar);
5887 const char* yyprefix;
5888 char *yymsg;
5889 int yyx;
Chris Lattner0275cff2007-08-06 21:00:46 +00005890
David Greene5fd22a82007-09-04 18:46:50 +00005891 /* Start YYX at -YYN if negative to avoid negative indexes in
5892 YYCHECK. */
5893 int yyxbegin = yyn < 0 ? -yyn : 0;
5894
5895 /* Stay within bounds of both yycheck and yytname. */
5896 int yychecklim = YYLAST - yyn;
5897 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5898 int yycount = 0;
5899
5900 yyprefix = ", expecting ";
5901 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5902 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5903 {
5904 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
5905 yycount += 1;
5906 if (yycount == 5)
5907 {
5908 yysize = 0;
5909 break;
5910 }
5911 }
5912 yysize += (sizeof ("syntax error, unexpected ")
5913 + yystrlen (yytname[yytype]));
5914 yymsg = (char *) YYSTACK_ALLOC (yysize);
5915 if (yymsg != 0)
Chris Lattner0275cff2007-08-06 21:00:46 +00005916 {
David Greene5fd22a82007-09-04 18:46:50 +00005917 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
5918 yyp = yystpcpy (yyp, yytname[yytype]);
Chris Lattner0275cff2007-08-06 21:00:46 +00005919
David Greene5fd22a82007-09-04 18:46:50 +00005920 if (yycount < 5)
Chris Lattner0275cff2007-08-06 21:00:46 +00005921 {
David Greene5fd22a82007-09-04 18:46:50 +00005922 yyprefix = ", expecting ";
5923 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5924 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
Chris Lattner0275cff2007-08-06 21:00:46 +00005925 {
David Greene5fd22a82007-09-04 18:46:50 +00005926 yyp = yystpcpy (yyp, yyprefix);
5927 yyp = yystpcpy (yyp, yytname[yyx]);
5928 yyprefix = " or ";
Chris Lattner0275cff2007-08-06 21:00:46 +00005929 }
5930 }
David Greene5fd22a82007-09-04 18:46:50 +00005931 yyerror (yymsg);
5932 YYSTACK_FREE (yymsg);
Chris Lattner0275cff2007-08-06 21:00:46 +00005933 }
5934 else
David Greene5fd22a82007-09-04 18:46:50 +00005935 yyerror ("syntax error; also virtual memory exhausted");
Chris Lattner0275cff2007-08-06 21:00:46 +00005936 }
5937 else
5938#endif /* YYERROR_VERBOSE */
David Greene5fd22a82007-09-04 18:46:50 +00005939 yyerror ("syntax error");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005940 }
5941
David Greene5fd22a82007-09-04 18:46:50 +00005942
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005943
5944 if (yyerrstatus == 3)
5945 {
David Greene5fd22a82007-09-04 18:46:50 +00005946 /* If just tried and failed to reuse lookahead token after an
5947 error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005948
David Greene5fd22a82007-09-04 18:46:50 +00005949 if (yychar <= YYEOF)
5950 {
5951 /* If at end of input, pop the error token,
5952 then the rest of the stack, then return failure. */
5953 if (yychar == YYEOF)
5954 for (;;)
5955 {
5956 YYPOPSTACK;
5957 if (yyssp == yyss)
5958 YYABORT;
5959 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
5960 yydestruct (yystos[*yyssp], yyvsp);
5961 }
5962 }
5963 else
5964 {
5965 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
5966 yydestruct (yytoken, &yylval);
5967 yychar = YYEMPTY;
5968
5969 }
5970 }
5971
5972 /* Else will try to reuse lookahead token after shifting the error
5973 token. */
5974 goto yyerrlab1;
5975
5976
5977/*---------------------------------------------------.
5978| yyerrorlab -- error raised explicitly by YYERROR. |
5979`---------------------------------------------------*/
5980yyerrorlab:
5981
5982#ifdef __GNUC__
5983 /* Pacify GCC when the user code never invokes YYERROR and the label
5984 yyerrorlab therefore never appears in user code. */
5985 if (0)
5986 goto yyerrorlab;
5987#endif
5988
5989 yyvsp -= yylen;
5990 yyssp -= yylen;
5991 yystate = *yyssp;
5992 goto yyerrlab1;
5993
5994
5995/*-------------------------------------------------------------.
5996| yyerrlab1 -- common code for both syntax error and YYERROR. |
5997`-------------------------------------------------------------*/
5998yyerrlab1:
5999 yyerrstatus = 3; /* Each real token shifted decrements this. */
6000
6001 for (;;)
6002 {
6003 yyn = yypact[yystate];
6004 if (yyn != YYPACT_NINF)
6005 {
6006 yyn += YYTERROR;
6007 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
6008 {
6009 yyn = yytable[yyn];
6010 if (0 < yyn)
6011 break;
6012 }
6013 }
6014
6015 /* Pop the current state because it cannot handle the error token. */
6016 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00006017 YYABORT;
6018
David Greene5fd22a82007-09-04 18:46:50 +00006019 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
6020 yydestruct (yystos[yystate], yyvsp);
6021 YYPOPSTACK;
6022 yystate = *yyssp;
6023 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006024 }
6025
6026 if (yyn == YYFINAL)
6027 YYACCEPT;
6028
David Greene5fd22a82007-09-04 18:46:50 +00006029 YYDPRINTF ((stderr, "Shifting error token, "));
Chris Lattner0275cff2007-08-06 21:00:46 +00006030
Reid Spencer68a24bd2005-08-27 18:50:39 +00006031 *++yyvsp = yylval;
David Greene5fd22a82007-09-04 18:46:50 +00006032
Reid Spencerb8f85052007-07-31 03:50:36 +00006033
Reid Spencer68a24bd2005-08-27 18:50:39 +00006034 yystate = yyn;
6035 goto yynewstate;
6036
Chris Lattner0275cff2007-08-06 21:00:46 +00006037
David Greene5fd22a82007-09-04 18:46:50 +00006038/*-------------------------------------.
6039| yyacceptlab -- YYACCEPT comes here. |
6040`-------------------------------------*/
6041yyacceptlab:
6042 yyresult = 0;
6043 goto yyreturn;
6044
6045/*-----------------------------------.
6046| yyabortlab -- YYABORT comes here. |
6047`-----------------------------------*/
6048yyabortlab:
6049 yyresult = 1;
6050 goto yyreturn;
6051
6052#ifndef yyoverflow
6053/*----------------------------------------------.
6054| yyoverflowlab -- parser overflow comes here. |
6055`----------------------------------------------*/
6056yyoverflowlab:
6057 yyerror ("parser stack overflow");
6058 yyresult = 2;
6059 /* Fall through. */
Chandler Carruth02202192007-08-04 01:56:21 +00006060#endif
David Greene5fd22a82007-09-04 18:46:50 +00006061
6062yyreturn:
6063#ifndef yyoverflow
6064 if (yyss != yyssa)
6065 YYSTACK_FREE (yyss);
6066#endif
6067 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00006068}
David Greene5fd22a82007-09-04 18:46:50 +00006069
6070
6071#line 3078 "/users/dag/projects/cascade/llvm.modified/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00006072
6073
Reid Spencer14310612006-12-31 05:40:51 +00006074// common code from the two 'RunVMAsmParser' functions
6075static Module* RunParser(Module * M) {
6076
6077 llvmAsmlineno = 1; // Reset the current line number...
6078 CurModule.CurrentModule = M;
6079#if YYDEBUG
6080 yydebug = Debug;
6081#endif
6082
6083 // Check to make sure the parser succeeded
6084 if (yyparse()) {
6085 if (ParserResult)
6086 delete ParserResult;
6087 return 0;
6088 }
6089
Reid Spencer0d60b5a2007-03-30 01:37:39 +00006090 // Emit an error if there are any unresolved types left.
6091 if (!CurModule.LateResolveTypes.empty()) {
6092 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
6093 if (DID.Type == ValID::LocalName) {
6094 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
6095 } else {
6096 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
6097 }
6098 if (ParserResult)
6099 delete ParserResult;
6100 return 0;
6101 }
6102
6103 // Emit an error if there are any unresolved values left.
6104 if (!CurModule.LateResolveValues.empty()) {
6105 Value *V = CurModule.LateResolveValues.back();
6106 std::map<Value*, std::pair<ValID, int> >::iterator I =
6107 CurModule.PlaceHolderInfo.find(V);
6108
6109 if (I != CurModule.PlaceHolderInfo.end()) {
6110 ValID &DID = I->second.first;
6111 if (DID.Type == ValID::LocalName) {
6112 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
6113 } else {
6114 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
6115 }
6116 if (ParserResult)
6117 delete ParserResult;
6118 return 0;
6119 }
6120 }
6121
Reid Spencer14310612006-12-31 05:40:51 +00006122 // Check to make sure that parsing produced a result
6123 if (!ParserResult)
6124 return 0;
6125
6126 // Reset ParserResult variable while saving its value for the result.
6127 Module *Result = ParserResult;
6128 ParserResult = 0;
6129
6130 return Result;
6131}
6132
Reid Spencer61c83e02006-08-18 08:43:06 +00006133void llvm::GenerateError(const std::string &message, int LineNo) {
6134 if (LineNo == -1) LineNo = llvmAsmlineno;
6135 // TODO: column number in exception
6136 if (TheParseError)
6137 TheParseError->setError(CurFilename, message, LineNo);
6138 TriggerError = 1;
6139}
Reid Spencer68a24bd2005-08-27 18:50:39 +00006140
6141int yyerror(const char *ErrorMsg) {
6142 std::string where
6143 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
6144 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00006145 std::string errMsg = where + "error: " + std::string(ErrorMsg);
6146 if (yychar != YYEMPTY && yychar != 0)
6147 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
6148 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00006149 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00006150 return 0;
6151}
David Greene5fd22a82007-09-04 18:46:50 +00006152