blob: 9afa42490c21d4b5387a386dda7e1ec6a7658c38 [file] [log] [blame]
Reid Spencer38c91a92007-02-28 02:24:54 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencer38c91a92007-02-28 02:24:54 +00003/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00005
Reid Spencer38c91a92007-02-28 02:24:54 +00006 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
Anton Korobeynikov178a3522007-01-12 19:22:51 +000010
Reid Spencer38c91a92007-02-28 02:24:54 +000011 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
37#define YYBISON 1
38
39/* Bison version. */
40#define YYBISON_VERSION "2.1"
41
42/* Skeleton name. */
43#define YYSKELETON_NAME "yacc.c"
44
45/* Pure parsers. */
46#define YYPURE 0
47
48/* Using locations. */
49#define YYLSP_NEEDED 0
50
51/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000052#define yyparse llvmAsmparse
Reid Spencer38c91a92007-02-28 02:24:54 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Reid Spencer38c91a92007-02-28 02:24:54 +000055#define yylval llvmAsmlval
56#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000057#define yydebug llvmAsmdebug
58#define yynerrs llvmAsmnerrs
59
Reid Spencer38c91a92007-02-28 02:24:54 +000060
61/* Tokens. */
62#ifndef YYTOKENTYPE
63# define YYTOKENTYPE
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
65 know about them. */
66 enum yytokentype {
67 ESINT64VAL = 258,
68 EUINT64VAL = 259,
69 ESAPINTVAL = 260,
70 EUAPINTVAL = 261,
71 LOCALVAL_ID = 262,
72 GLOBALVAL_ID = 263,
73 FPVAL = 264,
74 VOID = 265,
75 INTTYPE = 266,
76 FLOAT = 267,
77 DOUBLE = 268,
78 LABEL = 269,
79 TYPE = 270,
80 LOCALVAR = 271,
81 GLOBALVAR = 272,
82 LABELSTR = 273,
83 STRINGCONSTANT = 274,
84 ATSTRINGCONSTANT = 275,
85 IMPLEMENTATION = 276,
86 ZEROINITIALIZER = 277,
87 TRUETOK = 278,
88 FALSETOK = 279,
89 BEGINTOK = 280,
90 ENDTOK = 281,
91 DECLARE = 282,
92 DEFINE = 283,
93 GLOBAL = 284,
94 CONSTANT = 285,
95 SECTION = 286,
96 VOLATILE = 287,
97 TO = 288,
98 DOTDOTDOT = 289,
99 NULL_TOK = 290,
100 UNDEF = 291,
101 INTERNAL = 292,
102 LINKONCE = 293,
103 WEAK = 294,
104 APPENDING = 295,
105 DLLIMPORT = 296,
106 DLLEXPORT = 297,
107 EXTERN_WEAK = 298,
108 OPAQUE = 299,
109 EXTERNAL = 300,
110 TARGET = 301,
111 TRIPLE = 302,
112 ALIGN = 303,
113 DEPLIBS = 304,
114 CALL = 305,
115 TAIL = 306,
116 ASM_TOK = 307,
117 MODULE = 308,
118 SIDEEFFECT = 309,
119 CC_TOK = 310,
120 CCC_TOK = 311,
121 FASTCC_TOK = 312,
122 COLDCC_TOK = 313,
123 X86_STDCALLCC_TOK = 314,
124 X86_FASTCALLCC_TOK = 315,
125 DATALAYOUT = 316,
126 RET = 317,
127 BR = 318,
128 SWITCH = 319,
129 INVOKE = 320,
130 UNWIND = 321,
131 UNREACHABLE = 322,
132 ADD = 323,
133 SUB = 324,
134 MUL = 325,
135 UDIV = 326,
136 SDIV = 327,
137 FDIV = 328,
138 UREM = 329,
139 SREM = 330,
140 FREM = 331,
141 AND = 332,
142 OR = 333,
143 XOR = 334,
144 SHL = 335,
145 LSHR = 336,
146 ASHR = 337,
147 ICMP = 338,
148 FCMP = 339,
149 EQ = 340,
150 NE = 341,
151 SLT = 342,
152 SGT = 343,
153 SLE = 344,
154 SGE = 345,
155 ULT = 346,
156 UGT = 347,
157 ULE = 348,
158 UGE = 349,
159 OEQ = 350,
160 ONE = 351,
161 OLT = 352,
162 OGT = 353,
163 OLE = 354,
164 OGE = 355,
165 ORD = 356,
166 UNO = 357,
167 UEQ = 358,
168 UNE = 359,
169 MALLOC = 360,
170 ALLOCA = 361,
171 FREE = 362,
172 LOAD = 363,
173 STORE = 364,
174 GETELEMENTPTR = 365,
175 TRUNC = 366,
176 ZEXT = 367,
177 SEXT = 368,
178 FPTRUNC = 369,
179 FPEXT = 370,
180 BITCAST = 371,
181 UITOFP = 372,
182 SITOFP = 373,
183 FPTOUI = 374,
184 FPTOSI = 375,
185 INTTOPTR = 376,
186 PTRTOINT = 377,
187 PHI_TOK = 378,
188 SELECT = 379,
189 VAARG = 380,
190 EXTRACTELEMENT = 381,
191 INSERTELEMENT = 382,
192 SHUFFLEVECTOR = 383,
193 NORETURN = 384,
194 INREG = 385,
195 SRET = 386,
196 DEFAULT = 387,
197 HIDDEN = 388
198 };
199#endif
200/* Tokens. */
201#define ESINT64VAL 258
202#define EUINT64VAL 259
203#define ESAPINTVAL 260
204#define EUAPINTVAL 261
205#define LOCALVAL_ID 262
206#define GLOBALVAL_ID 263
207#define FPVAL 264
208#define VOID 265
209#define INTTYPE 266
210#define FLOAT 267
211#define DOUBLE 268
212#define LABEL 269
213#define TYPE 270
214#define LOCALVAR 271
215#define GLOBALVAR 272
216#define LABELSTR 273
217#define STRINGCONSTANT 274
218#define ATSTRINGCONSTANT 275
219#define IMPLEMENTATION 276
220#define ZEROINITIALIZER 277
221#define TRUETOK 278
222#define FALSETOK 279
223#define BEGINTOK 280
224#define ENDTOK 281
225#define DECLARE 282
226#define DEFINE 283
227#define GLOBAL 284
228#define CONSTANT 285
229#define SECTION 286
230#define VOLATILE 287
231#define TO 288
232#define DOTDOTDOT 289
233#define NULL_TOK 290
234#define UNDEF 291
235#define INTERNAL 292
236#define LINKONCE 293
237#define WEAK 294
238#define APPENDING 295
239#define DLLIMPORT 296
240#define DLLEXPORT 297
241#define EXTERN_WEAK 298
242#define OPAQUE 299
243#define EXTERNAL 300
244#define TARGET 301
245#define TRIPLE 302
246#define ALIGN 303
247#define DEPLIBS 304
248#define CALL 305
249#define TAIL 306
250#define ASM_TOK 307
251#define MODULE 308
252#define SIDEEFFECT 309
253#define CC_TOK 310
254#define CCC_TOK 311
255#define FASTCC_TOK 312
256#define COLDCC_TOK 313
257#define X86_STDCALLCC_TOK 314
258#define X86_FASTCALLCC_TOK 315
259#define DATALAYOUT 316
260#define RET 317
261#define BR 318
262#define SWITCH 319
263#define INVOKE 320
264#define UNWIND 321
265#define UNREACHABLE 322
266#define ADD 323
267#define SUB 324
268#define MUL 325
269#define UDIV 326
270#define SDIV 327
271#define FDIV 328
272#define UREM 329
273#define SREM 330
274#define FREM 331
275#define AND 332
276#define OR 333
277#define XOR 334
278#define SHL 335
279#define LSHR 336
280#define ASHR 337
281#define ICMP 338
282#define FCMP 339
283#define EQ 340
284#define NE 341
285#define SLT 342
286#define SGT 343
287#define SLE 344
288#define SGE 345
289#define ULT 346
290#define UGT 347
291#define ULE 348
292#define UGE 349
293#define OEQ 350
294#define ONE 351
295#define OLT 352
296#define OGT 353
297#define OLE 354
298#define OGE 355
299#define ORD 356
300#define UNO 357
301#define UEQ 358
302#define UNE 359
303#define MALLOC 360
304#define ALLOCA 361
305#define FREE 362
306#define LOAD 363
307#define STORE 364
308#define GETELEMENTPTR 365
309#define TRUNC 366
310#define ZEXT 367
311#define SEXT 368
312#define FPTRUNC 369
313#define FPEXT 370
314#define BITCAST 371
315#define UITOFP 372
316#define SITOFP 373
317#define FPTOUI 374
318#define FPTOSI 375
319#define INTTOPTR 376
320#define PTRTOINT 377
321#define PHI_TOK 378
322#define SELECT 379
323#define VAARG 380
324#define EXTRACTELEMENT 381
325#define INSERTELEMENT 382
326#define SHUFFLEVECTOR 383
327#define NORETURN 384
328#define INREG 385
329#define SRET 386
330#define DEFAULT 387
331#define HIDDEN 388
332
333
334
335
336/* Copy the first part of user declarations. */
337#line 14 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000338
339#include "ParserInternals.h"
340#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000341#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000342#include "llvm/Instructions.h"
343#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000344#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000345#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000346#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000347#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000348#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000349#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000350#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000351#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000352#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000353#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000354#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000355#ifndef NDEBUG
356#define YYDEBUG 1
357#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000358
Reid Spencere4f47592006-08-18 17:32:55 +0000359// The following is a gross hack. In order to rid the libAsmParser library of
360// exceptions, we have to have a way of getting the yyparse function to go into
361// an error situation. So, whenever we want an error to occur, the GenerateError
362// function (see bottom of file) sets TriggerError. Then, at the end of each
363// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
364// (a goto) to put YACC in error state. Furthermore, several calls to
365// GenerateError are made from inside productions and they must simulate the
366// previous exception behavior by exiting the production immediately. We have
367// replaced these with the GEN_ERROR macro which calls GeneratError and then
368// immediately invokes YYERROR. This would be so much cleaner if it was a
369// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000370static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000371#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000372#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
373
Reid Spencer68a24bd2005-08-27 18:50:39 +0000374int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
375int yylex(); // declaration" of xxx warnings.
376int yyparse();
377
378namespace llvm {
379 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000380#if YYDEBUG
381static cl::opt<bool>
382Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
383 cl::Hidden, cl::init(false));
384#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000385}
386using namespace llvm;
387
388static Module *ParserResult;
389
390// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
391// relating to upreferences in the input stream.
392//
393//#define DEBUG_UPREFS 1
394#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000395#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000396#else
397#define UR_OUT(X)
398#endif
399
400#define YYERROR_VERBOSE 1
401
Chris Lattnerb475c422005-11-12 18:22:38 +0000402static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000403
404
405// This contains info used when building the body of a function. It is
406// destroyed when the function is completed.
407//
408typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000409
Reid Spencer68a24bd2005-08-27 18:50:39 +0000410static void
411ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
412 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
413
414static struct PerModuleInfo {
415 Module *CurrentModule;
416 std::map<const Type *, ValueList> Values; // Module level numbered definitions
417 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000418 std::vector<PATypeHolder> Types;
419 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000420
421 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000422 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000423 /// that we can resolve them later and print error messages as appropriate.
424 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
425
426 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
427 // references to global values. Global values may be referenced before they
428 // are defined, and if so, the temporary object that they represent is held
429 // here. This is used for forward references of GlobalValues.
430 //
431 typedef std::map<std::pair<const PointerType *,
432 ValID>, GlobalValue*> GlobalRefsType;
433 GlobalRefsType GlobalRefs;
434
435 void ModuleDone() {
436 // If we could not resolve some functions at function compilation time
437 // (calls to functions before they are defined), resolve them now... Types
438 // are resolved when the constant pool has been completely parsed.
439 //
440 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000441 if (TriggerError)
442 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000443
444 // Check to make sure that all global value forward references have been
445 // resolved!
446 //
447 if (!GlobalRefs.empty()) {
448 std::string UndefinedReferences = "Unresolved global references exist:\n";
449
450 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
451 I != E; ++I) {
452 UndefinedReferences += " " + I->first.first->getDescription() + " " +
453 I->first.second.getName() + "\n";
454 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000455 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000456 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000457 }
458
459 Values.clear(); // Clear out function local definitions
460 Types.clear();
461 CurrentModule = 0;
462 }
463
Reid Spencer68a24bd2005-08-27 18:50:39 +0000464 // GetForwardRefForGlobal - Check to see if there is a forward reference
465 // for this global. If so, remove it from the GlobalRefs map and return it.
466 // If not, just return null.
467 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
468 // Check to see if there is a forward reference to this global variable...
469 // if there is, eliminate it and patch the reference to use the new def'n.
470 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
471 GlobalValue *Ret = 0;
472 if (I != GlobalRefs.end()) {
473 Ret = I->second;
474 GlobalRefs.erase(I);
475 }
476 return Ret;
477 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000478
479 bool TypeIsUnresolved(PATypeHolder* PATy) {
480 // If it isn't abstract, its resolved
481 const Type* Ty = PATy->get();
482 if (!Ty->isAbstract())
483 return false;
484 // Traverse the type looking for abstract types. If it isn't abstract then
485 // we don't need to traverse that leg of the type.
486 std::vector<const Type*> WorkList, SeenList;
487 WorkList.push_back(Ty);
488 while (!WorkList.empty()) {
489 const Type* Ty = WorkList.back();
490 SeenList.push_back(Ty);
491 WorkList.pop_back();
492 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
493 // Check to see if this is an unresolved type
494 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
495 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
496 for ( ; I != E; ++I) {
497 if (I->second.get() == OpTy)
498 return true;
499 }
500 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
501 const Type* TheTy = SeqTy->getElementType();
502 if (TheTy->isAbstract() && TheTy != Ty) {
503 std::vector<const Type*>::iterator I = SeenList.begin(),
504 E = SeenList.end();
505 for ( ; I != E; ++I)
506 if (*I == TheTy)
507 break;
508 if (I == E)
509 WorkList.push_back(TheTy);
510 }
511 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
512 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
513 const Type* TheTy = StrTy->getElementType(i);
514 if (TheTy->isAbstract() && TheTy != Ty) {
515 std::vector<const Type*>::iterator I = SeenList.begin(),
516 E = SeenList.end();
517 for ( ; I != E; ++I)
518 if (*I == TheTy)
519 break;
520 if (I == E)
521 WorkList.push_back(TheTy);
522 }
523 }
524 }
525 }
526 return false;
527 }
528
529
Reid Spencer68a24bd2005-08-27 18:50:39 +0000530} CurModule;
531
532static struct PerFunctionInfo {
533 Function *CurrentFunction; // Pointer to current function being created
534
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000535 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000536 std::map<const Type*, ValueList> LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000537 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000538 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000539 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000540
541 /// BBForwardRefs - When we see forward references to basic blocks, keep
542 /// track of them here.
543 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
544 std::vector<BasicBlock*> NumberedBlocks;
545 unsigned NextBBNum;
546
547 inline PerFunctionInfo() {
548 CurrentFunction = 0;
549 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000550 Linkage = GlobalValue::ExternalLinkage;
551 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000552 }
553
554 inline void FunctionStart(Function *M) {
555 CurrentFunction = M;
556 NextBBNum = 0;
557 }
558
559 void FunctionDone() {
560 NumberedBlocks.clear();
561
562 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000563 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000564 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000565 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000566 return;
567 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000568
569 // Resolve all forward references now.
570 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
571
572 Values.clear(); // Clear out function local definitions
573 CurrentFunction = 0;
574 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000575 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000576 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000577 }
578} CurFun; // Info for the current function...
579
580static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
581
582
583//===----------------------------------------------------------------------===//
584// Code to handle definitions of all the types
585//===----------------------------------------------------------------------===//
586
587static int InsertValue(Value *V,
588 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
589 if (V->hasName()) return -1; // Is this a numbered definition?
590
591 // Yes, insert the value into the value table...
592 ValueList &List = ValueTab[V->getType()];
593 List.push_back(V);
594 return List.size()-1;
595}
596
597static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
598 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000599 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000600 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000601 if (D.Num < CurModule.Types.size())
602 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000603 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000604 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000605 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
606 D.destroy(); // Free old strdup'd memory...
607 return N;
608 }
609 break;
610 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000611 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000612 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000613 }
614
615 // If we reached here, we referenced either a symbol that we don't know about
616 // or an id number that hasn't been read yet. We may be referencing something
617 // forward, so just create an entry to be resolved later and get to it...
618 //
619 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
620
621
622 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000623 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000624 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000625 return 0;
626 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000627 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000628 return 0;
629 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000630 }
631
Reid Spencer861d9d62006-11-28 07:29:44 +0000632 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000633 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000634 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000635
Reid Spencer861d9d62006-11-28 07:29:44 +0000636 Type *Typ = OpaqueType::get();
637 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
638 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000639 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000640
Reid Spencer68a24bd2005-08-27 18:50:39 +0000641// getValNonImprovising - Look up the value specified by the provided type and
642// the provided ValID. If the value exists and has already been defined, return
643// it. Otherwise return null.
644//
645static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000646 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000647 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000648 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000649 return 0;
650 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000651
652 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000653 case ValID::LocalID: { // Is it a numbered definition?
654 // Module constants occupy the lowest numbered slots.
655 std::map<const Type*,ValueList>::iterator VI = CurFun.Values.find(Ty);
656 // Make sure that our type is within bounds.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000657 if (VI == CurFun.Values.end()) return 0;
658
Reid Spencer41dff5e2007-01-26 08:05:27 +0000659 // Check that the number is within bounds.
660 if (D.Num >= VI->second.size()) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000661
Reid Spencer41dff5e2007-01-26 08:05:27 +0000662 return VI->second[D.Num];
663 }
664 case ValID::GlobalID: { // Is it a numbered definition?
665 unsigned Num = D.Num;
666
667 // Module constants occupy the lowest numbered slots...
668 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
Reid Spenceref9b9a72007-02-05 20:47:22 +0000669 if (VI == CurModule.Values.end())
670 return 0;
671 if (D.Num >= VI->second.size())
672 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000673 return VI->second[Num];
674 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000675
676 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000677 if (!inFunctionScope())
678 return 0;
679 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
680 Value *N = SymTab.lookup(D.Name);
681 if (N == 0)
682 return 0;
683 if (N->getType() != Ty)
684 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000685
686 D.destroy(); // Free old strdup'd memory...
687 return N;
688 }
689 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000690 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
691 Value *N = SymTab.lookup(D.Name);
692 if (N == 0)
693 return 0;
694 if (N->getType() != Ty)
695 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000696
697 D.destroy(); // Free old strdup'd memory...
698 return N;
699 }
700
701 // Check to make sure that "Ty" is an integral type, and that our
702 // value will fit into the specified type...
703 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000704 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000705 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000706 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000707 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000708 return 0;
709 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000710 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000711
712 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000713 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
714 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000715 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000716 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000717 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000718 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000719 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000720 }
721 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000722 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000723 }
724
725 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000726 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000727 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000728 return 0;
729 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000730 return ConstantFP::get(Ty, D.ConstPoolFP);
731
732 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000733 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000734 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000735 return 0;
736 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000737 return ConstantPointerNull::get(cast<PointerType>(Ty));
738
739 case ValID::ConstUndefVal: // Is it an undef value?
740 return UndefValue::get(Ty);
741
Chris Lattner7aa61892005-12-21 17:53:23 +0000742 case ValID::ConstZeroVal: // Is it a zero value?
743 return Constant::getNullValue(Ty);
744
Reid Spencer68a24bd2005-08-27 18:50:39 +0000745 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000746 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000747 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000748 return 0;
749 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000750 return D.ConstantValue;
751
Chris Lattner0e9c3762006-01-25 22:27:16 +0000752 case ValID::InlineAsmVal: { // Inline asm expression
753 const PointerType *PTy = dyn_cast<PointerType>(Ty);
754 const FunctionType *FTy =
755 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000756 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000757 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000758 return 0;
759 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000760 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
761 D.IAD->HasSideEffects);
762 D.destroy(); // Free InlineAsmDescriptor.
763 return IA;
764 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000765 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000766 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000767 return 0;
768 } // End of switch
769
Reid Spencera9720f52007-02-05 17:04:00 +0000770 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000771 return 0;
772}
773
774// getVal - This function is identical to getValNonImprovising, except that if a
775// value is not already defined, it "improvises" by creating a placeholder var
776// that looks and acts just like the requested variable. When the value is
777// defined later, all uses of the placeholder variable are replaced with the
778// real thing.
779//
780static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000781 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000782 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000783 return 0;
784 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000785
786 // See if the value has already been defined.
787 Value *V = getValNonImprovising(Ty, ID);
788 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000789 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000790
Reid Spencer5b7e7532006-09-28 19:28:24 +0000791 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000792 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000793 return 0;
794 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000795
796 // If we reached here, we referenced either a symbol that we don't know about
797 // or an id number that hasn't been read yet. We may be referencing something
798 // forward, so just create an entry to be resolved later and get to it...
799 //
800 V = new Argument(Ty);
801
802 // Remember where this forward reference came from. FIXME, shouldn't we try
803 // to recycle these things??
804 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
805 llvmAsmlineno)));
806
807 if (inFunctionScope())
808 InsertValue(V, CurFun.LateResolveValues);
809 else
810 InsertValue(V, CurModule.LateResolveValues);
811 return V;
812}
813
814/// getBBVal - This is used for two purposes:
815/// * If isDefinition is true, a new basic block with the specified ID is being
816/// defined.
817/// * If isDefinition is true, this is a reference to a basic block, which may
818/// or may not be a forward reference.
819///
820static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
Reid Spencera9720f52007-02-05 17:04:00 +0000821 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000822
823 std::string Name;
824 BasicBlock *BB = 0;
825 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000826 default:
827 GenerateError("Illegal label reference " + ID.getName());
828 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000829 case ValID::LocalID: // Is it a numbered definition?
830 if (ID.Num >= CurFun.NumberedBlocks.size())
Reid Spencer68a24bd2005-08-27 18:50:39 +0000831 CurFun.NumberedBlocks.resize(ID.Num+1);
832 BB = CurFun.NumberedBlocks[ID.Num];
833 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000834 case ValID::LocalName: // Is it a named definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000835 Name = ID.Name;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000836 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
837 if (N && N->getType()->getTypeID() == Type::LabelTyID)
Reid Spencer68a24bd2005-08-27 18:50:39 +0000838 BB = cast<BasicBlock>(N);
839 break;
840 }
841
842 // See if the block has already been defined.
843 if (BB) {
844 // If this is the definition of the block, make sure the existing value was
845 // just a forward reference. If it was a forward reference, there will be
846 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000847 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000848 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000849 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000850 return 0;
851 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000852
853 ID.destroy(); // Free strdup'd memory.
854 return BB;
855 }
856
857 // Otherwise this block has not been seen before.
858 BB = new BasicBlock("", CurFun.CurrentFunction);
Reid Spencer41dff5e2007-01-26 08:05:27 +0000859 if (ID.Type == ValID::LocalName) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000860 BB->setName(ID.Name);
861 } else {
862 CurFun.NumberedBlocks[ID.Num] = BB;
863 }
864
865 // If this is not a definition, keep track of it so we can use it as a forward
866 // reference.
867 if (!isDefinition) {
868 // Remember where this forward reference came from.
869 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
870 } else {
871 // The forward declaration could have been inserted anywhere in the
872 // function: insert it into the correct place now.
873 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
874 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
875 }
876 ID.destroy();
877 return BB;
878}
879
880
881//===----------------------------------------------------------------------===//
882// Code to handle forward references in instructions
883//===----------------------------------------------------------------------===//
884//
885// This code handles the late binding needed with statements that reference
886// values not defined yet... for example, a forward branch, or the PHI node for
887// a loop body.
888//
889// This keeps a table (CurFun.LateResolveValues) of all such forward references
890// and back patchs after we are done.
891//
892
893// ResolveDefinitions - If we could not resolve some defs at parsing
894// time (forward branches, phi functions for loops, etc...) resolve the
895// defs now...
896//
897static void
898ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
899 std::map<const Type*,ValueList> *FutureLateResolvers) {
900 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
901 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
902 E = LateResolvers.end(); LRI != E; ++LRI) {
903 ValueList &List = LRI->second;
904 while (!List.empty()) {
905 Value *V = List.back();
906 List.pop_back();
907
908 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
909 CurModule.PlaceHolderInfo.find(V);
Reid Spencera9720f52007-02-05 17:04:00 +0000910 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000911
912 ValID &DID = PHI->second.first;
913
914 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000915 if (TriggerError)
916 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000917 if (TheRealValue) {
918 V->replaceAllUsesWith(TheRealValue);
919 delete V;
920 CurModule.PlaceHolderInfo.erase(PHI);
921 } else if (FutureLateResolvers) {
922 // Functions have their unresolved items forwarded to the module late
923 // resolver table
924 InsertValue(V, *FutureLateResolvers);
925 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000926 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000927 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000928 "' of type '" + V->getType()->getDescription() + "'",
929 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000930 return;
931 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000932 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000933 itostr(DID.Num) + " of type '" +
934 V->getType()->getDescription() + "'",
935 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000936 return;
937 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000938 }
939 }
940 }
941
942 LateResolvers.clear();
943}
944
945// ResolveTypeTo - A brand new type was just declared. This means that (if
946// name is not null) things referencing Name can be resolved. Otherwise, things
947// refering to the number can be resolved. Do this now.
948//
949static void ResolveTypeTo(char *Name, const Type *ToTy) {
950 ValID D;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000951 if (Name) D = ValID::createLocalName(Name);
952 else D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000953
Reid Spencer861d9d62006-11-28 07:29:44 +0000954 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000955 CurModule.LateResolveTypes.find(D);
956 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000957 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000958 CurModule.LateResolveTypes.erase(I);
959 }
960}
961
962// setValueName - Set the specified value to the name given. The name may be
963// null potentially, in which case this is a noop. The string passed in is
964// assumed to be a malloc'd string buffer, and is free'd by this function.
965//
966static void setValueName(Value *V, char *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000967 if (!NameStr) return;
968 std::string Name(NameStr); // Copy string
969 free(NameStr); // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000970
Reid Spencer41dff5e2007-01-26 08:05:27 +0000971 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000972 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000973 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000974 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000975
Reid Spencera9720f52007-02-05 17:04:00 +0000976 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000977 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
978 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000979 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000980 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000981 return;
982 }
983
984 // Set the name.
985 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000986}
987
988/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
989/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000990static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000991ParseGlobalVariable(char *NameStr,
992 GlobalValue::LinkageTypes Linkage,
993 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +0000994 bool isConstantGlobal, const Type *Ty,
995 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000996 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000997 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000998 return 0;
999 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001000
1001 const PointerType *PTy = PointerType::get(Ty);
1002
1003 std::string Name;
1004 if (NameStr) {
1005 Name = NameStr; // Copy string
1006 free(NameStr); // Free old string
1007 }
1008
1009 // See if this global value was forward referenced. If so, recycle the
1010 // object.
1011 ValID ID;
1012 if (!Name.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001013 ID = ValID::createGlobalName((char*)Name.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001014 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +00001015 ID = ValID::createGlobalID(CurModule.Values[PTy].size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00001016 }
1017
1018 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1019 // Move the global to the end of the list, from whereever it was
1020 // previously inserted.
1021 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1022 CurModule.CurrentModule->getGlobalList().remove(GV);
1023 CurModule.CurrentModule->getGlobalList().push_back(GV);
1024 GV->setInitializer(Initializer);
1025 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001026 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001027 GV->setConstant(isConstantGlobal);
1028 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001029 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001030 }
1031
Reid Spenceref9b9a72007-02-05 20:47:22 +00001032 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +00001033 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00001034 // if the global we're parsing has an initializer (is a definition) and
1035 // has external linkage.
1036 if (Initializer && Linkage != GlobalValue::InternalLinkage)
1037 // If there is already a global with external linkage with this name
1038 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
1039 // If we allow this GVar to get created, it will be renamed in the
1040 // symbol table because it conflicts with an existing GVar. We can't
1041 // allow redefinition of GVars whose linking indicates that their name
1042 // must stay the same. Issue the error.
1043 GenerateError("Redefinition of global variable named '" + Name +
1044 "' of type '" + Ty->getDescription() + "'");
1045 return 0;
1046 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001047 }
1048
1049 // Otherwise there is no existing GV to use, create one now.
1050 GlobalVariable *GV =
1051 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1052 CurModule.CurrentModule);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001053 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001054 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +00001055 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001056}
1057
1058// setTypeName - Set the specified type to the name given. The name may be
1059// null potentially, in which case this is a noop. The string passed in is
1060// assumed to be a malloc'd string buffer, and is freed by this function.
1061//
1062// This function returns true if the type has already been defined, but is
1063// allowed to be redefined in the specified context. If the name is a new name
1064// for the type plane, it is inserted and false is returned.
1065static bool setTypeName(const Type *T, char *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +00001066 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001067 if (NameStr == 0) return false;
1068
1069 std::string Name(NameStr); // Copy string
1070 free(NameStr); // Free old string
1071
1072 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +00001073 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +00001074 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001075 return false;
1076 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001077
1078 // Set the type name, checking for conflicts as we do so.
1079 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1080
1081 if (AlreadyExists) { // Inserting a name that is already defined???
1082 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +00001083 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001084
1085 // There is only one case where this is allowed: when we are refining an
1086 // opaque type. In this case, Existing will be an opaque type.
1087 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1088 // We ARE replacing an opaque type!
1089 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1090 return true;
1091 }
1092
1093 // Otherwise, this is an attempt to redefine a type. That's okay if
1094 // the redefinition is identical to the original. This will be so if
1095 // Existing and T point to the same Type object. In this one case we
1096 // allow the equivalent redefinition.
1097 if (Existing == T) return true; // Yes, it's equal.
1098
1099 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +00001100 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00001101 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001102 }
1103
1104 return false;
1105}
1106
1107//===----------------------------------------------------------------------===//
1108// Code for handling upreferences in type names...
1109//
1110
1111// TypeContains - Returns true if Ty directly contains E in it.
1112//
1113static bool TypeContains(const Type *Ty, const Type *E) {
1114 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1115 E) != Ty->subtype_end();
1116}
1117
1118namespace {
1119 struct UpRefRecord {
1120 // NestingLevel - The number of nesting levels that need to be popped before
1121 // this type is resolved.
1122 unsigned NestingLevel;
1123
1124 // LastContainedTy - This is the type at the current binding level for the
1125 // type. Every time we reduce the nesting level, this gets updated.
1126 const Type *LastContainedTy;
1127
1128 // UpRefTy - This is the actual opaque type that the upreference is
1129 // represented with.
1130 OpaqueType *UpRefTy;
1131
1132 UpRefRecord(unsigned NL, OpaqueType *URTy)
1133 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1134 };
1135}
1136
1137// UpRefs - A list of the outstanding upreferences that need to be resolved.
1138static std::vector<UpRefRecord> UpRefs;
1139
1140/// HandleUpRefs - Every time we finish a new layer of types, this function is
1141/// called. It loops through the UpRefs vector, which is a list of the
1142/// currently active types. For each type, if the up reference is contained in
1143/// the newly completed type, we decrement the level count. When the level
1144/// count reaches zero, the upreferenced type is the type that is passed in:
1145/// thus we can complete the cycle.
1146///
1147static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001148 // If Ty isn't abstract, or if there are no up-references in it, then there is
1149 // nothing to resolve here.
1150 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1151
Reid Spencer68a24bd2005-08-27 18:50:39 +00001152 PATypeHolder Ty(ty);
1153 UR_OUT("Type '" << Ty->getDescription() <<
1154 "' newly formed. Resolving upreferences.\n" <<
1155 UpRefs.size() << " upreferences active!\n");
1156
1157 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1158 // to zero), we resolve them all together before we resolve them to Ty. At
1159 // the end of the loop, if there is anything to resolve to Ty, it will be in
1160 // this variable.
1161 OpaqueType *TypeToResolve = 0;
1162
1163 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1164 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1165 << UpRefs[i].second->getDescription() << ") = "
1166 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1167 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1168 // Decrement level of upreference
1169 unsigned Level = --UpRefs[i].NestingLevel;
1170 UpRefs[i].LastContainedTy = Ty;
1171 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1172 if (Level == 0) { // Upreference should be resolved!
1173 if (!TypeToResolve) {
1174 TypeToResolve = UpRefs[i].UpRefTy;
1175 } else {
1176 UR_OUT(" * Resolving upreference for "
1177 << UpRefs[i].second->getDescription() << "\n";
1178 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1179 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1180 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1181 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1182 }
1183 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1184 --i; // Do not skip the next element...
1185 }
1186 }
1187 }
1188
1189 if (TypeToResolve) {
1190 UR_OUT(" * Resolving upreference for "
1191 << UpRefs[i].second->getDescription() << "\n";
1192 std::string OldName = TypeToResolve->getDescription());
1193 TypeToResolve->refineAbstractTypeTo(Ty);
1194 }
1195
1196 return Ty;
1197}
1198
Reid Spencer68a24bd2005-08-27 18:50:39 +00001199//===----------------------------------------------------------------------===//
1200// RunVMAsmParser - Define an interface to this parser
1201//===----------------------------------------------------------------------===//
1202//
Reid Spencer14310612006-12-31 05:40:51 +00001203static Module* RunParser(Module * M);
1204
Reid Spencer68a24bd2005-08-27 18:50:39 +00001205Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1206 set_scan_file(F);
1207
1208 CurFilename = Filename;
1209 return RunParser(new Module(CurFilename));
1210}
1211
1212Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1213 set_scan_string(AsmString);
1214
1215 CurFilename = "from_memory";
1216 if (M == NULL) {
1217 return RunParser(new Module (CurFilename));
1218 } else {
1219 return RunParser(M);
1220 }
1221}
1222
1223
Reid Spencer38c91a92007-02-28 02:24:54 +00001224
1225/* Enabling traces. */
1226#ifndef YYDEBUG
1227# define YYDEBUG 0
1228#endif
1229
1230/* Enabling verbose error messages. */
1231#ifdef YYERROR_VERBOSE
1232# undef YYERROR_VERBOSE
1233# define YYERROR_VERBOSE 1
1234#else
1235# define YYERROR_VERBOSE 0
1236#endif
1237
1238/* Enabling the token table. */
1239#ifndef YYTOKEN_TABLE
1240# define YYTOKEN_TABLE 0
1241#endif
1242
1243#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1244#line 901 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
1245typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001246 llvm::Module *ModuleVal;
1247 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001248 llvm::BasicBlock *BasicBlockVal;
1249 llvm::TerminatorInst *TermInstVal;
1250 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001251 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001252
Reid Spencera132e042006-12-03 05:46:11 +00001253 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001254 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001255 llvm::PATypeHolder *TypeVal;
1256 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001257 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001258 llvm::ArgListType *ArgList;
1259 llvm::TypeWithAttrs TypeWithAttrs;
1260 llvm::TypeWithAttrsList *TypeWithAttrsList;
1261 llvm::ValueRefList *ValueRefList;
1262
Reid Spencer68a24bd2005-08-27 18:50:39 +00001263 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001264 std::list<std::pair<llvm::Value*,
1265 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001266 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001267 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001268
1269 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001270 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer14310612006-12-31 05:40:51 +00001271 llvm::FunctionType::ParameterAttributes ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001272 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001273 int64_t SInt64Val;
1274 uint64_t UInt64Val;
1275 int SIntVal;
1276 unsigned UIntVal;
1277 double FPVal;
1278 bool BoolVal;
1279
1280 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001281 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001282
Reid Spencera132e042006-12-03 05:46:11 +00001283 llvm::Instruction::BinaryOps BinaryOpVal;
1284 llvm::Instruction::TermOps TermOpVal;
1285 llvm::Instruction::MemoryOps MemOpVal;
1286 llvm::Instruction::CastOps CastOpVal;
1287 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001288 llvm::ICmpInst::Predicate IPredicate;
1289 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner9d2fda62007-02-13 05:53:56 +00001290} YYSTYPE;
Reid Spencer38c91a92007-02-28 02:24:54 +00001291/* Line 196 of yacc.c. */
1292#line 1293 "llvmAsmParser.tab.c"
1293# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1294# define YYSTYPE_IS_DECLARED 1
1295# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001296#endif
1297
Reid Spencer41dff5e2007-01-26 08:05:27 +00001298
Reid Spencer68a24bd2005-08-27 18:50:39 +00001299
Reid Spencer38c91a92007-02-28 02:24:54 +00001300/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001301
1302
Reid Spencer38c91a92007-02-28 02:24:54 +00001303/* Line 219 of yacc.c. */
1304#line 1305 "llvmAsmParser.tab.c"
Reid Spencer41dff5e2007-01-26 08:05:27 +00001305
Reid Spencer38c91a92007-02-28 02:24:54 +00001306#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1307# define YYSIZE_T __SIZE_TYPE__
1308#endif
1309#if ! defined (YYSIZE_T) && defined (size_t)
1310# define YYSIZE_T size_t
1311#endif
1312#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1313# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1314# define YYSIZE_T size_t
1315#endif
1316#if ! defined (YYSIZE_T)
1317# define YYSIZE_T unsigned int
1318#endif
Chris Lattner9d2fda62007-02-13 05:53:56 +00001319
Reid Spencer38c91a92007-02-28 02:24:54 +00001320#ifndef YY_
1321# if YYENABLE_NLS
1322# if ENABLE_NLS
1323# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1324# define YY_(msgid) dgettext ("bison-runtime", msgid)
1325# endif
1326# endif
1327# ifndef YY_
1328# define YY_(msgid) msgid
1329# endif
1330#endif
1331
1332#if ! defined (yyoverflow) || YYERROR_VERBOSE
1333
1334/* The parser invokes alloca or malloc; define the necessary symbols. */
1335
1336# ifdef YYSTACK_USE_ALLOCA
1337# if YYSTACK_USE_ALLOCA
1338# ifdef __GNUC__
1339# define YYSTACK_ALLOC __builtin_alloca
1340# else
1341# define YYSTACK_ALLOC alloca
1342# if defined (__STDC__) || defined (__cplusplus)
1343# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1344# define YYINCLUDED_STDLIB_H
1345# endif
1346# endif
1347# endif
1348# endif
1349
1350# ifdef YYSTACK_ALLOC
1351 /* Pacify GCC's `empty if-body' warning. */
1352# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1353# ifndef YYSTACK_ALLOC_MAXIMUM
1354 /* The OS might guarantee only one guard page at the bottom of the stack,
1355 and a page size can be as small as 4096 bytes. So we cannot safely
1356 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1357 to allow for a few compiler-allocated temporary stack slots. */
1358# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1359# endif
1360# else
1361# define YYSTACK_ALLOC YYMALLOC
1362# define YYSTACK_FREE YYFREE
1363# ifndef YYSTACK_ALLOC_MAXIMUM
1364# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1365# endif
1366# ifdef __cplusplus
1367extern "C" {
1368# endif
1369# ifndef YYMALLOC
1370# define YYMALLOC malloc
1371# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1372 && (defined (__STDC__) || defined (__cplusplus)))
1373void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1374# endif
1375# endif
1376# ifndef YYFREE
1377# define YYFREE free
1378# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1379 && (defined (__STDC__) || defined (__cplusplus)))
1380void free (void *); /* INFRINGES ON USER NAME SPACE */
1381# endif
1382# endif
1383# ifdef __cplusplus
1384}
1385# endif
1386# endif
1387#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1388
1389
1390#if (! defined (yyoverflow) \
1391 && (! defined (__cplusplus) \
1392 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1393
1394/* A type that is properly aligned for any stack member. */
1395union yyalloc
1396{
1397 short int yyss;
1398 YYSTYPE yyvs;
1399 };
1400
1401/* The size of the maximum gap between one aligned stack and the next. */
1402# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1403
1404/* The size of an array large to enough to hold all stacks, each with
1405 N elements. */
1406# define YYSTACK_BYTES(N) \
1407 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1408 + YYSTACK_GAP_MAXIMUM)
1409
1410/* Copy COUNT objects from FROM to TO. The source and destination do
1411 not overlap. */
1412# ifndef YYCOPY
1413# if defined (__GNUC__) && 1 < __GNUC__
1414# define YYCOPY(To, From, Count) \
1415 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1416# else
1417# define YYCOPY(To, From, Count) \
1418 do \
1419 { \
1420 YYSIZE_T yyi; \
1421 for (yyi = 0; yyi < (Count); yyi++) \
1422 (To)[yyi] = (From)[yyi]; \
1423 } \
1424 while (0)
1425# endif
1426# endif
1427
1428/* Relocate STACK from its old location to the new one. The
1429 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1430 elements in the stack, and YYPTR gives the new location of the
1431 stack. Advance YYPTR to a properly aligned location for the next
1432 stack. */
1433# define YYSTACK_RELOCATE(Stack) \
1434 do \
1435 { \
1436 YYSIZE_T yynewbytes; \
1437 YYCOPY (&yyptr->Stack, Stack, yysize); \
1438 Stack = &yyptr->Stack; \
1439 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1440 yyptr += yynewbytes / sizeof (*yyptr); \
1441 } \
1442 while (0)
Chris Lattner9d2fda62007-02-13 05:53:56 +00001443
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001444#endif
1445
Reid Spencer38c91a92007-02-28 02:24:54 +00001446#if defined (__STDC__) || defined (__cplusplus)
1447 typedef signed char yysigned_char;
Reid Spencer5cbf9852007-01-30 20:08:39 +00001448#else
Reid Spencer38c91a92007-02-28 02:24:54 +00001449 typedef short int yysigned_char;
Reid Spencer5cbf9852007-01-30 20:08:39 +00001450#endif
1451
Reid Spencer38c91a92007-02-28 02:24:54 +00001452/* YYFINAL -- State number of the termination state. */
1453#define YYFINAL 40
1454/* YYLAST -- Last index in YYTABLE. */
1455#define YYLAST 1429
1456
1457/* YYNTOKENS -- Number of terminals. */
1458#define YYNTOKENS 148
1459/* YYNNTS -- Number of nonterminals. */
1460#define YYNNTS 78
1461/* YYNRULES -- Number of rules. */
1462#define YYNRULES 286
1463/* YYNRULES -- Number of states. */
1464#define YYNSTATES 559
1465
1466/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1467#define YYUNDEFTOK 2
1468#define YYMAXUTOK 388
1469
1470#define YYTRANSLATE(YYX) \
1471 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1472
1473/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1474static const unsigned char yytranslate[] =
1475{
1476 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1477 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1478 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1479 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1480 138, 139, 136, 2, 135, 2, 2, 2, 2, 2,
1481 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1482 143, 134, 144, 2, 2, 2, 2, 2, 2, 2,
1483 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1484 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1485 2, 140, 137, 142, 2, 2, 2, 2, 2, 147,
1486 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1487 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1488 141, 2, 2, 145, 2, 146, 2, 2, 2, 2,
1489 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1490 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1491 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1492 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1493 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1494 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1495 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1496 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1497 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1498 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1499 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1500 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1501 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1502 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1503 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1504 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1505 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1506 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1507 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1508 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1509 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1510 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1511 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1512 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1513 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1514 125, 126, 127, 128, 129, 130, 131, 132, 133
1515};
1516
1517#if YYDEBUG
1518/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1519 YYRHS. */
1520static const unsigned short int yyprhs[] =
1521{
1522 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1523 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1524 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1525 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
1526 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1527 99, 101, 103, 105, 107, 109, 111, 113, 115, 117,
1528 119, 121, 122, 125, 126, 128, 130, 133, 134, 136,
1529 138, 140, 142, 144, 146, 148, 150, 151, 153, 154,
1530 156, 158, 159, 161, 163, 165, 167, 168, 170, 172,
1531 174, 176, 178, 181, 183, 185, 187, 189, 190, 193,
1532 195, 197, 198, 201, 202, 205, 206, 210, 213, 214,
1533 216, 217, 221, 223, 226, 228, 230, 232, 234, 236,
1534 238, 241, 243, 246, 252, 258, 264, 270, 274, 277,
1535 283, 288, 291, 293, 295, 297, 301, 303, 307, 309,
1536 310, 312, 316, 321, 325, 329, 334, 339, 343, 350,
1537 356, 359, 362, 365, 368, 371, 374, 377, 380, 383,
1538 386, 389, 392, 399, 405, 414, 421, 428, 436, 444,
1539 451, 460, 469, 473, 475, 477, 479, 481, 482, 484,
1540 487, 488, 492, 493, 497, 501, 503, 507, 511, 512,
1541 519, 520, 528, 529, 537, 540, 544, 546, 550, 554,
1542 558, 562, 564, 565, 571, 575, 577, 581, 583, 584,
1543 594, 596, 598, 603, 605, 607, 610, 614, 615, 617,
1544 619, 621, 623, 625, 627, 629, 631, 633, 637, 639,
1545 645, 647, 649, 651, 653, 655, 657, 660, 663, 666,
1546 670, 673, 674, 676, 679, 682, 686, 696, 706, 715,
1547 730, 732, 734, 741, 747, 750, 757, 765, 769, 775,
1548 776, 777, 781, 784, 786, 792, 798, 805, 812, 817,
1549 824, 829, 834, 841, 848, 851, 860, 862, 864, 865,
1550 869, 876, 880, 887, 890, 895, 902
1551};
1552
1553/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1554static const short int yyrhs[] =
1555{
1556 188, 0, -1, 68, -1, 69, -1, 70, -1, 71,
1557 -1, 72, -1, 73, -1, 74, -1, 75, -1, 76,
1558 -1, 80, -1, 81, -1, 82, -1, 77, -1, 78,
1559 -1, 79, -1, 111, -1, 112, -1, 113, -1, 114,
1560 -1, 115, -1, 116, -1, 117, -1, 118, -1, 119,
1561 -1, 120, -1, 121, -1, 122, -1, 85, -1, 86,
1562 -1, 87, -1, 88, -1, 89, -1, 90, -1, 91,
1563 -1, 92, -1, 93, -1, 94, -1, 95, -1, 96,
1564 -1, 97, -1, 98, -1, 99, -1, 100, -1, 101,
1565 -1, 102, -1, 103, -1, 104, -1, 91, -1, 92,
1566 -1, 93, -1, 94, -1, 23, -1, 24, -1, 11,
1567 -1, 12, -1, 13, -1, 16, -1, 19, -1, 156,
1568 -1, -1, 156, 134, -1, -1, 17, -1, 20, -1,
1569 159, 134, -1, -1, 37, -1, 39, -1, 38, -1,
1570 40, -1, 42, -1, 41, -1, 43, -1, 45, -1,
1571 -1, 133, -1, -1, 41, -1, 43, -1, -1, 37,
1572 -1, 38, -1, 39, -1, 42, -1, -1, 56, -1,
1573 57, -1, 58, -1, 59, -1, 60, -1, 55, 4,
1574 -1, 112, -1, 113, -1, 130, -1, 131, -1, -1,
1575 168, 167, -1, 129, -1, 167, -1, -1, 170, 169,
1576 -1, -1, 48, 4, -1, -1, 135, 48, 4, -1,
1577 31, 19, -1, -1, 173, -1, -1, 135, 176, 175,
1578 -1, 173, -1, 48, 4, -1, 11, -1, 12, -1,
1579 13, -1, 14, -1, 44, -1, 177, -1, 178, 136,
1580 -1, 210, -1, 137, 4, -1, 178, 138, 182, 139,
1581 170, -1, 10, 138, 182, 139, 170, -1, 140, 4,
1582 141, 178, 142, -1, 143, 4, 141, 178, 144, -1,
1583 145, 183, 146, -1, 145, 146, -1, 143, 145, 183,
1584 146, 144, -1, 143, 145, 146, 144, -1, 178, 168,
1585 -1, 178, -1, 10, -1, 179, -1, 181, 135, 179,
1586 -1, 181, -1, 181, 135, 34, -1, 34, -1, -1,
1587 178, -1, 183, 135, 178, -1, 178, 140, 186, 142,
1588 -1, 178, 140, 142, -1, 178, 147, 19, -1, 178,
1589 143, 186, 144, -1, 178, 145, 186, 146, -1, 178,
1590 145, 146, -1, 178, 143, 145, 186, 146, 144, -1,
1591 178, 143, 145, 146, 144, -1, 178, 35, -1, 178,
1592 36, -1, 178, 210, -1, 178, 185, -1, 178, 22,
1593 -1, 154, 3, -1, 154, 5, -1, 154, 4, -1,
1594 154, 6, -1, 11, 23, -1, 11, 24, -1, 155,
1595 9, -1, 151, 138, 184, 33, 178, 139, -1, 110,
1596 138, 184, 221, 139, -1, 124, 138, 184, 135, 184,
1597 135, 184, 139, -1, 149, 138, 184, 135, 184, 139,
1598 -1, 150, 138, 184, 135, 184, 139, -1, 83, 152,
1599 138, 184, 135, 184, 139, -1, 84, 153, 138, 184,
1600 135, 184, 139, -1, 126, 138, 184, 135, 184, 139,
1601 -1, 127, 138, 184, 135, 184, 135, 184, 139, -1,
1602 128, 138, 184, 135, 184, 135, 184, 139, -1, 186,
1603 135, 184, -1, 184, -1, 29, -1, 30, -1, 189,
1604 -1, -1, 190, -1, 189, 190, -1, -1, 28, 191,
1605 206, -1, -1, 27, 192, 207, -1, 53, 52, 196,
1606 -1, 21, -1, 158, 15, 178, -1, 158, 15, 10,
1607 -1, -1, 160, 163, 187, 184, 193, 175, -1, -1,
1608 160, 161, 163, 187, 184, 194, 175, -1, -1, 160,
1609 162, 163, 187, 178, 195, 175, -1, 46, 197, -1,
1610 49, 134, 198, -1, 19, -1, 47, 134, 19, -1,
1611 61, 134, 19, -1, 140, 199, 142, -1, 199, 135,
1612 19, -1, 19, -1, -1, 200, 135, 178, 168, 157,
1613 -1, 178, 168, 157, -1, 200, -1, 200, 135, 34,
1614 -1, 34, -1, -1, 166, 180, 159, 138, 201, 139,
1615 170, 174, 171, -1, 25, -1, 145, -1, 165, 163,
1616 202, 203, -1, 26, -1, 146, -1, 213, 205, -1,
1617 164, 163, 202, -1, -1, 54, -1, 3, -1, 4,
1618 -1, 9, -1, 23, -1, 24, -1, 35, -1, 36,
1619 -1, 22, -1, 143, 186, 144, -1, 185, -1, 52,
1620 208, 19, 135, 19, -1, 7, -1, 8, -1, 156,
1621 -1, 159, -1, 210, -1, 209, -1, 178, 211, -1,
1622 213, 214, -1, 204, 214, -1, 215, 158, 216, -1,
1623 215, 218, -1, -1, 18, -1, 62, 212, -1, 62,
1624 10, -1, 63, 14, 211, -1, 63, 11, 211, 135,
1625 14, 211, 135, 14, 211, -1, 64, 154, 211, 135,
1626 14, 211, 140, 217, 142, -1, 64, 154, 211, 135,
1627 14, 211, 140, 142, -1, 65, 166, 180, 211, 138,
1628 220, 139, 170, 33, 14, 211, 66, 14, 211, -1,
1629 66, -1, 67, -1, 217, 154, 209, 135, 14, 211,
1630 -1, 154, 209, 135, 14, 211, -1, 158, 223, -1,
1631 178, 140, 211, 135, 211, 142, -1, 219, 135, 140,
1632 211, 135, 211, 142, -1, 178, 211, 168, -1, 220,
1633 135, 178, 211, 168, -1, -1, -1, 221, 135, 212,
1634 -1, 51, 50, -1, 50, -1, 149, 178, 211, 135,
1635 211, -1, 150, 178, 211, 135, 211, -1, 83, 152,
1636 178, 211, 135, 211, -1, 84, 153, 178, 211, 135,
1637 211, -1, 151, 212, 33, 178, -1, 124, 212, 135,
1638 212, 135, 212, -1, 125, 212, 135, 178, -1, 126,
1639 212, 135, 212, -1, 127, 212, 135, 212, 135, 212,
1640 -1, 128, 212, 135, 212, 135, 212, -1, 123, 219,
1641 -1, 222, 166, 180, 211, 138, 220, 139, 170, -1,
1642 225, -1, 32, -1, -1, 105, 178, 172, -1, 105,
1643 178, 135, 11, 211, 172, -1, 106, 178, 172, -1,
1644 106, 178, 135, 11, 211, 172, -1, 107, 212, -1,
1645 224, 108, 178, 211, -1, 224, 109, 212, 135, 178,
1646 211, -1, 110, 178, 211, 221, -1
1647};
1648
1649/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1650static const unsigned short int yyrline[] =
1651{
1652 0, 1055, 1055, 1055, 1055, 1055, 1055, 1055, 1055, 1055,
1653 1055, 1056, 1056, 1056, 1056, 1056, 1056, 1057, 1057, 1057,
1654 1057, 1057, 1057, 1058, 1058, 1058, 1058, 1058, 1058, 1061,
1655 1061, 1062, 1062, 1063, 1063, 1064, 1064, 1065, 1065, 1069,
1656 1069, 1070, 1070, 1071, 1071, 1072, 1072, 1073, 1073, 1074,
1657 1074, 1075, 1075, 1076, 1077, 1082, 1083, 1083, 1085, 1085,
1658 1086, 1086, 1090, 1094, 1099, 1099, 1101, 1105, 1111, 1112,
1659 1113, 1114, 1115, 1119, 1120, 1121, 1125, 1126, 1130, 1131,
1660 1132, 1136, 1137, 1138, 1139, 1140, 1143, 1144, 1145, 1146,
1661 1147, 1148, 1149, 1156, 1157, 1158, 1159, 1162, 1163, 1168,
1662 1169, 1172, 1173, 1180, 1181, 1187, 1188, 1196, 1204, 1205,
1663 1210, 1211, 1212, 1217, 1230, 1230, 1230, 1230, 1233, 1237,
1664 1241, 1248, 1253, 1261, 1279, 1297, 1302, 1314, 1324, 1328,
1665 1338, 1345, 1352, 1359, 1364, 1369, 1376, 1377, 1384, 1391,
1666 1399, 1404, 1415, 1443, 1459, 1488, 1516, 1541, 1560, 1586,
Reid Spencer10794272007-03-01 19:41:47 +00001667 1606, 1618, 1625, 1691, 1701, 1711, 1720, 1730, 1738, 1748,
1668 1753, 1758, 1766, 1778, 1800, 1808, 1814, 1825, 1830, 1835,
1669 1841, 1847, 1856, 1860, 1868, 1868, 1879, 1884, 1892, 1893,
1670 1897, 1897, 1901, 1901, 1904, 1907, 1919, 1943, 1954, 1954,
1671 1964, 1964, 1972, 1972, 1982, 1985, 1991, 2004, 2008, 2013,
1672 2015, 2020, 2025, 2034, 2044, 2055, 2059, 2068, 2077, 2082,
1673 2194, 2194, 2196, 2205, 2205, 2207, 2212, 2224, 2228, 2233,
1674 2237, 2241, 2245, 2249, 2253, 2257, 2261, 2265, 2290, 2294,
1675 2308, 2312, 2316, 2320, 2326, 2326, 2332, 2341, 2345, 2354,
1676 2364, 2373, 2385, 2398, 2402, 2406, 2411, 2421, 2440, 2449,
1677 2516, 2520, 2527, 2538, 2551, 2561, 2572, 2582, 2590, 2598,
1678 2601, 2602, 2609, 2613, 2618, 2639, 2656, 2669, 2682, 2694,
1679 2702, 2709, 2715, 2721, 2727, 2742, 2806, 2811, 2815, 2822,
1680 2829, 2837, 2844, 2852, 2860, 2874, 2891
Reid Spencer38c91a92007-02-28 02:24:54 +00001681};
1682#endif
1683
1684#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1685/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1686 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1687static const char *const yytname[] =
1688{
1689 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL",
1690 "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE",
1691 "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR",
1692 "STRINGCONSTANT", "ATSTRINGCONSTANT", "IMPLEMENTATION",
1693 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1694 "DECLARE", "DEFINE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1695 "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK",
1696 "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1697 "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL",
1698 "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK",
1699 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1700 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1701 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1702 "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT",
1703 "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT",
1704 "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE",
1705 "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC",
1706 "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR",
1707 "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT",
1708 "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET", "DEFAULT",
1709 "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'",
1710 "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps",
1711 "LogicalOps", "CastOps", "IPredicates", "FPredicates", "IntType",
1712 "FPType", "LocalName", "OptLocalName", "OptLocalAssign", "GlobalName",
1713 "OptGlobalAssign", "GVInternalLinkage", "GVExternalLinkage",
1714 "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage",
1715 "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr",
1716 "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString", "OptSection",
1717 "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types",
1718 "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI",
1719 "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "Module",
1720 "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock",
1721 "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH",
1722 "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END",
1723 "Function", "FunctionProto", "OptSideEffect", "ConstValueRef",
1724 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1725 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1726 "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal",
1727 "OptVolatile", "MemoryInst", 0
1728};
1729#endif
1730
1731# ifdef YYPRINT
1732/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1733 token YYLEX-NUM. */
1734static const unsigned short int yytoknum[] =
1735{
1736 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1737 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1738 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1739 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1740 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1741 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1742 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1743 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1744 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1745 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1746 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1747 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1748 375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1749 385, 386, 387, 388, 61, 44, 42, 92, 40, 41,
1750 91, 120, 93, 60, 62, 123, 125, 99
1751};
1752# endif
1753
1754/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1755static const unsigned char yyr1[] =
1756{
1757 0, 148, 149, 149, 149, 149, 149, 149, 149, 149,
1758 149, 150, 150, 150, 150, 150, 150, 151, 151, 151,
1759 151, 151, 151, 151, 151, 151, 151, 151, 151, 152,
1760 152, 152, 152, 152, 152, 152, 152, 152, 152, 153,
1761 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
1762 153, 153, 153, 153, 153, 154, 155, 155, 156, 156,
1763 157, 157, 158, 158, 159, 159, 160, 160, 161, 161,
1764 161, 161, 161, 162, 162, 162, 163, 163, 164, 164,
1765 164, 165, 165, 165, 165, 165, 166, 166, 166, 166,
1766 166, 166, 166, 167, 167, 167, 167, 168, 168, 169,
1767 169, 170, 170, 171, 171, 172, 172, 173, 174, 174,
1768 175, 175, 176, 176, 177, 177, 177, 177, 178, 178,
1769 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
1770 178, 179, 180, 180, 181, 181, 182, 182, 182, 182,
1771 183, 183, 184, 184, 184, 184, 184, 184, 184, 184,
1772 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
1773 184, 184, 185, 185, 185, 185, 185, 185, 185, 185,
1774 185, 185, 186, 186, 187, 187, 188, 188, 189, 189,
1775 191, 190, 192, 190, 190, 190, 190, 190, 193, 190,
1776 194, 190, 195, 190, 190, 190, 196, 197, 197, 198,
1777 199, 199, 199, 200, 200, 201, 201, 201, 201, 202,
1778 203, 203, 204, 205, 205, 206, 207, 208, 208, 209,
1779 209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
1780 210, 210, 210, 210, 211, 211, 212, 213, 213, 214,
1781 215, 215, 215, 216, 216, 216, 216, 216, 216, 216,
1782 216, 216, 217, 217, 218, 219, 219, 220, 220, 220,
1783 221, 221, 222, 222, 223, 223, 223, 223, 223, 223,
1784 223, 223, 223, 223, 223, 223, 223, 224, 224, 225,
1785 225, 225, 225, 225, 225, 225, 225
1786};
1787
1788/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1789static const unsigned char yyr2[] =
1790{
1791 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1792 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1793 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1794 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1795 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1796 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1797 1, 0, 2, 0, 1, 1, 2, 0, 1, 1,
1798 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
1799 1, 0, 1, 1, 1, 1, 0, 1, 1, 1,
1800 1, 1, 2, 1, 1, 1, 1, 0, 2, 1,
1801 1, 0, 2, 0, 2, 0, 3, 2, 0, 1,
1802 0, 3, 1, 2, 1, 1, 1, 1, 1, 1,
1803 2, 1, 2, 5, 5, 5, 5, 3, 2, 5,
1804 4, 2, 1, 1, 1, 3, 1, 3, 1, 0,
1805 1, 3, 4, 3, 3, 4, 4, 3, 6, 5,
1806 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1807 2, 2, 6, 5, 8, 6, 6, 7, 7, 6,
1808 8, 8, 3, 1, 1, 1, 1, 0, 1, 2,
1809 0, 3, 0, 3, 3, 1, 3, 3, 0, 6,
1810 0, 7, 0, 7, 2, 3, 1, 3, 3, 3,
1811 3, 1, 0, 5, 3, 1, 3, 1, 0, 9,
1812 1, 1, 4, 1, 1, 2, 3, 0, 1, 1,
1813 1, 1, 1, 1, 1, 1, 1, 3, 1, 5,
1814 1, 1, 1, 1, 1, 1, 2, 2, 2, 3,
1815 2, 0, 1, 2, 2, 3, 9, 9, 8, 14,
1816 1, 1, 6, 5, 2, 6, 7, 3, 5, 0,
1817 0, 3, 2, 1, 5, 5, 6, 6, 4, 6,
1818 4, 4, 6, 6, 2, 8, 1, 1, 0, 3,
1819 6, 3, 6, 2, 4, 6, 4
1820};
1821
1822/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1823 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1824 means the default is an error. */
1825static const unsigned short int yydefact[] =
1826{
1827 67, 58, 64, 59, 65, 185, 182, 180, 0, 0,
1828 0, 0, 0, 0, 76, 0, 67, 178, 78, 81,
1829 0, 0, 194, 0, 0, 62, 0, 66, 68, 70,
1830 69, 71, 73, 72, 74, 75, 77, 76, 76, 0,
1831 1, 179, 79, 80, 76, 183, 82, 83, 84, 85,
1832 76, 241, 181, 241, 0, 0, 202, 195, 196, 184,
1833 230, 231, 187, 114, 115, 116, 117, 118, 0, 0,
1834 0, 0, 232, 233, 119, 186, 121, 0, 0, 174,
1835 175, 0, 86, 86, 242, 238, 63, 213, 214, 215,
1836 237, 197, 198, 201, 0, 139, 122, 0, 0, 0,
1837 0, 128, 140, 0, 120, 139, 0, 0, 114, 115,
1838 116, 0, 0, 0, 188, 0, 87, 88, 89, 90,
1839 91, 0, 216, 0, 278, 240, 0, 199, 138, 97,
1840 134, 136, 0, 0, 0, 0, 0, 0, 127, 0,
1841 190, 192, 159, 160, 155, 157, 156, 158, 161, 154,
1842 150, 151, 2, 3, 4, 5, 6, 7, 8, 9,
1843 10, 14, 15, 16, 11, 12, 13, 0, 0, 0,
1844 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1845 27, 28, 0, 0, 0, 0, 0, 0, 0, 0,
1846 0, 0, 0, 153, 152, 110, 92, 133, 132, 0,
1847 210, 211, 212, 277, 263, 0, 0, 0, 0, 86,
1848 250, 251, 0, 0, 0, 0, 0, 0, 0, 0,
1849 0, 0, 0, 0, 0, 0, 0, 239, 86, 254,
1850 0, 276, 200, 131, 0, 101, 0, 0, 130, 0,
1851 141, 101, 110, 110, 29, 30, 31, 32, 33, 34,
1852 35, 36, 37, 38, 0, 53, 54, 49, 50, 51,
1853 52, 39, 40, 41, 42, 43, 44, 45, 46, 47,
1854 48, 0, 0, 0, 0, 0, 0, 143, 173, 0,
1855 0, 0, 147, 0, 144, 0, 0, 0, 0, 189,
1856 0, 262, 244, 0, 243, 0, 0, 55, 0, 0,
1857 0, 0, 105, 105, 283, 0, 0, 274, 0, 0,
1858 0, 0, 0, 0, 0, 0, 0, 0, 0, 93,
1859 94, 95, 96, 98, 137, 135, 124, 125, 126, 129,
1860 123, 191, 193, 0, 0, 260, 0, 0, 0, 0,
1861 0, 142, 128, 140, 0, 145, 146, 0, 0, 0,
1862 0, 0, 112, 110, 208, 219, 220, 221, 226, 222,
1863 223, 224, 225, 217, 0, 228, 235, 234, 236, 0,
1864 245, 0, 0, 0, 0, 0, 279, 0, 281, 260,
1865 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1866 0, 0, 0, 99, 100, 102, 0, 0, 0, 0,
1867 0, 0, 0, 172, 149, 0, 0, 0, 0, 107,
1868 113, 111, 207, 97, 205, 0, 218, 0, 0, 0,
1869 0, 0, 0, 0, 0, 0, 0, 286, 0, 0,
1870 0, 270, 271, 0, 0, 0, 0, 268, 0, 284,
1871 0, 0, 0, 0, 163, 0, 0, 0, 0, 148,
1872 0, 0, 0, 61, 0, 101, 0, 227, 0, 0,
1873 259, 0, 0, 105, 106, 105, 0, 0, 0, 0,
1874 0, 264, 265, 259, 0, 0, 0, 261, 0, 169,
1875 0, 0, 165, 166, 162, 60, 204, 206, 97, 108,
1876 0, 0, 0, 0, 0, 266, 267, 0, 280, 282,
1877 0, 0, 269, 272, 273, 0, 285, 167, 168, 0,
1878 0, 0, 61, 109, 103, 229, 0, 0, 97, 0,
1879 101, 255, 0, 101, 164, 170, 171, 203, 0, 209,
1880 0, 248, 0, 0, 257, 0, 0, 256, 275, 104,
1881 246, 0, 247, 0, 97, 0, 0, 0, 258, 0,
1882 0, 0, 0, 253, 0, 0, 252, 0, 249
1883};
1884
1885/* YYDEFGOTO[NTERM-NUM]. */
1886static const short int yydefgoto[] =
1887{
1888 -1, 190, 191, 192, 254, 271, 111, 112, 72, 486,
1889 12, 73, 14, 37, 38, 39, 44, 50, 121, 323,
1890 233, 395, 326, 529, 376, 352, 514, 289, 353, 74,
1891 113, 130, 199, 131, 132, 103, 278, 365, 279, 81,
1892 15, 16, 17, 19, 18, 195, 242, 243, 59, 22,
1893 57, 94, 414, 415, 122, 202, 51, 89, 52, 45,
1894 417, 366, 76, 368, 294, 53, 85, 86, 227, 533,
1895 125, 307, 494, 398, 228, 229, 230, 231
1896};
1897
1898/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1899 STATE-NUM. */
1900#define YYPACT_NINF -440
1901static const short int yypact[] =
1902{
1903 406, -440, -440, -440, -440, -440, -440, -440, -2, -101,
1904 21, -55, 80, -20, 15, 132, 556, -440, 253, 197,
1905 -7, 87, -440, 20, 207, -440, 893, -440, -440, -440,
1906 -440, -440, -440, -440, -440, -440, -440, 97, 97, 125,
1907 -440, -440, -440, -440, 97, -440, -440, -440, -440, -440,
1908 97, 235, -440, 6, 240, 248, 258, -440, -440, -440,
1909 -440, -440, 134, -440, -440, -440, -440, -440, 269, 277,
1910 11, 123, -440, -440, -440, 33, -440, 125, 125, -440,
1911 -440, 1055, 128, 128, -440, -440, 47, -440, -440, -440,
1912 -440, -440, -440, -440, -57, 939, -440, 154, 156, 488,
1913 134, -440, 33, -112, -440, 939, 1055, 1149, 38, 281,
1914 289, 239, 293, 850, -440, 299, -440, -440, -440, -440,
1915 -440, 1168, -440, 2, 1301, -440, 285, -440, -440, 33,
1916 -440, 170, 167, 1149, 1149, 164, -97, 1149, -440, 171,
1917 -440, 33, -440, -440, -440, -440, -440, -440, -440, -440,
1918 -440, -440, -440, -440, -440, -440, -440, -440, -440, -440,
1919 -440, -440, -440, -440, -440, -440, -440, 254, 446, 174,
1920 -440, -440, -440, -440, -440, -440, -440, -440, -440, -440,
1921 -440, -440, 175, 176, 177, 178, 109, 1203, 676, 290,
1922 181, 182, 183, -440, -440, 187, -440, 134, 33, 93,
1923 -440, -440, -440, -440, -440, 273, 1217, 127, 313, 128,
1924 -440, -440, 254, 446, 1149, 1149, 1149, 1149, 1149, 1149,
1925 1149, 1149, 1149, 1149, 1149, 1149, 1149, -440, 128, -440,
1926 70, -440, -440, -29, 1098, -440, 72, -39, -440, 184,
1927 33, -440, 187, 187, -440, -440, -440, -440, -440, -440,
1928 -440, -440, -440, -440, 188, -440, -440, -440, -440, -440,
1929 -440, -440, -440, -440, -440, -440, -440, -440, -440, -440,
1930 -440, 196, 1055, 1055, 1055, 1055, 1055, -440, -440, 22,
1931 771, -44, -440, -59, -440, 1055, 1055, 1055, -9, -440,
1932 198, -440, 134, 591, -440, 728, 728, -440, 728, 1168,
1933 1149, 1149, 112, 147, -440, 591, 75, 190, 200, 214,
1934 215, 217, 219, 591, 591, 322, 1168, 1149, 1149, -440,
1935 -440, -440, -440, -440, -440, -440, -41, -440, -440, -440,
1936 -41, -440, -440, 1055, 1055, -440, 230, 231, 232, 233,
1937 1055, -440, 225, 850, -43, -440, -440, 236, 241, 337,
1938 355, 371, -440, 187, 1114, -440, -440, -440, -440, -440,
1939 -440, -440, -440, 323, 1055, -440, -440, -440, -440, 243,
1940 -440, 244, 728, 591, 591, 17, -440, 19, -440, -440,
1941 728, 242, 1149, 1149, 1149, 1149, 1149, 245, 246, 1149,
1942 728, 591, 249, -440, -440, -440, 252, 255, -24, 1055,
1943 1055, 1055, 1055, -440, -440, 247, 1055, 1055, 1149, -440,
1944 -440, -440, -440, 33, 257, 260, -440, 375, -37, 383,
1945 386, 264, 268, 272, 728, 400, 728, 275, 282, 728,
1946 284, 33, -440, 295, 296, 728, 728, 33, 270, -440,
1947 1149, 1055, 1055, 1149, -440, 297, 298, 301, 303, -440,
1948 300, 302, 150, 32, 1133, -440, 305, -440, 728, 728,
1949 1149, 728, 728, 307, -440, 307, 728, 311, 1149, 1149,
1950 1149, -440, -440, 1149, 591, 308, 310, -440, 1055, -440,
1951 1055, 1055, -440, -440, -440, -440, -440, -440, 33, 46,
1952 397, 315, 314, 591, 26, -440, -440, 376, -440, -440,
1953 309, 728, -440, -440, -440, 89, -440, -440, -440, 317,
1954 319, 321, 32, -440, 413, -440, 449, 7, -440, 1149,
1955 -440, -440, 324, -440, -440, -440, -440, -440, 460, -440,
1956 728, -440, 976, 9, -29, 591, 149, -440, -41, -440,
1957 -440, 330, -440, 976, -440, 453, 454, 336, -29, 728,
1958 728, 461, 412, -440, 728, 465, -440, 728, -440
1959};
1960
1961/* YYPGOTO[NTERM-NUM]. */
1962static const short int yypgoto[] =
1963{
1964 -440, 358, 359, 361, 274, 276, -206, -440, 0, -19,
1965 401, 13, -440, -440, -440, 31, -440, -440, -178, -309,
1966 -394, -440, -236, -440, -297, -1, -440, -207, -440, -440,
1967 -25, 263, -252, -440, 387, 404, -69, -110, -162, 160,
1968 -440, -440, 490, -440, -440, -440, -440, -440, -440, -440,
1969 -440, -440, -440, -440, 426, -440, -440, -440, -440, -440,
1970 -440, -439, -73, 100, -212, -440, 457, -440, -440, -440,
1971 -440, -440, 40, 135, -440, -440, -440, -440
1972};
1973
1974/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1975 positive, shift that token. If negative, reduce the rule which
1976 number is the opposite. If zero, do what YYDEFACT says.
1977 If YYTABLE_NINF, syntax error. */
1978#define YYTABLE_NINF -178
1979static const short int yytable[] =
1980{
1981 11, 75, 298, 193, 304, 330, 378, 308, 309, 310,
1982 311, 312, 114, 13, 315, 98, 11, 394, 297, 453,
1983 297, 394, 350, 137, 84, 281, 283, 200, 424, 13,
1984 426, 299, 87, 23, 138, 331, 332, 140, 137, 351,
1985 194, -55, -55, -55, -55, 20, 102, 372, 1, 239,
1986 316, 3, 28, 29, 30, 31, 32, 33, 34, 21,
1987 35, 142, 143, 1, 390, 425, 3, 425, 77, 78,
1988 129, 319, 320, 24, 102, 82, 340, 350, 126, 25,
1989 129, 83, 141, 319, 320, 127, 11, 346, 393, 321,
1990 322, 340, 340, 541, 512, 26, 198, 104, 340, 105,
1991 345, 321, 322, 405, 547, 328, 392, 457, 236, 237,
1992 2, 443, 240, 4, 27, 444, 60, 61, 344, 100,
1993 108, 109, 110, 66, 534, 1, 2, 54, 3, 4,
1994 60, 61, 40, 100, 63, 64, 65, 66, 295, 1,
1995 2, 296, 3, 4, 319, 320, 411, 201, 36, 531,
1996 548, 542, 88, 67, 79, 80, 99, 340, 319, 320,
1997 56, 519, 321, 322, 341, 520, 498, 67, 499, 104,
1998 430, 105, 432, 433, 434, 393, 321, 322, 317, 318,
1999 394, 293, 545, 115, 116, 117, 118, 119, 120, 302,
2000 303, 293, 305, 306, 293, 293, 293, 293, 293, 313,
2001 314, 293, 418, 335, 336, 337, 338, 339, 104, 129,
2002 105, 104, 290, 105, 327, 380, 347, 348, 349, 489,
2003 367, 55, 367, 367, 519, 367, 58, 394, 523, 394,
2004 36, 477, 367, 193, 46, 47, 48, 106, 107, 49,
2005 367, 367, 144, 145, 146, 147, 68, 375, 104, 69,
2006 105, 277, 70, 84, 71, 343, 502, 503, 504, 91,
2007 68, 319, 320, 69, 396, 397, 70, 92, 71, 101,
2008 194, 403, 95, 96, 198, 373, 374, 93, 393, 321,
2009 322, 97, 377, 104, 536, 105, 104, 538, 105, 484,
2010 -56, 198, 391, 293, 42, 133, 43, 134, -57, 367,
2011 367, 367, 148, 196, 232, 234, 235, 367, 238, 284,
2012 241, 532, 272, 273, 274, 275, 276, 367, 367, 285,
2013 286, 287, 288, 291, 297, 381, 333, 543, 329, 413,
2014 445, 446, 447, 448, 334, 382, 354, 450, 451, 244,
2015 245, 246, 247, 248, 249, 250, 251, 252, 253, 383,
2016 384, 367, 385, 367, 386, 389, 367, 293, 431, 293,
2017 293, 293, 367, 367, 437, 399, 400, 401, 402, 404,
2018 408, 406, 475, 476, 409, 410, 407, 416, 419, 420,
2019 435, 436, 429, 452, 440, 367, 367, 441, 367, 367,
2020 442, 449, 454, 367, 456, 369, 370, 458, 371, 455,
2021 459, 367, 460, 461, 464, 379, -177, 462, 473, 509,
2022 443, 510, 511, 387, 388, 474, 515, 466, 293, 468,
2023 367, -63, 1, 2, 425, 3, 4, 5, 367, 488,
2024 469, 470, 478, 6, 7, 493, 480, 479, 481, 482,
2025 490, 483, 497, 293, 293, 293, 501, 507, 493, 508,
2026 516, 521, 8, 485, 517, 9, 524, 367, 525, 10,
2027 526, 528, 367, 530, 539, 546, 537, 549, 550, 255,
2028 256, 551, 421, 422, 423, 554, 367, 367, 555, 557,
2029 428, 367, 224, 225, 367, 226, 300, 124, 513, 301,
2030 438, 439, 139, 527, 535, 60, 61, 325, 100, 63,
2031 64, 65, 66, 136, 1, 2, 41, 3, 4, 123,
2032 90, 0, 485, 505, 427, 0, 0, 0, 0, 0,
2033 0, 0, 0, 0, 463, 0, 465, 0, 0, 467,
2034 0, 0, 67, 0, 0, 471, 472, 257, 258, 259,
2035 260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
2036 270, 0, 0, 0, 0, 0, -176, 0, 491, 492,
2037 0, 495, 496, 0, 0, 0, 500, 0, 0, 0,
2038 0, -63, 1, 2, 506, 3, 4, 5, 0, 0,
2039 0, 0, 0, 6, 7, 0, 0, 0, 0, 0,
2040 0, 0, 0, 518, 355, 356, 0, 0, 60, 61,
2041 357, 522, 8, 0, 0, 9, 0, 1, 2, 10,
2042 3, 4, 0, 358, 359, 360, 0, 0, 0, 0,
2043 0, 0, 0, 0, 0, 68, 361, 362, 69, 0,
2044 540, 70, 0, 71, 135, 544, 0, 0, 0, 0,
2045 0, 0, 0, 363, 0, 0, 0, 0, 0, 552,
2046 553, 0, 0, 0, 556, 0, 0, 558, 0, 152,
2047 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
2048 163, 164, 165, 166, 167, 168, 0, 0, 0, 0,
2049 0, 0, 0, 60, 61, 0, 100, 108, 109, 110,
2050 66, 0, 1, 2, 0, 3, 4, 0, 0, 0,
2051 0, 169, 170, 171, 172, 173, 174, 175, 176, 177,
2052 178, 179, 180, 181, 0, 182, 0, 183, 184, 185,
2053 67, 0, 0, 0, 0, 0, 0, 104, 0, 105,
2054 0, 355, 356, 0, 364, 60, 61, 357, 0, 0,
2055 0, 0, 0, 0, 1, 2, 0, 3, 4, 0,
2056 358, 359, 360, 0, 0, 0, 0, 0, 0, 0,
2057 0, 0, 0, 361, 362, 0, 0, 0, 0, 0,
2058 0, 0, 0, 0, 0, 0, 0, 0, 60, 61,
2059 363, 100, 108, 109, 110, 66, 0, 1, 2, 0,
2060 3, 4, 0, 0, 0, 0, 152, 153, 154, 155,
2061 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
2062 166, 167, 168, 68, 0, 67, 69, 0, 0, 70,
2063 0, 71, 282, 0, 0, 0, 0, 0, 0, 0,
2064 0, 0, 0, 0, 0, 0, 0, 0, 169, 170,
2065 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
2066 181, 0, 182, 0, 183, 184, 185, 60, 61, 0,
2067 0, 0, 0, 0, 0, 0, 1, 2, 0, 3,
2068 4, 364, 149, 0, 0, 0, 0, 0, 0, 0,
2069 0, 0, 0, 0, 0, 150, 151, 0, 0, 0,
2070 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2071 60, 61, 0, 62, 63, 64, 65, 66, 68, 1,
2072 2, 69, 3, 4, 70, 0, 71, 342, 152, 153,
2073 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
2074 164, 165, 166, 167, 168, 0, 0, 67, 0, 0,
2075 0, 0, 0, 0, 0, 0, 60, 61, 0, 100,
2076 63, 64, 65, 66, 0, 1, 2, 0, 3, 4,
2077 169, 170, 171, 172, 173, 174, 175, 176, 177, 178,
2078 179, 180, 181, 128, 182, 0, 183, 184, 185, 355,
2079 356, 0, 0, 67, 0, 357, 104, 0, 105, 0,
2080 186, 0, 0, 187, 0, 188, 0, 189, 358, 359,
2081 360, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2082 0, 361, 362, 0, 0, 0, 0, 0, 0, 0,
2083 0, 0, 0, 0, 0, 0, 0, 0, 363, 0,
2084 68, 0, 0, 69, 0, 0, 70, 0, 71, 0,
2085 0, 0, 0, 0, 152, 153, 154, 155, 156, 157,
2086 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
2087 168, 0, 60, 61, 0, 100, 108, 109, 110, 66,
2088 0, 1, 2, 0, 3, 4, 68, 0, 0, 69,
2089 0, 0, 70, 0, 71, 0, 169, 170, 171, 172,
2090 173, 174, 175, 176, 177, 178, 179, 180, 181, 67,
2091 182, 0, 183, 184, 185, 60, 61, 0, 100, 63,
2092 64, 65, 66, 0, 1, 2, 0, 3, 4, 364,
2093 0, 60, 61, 0, 100, 63, 64, 65, 66, 0,
2094 1, 2, 324, 3, 4, 0, 0, 0, 0, 0,
2095 60, 61, 67, 100, 63, 64, 65, 66, 412, 1,
2096 2, 0, 3, 4, 0, 0, 60, 61, 67, 100,
2097 63, 64, 65, 66, 0, 1, 2, 487, 3, 4,
2098 0, 0, 0, 0, 0, 60, 61, 67, 197, 63,
2099 64, 65, 66, 0, 1, 2, 0, 3, 4, 0,
2100 0, 0, 68, 67, 0, 69, 0, 0, 70, 0,
2101 71, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2102 60, 61, 67, 100, 108, 109, 110, 66, 0, 1,
2103 2, 0, 3, 4, 60, 61, 0, 292, 63, 64,
2104 65, 66, 0, 1, 2, 68, 3, 4, 69, 0,
2105 0, 70, 0, 71, 0, 0, 0, 67, 0, 0,
2106 0, 68, 0, 0, 69, 0, 0, 70, 0, 71,
2107 0, 67, 0, 0, 0, 0, 0, 0, 0, 0,
2108 68, 0, 0, 69, 0, 0, 70, 0, 71, 0,
2109 0, 0, 0, 0, 0, 0, 68, 0, 0, 69,
2110 0, 0, 70, 0, 71, 0, 0, 0, 0, 0,
2111 0, 0, 0, 0, 0, 68, 0, 0, 69, 0,
2112 0, 70, 0, 71, 0, 0, 0, 0, 0, 0,
2113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2114 0, 0, 0, 203, 0, 0, 0, 0, 0, 0,
2115 68, 0, 0, 69, 0, 0, 70, 0, 280, 0,
2116 0, 204, 205, 0, 68, 0, 0, 69, 0, 0,
2117 70, 0, 71, 206, 207, 208, 209, 210, 211, 152,
2118 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
2119 163, 164, 165, 166, 212, 213, 0, 0, 0, 0,
2120 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2121 0, 0, 0, 0, 0, 0, 214, 215, 216, 0,
2122 0, 217, 170, 171, 172, 173, 174, 175, 176, 177,
2123 178, 179, 180, 181, 218, 219, 220, 221, 222, 223
2124};
2125
2126static const short int yycheck[] =
2127{
2128 0, 26, 208, 113, 216, 241, 303, 219, 220, 221,
2129 222, 223, 81, 0, 226, 4, 16, 326, 11, 413,
2130 11, 330, 31, 135, 18, 187, 188, 25, 11, 16,
2131 11, 209, 26, 134, 146, 242, 243, 106, 135, 48,
2132 113, 3, 4, 5, 6, 47, 71, 299, 16, 146,
2133 228, 19, 37, 38, 39, 40, 41, 42, 43, 61,
2134 45, 23, 24, 16, 316, 48, 19, 48, 37, 38,
2135 95, 112, 113, 52, 99, 44, 135, 31, 135, 134,
2136 105, 50, 107, 112, 113, 142, 86, 146, 129, 130,
2137 131, 135, 135, 532, 488, 15, 121, 136, 135, 138,
2138 144, 130, 131, 146, 543, 144, 318, 144, 133, 134,
2139 17, 135, 137, 20, 134, 139, 7, 8, 280, 10,
2140 11, 12, 13, 14, 518, 16, 17, 134, 19, 20,
2141 7, 8, 0, 10, 11, 12, 13, 14, 11, 16,
2142 17, 14, 19, 20, 112, 113, 353, 145, 133, 142,
2143 544, 142, 146, 44, 29, 30, 145, 135, 112, 113,
2144 140, 135, 130, 131, 142, 139, 463, 44, 465, 136,
2145 382, 138, 384, 385, 386, 129, 130, 131, 108, 109,
2146 489, 206, 33, 55, 56, 57, 58, 59, 60, 214,
2147 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
2148 225, 226, 364, 272, 273, 274, 275, 276, 136, 234,
2149 138, 136, 199, 138, 142, 140, 285, 286, 287, 455,
2150 293, 134, 295, 296, 135, 298, 19, 536, 139, 538,
2151 133, 443, 305, 343, 37, 38, 39, 77, 78, 42,
2152 313, 314, 3, 4, 5, 6, 137, 135, 136, 140,
2153 138, 142, 143, 18, 145, 280, 468, 469, 470, 19,
2154 137, 112, 113, 140, 333, 334, 143, 19, 145, 146,
2155 343, 340, 138, 4, 299, 300, 301, 19, 129, 130,
2156 131, 4, 135, 136, 520, 138, 136, 523, 138, 139,
2157 9, 316, 317, 318, 41, 141, 43, 141, 9, 372,
2158 373, 374, 9, 4, 19, 135, 139, 380, 144, 19,
2159 139, 517, 138, 138, 138, 138, 138, 390, 391, 138,
2160 138, 138, 135, 50, 11, 135, 138, 533, 144, 354,
2161 399, 400, 401, 402, 138, 135, 138, 406, 407, 85,
2162 86, 87, 88, 89, 90, 91, 92, 93, 94, 135,
2163 135, 424, 135, 426, 135, 33, 429, 382, 383, 384,
2164 385, 386, 435, 436, 389, 135, 135, 135, 135, 144,
2165 33, 135, 441, 442, 19, 4, 135, 54, 135, 135,
2166 135, 135, 140, 408, 135, 458, 459, 135, 461, 462,
2167 135, 144, 135, 466, 19, 295, 296, 14, 298, 139,
2168 14, 474, 138, 135, 4, 305, 0, 135, 138, 478,
2169 135, 480, 481, 313, 314, 440, 19, 135, 443, 135,
2170 493, 15, 16, 17, 48, 19, 20, 21, 501, 454,
2171 135, 135, 135, 27, 28, 460, 135, 139, 135, 139,
2172 135, 139, 135, 468, 469, 470, 135, 139, 473, 139,
2173 135, 142, 46, 453, 140, 49, 139, 530, 139, 53,
2174 139, 48, 535, 14, 4, 135, 142, 14, 14, 23,
2175 24, 135, 372, 373, 374, 14, 549, 550, 66, 14,
2176 380, 554, 124, 124, 557, 124, 212, 86, 489, 213,
2177 390, 391, 105, 512, 519, 7, 8, 234, 10, 11,
2178 12, 13, 14, 99, 16, 17, 16, 19, 20, 83,
2179 53, -1, 512, 473, 379, -1, -1, -1, -1, -1,
2180 -1, -1, -1, -1, 424, -1, 426, -1, -1, 429,
2181 -1, -1, 44, -1, -1, 435, 436, 91, 92, 93,
2182 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2183 104, -1, -1, -1, -1, -1, 0, -1, 458, 459,
2184 -1, 461, 462, -1, -1, -1, 466, -1, -1, -1,
2185 -1, 15, 16, 17, 474, 19, 20, 21, -1, -1,
2186 -1, -1, -1, 27, 28, -1, -1, -1, -1, -1,
2187 -1, -1, -1, 493, 3, 4, -1, -1, 7, 8,
2188 9, 501, 46, -1, -1, 49, -1, 16, 17, 53,
2189 19, 20, -1, 22, 23, 24, -1, -1, -1, -1,
2190 -1, -1, -1, -1, -1, 137, 35, 36, 140, -1,
2191 530, 143, -1, 145, 146, 535, -1, -1, -1, -1,
2192 -1, -1, -1, 52, -1, -1, -1, -1, -1, 549,
2193 550, -1, -1, -1, 554, -1, -1, 557, -1, 68,
2194 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2195 79, 80, 81, 82, 83, 84, -1, -1, -1, -1,
2196 -1, -1, -1, 7, 8, -1, 10, 11, 12, 13,
2197 14, -1, 16, 17, -1, 19, 20, -1, -1, -1,
2198 -1, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2199 119, 120, 121, 122, -1, 124, -1, 126, 127, 128,
2200 44, -1, -1, -1, -1, -1, -1, 136, -1, 138,
2201 -1, 3, 4, -1, 143, 7, 8, 9, -1, -1,
2202 -1, -1, -1, -1, 16, 17, -1, 19, 20, -1,
2203 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
2204 -1, -1, -1, 35, 36, -1, -1, -1, -1, -1,
2205 -1, -1, -1, -1, -1, -1, -1, -1, 7, 8,
2206 52, 10, 11, 12, 13, 14, -1, 16, 17, -1,
2207 19, 20, -1, -1, -1, -1, 68, 69, 70, 71,
2208 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2209 82, 83, 84, 137, -1, 44, 140, -1, -1, 143,
2210 -1, 145, 146, -1, -1, -1, -1, -1, -1, -1,
2211 -1, -1, -1, -1, -1, -1, -1, -1, 110, 111,
2212 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
2213 122, -1, 124, -1, 126, 127, 128, 7, 8, -1,
2214 -1, -1, -1, -1, -1, -1, 16, 17, -1, 19,
2215 20, 143, 22, -1, -1, -1, -1, -1, -1, -1,
2216 -1, -1, -1, -1, -1, 35, 36, -1, -1, -1,
2217 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2218 7, 8, -1, 10, 11, 12, 13, 14, 137, 16,
2219 17, 140, 19, 20, 143, -1, 145, 146, 68, 69,
2220 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2221 80, 81, 82, 83, 84, -1, -1, 44, -1, -1,
2222 -1, -1, -1, -1, -1, -1, 7, 8, -1, 10,
2223 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
2224 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
2225 120, 121, 122, 34, 124, -1, 126, 127, 128, 3,
2226 4, -1, -1, 44, -1, 9, 136, -1, 138, -1,
2227 140, -1, -1, 143, -1, 145, -1, 147, 22, 23,
2228 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2229 -1, 35, 36, -1, -1, -1, -1, -1, -1, -1,
2230 -1, -1, -1, -1, -1, -1, -1, -1, 52, -1,
2231 137, -1, -1, 140, -1, -1, 143, -1, 145, -1,
2232 -1, -1, -1, -1, 68, 69, 70, 71, 72, 73,
2233 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2234 84, -1, 7, 8, -1, 10, 11, 12, 13, 14,
2235 -1, 16, 17, -1, 19, 20, 137, -1, -1, 140,
2236 -1, -1, 143, -1, 145, -1, 110, 111, 112, 113,
2237 114, 115, 116, 117, 118, 119, 120, 121, 122, 44,
2238 124, -1, 126, 127, 128, 7, 8, -1, 10, 11,
2239 12, 13, 14, -1, 16, 17, -1, 19, 20, 143,
2240 -1, 7, 8, -1, 10, 11, 12, 13, 14, -1,
2241 16, 17, 34, 19, 20, -1, -1, -1, -1, -1,
2242 7, 8, 44, 10, 11, 12, 13, 14, 34, 16,
2243 17, -1, 19, 20, -1, -1, 7, 8, 44, 10,
2244 11, 12, 13, 14, -1, 16, 17, 34, 19, 20,
2245 -1, -1, -1, -1, -1, 7, 8, 44, 10, 11,
2246 12, 13, 14, -1, 16, 17, -1, 19, 20, -1,
2247 -1, -1, 137, 44, -1, 140, -1, -1, 143, -1,
2248 145, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2249 7, 8, 44, 10, 11, 12, 13, 14, -1, 16,
2250 17, -1, 19, 20, 7, 8, -1, 10, 11, 12,
2251 13, 14, -1, 16, 17, 137, 19, 20, 140, -1,
2252 -1, 143, -1, 145, -1, -1, -1, 44, -1, -1,
2253 -1, 137, -1, -1, 140, -1, -1, 143, -1, 145,
2254 -1, 44, -1, -1, -1, -1, -1, -1, -1, -1,
2255 137, -1, -1, 140, -1, -1, 143, -1, 145, -1,
2256 -1, -1, -1, -1, -1, -1, 137, -1, -1, 140,
2257 -1, -1, 143, -1, 145, -1, -1, -1, -1, -1,
2258 -1, -1, -1, -1, -1, 137, -1, -1, 140, -1,
2259 -1, 143, -1, 145, -1, -1, -1, -1, -1, -1,
2260 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2261 -1, -1, -1, 32, -1, -1, -1, -1, -1, -1,
2262 137, -1, -1, 140, -1, -1, 143, -1, 145, -1,
2263 -1, 50, 51, -1, 137, -1, -1, 140, -1, -1,
2264 143, -1, 145, 62, 63, 64, 65, 66, 67, 68,
2265 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2266 79, 80, 81, 82, 83, 84, -1, -1, -1, -1,
2267 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2268 -1, -1, -1, -1, -1, -1, 105, 106, 107, -1,
2269 -1, 110, 111, 112, 113, 114, 115, 116, 117, 118,
2270 119, 120, 121, 122, 123, 124, 125, 126, 127, 128
2271};
2272
2273/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2274 symbol of state STATE-NUM. */
2275static const unsigned char yystos[] =
2276{
2277 0, 16, 17, 19, 20, 21, 27, 28, 46, 49,
2278 53, 156, 158, 159, 160, 188, 189, 190, 192, 191,
2279 47, 61, 197, 134, 52, 134, 15, 134, 37, 38,
2280 39, 40, 41, 42, 43, 45, 133, 161, 162, 163,
2281 0, 190, 41, 43, 164, 207, 37, 38, 39, 42,
2282 165, 204, 206, 213, 134, 134, 140, 198, 19, 196,
2283 7, 8, 10, 11, 12, 13, 14, 44, 137, 140,
2284 143, 145, 156, 159, 177, 178, 210, 163, 163, 29,
2285 30, 187, 163, 163, 18, 214, 215, 26, 146, 205,
2286 214, 19, 19, 19, 199, 138, 4, 4, 4, 145,
2287 10, 146, 178, 183, 136, 138, 187, 187, 11, 12,
2288 13, 154, 155, 178, 184, 55, 56, 57, 58, 59,
2289 60, 166, 202, 202, 158, 218, 135, 142, 34, 178,
2290 179, 181, 182, 141, 141, 146, 183, 135, 146, 182,
2291 184, 178, 23, 24, 3, 4, 5, 6, 9, 22,
2292 35, 36, 68, 69, 70, 71, 72, 73, 74, 75,
2293 76, 77, 78, 79, 80, 81, 82, 83, 84, 110,
2294 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
2295 121, 122, 124, 126, 127, 128, 140, 143, 145, 147,
2296 149, 150, 151, 185, 210, 193, 4, 10, 178, 180,
2297 25, 145, 203, 32, 50, 51, 62, 63, 64, 65,
2298 66, 67, 83, 84, 105, 106, 107, 110, 123, 124,
2299 125, 126, 127, 128, 149, 150, 151, 216, 222, 223,
2300 224, 225, 19, 168, 135, 139, 178, 178, 144, 146,
2301 178, 139, 194, 195, 85, 86, 87, 88, 89, 90,
2302 91, 92, 93, 94, 152, 23, 24, 91, 92, 93,
2303 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
2304 104, 153, 138, 138, 138, 138, 138, 142, 184, 186,
2305 145, 186, 146, 186, 19, 138, 138, 138, 135, 175,
2306 159, 50, 10, 178, 212, 11, 14, 11, 154, 166,
2307 152, 153, 178, 178, 212, 178, 178, 219, 212, 212,
2308 212, 212, 212, 178, 178, 212, 166, 108, 109, 112,
2309 113, 130, 131, 167, 34, 179, 170, 142, 144, 144,
2310 170, 175, 175, 138, 138, 184, 184, 184, 184, 184,
2311 135, 142, 146, 178, 186, 144, 146, 184, 184, 184,
2312 31, 48, 173, 176, 138, 3, 4, 9, 22, 23,
2313 24, 35, 36, 52, 143, 185, 209, 210, 211, 211,
2314 211, 211, 180, 178, 178, 135, 172, 135, 172, 211,
2315 140, 135, 135, 135, 135, 135, 135, 211, 211, 33,
2316 180, 178, 212, 129, 167, 169, 184, 184, 221, 135,
2317 135, 135, 135, 184, 144, 146, 135, 135, 33, 19,
2318 4, 175, 34, 178, 200, 201, 54, 208, 186, 135,
2319 135, 211, 211, 211, 11, 48, 11, 221, 211, 140,
2320 212, 178, 212, 212, 212, 135, 135, 178, 211, 211,
2321 135, 135, 135, 135, 139, 184, 184, 184, 184, 144,
2322 184, 184, 178, 168, 135, 139, 19, 144, 14, 14,
2323 138, 135, 135, 211, 4, 211, 135, 211, 135, 135,
2324 135, 211, 211, 138, 178, 184, 184, 212, 135, 139,
2325 135, 135, 139, 139, 139, 156, 157, 34, 178, 170,
2326 135, 211, 211, 178, 220, 211, 211, 135, 172, 172,
2327 211, 135, 212, 212, 212, 220, 211, 139, 139, 184,
2328 184, 184, 168, 173, 174, 19, 135, 140, 211, 135,
2329 139, 142, 211, 139, 139, 139, 139, 157, 48, 171,
2330 14, 142, 154, 217, 168, 178, 170, 142, 170, 4,
2331 211, 209, 142, 154, 211, 33, 135, 209, 168, 14,
2332 14, 135, 211, 211, 14, 66, 211, 14, 211
2333};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002334
2335#define yyerrok (yyerrstatus = 0)
2336#define yyclearin (yychar = YYEMPTY)
Reid Spencer38c91a92007-02-28 02:24:54 +00002337#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002338#define YYEOF 0
Reid Spencer38c91a92007-02-28 02:24:54 +00002339
Reid Spencer68a24bd2005-08-27 18:50:39 +00002340#define YYACCEPT goto yyacceptlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002341#define YYABORT goto yyabortlab
2342#define YYERROR goto yyerrorlab
2343
2344
2345/* Like YYERROR except do call yyerror. This remains here temporarily
2346 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002347 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002348
Reid Spencer68a24bd2005-08-27 18:50:39 +00002349#define YYFAIL goto yyerrlab
Reid Spencer38c91a92007-02-28 02:24:54 +00002350
Reid Spencer68a24bd2005-08-27 18:50:39 +00002351#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer38c91a92007-02-28 02:24:54 +00002352
2353#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002354do \
2355 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer38c91a92007-02-28 02:24:54 +00002356 { \
2357 yychar = (Token); \
2358 yylval = (Value); \
2359 yytoken = YYTRANSLATE (yychar); \
Chris Lattner9d2fda62007-02-13 05:53:56 +00002360 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002361 goto yybackup; \
2362 } \
2363 else \
Reid Spencer38c91a92007-02-28 02:24:54 +00002364 { \
2365 yyerror (YY_("syntax error: cannot back up")); \
2366 YYERROR; \
2367 } \
Chris Lattner9d2fda62007-02-13 05:53:56 +00002368while (0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002369
Reid Spencer38c91a92007-02-28 02:24:54 +00002370
Reid Spencer68a24bd2005-08-27 18:50:39 +00002371#define YYTERROR 1
2372#define YYERRCODE 256
2373
Reid Spencer38c91a92007-02-28 02:24:54 +00002374
2375/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2376 If N is 0, then set CURRENT to the empty location which ends
2377 the previous symbol: RHS[0] (always defined). */
2378
2379#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2380#ifndef YYLLOC_DEFAULT
2381# define YYLLOC_DEFAULT(Current, Rhs, N) \
2382 do \
2383 if (N) \
2384 { \
2385 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2386 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2387 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2388 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2389 } \
2390 else \
2391 { \
2392 (Current).first_line = (Current).last_line = \
2393 YYRHSLOC (Rhs, 0).last_line; \
2394 (Current).first_column = (Current).last_column = \
2395 YYRHSLOC (Rhs, 0).last_column; \
2396 } \
2397 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002398#endif
2399
Reid Spencer38c91a92007-02-28 02:24:54 +00002400
2401/* YY_LOCATION_PRINT -- Print the location on the stream.
2402 This macro was not mandated originally: define only if we know
2403 we won't break user code: when these are the locations we know. */
2404
2405#ifndef YY_LOCATION_PRINT
2406# if YYLTYPE_IS_TRIVIAL
2407# define YY_LOCATION_PRINT(File, Loc) \
2408 fprintf (File, "%d.%d-%d.%d", \
2409 (Loc).first_line, (Loc).first_column, \
2410 (Loc).last_line, (Loc).last_column)
2411# else
2412# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2413# endif
2414#endif
2415
2416
2417/* YYLEX -- calling `yylex' with the right arguments. */
2418
Reid Spencer41dff5e2007-01-26 08:05:27 +00002419#ifdef YYLEX_PARAM
Reid Spencer38c91a92007-02-28 02:24:54 +00002420# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer41dff5e2007-01-26 08:05:27 +00002421#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002422# define YYLEX yylex ()
Chris Lattner32980692007-02-19 07:44:24 +00002423#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002424
2425/* Enable debugging if requested. */
2426#if YYDEBUG
2427
2428# ifndef YYFPRINTF
2429# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2430# define YYFPRINTF fprintf
2431# endif
2432
2433# define YYDPRINTF(Args) \
2434do { \
2435 if (yydebug) \
2436 YYFPRINTF Args; \
2437} while (0)
2438
2439# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2440do { \
2441 if (yydebug) \
2442 { \
2443 YYFPRINTF (stderr, "%s ", Title); \
2444 yysymprint (stderr, \
2445 Type, Value); \
2446 YYFPRINTF (stderr, "\n"); \
2447 } \
2448} while (0)
2449
2450/*------------------------------------------------------------------.
2451| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2452| TOP (included). |
2453`------------------------------------------------------------------*/
2454
2455#if defined (__STDC__) || defined (__cplusplus)
2456static void
2457yy_stack_print (short int *bottom, short int *top)
Chris Lattner32980692007-02-19 07:44:24 +00002458#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002459static void
2460yy_stack_print (bottom, top)
2461 short int *bottom;
2462 short int *top;
Chris Lattner32980692007-02-19 07:44:24 +00002463#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002464{
2465 YYFPRINTF (stderr, "Stack now");
2466 for (/* Nothing. */; bottom <= top; ++bottom)
2467 YYFPRINTF (stderr, " %d", *bottom);
2468 YYFPRINTF (stderr, "\n");
2469}
2470
2471# define YY_STACK_PRINT(Bottom, Top) \
2472do { \
2473 if (yydebug) \
2474 yy_stack_print ((Bottom), (Top)); \
2475} while (0)
2476
2477
2478/*------------------------------------------------.
2479| Report that the YYRULE is going to be reduced. |
2480`------------------------------------------------*/
2481
2482#if defined (__STDC__) || defined (__cplusplus)
2483static void
2484yy_reduce_print (int yyrule)
2485#else
2486static void
2487yy_reduce_print (yyrule)
2488 int yyrule;
Chris Lattner9d2fda62007-02-13 05:53:56 +00002489#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002490{
2491 int yyi;
2492 unsigned long int yylno = yyrline[yyrule];
2493 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2494 yyrule - 1, yylno);
2495 /* Print the symbols being reduced, and their result. */
2496 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2497 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2498 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2499}
Reid Spencer9d6565a2007-02-15 02:26:10 +00002500
Reid Spencer38c91a92007-02-28 02:24:54 +00002501# define YY_REDUCE_PRINT(Rule) \
2502do { \
2503 if (yydebug) \
2504 yy_reduce_print (Rule); \
2505} while (0)
Reid Spencer9d6565a2007-02-15 02:26:10 +00002506
Reid Spencer38c91a92007-02-28 02:24:54 +00002507/* Nonzero means print parse trace. It is left uninitialized so that
2508 multiple parsers can coexist. */
2509int yydebug;
2510#else /* !YYDEBUG */
2511# define YYDPRINTF(Args)
2512# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2513# define YY_STACK_PRINT(Bottom, Top)
2514# define YY_REDUCE_PRINT(Rule)
2515#endif /* !YYDEBUG */
Reid Spencer9d6565a2007-02-15 02:26:10 +00002516
Reid Spencer9d6565a2007-02-15 02:26:10 +00002517
Reid Spencer38c91a92007-02-28 02:24:54 +00002518/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002519#ifndef YYINITDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002520# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002521#endif
2522
Reid Spencer38c91a92007-02-28 02:24:54 +00002523/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2524 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002525
Reid Spencer38c91a92007-02-28 02:24:54 +00002526 Do not make this value too large; the results are undefined if
2527 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2528 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002529
2530#ifndef YYMAXDEPTH
Reid Spencer38c91a92007-02-28 02:24:54 +00002531# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002532#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00002533
Reid Spencer68a24bd2005-08-27 18:50:39 +00002534
2535
Reid Spencer38c91a92007-02-28 02:24:54 +00002536#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002537
Reid Spencer38c91a92007-02-28 02:24:54 +00002538# ifndef yystrlen
2539# if defined (__GLIBC__) && defined (_STRING_H)
2540# define yystrlen strlen
2541# else
2542/* Return the length of YYSTR. */
2543static YYSIZE_T
2544# if defined (__STDC__) || defined (__cplusplus)
2545yystrlen (const char *yystr)
2546# else
2547yystrlen (yystr)
2548 const char *yystr;
2549# endif
Chris Lattner32980692007-02-19 07:44:24 +00002550{
Reid Spencer38c91a92007-02-28 02:24:54 +00002551 const char *yys = yystr;
Chris Lattner32980692007-02-19 07:44:24 +00002552
Reid Spencer38c91a92007-02-28 02:24:54 +00002553 while (*yys++ != '\0')
2554 continue;
2555
2556 return yys - yystr - 1;
Chris Lattner32980692007-02-19 07:44:24 +00002557}
Reid Spencer38c91a92007-02-28 02:24:54 +00002558# endif
2559# endif
Chris Lattner32980692007-02-19 07:44:24 +00002560
Reid Spencer38c91a92007-02-28 02:24:54 +00002561# ifndef yystpcpy
2562# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2563# define yystpcpy stpcpy
2564# else
2565/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2566 YYDEST. */
2567static char *
2568# if defined (__STDC__) || defined (__cplusplus)
2569yystpcpy (char *yydest, const char *yysrc)
2570# else
2571yystpcpy (yydest, yysrc)
2572 char *yydest;
2573 const char *yysrc;
2574# endif
Chris Lattner32980692007-02-19 07:44:24 +00002575{
Reid Spencer38c91a92007-02-28 02:24:54 +00002576 char *yyd = yydest;
2577 const char *yys = yysrc;
Chris Lattner32980692007-02-19 07:44:24 +00002578
Reid Spencer38c91a92007-02-28 02:24:54 +00002579 while ((*yyd++ = *yys++) != '\0')
2580 continue;
2581
2582 return yyd - 1;
Chris Lattner32980692007-02-19 07:44:24 +00002583}
Reid Spencer38c91a92007-02-28 02:24:54 +00002584# endif
2585# endif
Chris Lattner32980692007-02-19 07:44:24 +00002586
Reid Spencer38c91a92007-02-28 02:24:54 +00002587# ifndef yytnamerr
2588/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2589 quotes and backslashes, so that it's suitable for yyerror. The
2590 heuristic is that double-quoting is unnecessary unless the string
2591 contains an apostrophe, a comma, or backslash (other than
2592 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2593 null, do not copy; instead, return the length of what the result
2594 would have been. */
2595static YYSIZE_T
2596yytnamerr (char *yyres, const char *yystr)
2597{
2598 if (*yystr == '"')
2599 {
2600 size_t yyn = 0;
2601 char const *yyp = yystr;
2602
2603 for (;;)
2604 switch (*++yyp)
2605 {
2606 case '\'':
2607 case ',':
2608 goto do_not_strip_quotes;
2609
2610 case '\\':
2611 if (*++yyp != '\\')
2612 goto do_not_strip_quotes;
2613 /* Fall through. */
2614 default:
2615 if (yyres)
2616 yyres[yyn] = *yyp;
2617 yyn++;
2618 break;
2619
2620 case '"':
2621 if (yyres)
2622 yyres[yyn] = '\0';
2623 return yyn;
2624 }
2625 do_not_strip_quotes: ;
2626 }
2627
2628 if (! yyres)
2629 return yystrlen (yystr);
2630
2631 return yystpcpy (yyres, yystr) - yyres;
2632}
2633# endif
2634
2635#endif /* YYERROR_VERBOSE */
2636
Reid Spencer9d6565a2007-02-15 02:26:10 +00002637
2638
Reid Spencer38c91a92007-02-28 02:24:54 +00002639#if YYDEBUG
2640/*--------------------------------.
2641| Print this symbol on YYOUTPUT. |
2642`--------------------------------*/
Reid Spencer9d6565a2007-02-15 02:26:10 +00002643
Reid Spencer38c91a92007-02-28 02:24:54 +00002644#if defined (__STDC__) || defined (__cplusplus)
2645static void
2646yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner32980692007-02-19 07:44:24 +00002647#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002648static void
2649yysymprint (yyoutput, yytype, yyvaluep)
2650 FILE *yyoutput;
2651 int yytype;
2652 YYSTYPE *yyvaluep;
2653#endif
2654{
2655 /* Pacify ``unused variable'' warnings. */
2656 (void) yyvaluep;
2657
2658 if (yytype < YYNTOKENS)
2659 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2660 else
2661 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2662
2663
2664# ifdef YYPRINT
2665 if (yytype < YYNTOKENS)
2666 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2667# endif
2668 switch (yytype)
2669 {
2670 default:
2671 break;
2672 }
2673 YYFPRINTF (yyoutput, ")");
2674}
2675
2676#endif /* ! YYDEBUG */
2677/*-----------------------------------------------.
2678| Release the memory associated to this symbol. |
2679`-----------------------------------------------*/
2680
2681#if defined (__STDC__) || defined (__cplusplus)
2682static void
2683yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2684#else
2685static void
2686yydestruct (yymsg, yytype, yyvaluep)
2687 const char *yymsg;
2688 int yytype;
2689 YYSTYPE *yyvaluep;
2690#endif
2691{
2692 /* Pacify ``unused variable'' warnings. */
2693 (void) yyvaluep;
2694
2695 if (!yymsg)
2696 yymsg = "Deleting";
2697 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2698
2699 switch (yytype)
2700 {
2701
2702 default:
2703 break;
2704 }
2705}
2706
2707
2708/* Prevent warnings from -Wmissing-prototypes. */
2709
2710#ifdef YYPARSE_PARAM
2711# if defined (__STDC__) || defined (__cplusplus)
2712int yyparse (void *YYPARSE_PARAM);
2713# else
2714int yyparse ();
2715# endif
2716#else /* ! YYPARSE_PARAM */
2717#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002718int yyparse (void);
Chris Lattner32980692007-02-19 07:44:24 +00002719#else
Reid Spencer38c91a92007-02-28 02:24:54 +00002720int yyparse ();
2721#endif
2722#endif /* ! YYPARSE_PARAM */
2723
2724
2725
2726/* The look-ahead symbol. */
2727int yychar;
2728
2729/* The semantic value of the look-ahead symbol. */
2730YYSTYPE yylval;
2731
2732/* Number of syntax errors so far. */
2733int yynerrs;
2734
2735
2736
2737/*----------.
2738| yyparse. |
2739`----------*/
2740
2741#ifdef YYPARSE_PARAM
2742# if defined (__STDC__) || defined (__cplusplus)
2743int yyparse (void *YYPARSE_PARAM)
2744# else
2745int yyparse (YYPARSE_PARAM)
2746 void *YYPARSE_PARAM;
2747# endif
2748#else /* ! YYPARSE_PARAM */
2749#if defined (__STDC__) || defined (__cplusplus)
2750int
2751yyparse (void)
2752#else
2753int
2754yyparse ()
2755
2756#endif
2757#endif
2758{
2759
2760 int yystate;
2761 int yyn;
2762 int yyresult;
2763 /* Number of tokens to shift before error messages enabled. */
2764 int yyerrstatus;
2765 /* Look-ahead token as an internal (translated) token number. */
2766 int yytoken = 0;
2767
2768 /* Three stacks and their tools:
2769 `yyss': related to states,
2770 `yyvs': related to semantic values,
2771 `yyls': related to locations.
2772
2773 Refer to the stacks thru separate pointers, to allow yyoverflow
2774 to reallocate them elsewhere. */
2775
2776 /* The state stack. */
2777 short int yyssa[YYINITDEPTH];
2778 short int *yyss = yyssa;
2779 short int *yyssp;
2780
2781 /* The semantic value stack. */
2782 YYSTYPE yyvsa[YYINITDEPTH];
2783 YYSTYPE *yyvs = yyvsa;
2784 YYSTYPE *yyvsp;
2785
2786
2787
Chris Lattner9d2fda62007-02-13 05:53:56 +00002788#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002789
Reid Spencer38c91a92007-02-28 02:24:54 +00002790 YYSIZE_T yystacksize = YYINITDEPTH;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002791
Reid Spencer38c91a92007-02-28 02:24:54 +00002792 /* The variables used to return semantic value and location from the
2793 action routines. */
2794 YYSTYPE yyval;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002795
Chris Lattner7d9801d2007-02-13 00:58:01 +00002796
Reid Spencer38c91a92007-02-28 02:24:54 +00002797 /* When reducing, the number of symbols on the RHS of the reduced
2798 rule. */
Chris Lattner9d2fda62007-02-13 05:53:56 +00002799 int yylen;
Chris Lattner7d9801d2007-02-13 00:58:01 +00002800
Reid Spencer38c91a92007-02-28 02:24:54 +00002801 YYDPRINTF ((stderr, "Starting parse\n"));
Chris Lattner7d9801d2007-02-13 00:58:01 +00002802
Reid Spencer68a24bd2005-08-27 18:50:39 +00002803 yystate = 0;
2804 yyerrstatus = 0;
2805 yynerrs = 0;
2806 yychar = YYEMPTY; /* Cause a token to be read. */
2807
2808 /* Initialize stack pointers.
2809 Waste one element of value and location stack
2810 so that they stay on the same level as the state stack.
2811 The wasted elements are never initialized. */
2812
Reid Spencer38c91a92007-02-28 02:24:54 +00002813 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002814 yyvsp = yyvs;
2815
Reid Spencer38c91a92007-02-28 02:24:54 +00002816 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002817
Reid Spencer38c91a92007-02-28 02:24:54 +00002818/*------------------------------------------------------------.
2819| yynewstate -- Push a new state, which is found in yystate. |
2820`------------------------------------------------------------*/
2821 yynewstate:
2822 /* In all cases, when you get here, the value and location stacks
2823 have just been pushed. so pushing a state here evens the stacks.
2824 */
2825 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002826
Reid Spencer38c91a92007-02-28 02:24:54 +00002827 yysetstate:
2828 *yyssp = yystate;
2829
2830 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002831 {
2832 /* Get the current used size of the three stacks, in elements. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002833 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002834
2835#ifdef yyoverflow
Reid Spencer38c91a92007-02-28 02:24:54 +00002836 {
2837 /* Give user a chance to reallocate the stack. Use copies of
2838 these so that the &'s don't force the real ones into
2839 memory. */
2840 YYSTYPE *yyvs1 = yyvs;
2841 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002842
Reid Spencer38c91a92007-02-28 02:24:54 +00002843
2844 /* Each stack pointer address is followed by the size of the
2845 data in use in that stack, in bytes. This used to be a
2846 conditional around just the two extra args, but that might
2847 be undefined if yyoverflow is a macro. */
2848 yyoverflow (YY_("memory exhausted"),
2849 &yyss1, yysize * sizeof (*yyssp),
2850 &yyvs1, yysize * sizeof (*yyvsp),
2851
2852 &yystacksize);
2853
2854 yyss = yyss1;
2855 yyvs = yyvs1;
2856 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002857#else /* no yyoverflow */
Reid Spencer38c91a92007-02-28 02:24:54 +00002858# ifndef YYSTACK_RELOCATE
2859 goto yyexhaustedlab;
2860# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002861 /* Extend the stack our own way. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002862 if (YYMAXDEPTH <= yystacksize)
2863 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002864 yystacksize *= 2;
Reid Spencer38c91a92007-02-28 02:24:54 +00002865 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002866 yystacksize = YYMAXDEPTH;
Reid Spencer38c91a92007-02-28 02:24:54 +00002867
2868 {
2869 short int *yyss1 = yyss;
2870 union yyalloc *yyptr =
2871 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2872 if (! yyptr)
2873 goto yyexhaustedlab;
2874 YYSTACK_RELOCATE (yyss);
2875 YYSTACK_RELOCATE (yyvs);
2876
2877# undef YYSTACK_RELOCATE
2878 if (yyss1 != yyssa)
2879 YYSTACK_FREE (yyss1);
2880 }
2881# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002882#endif /* no yyoverflow */
2883
Reid Spencer38c91a92007-02-28 02:24:54 +00002884 yyssp = yyss + yysize - 1;
2885 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002886
2887
Reid Spencer38c91a92007-02-28 02:24:54 +00002888 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2889 (unsigned long int) yystacksize));
2890
2891 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002892 YYABORT;
2893 }
2894
Reid Spencer38c91a92007-02-28 02:24:54 +00002895 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002896
2897 goto yybackup;
Reid Spencer38c91a92007-02-28 02:24:54 +00002898
2899/*-----------.
2900| yybackup. |
2901`-----------*/
2902yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002903
Chris Lattner9d2fda62007-02-13 05:53:56 +00002904/* Do appropriate processing given the current state. */
Reid Spencer38c91a92007-02-28 02:24:54 +00002905/* Read a look-ahead token if we need one and don't already have one. */
Chris Lattner9d2fda62007-02-13 05:53:56 +00002906/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002907
Reid Spencer38c91a92007-02-28 02:24:54 +00002908 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer5cbf9852007-01-30 20:08:39 +00002909
Reid Spencer68a24bd2005-08-27 18:50:39 +00002910 yyn = yypact[yystate];
Reid Spencer38c91a92007-02-28 02:24:54 +00002911 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002912 goto yydefault;
2913
Reid Spencer38c91a92007-02-28 02:24:54 +00002914 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002915
Reid Spencer38c91a92007-02-28 02:24:54 +00002916 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002917 if (yychar == YYEMPTY)
2918 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002919 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002920 yychar = YYLEX;
2921 }
2922
Reid Spencer38c91a92007-02-28 02:24:54 +00002923 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002924 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002925 yychar = yytoken = YYEOF;
2926 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002927 }
2928 else
2929 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002930 yytoken = YYTRANSLATE (yychar);
2931 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002932 }
2933
Reid Spencer38c91a92007-02-28 02:24:54 +00002934 /* If the proper action on seeing token YYTOKEN is to reduce or to
2935 detect an error, take that action. */
2936 yyn += yytoken;
2937 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002938 goto yydefault;
2939 yyn = yytable[yyn];
Reid Spencer38c91a92007-02-28 02:24:54 +00002940 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002941 {
Reid Spencer38c91a92007-02-28 02:24:54 +00002942 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002943 goto yyerrlab;
2944 yyn = -yyn;
2945 goto yyreduce;
2946 }
2947
2948 if (yyn == YYFINAL)
2949 YYACCEPT;
2950
Reid Spencer38c91a92007-02-28 02:24:54 +00002951 /* Shift the look-ahead token. */
2952 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer5cbf9852007-01-30 20:08:39 +00002953
Chris Lattner9d2fda62007-02-13 05:53:56 +00002954 /* Discard the token being shifted unless it is eof. */
Reid Spencer5cbf9852007-01-30 20:08:39 +00002955 if (yychar != YYEOF)
2956 yychar = YYEMPTY;
2957
Chris Lattner7d9801d2007-02-13 00:58:01 +00002958 *++yyvsp = yylval;
2959
Reid Spencer38c91a92007-02-28 02:24:54 +00002960
2961 /* Count tokens shifted since error; after three, turn off error
2962 status. */
2963 if (yyerrstatus)
2964 yyerrstatus--;
Chris Lattner9d2fda62007-02-13 05:53:56 +00002965
2966 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002967 goto yynewstate;
2968
Chris Lattner32980692007-02-19 07:44:24 +00002969
Reid Spencer38c91a92007-02-28 02:24:54 +00002970/*-----------------------------------------------------------.
2971| yydefault -- do the default action for the current state. |
2972`-----------------------------------------------------------*/
2973yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002974 yyn = yydefact[yystate];
2975 if (yyn == 0)
2976 goto yyerrlab;
Reid Spencer38c91a92007-02-28 02:24:54 +00002977 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002978
Reid Spencer38c91a92007-02-28 02:24:54 +00002979
2980/*-----------------------------.
2981| yyreduce -- Do a reduction. |
2982`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00002983yyreduce:
Reid Spencer38c91a92007-02-28 02:24:54 +00002984 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002985 yylen = yyr2[yyn];
2986
Reid Spencer38c91a92007-02-28 02:24:54 +00002987 /* If YYLEN is nonzero, implement the default value of the action:
2988 `$$ = $1'.
2989
2990 Otherwise, the following line sets YYVAL to garbage.
2991 This behavior is undocumented and Bison
2992 users should not rely upon it. Assigning to YYVAL
2993 unconditionally makes the parser a bit smaller, and it avoids a
2994 GCC warning that YYVAL may be used uninitialized. */
2995 yyval = yyvsp[1-yylen];
2996
2997
2998 YY_REDUCE_PRINT (yyn);
2999 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003000 {
Reid Spencer38c91a92007-02-28 02:24:54 +00003001 case 29:
3002#line 1061 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3003 { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;}
3004 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003005
Reid Spencer38c91a92007-02-28 02:24:54 +00003006 case 30:
3007#line 1061 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3008 { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;}
3009 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003010
Reid Spencer38c91a92007-02-28 02:24:54 +00003011 case 31:
3012#line 1062 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3013 { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;}
3014 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003015
Reid Spencer38c91a92007-02-28 02:24:54 +00003016 case 32:
3017#line 1062 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3018 { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;}
3019 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003020
Reid Spencer38c91a92007-02-28 02:24:54 +00003021 case 33:
3022#line 1063 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3023 { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;}
3024 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00003025
Reid Spencer38c91a92007-02-28 02:24:54 +00003026 case 34:
3027#line 1063 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3028 { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;}
3029 break;
3030
3031 case 35:
3032#line 1064 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3033 { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;}
3034 break;
3035
3036 case 36:
3037#line 1064 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3038 { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;}
3039 break;
3040
3041 case 37:
3042#line 1065 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3043 { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;}
3044 break;
3045
3046 case 38:
3047#line 1065 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3048 { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;}
3049 break;
3050
3051 case 39:
3052#line 1069 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3053 { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;}
3054 break;
3055
3056 case 40:
3057#line 1069 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3058 { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;}
3059 break;
3060
3061 case 41:
3062#line 1070 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3063 { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;}
3064 break;
3065
3066 case 42:
3067#line 1070 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3068 { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;}
3069 break;
3070
3071 case 43:
3072#line 1071 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3073 { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;}
3074 break;
3075
3076 case 44:
3077#line 1071 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3078 { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;}
3079 break;
3080
3081 case 45:
3082#line 1072 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3083 { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;}
3084 break;
3085
3086 case 46:
3087#line 1072 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3088 { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;}
3089 break;
3090
3091 case 47:
3092#line 1073 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3093 { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;}
3094 break;
3095
3096 case 48:
3097#line 1073 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3098 { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;}
3099 break;
3100
3101 case 49:
3102#line 1074 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3103 { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;}
3104 break;
3105
3106 case 50:
3107#line 1074 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3108 { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;}
3109 break;
3110
3111 case 51:
3112#line 1075 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3113 { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;}
3114 break;
3115
3116 case 52:
3117#line 1075 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3118 { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;}
3119 break;
3120
3121 case 53:
3122#line 1076 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3123 { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;}
3124 break;
3125
3126 case 54:
3127#line 1077 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3128 { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;}
3129 break;
3130
3131 case 61:
3132#line 1086 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3133 { (yyval.StrVal) = 0; ;}
3134 break;
3135
3136 case 62:
3137#line 1090 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3138 {
3139 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003140 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003141 ;}
3142 break;
3143
3144 case 63:
3145#line 1094 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3146 {
3147 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003148 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003149 ;}
3150 break;
3151
3152 case 66:
3153#line 1101 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3154 {
3155 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003156 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003157 ;}
3158 break;
3159
3160 case 67:
3161#line 1105 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3162 {
3163 (yyval.StrVal) = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003164 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003165 ;}
3166 break;
3167
3168 case 68:
3169#line 1111 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3170 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3171 break;
3172
3173 case 69:
3174#line 1112 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3175 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3176 break;
3177
3178 case 70:
3179#line 1113 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3180 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3181 break;
3182
3183 case 71:
3184#line 1114 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3185 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3186 break;
3187
3188 case 72:
3189#line 1115 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3190 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3191 break;
3192
3193 case 73:
3194#line 1119 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3195 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3196 break;
3197
3198 case 74:
3199#line 1120 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3200 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3201 break;
3202
3203 case 75:
3204#line 1121 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3205 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3206 break;
3207
3208 case 76:
3209#line 1125 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3210 { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;}
3211 break;
3212
3213 case 77:
3214#line 1126 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3215 { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;}
3216 break;
3217
3218 case 78:
3219#line 1130 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3220 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3221 break;
3222
3223 case 79:
3224#line 1131 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3225 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3226 break;
3227
3228 case 80:
3229#line 1132 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3230 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3231 break;
3232
3233 case 81:
3234#line 1136 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3235 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3236 break;
3237
3238 case 82:
3239#line 1137 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3240 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3241 break;
3242
3243 case 83:
3244#line 1138 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3245 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3246 break;
3247
3248 case 84:
3249#line 1139 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3250 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3251 break;
3252
3253 case 85:
3254#line 1140 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3255 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3256 break;
3257
3258 case 86:
3259#line 1143 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3260 { (yyval.UIntVal) = CallingConv::C; ;}
3261 break;
3262
3263 case 87:
3264#line 1144 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3265 { (yyval.UIntVal) = CallingConv::C; ;}
3266 break;
3267
3268 case 88:
3269#line 1145 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3270 { (yyval.UIntVal) = CallingConv::Fast; ;}
3271 break;
3272
3273 case 89:
3274#line 1146 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3275 { (yyval.UIntVal) = CallingConv::Cold; ;}
3276 break;
3277
3278 case 90:
3279#line 1147 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3280 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3281 break;
3282
3283 case 91:
3284#line 1148 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3285 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3286 break;
3287
3288 case 92:
3289#line 1149 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3290 {
3291 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencerb5334b02007-02-05 10:18:06 +00003292 GEN_ERROR("Calling conv too large");
Reid Spencer38c91a92007-02-28 02:24:54 +00003293 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003294 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003295 ;}
3296 break;
3297
3298 case 93:
3299#line 1156 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3300 { (yyval.ParamAttrs) = FunctionType::ZExtAttribute; ;}
3301 break;
3302
3303 case 94:
3304#line 1157 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3305 { (yyval.ParamAttrs) = FunctionType::SExtAttribute; ;}
3306 break;
3307
3308 case 95:
3309#line 1158 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3310 { (yyval.ParamAttrs) = FunctionType::InRegAttribute; ;}
3311 break;
3312
3313 case 96:
3314#line 1159 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3315 { (yyval.ParamAttrs) = FunctionType::StructRetAttribute; ;}
3316 break;
3317
3318 case 97:
3319#line 1162 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3320 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3321 break;
3322
3323 case 98:
3324#line 1163 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3325 {
3326 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
3327 ;}
3328 break;
3329
3330 case 99:
3331#line 1168 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3332 { (yyval.ParamAttrs) = FunctionType::NoReturnAttribute; ;}
3333 break;
3334
3335 case 101:
3336#line 1172 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3337 { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;}
3338 break;
3339
3340 case 102:
3341#line 1173 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3342 {
3343 (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs));
3344 ;}
3345 break;
3346
3347 case 103:
3348#line 1180 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3349 { (yyval.UIntVal) = 0; ;}
3350 break;
3351
3352 case 104:
3353#line 1181 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3354 {
3355 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3356 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003357 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003358 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003359;}
3360 break;
3361
3362 case 105:
3363#line 1187 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3364 { (yyval.UIntVal) = 0; ;}
3365 break;
3366
3367 case 106:
3368#line 1188 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3369 {
3370 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3371 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003372 GEN_ERROR("Alignment must be a power of two");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003373 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003374;}
3375 break;
3376
3377 case 107:
3378#line 1196 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3379 {
3380 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3381 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencerb5334b02007-02-05 10:18:06 +00003382 GEN_ERROR("Invalid character in section name");
Reid Spencer38c91a92007-02-28 02:24:54 +00003383 (yyval.StrVal) = (yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003384 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003385;}
3386 break;
3387
3388 case 108:
3389#line 1204 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3390 { (yyval.StrVal) = 0; ;}
3391 break;
3392
3393 case 109:
3394#line 1205 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3395 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3396 break;
3397
3398 case 110:
3399#line 1210 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3400 {;}
3401 break;
3402
3403 case 111:
3404#line 1211 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3405 {;}
3406 break;
3407
3408 case 112:
3409#line 1212 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3410 {
3411 CurGV->setSection((yyvsp[0].StrVal));
3412 free((yyvsp[0].StrVal));
Reid Spencer6f407902007-01-13 05:00:46 +00003413 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003414 ;}
3415 break;
3416
3417 case 113:
3418#line 1217 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3419 {
3420 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003421 GEN_ERROR("Alignment must be a power of two");
Reid Spencer38c91a92007-02-28 02:24:54 +00003422 CurGV->setAlignment((yyvsp[0].UInt64Val));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003423 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003424 ;}
3425 break;
3426
3427 case 118:
3428#line 1233 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3429 {
3430 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003431 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003432 ;}
3433 break;
3434
3435 case 119:
3436#line 1237 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3437 {
3438 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003439 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003440 ;}
3441 break;
3442
3443 case 120:
3444#line 1241 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3445 { // Pointer type?
3446 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003447 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencer38c91a92007-02-28 02:24:54 +00003448 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3449 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003450 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003451 ;}
3452 break;
3453
3454 case 121:
3455#line 1248 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3456 { // Named types are also simple types...
3457 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003458 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003459 (yyval.TypeVal) = new PATypeHolder(tmp);
3460 ;}
3461 break;
3462
3463 case 122:
3464#line 1253 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3465 { // Type UpReference
3466 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003467 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer38c91a92007-02-28 02:24:54 +00003468 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3469 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003470 UR_OUT("New Upreference!\n");
3471 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003472 ;}
3473 break;
3474
3475 case 123:
3476#line 1261 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3477 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003478 std::vector<const Type*> Params;
3479 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00003480 Attrs.push_back((yyvsp[0].ParamAttrs));
3481 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003482 Params.push_back(I->Ty->get());
3483 if (I->Ty->get() != Type::VoidTy)
3484 Attrs.push_back(I->Attrs);
3485 }
3486 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3487 if (isVarArg) Params.pop_back();
3488
Reid Spencer38c91a92007-02-28 02:24:54 +00003489 FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, Attrs);
3490 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3491 delete (yyvsp[-4].TypeVal); // Delete the return type handle
3492 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003493 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003494 ;}
3495 break;
3496
3497 case 124:
3498#line 1279 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3499 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003500 std::vector<const Type*> Params;
3501 std::vector<FunctionType::ParameterAttributes> Attrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00003502 Attrs.push_back((yyvsp[0].ParamAttrs));
3503 for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003504 Params.push_back(I->Ty->get());
3505 if (I->Ty->get() != Type::VoidTy)
3506 Attrs.push_back(I->Attrs);
3507 }
3508 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3509 if (isVarArg) Params.pop_back();
3510
Reid Spencer38c91a92007-02-28 02:24:54 +00003511 FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, Attrs);
3512 delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list
3513 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003514 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003515 ;}
3516 break;
3517
3518 case 125:
3519#line 1297 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3520 { // Sized array type?
3521 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3522 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003523 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003524 ;}
3525 break;
3526
3527 case 126:
3528#line 1302 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3529 { // Vector type?
3530 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3531 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003532 GEN_ERROR("Unsigned result not equal to signed result");
3533 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
Reid Spencer9d6565a2007-02-15 02:26:10 +00003534 GEN_ERROR("Element type of a VectorType must be primitive");
Reid Spencer38c91a92007-02-28 02:24:54 +00003535 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00003536 GEN_ERROR("Vector length should be a power of 2");
Reid Spencer38c91a92007-02-28 02:24:54 +00003537 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3538 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003539 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003540 ;}
3541 break;
3542
3543 case 127:
3544#line 1314 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3545 { // Structure type?
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003546 std::vector<const Type*> Elements;
Reid Spencer38c91a92007-02-28 02:24:54 +00003547 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3548 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003549 Elements.push_back(*I);
3550
Reid Spencer38c91a92007-02-28 02:24:54 +00003551 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3552 delete (yyvsp[-1].TypeList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003553 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003554 ;}
3555 break;
3556
3557 case 128:
3558#line 1324 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3559 { // Empty structure type?
3560 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003561 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003562 ;}
3563 break;
3564
3565 case 129:
3566#line 1328 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3567 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003568 std::vector<const Type*> Elements;
Reid Spencer38c91a92007-02-28 02:24:54 +00003569 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(),
3570 E = (yyvsp[-2].TypeList)->end(); I != E; ++I)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003571 Elements.push_back(*I);
3572
Reid Spencer38c91a92007-02-28 02:24:54 +00003573 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3574 delete (yyvsp[-2].TypeList);
Reid Spencer14310612006-12-31 05:40:51 +00003575 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003576 ;}
3577 break;
3578
3579 case 130:
3580#line 1338 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3581 { // Empty structure type?
3582 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003583 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003584 ;}
3585 break;
3586
3587 case 131:
3588#line 1345 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3589 {
3590 (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal);
3591 (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs);
3592 ;}
3593 break;
3594
3595 case 132:
3596#line 1352 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3597 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003598 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003599 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3600 if (!(*(yyvsp[0].TypeVal))->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00003601 GEN_ERROR("LLVM functions cannot return aggregate types");
Reid Spencer38c91a92007-02-28 02:24:54 +00003602 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3603 ;}
3604 break;
3605
3606 case 133:
3607#line 1359 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3608 {
3609 (yyval.TypeVal) = new PATypeHolder(Type::VoidTy);
3610 ;}
3611 break;
3612
3613 case 134:
3614#line 1364 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3615 {
3616 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
3617 (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer6f407902007-01-13 05:00:46 +00003618 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003619 ;}
3620 break;
3621
3622 case 135:
3623#line 1369 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3624 {
3625 ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs));
Reid Spencer3da59db2006-11-27 01:05:10 +00003626 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003627 ;}
3628 break;
3629
3630 case 137:
3631#line 1377 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3632 {
3633 (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003634 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3635 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003636 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003637 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003638 ;}
3639 break;
3640
3641 case 138:
3642#line 1384 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3643 {
3644 (yyval.TypeWithAttrsList) = new TypeWithAttrsList;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003645 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
3646 TWA.Ty = new PATypeHolder(Type::VoidTy);
Reid Spencer38c91a92007-02-28 02:24:54 +00003647 (yyval.TypeWithAttrsList)->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003648 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003649 ;}
3650 break;
3651
3652 case 139:
3653#line 1391 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3654 {
3655 (yyval.TypeWithAttrsList) = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003656 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003657 ;}
3658 break;
3659
3660 case 140:
3661#line 1399 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3662 {
3663 (yyval.TypeList) = new std::list<PATypeHolder>();
3664 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003665 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003666 ;}
3667 break;
3668
3669 case 141:
3670#line 1404 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3671 {
3672 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003673 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003674 ;}
3675 break;
3676
3677 case 142:
3678#line 1415 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3679 { // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003680 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003681 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3682 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003683 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003684 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003685 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003686 const Type *ETy = ATy->getElementType();
3687 int NumElements = ATy->getNumElements();
3688
3689 // Verify that we have the correct size...
Reid Spencer38c91a92007-02-28 02:24:54 +00003690 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003691 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003692 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003693 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003694
3695 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00003696 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3697 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003698 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3699 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer38c91a92007-02-28 02:24:54 +00003700 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003701 }
3702
Reid Spencer38c91a92007-02-28 02:24:54 +00003703 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3704 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003705 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003706 ;}
3707 break;
3708
3709 case 143:
3710#line 1443 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3711 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003712 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003713 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3714 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003715 if (ATy == 0)
3716 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003717 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003718
Andrew Lenharth6353e052006-12-08 18:07:09 +00003719 int NumElements = ATy->getNumElements();
3720 if (NumElements != -1 && NumElements != 0)
3721 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003722 " arguments, but has size of " + itostr(NumElements) +"");
Reid Spencer38c91a92007-02-28 02:24:54 +00003723 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3724 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003725 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003726 ;}
3727 break;
3728
3729 case 144:
3730#line 1459 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3731 {
Reid Spencer14310612006-12-31 05:40:51 +00003732 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003733 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3734 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003735 if (ATy == 0)
3736 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003737 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer61c83e02006-08-18 08:43:06 +00003738
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003739 int NumElements = ATy->getNumElements();
3740 const Type *ETy = ATy->getElementType();
Reid Spencer38c91a92007-02-28 02:24:54 +00003741 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3742 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003743 GEN_ERROR("Can't build string constant of size " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003744 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003745 " when array has size " + itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003746 std::vector<Constant*> Vals;
3747 if (ETy == Type::Int8Ty) {
Reid Spencer38c91a92007-02-28 02:24:54 +00003748 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003749 C != (unsigned char*)EndStr; ++C)
3750 Vals.push_back(ConstantInt::get(ETy, *C));
3751 } else {
Reid Spencer38c91a92007-02-28 02:24:54 +00003752 free((yyvsp[0].StrVal));
Reid Spencerb5334b02007-02-05 10:18:06 +00003753 GEN_ERROR("Cannot build string arrays of non byte sized elements");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003754 }
Reid Spencer38c91a92007-02-28 02:24:54 +00003755 free((yyvsp[0].StrVal));
3756 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3757 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003758 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003759 ;}
3760 break;
3761
3762 case 145:
3763#line 1488 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3764 { // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003765 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003766 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
3767 const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003768 if (PTy == 0)
3769 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003770 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003771 const Type *ETy = PTy->getElementType();
3772 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003773
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003774 // Verify that we have the correct size...
Reid Spencer38c91a92007-02-28 02:24:54 +00003775 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003776 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer38c91a92007-02-28 02:24:54 +00003777 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003778 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003779
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003780 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00003781 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3782 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003783 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3784 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer38c91a92007-02-28 02:24:54 +00003785 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003786 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003787
Reid Spencer38c91a92007-02-28 02:24:54 +00003788 (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[-1].ConstVector));
3789 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003790 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003791 ;}
3792 break;
3793
3794 case 146:
3795#line 1516 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3796 {
3797 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003798 if (STy == 0)
3799 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003800 (*(yyvsp[-3].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003801
Reid Spencer38c91a92007-02-28 02:24:54 +00003802 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003803 GEN_ERROR("Illegal number of initializers for structure type");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003804
3805 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer38c91a92007-02-28 02:24:54 +00003806 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3807 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003808 GEN_ERROR("Expected type '" +
3809 STy->getElementType(i)->getDescription() +
3810 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003811 " of structure initializer");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003812
3813 // Check to ensure that Type is not packed
3814 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003815 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003816
Reid Spencer38c91a92007-02-28 02:24:54 +00003817 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3818 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003819 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003820 ;}
3821 break;
3822
3823 case 147:
3824#line 1541 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3825 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003826 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003827 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
3828 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003829 if (STy == 0)
3830 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003831 (*(yyvsp[-2].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003832
3833 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003834 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003835
3836 // Check to ensure that Type is not packed
3837 if (STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003838 GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003839
Reid Spencer38c91a92007-02-28 02:24:54 +00003840 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3841 delete (yyvsp[-2].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003842 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003843 ;}
3844 break;
3845
3846 case 148:
3847#line 1560 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3848 {
3849 const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003850 if (STy == 0)
3851 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003852 (*(yyvsp[-5].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003853
Reid Spencer38c91a92007-02-28 02:24:54 +00003854 if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003855 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003856
3857 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer38c91a92007-02-28 02:24:54 +00003858 for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i)
3859 if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003860 GEN_ERROR("Expected type '" +
3861 STy->getElementType(i)->getDescription() +
3862 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003863 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003864
3865 // Check to ensure that Type is packed
3866 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003867 GEN_ERROR("Vector initializer to non-vector type '" +
3868 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003869
Reid Spencer38c91a92007-02-28 02:24:54 +00003870 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector));
3871 delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003872 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003873 ;}
3874 break;
3875
3876 case 149:
3877#line 1586 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3878 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003879 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003880 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
3881 const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003882 if (STy == 0)
3883 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003884 (*(yyvsp[-4].TypeVal))->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003885
3886 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003887 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003888
3889 // Check to ensure that Type is packed
3890 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003891 GEN_ERROR("Vector initializer to non-vector type '" +
3892 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003893
Reid Spencer38c91a92007-02-28 02:24:54 +00003894 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3895 delete (yyvsp[-4].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003896 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003897 ;}
3898 break;
3899
3900 case 150:
3901#line 1606 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3902 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003903 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003904 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3905 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003906 if (PTy == 0)
3907 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00003908 (*(yyvsp[-1].TypeVal))->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003909
Reid Spencer38c91a92007-02-28 02:24:54 +00003910 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3911 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003912 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003913 ;}
3914 break;
3915
3916 case 151:
3917#line 1618 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3918 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00003919 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003920 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3921 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3922 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003923 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003924 ;}
3925 break;
3926
3927 case 152:
3928#line 1625 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3929 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003930 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00003931 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
3932 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003933 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003934 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003935
3936 // ConstExprs can exist in the body of a function, thus creating
3937 // GlobalValues whenever they refer to a variable. Because we are in
3938 // the context of a function, getValNonImprovising will search the functions
3939 // symbol table instead of the module symbol table for the global symbol,
3940 // which throws things all off. To get around this, we just tell
3941 // getValNonImprovising that we are at global scope here.
3942 //
3943 Function *SavedCurFn = CurFun.CurrentFunction;
3944 CurFun.CurrentFunction = 0;
3945
Reid Spencer38c91a92007-02-28 02:24:54 +00003946 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003947 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003948
3949 CurFun.CurrentFunction = SavedCurFn;
3950
3951 // If this is an initializer for a constant pointer, which is referencing a
3952 // (currently) undefined variable, create a stub now that shall be replaced
3953 // in the future with the right type of variable.
3954 //
3955 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00003956 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003957 const PointerType *PT = cast<PointerType>(Ty);
3958
3959 // First check to see if the forward references value is already created!
3960 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer38c91a92007-02-28 02:24:54 +00003961 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003962
3963 if (I != CurModule.GlobalRefs.end()) {
3964 V = I->second; // Placeholder already exists, use it...
Reid Spencer38c91a92007-02-28 02:24:54 +00003965 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003966 } else {
3967 std::string Name;
Reid Spencer38c91a92007-02-28 02:24:54 +00003968 if ((yyvsp[0].ValIDVal).Type == ValID::GlobalName)
3969 Name = (yyvsp[0].ValIDVal).Name;
3970 else if ((yyvsp[0].ValIDVal).Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003971 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003972
3973 // Create the forward referenced global.
3974 GlobalValue *GV;
3975 if (const FunctionType *FTy =
3976 dyn_cast<FunctionType>(PT->getElementType())) {
3977 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3978 CurModule.CurrentModule);
3979 } else {
3980 GV = new GlobalVariable(PT->getElementType(), false,
3981 GlobalValue::ExternalLinkage, 0,
3982 Name, CurModule.CurrentModule);
3983 }
3984
3985 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer38c91a92007-02-28 02:24:54 +00003986 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003987 V = GV;
3988 }
3989 }
3990
Reid Spencer38c91a92007-02-28 02:24:54 +00003991 (yyval.ConstVal) = cast<GlobalValue>(V);
3992 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003993 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00003994 ;}
3995 break;
3996
3997 case 153:
3998#line 1691 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3999 {
Reid Spencer14310612006-12-31 05:40:51 +00004000 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004001 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4002 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004003 GEN_ERROR("Mismatched types for constant expression: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00004004 (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription());
4005 (yyval.ConstVal) = (yyvsp[0].ConstVal);
4006 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004007 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004008 ;}
4009 break;
4010
4011 case 154:
4012#line 1701 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4013 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004014 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004015 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4016 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004017 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencerb5334b02007-02-05 10:18:06 +00004018 GEN_ERROR("Cannot create a null initialized value of this type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004019 (yyval.ConstVal) = Constant::getNullValue(Ty);
4020 delete (yyvsp[-1].TypeVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004021 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004022 ;}
4023 break;
4024
4025 case 155:
4026#line 1711 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
4027 { // integral constants
4028 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004029 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004030 APInt Val(64, (yyvsp[0].SInt64Val));
4031 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
Reid Spencer10794272007-03-01 19:41:47 +00004032 Val.sextOrTrunc(BitWidth);
4033 (yyval.ConstVal) = ConstantInt::get(Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004034 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004035 ;}
4036 break;
4037
4038 case 156:
Reid Spencer10794272007-03-01 19:41:47 +00004039#line 1720 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004040 { // arbitrary precision integer constants
4041 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4042 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
4043 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004044 }
4045 (yyvsp[0].APIntVal)->sextOrTrunc(BitWidth);
4046 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004047 delete (yyvsp[0].APIntVal);
4048 CHECK_FOR_ERROR
4049 ;}
4050 break;
4051
4052 case 157:
Reid Spencer10794272007-03-01 19:41:47 +00004053#line 1730 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004054 { // integral constants
4055 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004056 GEN_ERROR("Constant value doesn't fit in type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004057 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4058 APInt Val(BitWidth, (yyvsp[0].UInt64Val));
Reid Spencer10794272007-03-01 19:41:47 +00004059 (yyval.ConstVal) = ConstantInt::get(Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004060 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004061 ;}
4062 break;
4063
4064 case 158:
Reid Spencer10794272007-03-01 19:41:47 +00004065#line 1738 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004066 { // arbitrary precision integer constants
4067 uint32_t BitWidth = cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth();
4068 if ((yyvsp[0].APIntVal)->getBitWidth() > BitWidth) {
4069 GEN_ERROR("Constant value does not fit in type");
Reid Spencer10794272007-03-01 19:41:47 +00004070 }
4071 (yyvsp[0].APIntVal)->zextOrTrunc(BitWidth);
4072 (yyval.ConstVal) = ConstantInt::get(*(yyvsp[0].APIntVal));
Reid Spencer38c91a92007-02-28 02:24:54 +00004073 delete (yyvsp[0].APIntVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004074 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004075 ;}
4076 break;
4077
4078 case 159:
Reid Spencer10794272007-03-01 19:41:47 +00004079#line 1748 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004080 { // Boolean constants
4081 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4082 (yyval.ConstVal) = ConstantInt::getTrue();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004083 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004084 ;}
4085 break;
4086
4087 case 160:
Reid Spencer10794272007-03-01 19:41:47 +00004088#line 1753 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004089 { // Boolean constants
4090 assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?");
4091 (yyval.ConstVal) = ConstantInt::getFalse();
4092 CHECK_FOR_ERROR
4093 ;}
4094 break;
4095
4096 case 161:
Reid Spencer10794272007-03-01 19:41:47 +00004097#line 1758 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004098 { // Float & Double constants
4099 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004100 GEN_ERROR("Floating point constant invalid for type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004101 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer6f407902007-01-13 05:00:46 +00004102 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004103 ;}
4104 break;
4105
4106 case 162:
Reid Spencer10794272007-03-01 19:41:47 +00004107#line 1766 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004108 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004109 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004110 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4111 Constant *Val = (yyvsp[-3].ConstVal);
4112 const Type *DestTy = (yyvsp[-1].TypeVal)->get();
4113 if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004114 GEN_ERROR("invalid cast opcode for cast from '" +
4115 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004116 DestTy->getDescription() + "'");
Reid Spencer38c91a92007-02-28 02:24:54 +00004117 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy);
4118 delete (yyvsp[-1].TypeVal);
4119 ;}
4120 break;
4121
4122 case 163:
Reid Spencer10794272007-03-01 19:41:47 +00004123#line 1778 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004124 {
4125 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004126 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004127
4128 const Type *IdxTy =
Reid Spencer38c91a92007-02-28 02:24:54 +00004129 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), &(*(yyvsp[-1].ValueList))[0], (yyvsp[-1].ValueList)->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00004130 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004131 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004132 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004133
Chris Lattnerf7469af2007-01-31 04:44:08 +00004134 SmallVector<Constant*, 8> IdxVec;
Reid Spencer38c91a92007-02-28 02:24:54 +00004135 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
4136 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004137 IdxVec.push_back(C);
4138 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004139 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004140
Reid Spencer38c91a92007-02-28 02:24:54 +00004141 delete (yyvsp[-1].ValueList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004142
Reid Spencer38c91a92007-02-28 02:24:54 +00004143 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00004144 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004145 ;}
4146 break;
4147
4148 case 164:
Reid Spencer10794272007-03-01 19:41:47 +00004149#line 1800 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004150 {
4151 if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00004152 GEN_ERROR("Select condition must be of boolean type");
Reid Spencer38c91a92007-02-28 02:24:54 +00004153 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004154 GEN_ERROR("Select operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004155 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004156 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004157 ;}
4158 break;
4159
4160 case 165:
Reid Spencer10794272007-03-01 19:41:47 +00004161#line 1808 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004162 {
4163 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004164 GEN_ERROR("Binary operator types must match");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004165 CHECK_FOR_ERROR;
Reid Spencer38c91a92007-02-28 02:24:54 +00004166 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4167 ;}
4168 break;
4169
4170 case 166:
Reid Spencer10794272007-03-01 19:41:47 +00004171#line 1814 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004172 {
4173 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004174 GEN_ERROR("Logical operator types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004175 if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) {
4176 if (Instruction::isShift((yyvsp[-5].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].ConstVal)->getType()) ||
4177 !cast<VectorType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00004178 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004179 }
Reid Spencer38c91a92007-02-28 02:24:54 +00004180 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004181 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004182 ;}
4183 break;
4184
4185 case 167:
Reid Spencer10794272007-03-01 19:41:47 +00004186#line 1825 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004187 {
4188 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004189 GEN_ERROR("icmp operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004190 (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4191 ;}
4192 break;
4193
4194 case 168:
Reid Spencer10794272007-03-01 19:41:47 +00004195#line 1830 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004196 {
4197 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00004198 GEN_ERROR("fcmp operand types must match");
Reid Spencer38c91a92007-02-28 02:24:54 +00004199 (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
4200 ;}
4201 break;
4202
4203 case 169:
Reid Spencer10794272007-03-01 19:41:47 +00004204#line 1835 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004205 {
4206 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004207 GEN_ERROR("Invalid extractelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004208 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004209 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004210 ;}
4211 break;
4212
4213 case 170:
Reid Spencer10794272007-03-01 19:41:47 +00004214#line 1841 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004215 {
4216 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004217 GEN_ERROR("Invalid insertelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004218 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004219 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004220 ;}
4221 break;
4222
4223 case 171:
Reid Spencer10794272007-03-01 19:41:47 +00004224#line 1847 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004225 {
4226 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00004227 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00004228 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004229 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004230 ;}
4231 break;
4232
4233 case 172:
Reid Spencer10794272007-03-01 19:41:47 +00004234#line 1856 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004235 {
4236 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004237 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004238 ;}
4239 break;
4240
4241 case 173:
Reid Spencer10794272007-03-01 19:41:47 +00004242#line 1860 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004243 {
4244 (yyval.ConstVector) = new std::vector<Constant*>();
4245 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004246 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004247 ;}
4248 break;
4249
4250 case 174:
Reid Spencer10794272007-03-01 19:41:47 +00004251#line 1868 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004252 { (yyval.BoolVal) = false; ;}
4253 break;
4254
4255 case 175:
Reid Spencer10794272007-03-01 19:41:47 +00004256#line 1868 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004257 { (yyval.BoolVal) = true; ;}
4258 break;
4259
4260 case 176:
Reid Spencer10794272007-03-01 19:41:47 +00004261#line 1879 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004262 {
4263 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004264 CurModule.ModuleDone();
4265 CHECK_FOR_ERROR;
Reid Spencer38c91a92007-02-28 02:24:54 +00004266 ;}
4267 break;
4268
4269 case 177:
Reid Spencer10794272007-03-01 19:41:47 +00004270#line 1884 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004271 {
4272 (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004273 CurModule.ModuleDone();
4274 CHECK_FOR_ERROR;
Reid Spencer38c91a92007-02-28 02:24:54 +00004275 ;}
4276 break;
4277
4278 case 180:
Reid Spencer10794272007-03-01 19:41:47 +00004279#line 1897 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004280 { CurFun.isDeclare = false; ;}
4281 break;
4282
4283 case 181:
Reid Spencer10794272007-03-01 19:41:47 +00004284#line 1897 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004285 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004286 CurFun.FunctionDone();
4287 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004288 ;}
4289 break;
4290
4291 case 182:
Reid Spencer10794272007-03-01 19:41:47 +00004292#line 1901 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004293 { CurFun.isDeclare = true; ;}
4294 break;
4295
4296 case 183:
Reid Spencer10794272007-03-01 19:41:47 +00004297#line 1901 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004298 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004299 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004300 ;}
4301 break;
4302
4303 case 184:
Reid Spencer10794272007-03-01 19:41:47 +00004304#line 1904 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004305 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004306 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004307 ;}
4308 break;
4309
4310 case 185:
Reid Spencer10794272007-03-01 19:41:47 +00004311#line 1907 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004312 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004313 // Emit an error if there are any unresolved types left.
4314 if (!CurModule.LateResolveTypes.empty()) {
4315 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004316 if (DID.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +00004317 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
4318 } else {
4319 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
4320 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004321 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004322 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004323 ;}
4324 break;
4325
4326 case 186:
Reid Spencer10794272007-03-01 19:41:47 +00004327#line 1919 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004328 {
Reid Spencer14310612006-12-31 05:40:51 +00004329 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004330 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004331 // Eagerly resolve types. This is not an optimization, this is a
4332 // requirement that is due to the fact that we could have this:
4333 //
4334 // %list = type { %list * }
4335 // %list = type { %list * } ; repeated type decl
4336 //
4337 // If types are not resolved eagerly, then the two types will not be
4338 // determined to be the same type!
4339 //
Reid Spencer38c91a92007-02-28 02:24:54 +00004340 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004341
Reid Spencer38c91a92007-02-28 02:24:54 +00004342 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004343 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004344 // If this is a named type that is not a redefinition, add it to the slot
4345 // table.
Reid Spencer38c91a92007-02-28 02:24:54 +00004346 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004347 }
Reid Spencera132e042006-12-03 05:46:11 +00004348
Reid Spencer38c91a92007-02-28 02:24:54 +00004349 delete (yyvsp[0].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004350 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004351 ;}
4352 break;
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00004353
Reid Spencer38c91a92007-02-28 02:24:54 +00004354 case 187:
Reid Spencer10794272007-03-01 19:41:47 +00004355#line 1943 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004356 {
4357 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType));
4358
4359 if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004360 CHECK_FOR_ERROR
4361 // If this is a named type that is not a redefinition, add it to the slot
4362 // table.
Reid Spencer38c91a92007-02-28 02:24:54 +00004363 CurModule.Types.push_back((yyvsp[0].PrimType));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004364 }
Reid Spencer6e18b7d2006-12-03 06:59:29 +00004365 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004366 ;}
4367 break;
4368
4369 case 188:
Reid Spencer10794272007-03-01 19:41:47 +00004370#line 1954 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004371 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004372 /* "Externally Visible" Linkage */
Reid Spencer38c91a92007-02-28 02:24:54 +00004373 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004374 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer38c91a92007-02-28 02:24:54 +00004375 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage,
4376 (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004377 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004378 ;}
4379 break;
4380
4381 case 189:
Reid Spencer10794272007-03-01 19:41:47 +00004382#line 1961 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004383 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004384 CurGV = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00004385 ;}
4386 break;
4387
4388 case 190:
Reid Spencer10794272007-03-01 19:41:47 +00004389#line 1964 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004390 {
4391 if ((yyvsp[0].ConstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004392 GEN_ERROR("Global value initializer is not a constant");
Reid Spencer38c91a92007-02-28 02:24:54 +00004393 CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004394 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004395 ;}
4396 break;
4397
4398 case 191:
Reid Spencer10794272007-03-01 19:41:47 +00004399#line 1969 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004400 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004401 CurGV = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00004402 ;}
4403 break;
4404
4405 case 192:
Reid Spencer10794272007-03-01 19:41:47 +00004406#line 1972 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004407 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004408 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004409 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
4410 CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004411 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004412 delete (yyvsp[0].TypeVal);
4413 ;}
4414 break;
4415
4416 case 193:
Reid Spencer10794272007-03-01 19:41:47 +00004417#line 1978 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004418 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004419 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004420 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004421 ;}
4422 break;
4423
4424 case 194:
Reid Spencer10794272007-03-01 19:41:47 +00004425#line 1982 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004426 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004427 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004428 ;}
4429 break;
4430
4431 case 195:
Reid Spencer10794272007-03-01 19:41:47 +00004432#line 1985 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004433 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004434 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004435 ;}
4436 break;
4437
4438 case 196:
Reid Spencer10794272007-03-01 19:41:47 +00004439#line 1991 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004440 {
Chris Lattner66316012006-01-24 04:14:29 +00004441 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer38c91a92007-02-28 02:24:54 +00004442 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4443 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4444 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004445
4446 if (AsmSoFar.empty())
4447 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4448 else
4449 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004450 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004451;}
4452 break;
4453
4454 case 197:
Reid Spencer10794272007-03-01 19:41:47 +00004455#line 2004 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004456 {
4457 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4458 free((yyvsp[0].StrVal));
4459 ;}
4460 break;
4461
4462 case 198:
Reid Spencer10794272007-03-01 19:41:47 +00004463#line 2008 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004464 {
4465 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4466 free((yyvsp[0].StrVal));
4467 ;}
4468 break;
4469
4470 case 200:
Reid Spencer10794272007-03-01 19:41:47 +00004471#line 2015 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004472 {
4473 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4474 free((yyvsp[0].StrVal));
Reid Spencer41dff5e2007-01-26 08:05:27 +00004475 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004476 ;}
4477 break;
4478
4479 case 201:
Reid Spencer10794272007-03-01 19:41:47 +00004480#line 2020 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004481 {
4482 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4483 free((yyvsp[0].StrVal));
Reid Spencera54b7cb2007-01-12 07:05:14 +00004484 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004485 ;}
4486 break;
4487
4488 case 202:
Reid Spencer10794272007-03-01 19:41:47 +00004489#line 2025 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004490 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004491 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004492 ;}
4493 break;
4494
4495 case 203:
Reid Spencer10794272007-03-01 19:41:47 +00004496#line 2034 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004497 {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004498 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004499 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4500 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004501 GEN_ERROR("void typed arguments are invalid");
Reid Spencer38c91a92007-02-28 02:24:54 +00004502 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4503 (yyval.ArgList) = (yyvsp[-4].ArgList);
4504 (yyvsp[-4].ArgList)->push_back(E);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004505 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004506 ;}
4507 break;
4508
4509 case 204:
Reid Spencer10794272007-03-01 19:41:47 +00004510#line 2044 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004511 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004512 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004513 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
4514 if (*(yyvsp[-2].TypeVal) == Type::VoidTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00004515 GEN_ERROR("void typed arguments are invalid");
Reid Spencer38c91a92007-02-28 02:24:54 +00004516 ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal);
4517 (yyval.ArgList) = new ArgListType;
4518 (yyval.ArgList)->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004519 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004520 ;}
4521 break;
4522
4523 case 205:
Reid Spencer10794272007-03-01 19:41:47 +00004524#line 2055 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004525 {
4526 (yyval.ArgList) = (yyvsp[0].ArgList);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004527 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004528 ;}
4529 break;
4530
4531 case 206:
Reid Spencer10794272007-03-01 19:41:47 +00004532#line 2059 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004533 {
4534 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004535 struct ArgListEntry E;
4536 E.Ty = new PATypeHolder(Type::VoidTy);
4537 E.Name = 0;
4538 E.Attrs = FunctionType::NoAttributeSet;
Reid Spencer38c91a92007-02-28 02:24:54 +00004539 (yyval.ArgList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004540 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004541 ;}
4542 break;
4543
4544 case 207:
Reid Spencer10794272007-03-01 19:41:47 +00004545#line 2068 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004546 {
4547 (yyval.ArgList) = new ArgListType;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004548 struct ArgListEntry E;
4549 E.Ty = new PATypeHolder(Type::VoidTy);
4550 E.Name = 0;
4551 E.Attrs = FunctionType::NoAttributeSet;
Reid Spencer38c91a92007-02-28 02:24:54 +00004552 (yyval.ArgList)->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004553 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004554 ;}
4555 break;
4556
4557 case 208:
Reid Spencer10794272007-03-01 19:41:47 +00004558#line 2077 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004559 {
4560 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004561 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004562 ;}
4563 break;
4564
4565 case 209:
Reid Spencer10794272007-03-01 19:41:47 +00004566#line 2083 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004567 {
4568 UnEscapeLexed((yyvsp[-6].StrVal));
4569 std::string FunctionName((yyvsp[-6].StrVal));
4570 free((yyvsp[-6].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004571
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004572 // Check the function result for abstractness if this is a define. We should
4573 // have no abstract types at this point
Reid Spencer38c91a92007-02-28 02:24:54 +00004574 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal)))
4575 GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004576
Reid Spencer68a24bd2005-08-27 18:50:39 +00004577 std::vector<const Type*> ParamTypeList;
Reid Spencer14310612006-12-31 05:40:51 +00004578 std::vector<FunctionType::ParameterAttributes> ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00004579 ParamAttrs.push_back((yyvsp[-2].ParamAttrs));
4580 if ((yyvsp[-4].ArgList)) { // If there are arguments...
4581 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004582 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004583 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4584 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004585 ParamTypeList.push_back(Ty);
4586 if (Ty != Type::VoidTy)
4587 ParamAttrs.push_back(I->Attrs);
4588 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004589 }
4590
4591 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4592 if (isVarArg) ParamTypeList.pop_back();
4593
Reid Spencer38c91a92007-02-28 02:24:54 +00004594 FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg,
Reid Spencer14310612006-12-31 05:40:51 +00004595 ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004596 const PointerType *PFT = PointerType::get(FT);
Reid Spencer38c91a92007-02-28 02:24:54 +00004597 delete (yyvsp[-7].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004598
4599 ValID ID;
4600 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004601 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004602 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004603 ID = ValID::createGlobalID(CurModule.Values[PFT].size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004604 }
4605
4606 Function *Fn = 0;
4607 // See if this function was forward referenced. If so, recycle the object.
4608 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4609 // Move the function to the end of the list, from whereever it was
4610 // previously inserted.
4611 Fn = cast<Function>(FWRef);
4612 CurModule.CurrentModule->getFunctionList().remove(Fn);
4613 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4614 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004615 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
4616 if (Fn->getFunctionType() != FT ) {
4617 // The existing function doesn't have the same type. This is an overload
4618 // error.
4619 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4620 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
4621 // Neither the existing or the current function is a declaration and they
4622 // have the same name and same type. Clearly this is a redefinition.
Reid Spencerb5334b02007-02-05 10:18:06 +00004623 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004624 } if (Fn->isDeclaration()) {
4625 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004626 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4627 AI != AE; ++AI)
4628 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004629 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004630 } else { // Not already defined?
4631 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4632 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004633
Reid Spencer68a24bd2005-08-27 18:50:39 +00004634 InsertValue(Fn, CurModule.Values);
4635 }
4636
4637 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004638
4639 if (CurFun.isDeclare) {
4640 // If we have declaration, always overwrite linkage. This will allow us to
4641 // correctly handle cases, when pointer to function is passed as argument to
4642 // another function.
4643 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004644 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004645 }
Reid Spencer38c91a92007-02-28 02:24:54 +00004646 Fn->setCallingConv((yyvsp[-8].UIntVal));
4647 Fn->setAlignment((yyvsp[0].UIntVal));
4648 if ((yyvsp[-1].StrVal)) {
4649 Fn->setSection((yyvsp[-1].StrVal));
4650 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004651 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004652
4653 // Add all of the arguments we parsed to the function...
Reid Spencer38c91a92007-02-28 02:24:54 +00004654 if ((yyvsp[-4].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004655 if (isVarArg) { // Nuke the last entry
Reid Spencer38c91a92007-02-28 02:24:54 +00004656 assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004657 "Not a varargs marker!");
Reid Spencer38c91a92007-02-28 02:24:54 +00004658 delete (yyvsp[-4].ArgList)->back().Ty;
4659 (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004660 }
4661 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004662 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004663 unsigned Idx = 1;
Reid Spencer38c91a92007-02-28 02:24:54 +00004664 for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin();
4665 I != (yyvsp[-4].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004666 delete I->Ty; // Delete the typeholder...
Reid Spenceref9b9a72007-02-05 20:47:22 +00004667 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004668 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004669 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004670 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004671 }
Reid Spencera132e042006-12-03 05:46:11 +00004672
Reid Spencer38c91a92007-02-28 02:24:54 +00004673 delete (yyvsp[-4].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004674 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004675 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004676;}
4677 break;
4678
4679 case 212:
Reid Spencer10794272007-03-01 19:41:47 +00004680#line 2196 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004681 {
4682 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004683
4684 // Make sure that we keep track of the linkage type even if there was a
4685 // previous "declare".
Reid Spencer38c91a92007-02-28 02:24:54 +00004686 (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage));
4687 (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility));
4688;}
4689 break;
4690
4691 case 215:
Reid Spencer10794272007-03-01 19:41:47 +00004692#line 2207 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004693 {
4694 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004695 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004696;}
4697 break;
4698
4699 case 216:
Reid Spencer10794272007-03-01 19:41:47 +00004700#line 2212 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004701 {
4702 CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage));
4703 CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility));
4704 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004705 CurFun.FunctionDone();
4706 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004707 ;}
4708 break;
4709
4710 case 217:
Reid Spencer10794272007-03-01 19:41:47 +00004711#line 2224 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004712 {
4713 (yyval.BoolVal) = false;
Reid Spencer41dff5e2007-01-26 08:05:27 +00004714 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004715 ;}
4716 break;
4717
4718 case 218:
Reid Spencer10794272007-03-01 19:41:47 +00004719#line 2228 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004720 {
4721 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004722 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004723 ;}
4724 break;
4725
4726 case 219:
Reid Spencer10794272007-03-01 19:41:47 +00004727#line 2233 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004728 { // A reference to a direct constant
4729 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004730 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004731 ;}
4732 break;
4733
4734 case 220:
Reid Spencer10794272007-03-01 19:41:47 +00004735#line 2237 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004736 {
4737 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Reid Spencer6f407902007-01-13 05:00:46 +00004738 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004739 ;}
4740 break;
4741
4742 case 221:
Reid Spencer10794272007-03-01 19:41:47 +00004743#line 2241 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004744 { // Perhaps it's an FP constant?
4745 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004746 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004747 ;}
4748 break;
4749
4750 case 222:
Reid Spencer10794272007-03-01 19:41:47 +00004751#line 2245 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004752 {
4753 (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004754 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004755 ;}
4756 break;
4757
4758 case 223:
Reid Spencer10794272007-03-01 19:41:47 +00004759#line 2249 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004760 {
4761 (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004762 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004763 ;}
4764 break;
4765
4766 case 224:
Reid Spencer10794272007-03-01 19:41:47 +00004767#line 2253 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004768 {
4769 (yyval.ValIDVal) = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004770 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004771 ;}
4772 break;
4773
4774 case 225:
Reid Spencer10794272007-03-01 19:41:47 +00004775#line 2257 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004776 {
4777 (yyval.ValIDVal) = ValID::createUndef();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004778 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004779 ;}
4780 break;
4781
4782 case 226:
Reid Spencer10794272007-03-01 19:41:47 +00004783#line 2261 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004784 { // A vector zero constant.
4785 (yyval.ValIDVal) = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00004786 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004787 ;}
4788 break;
4789
4790 case 227:
Reid Spencer10794272007-03-01 19:41:47 +00004791#line 2265 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004792 { // Nonempty unsized packed vector
4793 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4794 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004795
Reid Spencer9d6565a2007-02-15 02:26:10 +00004796 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004797 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004798 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004799 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004800 ETy,
4801 NumElements)
4802 )
4803 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004804
4805 // Verify all elements are correct type!
Reid Spencer38c91a92007-02-28 02:24:54 +00004806 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4807 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004808 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004809 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00004810 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004811 }
4812
Reid Spencer38c91a92007-02-28 02:24:54 +00004813 (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[-1].ConstVector)));
4814 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer41dff5e2007-01-26 08:05:27 +00004815 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004816 ;}
4817 break;
4818
4819 case 228:
Reid Spencer10794272007-03-01 19:41:47 +00004820#line 2290 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004821 {
4822 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004823 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004824 ;}
4825 break;
4826
4827 case 229:
Reid Spencer10794272007-03-01 19:41:47 +00004828#line 2294 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004829 {
4830 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4831 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4832 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4833 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4834 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4835 free((yyvsp[-2].StrVal));
4836 free((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004837 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004838 ;}
4839 break;
4840
4841 case 230:
Reid Spencer10794272007-03-01 19:41:47 +00004842#line 2308 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004843 { // Is it an integer reference...?
4844 (yyval.ValIDVal) = ValID::createLocalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004845 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004846 ;}
4847 break;
4848
4849 case 231:
Reid Spencer10794272007-03-01 19:41:47 +00004850#line 2312 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004851 {
4852 (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[0].UIntVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004853 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004854 ;}
4855 break;
4856
4857 case 232:
Reid Spencer10794272007-03-01 19:41:47 +00004858#line 2316 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004859 { // Is it a named reference...?
4860 (yyval.ValIDVal) = ValID::createLocalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004861 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004862 ;}
4863 break;
4864
4865 case 233:
Reid Spencer10794272007-03-01 19:41:47 +00004866#line 2320 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004867 { // Is it a named reference...?
4868 (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[0].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004869 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004870 ;}
4871 break;
4872
4873 case 236:
Reid Spencer10794272007-03-01 19:41:47 +00004874#line 2332 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004875 {
Reid Spencer832254e2007-02-02 02:16:23 +00004876 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00004877 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
4878 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
4879 delete (yyvsp[-1].TypeVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004880 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004881 ;}
4882 break;
4883
4884 case 237:
Reid Spencer10794272007-03-01 19:41:47 +00004885#line 2341 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004886 {
4887 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004888 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004889 ;}
4890 break;
4891
4892 case 238:
Reid Spencer10794272007-03-01 19:41:47 +00004893#line 2345 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004894 { // Do not allow functions with 0 basic blocks
4895 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004896 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004897 ;}
4898 break;
4899
4900 case 239:
Reid Spencer10794272007-03-01 19:41:47 +00004901#line 2354 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004902 {
4903 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
Reid Spencer832254e2007-02-02 02:16:23 +00004904 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004905 InsertValue((yyvsp[0].TermInstVal));
4906 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4907 InsertValue((yyvsp[-2].BasicBlockVal));
4908 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004909 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004910 ;}
4911 break;
4912
4913 case 240:
Reid Spencer10794272007-03-01 19:41:47 +00004914#line 2364 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004915 {
4916 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004917 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4918 if (CI2->getParent() == 0)
Reid Spencer38c91a92007-02-28 02:24:54 +00004919 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
4920 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4921 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004922 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004923 ;}
4924 break;
4925
4926 case 241:
Reid Spencer10794272007-03-01 19:41:47 +00004927#line 2373 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004928 {
4929 (yyval.BasicBlockVal) = getBBVal(ValID::createLocalID(CurFun.NextBBNum++), true);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004930 CHECK_FOR_ERROR
4931
4932 // Make sure to move the basic block to the correct location in the
4933 // function, instead of leaving it inserted wherever it was first
4934 // referenced.
4935 Function::BasicBlockListType &BBL =
4936 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer38c91a92007-02-28 02:24:54 +00004937 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00004938 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004939 ;}
4940 break;
4941
4942 case 242:
Reid Spencer10794272007-03-01 19:41:47 +00004943#line 2385 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004944 {
4945 (yyval.BasicBlockVal) = getBBVal(ValID::createLocalName((yyvsp[0].StrVal)), true);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004946 CHECK_FOR_ERROR
4947
4948 // Make sure to move the basic block to the correct location in the
4949 // function, instead of leaving it inserted wherever it was first
4950 // referenced.
4951 Function::BasicBlockListType &BBL =
4952 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer38c91a92007-02-28 02:24:54 +00004953 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004954 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00004955 ;}
4956 break;
Reid Spencer3822ff52006-11-08 06:47:33 +00004957
Reid Spencer38c91a92007-02-28 02:24:54 +00004958 case 243:
Reid Spencer10794272007-03-01 19:41:47 +00004959#line 2398 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004960 { // Return with a result...
4961 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
4962 CHECK_FOR_ERROR
4963 ;}
4964 break;
4965
4966 case 244:
Reid Spencer10794272007-03-01 19:41:47 +00004967#line 2402 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004968 { // Return with no result...
4969 (yyval.TermInstVal) = new ReturnInst();
4970 CHECK_FOR_ERROR
4971 ;}
4972 break;
4973
4974 case 245:
Reid Spencer10794272007-03-01 19:41:47 +00004975#line 2406 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004976 { // Unconditional Branch...
4977 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
4978 CHECK_FOR_ERROR
4979 (yyval.TermInstVal) = new BranchInst(tmpBB);
4980 ;}
4981 break;
4982
4983 case 246:
Reid Spencer10794272007-03-01 19:41:47 +00004984#line 2411 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004985 {
4986 assert(cast<IntegerType>((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?");
4987 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
4988 CHECK_FOR_ERROR
4989 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
4990 CHECK_FOR_ERROR
4991 Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal));
4992 CHECK_FOR_ERROR
4993 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4994 ;}
4995 break;
4996
4997 case 247:
Reid Spencer10794272007-03-01 19:41:47 +00004998#line 2421 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00004999 {
5000 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
5001 CHECK_FOR_ERROR
5002 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
5003 CHECK_FOR_ERROR
5004 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
5005 (yyval.TermInstVal) = S;
5006
5007 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
5008 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005009 for (; I != E; ++I) {
5010 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5011 S->addCase(CI, I->second);
5012 else
Reid Spencerb5334b02007-02-05 10:18:06 +00005013 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005014 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005015 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00005016 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005017 ;}
5018 break;
5019
5020 case 248:
Reid Spencer10794272007-03-01 19:41:47 +00005021#line 2440 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005022 {
5023 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005024 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005025 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005026 CHECK_FOR_ERROR
5027 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencer38c91a92007-02-28 02:24:54 +00005028 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00005029 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005030 ;}
5031 break;
5032
5033 case 249:
Reid Spencer10794272007-03-01 19:41:47 +00005034#line 2450 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005035 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005036
Reid Spencer14310612006-12-31 05:40:51 +00005037 // Handle the short syntax
5038 const PointerType *PFTy = 0;
5039 const FunctionType *Ty = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00005040 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005041 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5042 // Pull out the types of all of the arguments...
5043 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005044 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00005045 ParamAttrs.push_back((yyvsp[-6].ParamAttrs));
5046 for (ValueRefList::iterator I = (yyvsp[-8].ValueRefList)->begin(), E = (yyvsp[-8].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005047 const Type *Ty = I->Val->getType();
5048 if (Ty == Type::VoidTy)
5049 GEN_ERROR("Short call syntax cannot be used with varargs");
5050 ParamTypes.push_back(Ty);
5051 ParamAttrs.push_back(I->Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005052 }
5053
Reid Spencer38c91a92007-02-28 02:24:54 +00005054 Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005055 PFTy = PointerType::get(Ty);
5056 }
5057
Reid Spencer38c91a92007-02-28 02:24:54 +00005058 Value *V = getVal(PFTy, (yyvsp[-10].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005059 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005060 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005061 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005062 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005063 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005064
Reid Spencer14310612006-12-31 05:40:51 +00005065 // Check the arguments
5066 ValueList Args;
Reid Spencer38c91a92007-02-28 02:24:54 +00005067 if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00005068 // Make sure no arguments is a good thing!
5069 if (Ty->getNumParams() != 0)
5070 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005071 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005072 } else { // Has arguments?
5073 // Loop through FunctionType's arguments and ensure they are specified
5074 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00005075 FunctionType::param_iterator I = Ty->param_begin();
5076 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer38c91a92007-02-28 02:24:54 +00005077 ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005078
Reid Spencer14310612006-12-31 05:40:51 +00005079 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5080 if (ArgI->Val->getType() != *I)
5081 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005082 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005083 Args.push_back(ArgI->Val);
5084 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005085
Reid Spencer14310612006-12-31 05:40:51 +00005086 if (Ty->isVarArg()) {
5087 if (I == E)
5088 for (; ArgI != ArgE; ++ArgI)
5089 Args.push_back(ArgI->Val); // push the remaining varargs
5090 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005091 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005092 }
Reid Spencer14310612006-12-31 05:40:51 +00005093
5094 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00005095 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Reid Spencer38c91a92007-02-28 02:24:54 +00005096 II->setCallingConv((yyvsp[-12].UIntVal));
5097 (yyval.TermInstVal) = II;
5098 delete (yyvsp[-8].ValueRefList);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005099 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005100 ;}
5101 break;
5102
5103 case 250:
Reid Spencer10794272007-03-01 19:41:47 +00005104#line 2516 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005105 {
5106 (yyval.TermInstVal) = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005107 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005108 ;}
5109 break;
5110
5111 case 251:
Reid Spencer10794272007-03-01 19:41:47 +00005112#line 2520 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005113 {
5114 (yyval.TermInstVal) = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005115 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005116 ;}
5117 break;
5118
5119 case 252:
Reid Spencer10794272007-03-01 19:41:47 +00005120#line 2527 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005121 {
5122 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
5123 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005124 CHECK_FOR_ERROR
5125 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005126 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005127
Reid Spencer38c91a92007-02-28 02:24:54 +00005128 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005129 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005130 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5131 ;}
5132 break;
5133
5134 case 253:
Reid Spencer10794272007-03-01 19:41:47 +00005135#line 2538 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005136 {
5137 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
5138 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005139 CHECK_FOR_ERROR
5140
5141 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005142 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005143
Reid Spencer38c91a92007-02-28 02:24:54 +00005144 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005145 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005146 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
5147 ;}
5148 break;
5149
5150 case 254:
Reid Spencer10794272007-03-01 19:41:47 +00005151#line 2551 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005152 {
Reid Spenceref9b9a72007-02-05 20:47:22 +00005153 // Is this definition named?? if so, assign the name...
Reid Spencer38c91a92007-02-28 02:24:54 +00005154 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Reid Spenceref9b9a72007-02-05 20:47:22 +00005155 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005156 InsertValue((yyvsp[0].InstVal));
5157 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spenceref9b9a72007-02-05 20:47:22 +00005158 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005159 ;}
5160 break;
5161
5162 case 255:
Reid Spencer10794272007-03-01 19:41:47 +00005163#line 2561 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005164 { // Used for PHI nodes
Reid Spencer14310612006-12-31 05:40:51 +00005165 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005166 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription());
5167 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
5168 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005169 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005170 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005171 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005172 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5173 delete (yyvsp[-5].TypeVal);
5174 ;}
5175 break;
5176
5177 case 256:
Reid Spencer10794272007-03-01 19:41:47 +00005178#line 2572 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005179 {
5180 (yyval.PHIList) = (yyvsp[-6].PHIList);
5181 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005182 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005183 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005184 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005185 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
5186 ;}
5187 break;
5188
5189 case 257:
Reid Spencer10794272007-03-01 19:41:47 +00005190#line 2582 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005191 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005192 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005193 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005194 // Used for call and invoke instructions
Reid Spencer38c91a92007-02-28 02:24:54 +00005195 (yyval.ValueRefList) = new ValueRefList();
5196 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5197 (yyval.ValueRefList)->push_back(E);
5198 ;}
5199 break;
5200
5201 case 258:
Reid Spencer10794272007-03-01 19:41:47 +00005202#line 2590 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005203 {
Reid Spencer14310612006-12-31 05:40:51 +00005204 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005205 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5206 (yyval.ValueRefList) = (yyvsp[-4].ValueRefList);
5207 ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal));
5208 (yyval.ValueRefList)->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00005209 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005210 ;}
5211 break;
5212
5213 case 259:
Reid Spencer10794272007-03-01 19:41:47 +00005214#line 2598 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005215 { (yyval.ValueRefList) = new ValueRefList(); ;}
5216 break;
5217
5218 case 260:
Reid Spencer10794272007-03-01 19:41:47 +00005219#line 2601 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005220 { (yyval.ValueList) = new std::vector<Value*>(); ;}
5221 break;
5222
5223 case 261:
Reid Spencer10794272007-03-01 19:41:47 +00005224#line 2602 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005225 {
5226 (yyval.ValueList) = (yyvsp[-2].ValueList);
5227 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer14310612006-12-31 05:40:51 +00005228 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005229 ;}
5230 break;
5231
5232 case 262:
Reid Spencer10794272007-03-01 19:41:47 +00005233#line 2609 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005234 {
5235 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005236 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005237 ;}
5238 break;
5239
5240 case 263:
Reid Spencer10794272007-03-01 19:41:47 +00005241#line 2613 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005242 {
5243 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005244 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005245 ;}
5246 break;
5247
5248 case 264:
Reid Spencer10794272007-03-01 19:41:47 +00005249#line 2618 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005250 {
Reid Spencer14310612006-12-31 05:40:51 +00005251 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005252 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5253 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
5254 !isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00005255 GEN_ERROR(
Reid Spencerb5334b02007-02-05 10:18:06 +00005256 "Arithmetic operator requires integer, FP, or packed operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005257 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()) &&
5258 ((yyvsp[-4].BinaryOpVal) == Instruction::URem ||
5259 (yyvsp[-4].BinaryOpVal) == Instruction::SRem ||
5260 (yyvsp[-4].BinaryOpVal) == Instruction::FRem))
Chris Lattner32980692007-02-19 07:44:24 +00005261 GEN_ERROR("Remainder not supported on vector types");
Reid Spencer38c91a92007-02-28 02:24:54 +00005262 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005263 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005264 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005265 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005266 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
5267 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005268 GEN_ERROR("binary operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005269 delete (yyvsp[-3].TypeVal);
5270 ;}
5271 break;
5272
5273 case 265:
Reid Spencer10794272007-03-01 19:41:47 +00005274#line 2639 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005275 {
Reid Spencer14310612006-12-31 05:40:51 +00005276 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005277 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5278 if (!(*(yyvsp[-3].TypeVal))->isInteger()) {
5279 if (Instruction::isShift((yyvsp[-4].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].TypeVal)->get()) ||
5280 !cast<VectorType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger())
Reid Spencerb5334b02007-02-05 10:18:06 +00005281 GEN_ERROR("Logical operator requires integral operands");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005282 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005283 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005284 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005285 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005286 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005287 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
5288 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005289 GEN_ERROR("binary operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005290 delete (yyvsp[-3].TypeVal);
5291 ;}
5292 break;
5293
5294 case 266:
Reid Spencer10794272007-03-01 19:41:47 +00005295#line 2656 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005296 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005297 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005298 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5299 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Chris Lattner32980692007-02-19 07:44:24 +00005300 GEN_ERROR("Vector types not supported by icmp instruction");
Reid Spencer38c91a92007-02-28 02:24:54 +00005301 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005302 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005303 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005304 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005305 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2);
5306 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005307 GEN_ERROR("icmp operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005308 ;}
5309 break;
5310
5311 case 267:
Reid Spencer10794272007-03-01 19:41:47 +00005312#line 2669 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005313 {
Reid Spencer14310612006-12-31 05:40:51 +00005314 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005315 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription());
5316 if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()))
Chris Lattner32980692007-02-19 07:44:24 +00005317 GEN_ERROR("Vector types not supported by fcmp instruction");
Reid Spencer38c91a92007-02-28 02:24:54 +00005318 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005319 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005320 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005321 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005322 (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2);
5323 if ((yyval.InstVal) == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00005324 GEN_ERROR("fcmp operator returned null");
Reid Spencer38c91a92007-02-28 02:24:54 +00005325 ;}
5326 break;
5327
5328 case 268:
Reid Spencer10794272007-03-01 19:41:47 +00005329#line 2682 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005330 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005331 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005332 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5333 Value* Val = (yyvsp[-2].ValueVal);
5334 const Type* DestTy = (yyvsp[0].TypeVal)->get();
5335 if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005336 GEN_ERROR("invalid cast opcode for cast from '" +
5337 Val->getType()->getDescription() + "' to '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005338 DestTy->getDescription() + "'");
Reid Spencer38c91a92007-02-28 02:24:54 +00005339 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy);
5340 delete (yyvsp[0].TypeVal);
5341 ;}
5342 break;
5343
5344 case 269:
Reid Spencer10794272007-03-01 19:41:47 +00005345#line 2694 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005346 {
5347 if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00005348 GEN_ERROR("select condition must be boolean");
Reid Spencer38c91a92007-02-28 02:24:54 +00005349 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Reid Spencerb5334b02007-02-05 10:18:06 +00005350 GEN_ERROR("select value types should match");
Reid Spencer38c91a92007-02-28 02:24:54 +00005351 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005352 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005353 ;}
5354 break;
5355
5356 case 270:
Reid Spencer10794272007-03-01 19:41:47 +00005357#line 2702 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005358 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005359 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005360 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
5361 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
5362 delete (yyvsp[0].TypeVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005363 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005364 ;}
5365 break;
5366
5367 case 271:
Reid Spencer10794272007-03-01 19:41:47 +00005368#line 2709 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005369 {
5370 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005371 GEN_ERROR("Invalid extractelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005372 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005373 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005374 ;}
5375 break;
5376
5377 case 272:
Reid Spencer10794272007-03-01 19:41:47 +00005378#line 2715 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005379 {
5380 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005381 GEN_ERROR("Invalid insertelement operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005382 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00005383 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005384 ;}
5385 break;
5386
5387 case 273:
Reid Spencer10794272007-03-01 19:41:47 +00005388#line 2721 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005389 {
5390 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencerb5334b02007-02-05 10:18:06 +00005391 GEN_ERROR("Invalid shufflevector operands");
Reid Spencer38c91a92007-02-28 02:24:54 +00005392 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005393 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005394 ;}
5395 break;
5396
5397 case 274:
Reid Spencer10794272007-03-01 19:41:47 +00005398#line 2727 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005399 {
5400 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005401 if (!Ty->isFirstClassType())
Reid Spencerb5334b02007-02-05 10:18:06 +00005402 GEN_ERROR("PHI node operands must be of first class type");
Reid Spencer38c91a92007-02-28 02:24:54 +00005403 (yyval.InstVal) = new PHINode(Ty);
5404 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5405 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5406 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Reid Spencerb5334b02007-02-05 10:18:06 +00005407 GEN_ERROR("All elements of a PHI node must be of the same type");
Reid Spencer38c91a92007-02-28 02:24:54 +00005408 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5409 (yyvsp[0].PHIList)->pop_front();
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005410 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005411 delete (yyvsp[0].PHIList); // Free the list...
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005412 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005413 ;}
5414 break;
5415
5416 case 275:
Reid Spencer10794272007-03-01 19:41:47 +00005417#line 2743 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005418 {
Reid Spencer14310612006-12-31 05:40:51 +00005419
5420 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00005421 const PointerType *PFTy = 0;
5422 const FunctionType *Ty = 0;
Reid Spencer38c91a92007-02-28 02:24:54 +00005423 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00005424 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5425 // Pull out the types of all of the arguments...
5426 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00005427 FunctionType::ParamAttrsList ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00005428 ParamAttrs.push_back((yyvsp[0].ParamAttrs));
5429 for (ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00005430 const Type *Ty = I->Val->getType();
5431 if (Ty == Type::VoidTy)
5432 GEN_ERROR("Short call syntax cannot be used with varargs");
5433 ParamTypes.push_back(Ty);
5434 ParamAttrs.push_back(I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005435 }
5436
Reid Spencer38c91a92007-02-28 02:24:54 +00005437 Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, ParamAttrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00005438 PFTy = PointerType::get(Ty);
5439 }
5440
Reid Spencer38c91a92007-02-28 02:24:54 +00005441 Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00005442 CHECK_FOR_ERROR
5443
Reid Spencer14310612006-12-31 05:40:51 +00005444 // Check the arguments
5445 ValueList Args;
Reid Spencer38c91a92007-02-28 02:24:54 +00005446 if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00005447 // Make sure no arguments is a good thing!
5448 if (Ty->getNumParams() != 0)
5449 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00005450 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005451 } else { // Has arguments?
5452 // Loop through FunctionType's arguments and ensure they are specified
5453 // correctly!
5454 //
5455 FunctionType::param_iterator I = Ty->param_begin();
5456 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer38c91a92007-02-28 02:24:54 +00005457 ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00005458
Reid Spencer14310612006-12-31 05:40:51 +00005459 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5460 if (ArgI->Val->getType() != *I)
5461 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00005462 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00005463 Args.push_back(ArgI->Val);
5464 }
5465 if (Ty->isVarArg()) {
5466 if (I == E)
5467 for (; ArgI != ArgE; ++ArgI)
5468 Args.push_back(ArgI->Val); // push the remaining varargs
5469 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00005470 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00005471 }
Reid Spencer14310612006-12-31 05:40:51 +00005472 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00005473 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Reid Spencer38c91a92007-02-28 02:24:54 +00005474 CI->setTailCall((yyvsp[-7].BoolVal));
5475 CI->setCallingConv((yyvsp[-6].UIntVal));
5476 (yyval.InstVal) = CI;
5477 delete (yyvsp[-2].ValueRefList);
5478 delete (yyvsp[-5].TypeVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00005479 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005480 ;}
5481 break;
5482
5483 case 276:
Reid Spencer10794272007-03-01 19:41:47 +00005484#line 2806 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005485 {
5486 (yyval.InstVal) = (yyvsp[0].InstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005487 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005488 ;}
5489 break;
5490
5491 case 277:
Reid Spencer10794272007-03-01 19:41:47 +00005492#line 2811 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005493 {
5494 (yyval.BoolVal) = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005495 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005496 ;}
5497 break;
5498
5499 case 278:
Reid Spencer10794272007-03-01 19:41:47 +00005500#line 2815 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005501 {
5502 (yyval.BoolVal) = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00005503 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005504 ;}
5505 break;
5506
5507 case 279:
Reid Spencer10794272007-03-01 19:41:47 +00005508#line 2822 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005509 {
Reid Spencer6f407902007-01-13 05:00:46 +00005510 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005511 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5512 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5513 delete (yyvsp[-1].TypeVal);
Reid Spencer6f407902007-01-13 05:00:46 +00005514 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005515 ;}
5516 break;
5517
5518 case 280:
Reid Spencer10794272007-03-01 19:41:47 +00005519#line 2829 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005520 {
Reid Spencer14310612006-12-31 05:40:51 +00005521 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005522 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5523 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencere4d87aa2006-12-23 06:05:41 +00005524 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005525 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5526 delete (yyvsp[-4].TypeVal);
5527 ;}
5528 break;
5529
5530 case 281:
Reid Spencer10794272007-03-01 19:41:47 +00005531#line 2837 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005532 {
Reid Spencer14310612006-12-31 05:40:51 +00005533 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005534 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5535 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5536 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005537 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005538 ;}
5539 break;
5540
5541 case 282:
Reid Spencer10794272007-03-01 19:41:47 +00005542#line 2844 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005543 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005544 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005545 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription());
5546 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005547 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005548 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5549 delete (yyvsp[-4].TypeVal);
5550 ;}
5551 break;
5552
5553 case 283:
Reid Spencer10794272007-03-01 19:41:47 +00005554#line 2852 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005555 {
5556 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005557 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005558 (yyvsp[0].ValueVal)->getType()->getDescription() + "");
5559 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005560 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005561 ;}
5562 break;
5563
5564 case 284:
Reid Spencer10794272007-03-01 19:41:47 +00005565#line 2860 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005566 {
Reid Spencer14310612006-12-31 05:40:51 +00005567 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005568 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5569 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005570 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005571 (*(yyvsp[-1].TypeVal))->getDescription());
5572 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005573 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005574 (*(yyvsp[-1].TypeVal))->getDescription());
5575 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005576 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005577 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5578 delete (yyvsp[-1].TypeVal);
5579 ;}
5580 break;
5581
5582 case 285:
Reid Spencer10794272007-03-01 19:41:47 +00005583#line 2874 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005584 {
Reid Spencer14310612006-12-31 05:40:51 +00005585 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005586 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription());
5587 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005588 if (!PT)
5589 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencer38c91a92007-02-28 02:24:54 +00005590 (*(yyvsp[-1].TypeVal))->getDescription());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005591 const Type *ElTy = PT->getElementType();
Reid Spencer38c91a92007-02-28 02:24:54 +00005592 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5593 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencerb5334b02007-02-05 10:18:06 +00005594 "' into space of type '" + ElTy->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005595
Reid Spencer38c91a92007-02-28 02:24:54 +00005596 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005597 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005598 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5599 delete (yyvsp[-1].TypeVal);
5600 ;}
5601 break;
5602
5603 case 286:
Reid Spencer10794272007-03-01 19:41:47 +00005604#line 2891 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer38c91a92007-02-28 02:24:54 +00005605 {
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00005606 if (!UpRefs.empty())
Reid Spencer38c91a92007-02-28 02:24:54 +00005607 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription());
5608 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005609 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005610
Reid Spencer38c91a92007-02-28 02:24:54 +00005611 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005612 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencer38c91a92007-02-28 02:24:54 +00005613 (*(yyvsp[-2].TypeVal))->getDescription()+ "'");
5614 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005615 CHECK_FOR_ERROR
Reid Spencer38c91a92007-02-28 02:24:54 +00005616 (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size());
5617 delete (yyvsp[-2].TypeVal);
5618 delete (yyvsp[0].ValueList);
5619 ;}
5620 break;
5621
5622
5623 default: break;
5624 }
5625
5626/* Line 1126 of yacc.c. */
Reid Spencer10794272007-03-01 19:41:47 +00005627#line 5628 "llvmAsmParser.tab.c"
Chris Lattner9d2fda62007-02-13 05:53:56 +00005628
5629 yyvsp -= yylen;
5630 yyssp -= yylen;
Reid Spencer5cbf9852007-01-30 20:08:39 +00005631
Reid Spencer38c91a92007-02-28 02:24:54 +00005632
5633 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005634
5635 *++yyvsp = yyval;
5636
5637
Reid Spencer38c91a92007-02-28 02:24:54 +00005638 /* Now `shift' the result of the reduction. Determine what state
5639 that goes to, based on the state we popped back to and the rule
5640 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005641
5642 yyn = yyr1[yyn];
5643
Reid Spencer38c91a92007-02-28 02:24:54 +00005644 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5645 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005646 yystate = yytable[yystate];
5647 else
Reid Spencer38c91a92007-02-28 02:24:54 +00005648 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005649
5650 goto yynewstate;
5651
5652
Reid Spencer38c91a92007-02-28 02:24:54 +00005653/*------------------------------------.
5654| yyerrlab -- here on detecting error |
5655`------------------------------------*/
5656yyerrlab:
5657 /* If not already recovering from an error, report this error. */
5658 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005659 {
5660 ++yynerrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00005661#if YYERROR_VERBOSE
Chris Lattner9d2fda62007-02-13 05:53:56 +00005662 yyn = yypact[yystate];
5663
Reid Spencer38c91a92007-02-28 02:24:54 +00005664 if (YYPACT_NINF < yyn && yyn < YYLAST)
Chris Lattner9d2fda62007-02-13 05:53:56 +00005665 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005666 int yytype = YYTRANSLATE (yychar);
5667 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5668 YYSIZE_T yysize = yysize0;
5669 YYSIZE_T yysize1;
5670 int yysize_overflow = 0;
5671 char *yymsg = 0;
5672# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5673 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5674 int yyx;
Chris Lattner9d2fda62007-02-13 05:53:56 +00005675
Reid Spencer38c91a92007-02-28 02:24:54 +00005676#if 0
5677 /* This is so xgettext sees the translatable formats that are
5678 constructed on the fly. */
5679 YY_("syntax error, unexpected %s");
5680 YY_("syntax error, unexpected %s, expecting %s");
5681 YY_("syntax error, unexpected %s, expecting %s or %s");
5682 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5683 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5684#endif
5685 char *yyfmt;
5686 char const *yyf;
5687 static char const yyunexpected[] = "syntax error, unexpected %s";
5688 static char const yyexpecting[] = ", expecting %s";
5689 static char const yyor[] = " or %s";
5690 char yyformat[sizeof yyunexpected
5691 + sizeof yyexpecting - 1
5692 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5693 * (sizeof yyor - 1))];
5694 char const *yyprefix = yyexpecting;
5695
5696 /* Start YYX at -YYN if negative to avoid negative indexes in
5697 YYCHECK. */
5698 int yyxbegin = yyn < 0 ? -yyn : 0;
5699
5700 /* Stay within bounds of both yycheck and yytname. */
5701 int yychecklim = YYLAST - yyn;
5702 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5703 int yycount = 1;
5704
5705 yyarg[0] = yytname[yytype];
5706 yyfmt = yystpcpy (yyformat, yyunexpected);
5707
5708 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5709 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5710 {
5711 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5712 {
5713 yycount = 1;
5714 yysize = yysize0;
5715 yyformat[sizeof yyunexpected - 1] = '\0';
5716 break;
5717 }
5718 yyarg[yycount++] = yytname[yyx];
5719 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5720 yysize_overflow |= yysize1 < yysize;
5721 yysize = yysize1;
5722 yyfmt = yystpcpy (yyfmt, yyprefix);
5723 yyprefix = yyor;
5724 }
5725
5726 yyf = YY_(yyformat);
5727 yysize1 = yysize + yystrlen (yyf);
5728 yysize_overflow |= yysize1 < yysize;
5729 yysize = yysize1;
5730
5731 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5732 yymsg = (char *) YYSTACK_ALLOC (yysize);
5733 if (yymsg)
Chris Lattner9d2fda62007-02-13 05:53:56 +00005734 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005735 /* Avoid sprintf, as that infringes on the user's name space.
5736 Don't have undefined behavior even if the translation
5737 produced a string with the wrong number of "%s"s. */
5738 char *yyp = yymsg;
5739 int yyi = 0;
5740 while ((*yyp = *yyf))
Chris Lattner9d2fda62007-02-13 05:53:56 +00005741 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005742 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5743 {
5744 yyp += yytnamerr (yyp, yyarg[yyi++]);
5745 yyf += 2;
5746 }
5747 else
5748 {
5749 yyp++;
5750 yyf++;
5751 }
Chris Lattner9d2fda62007-02-13 05:53:56 +00005752 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005753 yyerror (yymsg);
5754 YYSTACK_FREE (yymsg);
Chris Lattner9d2fda62007-02-13 05:53:56 +00005755 }
5756 else
Reid Spencer38c91a92007-02-28 02:24:54 +00005757 {
5758 yyerror (YY_("syntax error"));
5759 goto yyexhaustedlab;
5760 }
Chris Lattner9d2fda62007-02-13 05:53:56 +00005761 }
5762 else
5763#endif /* YYERROR_VERBOSE */
Reid Spencer38c91a92007-02-28 02:24:54 +00005764 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005765 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00005766
Reid Spencer38c91a92007-02-28 02:24:54 +00005767
Reid Spencer41dff5e2007-01-26 08:05:27 +00005768
5769 if (yyerrstatus == 3)
5770 {
Reid Spencer38c91a92007-02-28 02:24:54 +00005771 /* If just tried and failed to reuse look-ahead token after an
5772 error, discard it. */
Reid Spencer41dff5e2007-01-26 08:05:27 +00005773
Reid Spencer38c91a92007-02-28 02:24:54 +00005774 if (yychar <= YYEOF)
5775 {
5776 /* Return failure if at end of input. */
5777 if (yychar == YYEOF)
5778 YYABORT;
5779 }
5780 else
5781 {
5782 yydestruct ("Error: discarding", yytoken, &yylval);
5783 yychar = YYEMPTY;
5784 }
5785 }
5786
5787 /* Else will try to reuse look-ahead token after shifting the error
5788 token. */
5789 goto yyerrlab1;
5790
5791
5792/*---------------------------------------------------.
5793| yyerrorlab -- error raised explicitly by YYERROR. |
5794`---------------------------------------------------*/
5795yyerrorlab:
5796
5797 /* Pacify compilers like GCC when the user code never invokes
5798 YYERROR and the label yyerrorlab therefore never appears in user
5799 code. */
5800 if (0)
5801 goto yyerrorlab;
5802
5803yyvsp -= yylen;
5804 yyssp -= yylen;
5805 yystate = *yyssp;
5806 goto yyerrlab1;
5807
5808
5809/*-------------------------------------------------------------.
5810| yyerrlab1 -- common code for both syntax error and YYERROR. |
5811`-------------------------------------------------------------*/
5812yyerrlab1:
5813 yyerrstatus = 3; /* Each real token shifted decrements this. */
5814
5815 for (;;)
5816 {
5817 yyn = yypact[yystate];
5818 if (yyn != YYPACT_NINF)
5819 {
5820 yyn += YYTERROR;
5821 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5822 {
5823 yyn = yytable[yyn];
5824 if (0 < yyn)
5825 break;
5826 }
5827 }
5828
5829 /* Pop the current state because it cannot handle the error token. */
5830 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005831 YYABORT;
5832
Reid Spencere4d87aa2006-12-23 06:05:41 +00005833
Reid Spencer38c91a92007-02-28 02:24:54 +00005834 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5835 YYPOPSTACK;
5836 yystate = *yyssp;
5837 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005838 }
5839
5840 if (yyn == YYFINAL)
5841 YYACCEPT;
5842
Reid Spencer68a24bd2005-08-27 18:50:39 +00005843 *++yyvsp = yylval;
Reid Spencer38c91a92007-02-28 02:24:54 +00005844
5845
5846 /* Shift the error token. */
5847 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer41dff5e2007-01-26 08:05:27 +00005848
Reid Spencer68a24bd2005-08-27 18:50:39 +00005849 yystate = yyn;
5850 goto yynewstate;
5851
Chris Lattner32980692007-02-19 07:44:24 +00005852
Reid Spencer38c91a92007-02-28 02:24:54 +00005853/*-------------------------------------.
5854| yyacceptlab -- YYACCEPT comes here. |
5855`-------------------------------------*/
5856yyacceptlab:
5857 yyresult = 0;
5858 goto yyreturn;
5859
5860/*-----------------------------------.
5861| yyabortlab -- YYABORT comes here. |
5862`-----------------------------------*/
5863yyabortlab:
5864 yyresult = 1;
5865 goto yyreturn;
5866
5867#ifndef yyoverflow
5868/*-------------------------------------------------.
5869| yyexhaustedlab -- memory exhaustion comes here. |
5870`-------------------------------------------------*/
5871yyexhaustedlab:
5872 yyerror (YY_("memory exhausted"));
5873 yyresult = 2;
5874 /* Fall through. */
Chris Lattner32980692007-02-19 07:44:24 +00005875#endif
Reid Spencer38c91a92007-02-28 02:24:54 +00005876
5877yyreturn:
5878 if (yychar != YYEOF && yychar != YYEMPTY)
5879 yydestruct ("Cleanup: discarding lookahead",
5880 yytoken, &yylval);
5881 while (yyssp != yyss)
5882 {
5883 yydestruct ("Cleanup: popping",
5884 yystos[*yyssp], yyvsp);
5885 YYPOPSTACK;
Chris Lattner32980692007-02-19 07:44:24 +00005886 }
Reid Spencer38c91a92007-02-28 02:24:54 +00005887#ifndef yyoverflow
5888 if (yyss != yyssa)
5889 YYSTACK_FREE (yyss);
5890#endif
5891 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005892}
Reid Spencer38c91a92007-02-28 02:24:54 +00005893
5894
Reid Spencer10794272007-03-01 19:41:47 +00005895#line 2908 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005896
5897
Reid Spencer14310612006-12-31 05:40:51 +00005898// common code from the two 'RunVMAsmParser' functions
5899static Module* RunParser(Module * M) {
5900
5901 llvmAsmlineno = 1; // Reset the current line number...
5902 CurModule.CurrentModule = M;
5903#if YYDEBUG
5904 yydebug = Debug;
5905#endif
5906
5907 // Check to make sure the parser succeeded
5908 if (yyparse()) {
5909 if (ParserResult)
5910 delete ParserResult;
5911 return 0;
5912 }
5913
5914 // Check to make sure that parsing produced a result
5915 if (!ParserResult)
5916 return 0;
5917
5918 // Reset ParserResult variable while saving its value for the result.
5919 Module *Result = ParserResult;
5920 ParserResult = 0;
5921
5922 return Result;
5923}
5924
Reid Spencer61c83e02006-08-18 08:43:06 +00005925void llvm::GenerateError(const std::string &message, int LineNo) {
5926 if (LineNo == -1) LineNo = llvmAsmlineno;
5927 // TODO: column number in exception
5928 if (TheParseError)
5929 TheParseError->setError(CurFilename, message, LineNo);
5930 TriggerError = 1;
5931}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005932
5933int yyerror(const char *ErrorMsg) {
5934 std::string where
5935 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5936 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00005937 std::string errMsg = where + "error: " + std::string(ErrorMsg);
5938 if (yychar != YYEMPTY && yychar != 0)
5939 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
5940 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005941 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005942 return 0;
5943}
Reid Spencer38c91a92007-02-28 02:24:54 +00005944