blob: 13170807cb38145346fbe0705facf99d82f7cc33 [file] [log] [blame]
Reid Spencer61c83e02006-08-18 08:43:06 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencer61c83e02006-08-18 08:43:06 +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.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005
Reid Spencer61c83e02006-08-18 08:43:06 +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.
Reid Spencer68a24bd2005-08-27 18:50:39 +000010
Reid Spencer61c83e02006-08-18 08:43:06 +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 Spencer61c83e02006-08-18 08:43:06 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Reid Spencer61c83e02006-08-18 08:43:06 +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 Spencer61c83e02006-08-18 08:43:06 +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 SINTVAL = 260,
70 UINTVAL = 261,
71 FPVAL = 262,
72 VOID = 263,
73 BOOL = 264,
74 SBYTE = 265,
75 UBYTE = 266,
76 SHORT = 267,
77 USHORT = 268,
78 INT = 269,
79 UINT = 270,
80 LONG = 271,
81 ULONG = 272,
82 FLOAT = 273,
83 DOUBLE = 274,
84 TYPE = 275,
85 LABEL = 276,
86 VAR_ID = 277,
87 LABELSTR = 278,
88 STRINGCONSTANT = 279,
89 IMPLEMENTATION = 280,
90 ZEROINITIALIZER = 281,
91 TRUETOK = 282,
92 FALSETOK = 283,
93 BEGINTOK = 284,
94 ENDTOK = 285,
95 DECLARE = 286,
96 GLOBAL = 287,
97 CONSTANT = 288,
98 SECTION = 289,
99 VOLATILE = 290,
100 TO = 291,
101 DOTDOTDOT = 292,
102 NULL_TOK = 293,
103 UNDEF = 294,
104 CONST = 295,
105 INTERNAL = 296,
106 LINKONCE = 297,
107 WEAK = 298,
108 APPENDING = 299,
109 OPAQUE = 300,
110 NOT = 301,
111 EXTERNAL = 302,
112 TARGET = 303,
113 TRIPLE = 304,
114 ENDIAN = 305,
115 POINTERSIZE = 306,
116 LITTLE = 307,
117 BIG = 308,
118 ALIGN = 309,
119 DEPLIBS = 310,
120 CALL = 311,
121 TAIL = 312,
122 ASM_TOK = 313,
123 MODULE = 314,
124 SIDEEFFECT = 315,
125 CC_TOK = 316,
126 CCC_TOK = 317,
127 CSRETCC_TOK = 318,
128 FASTCC_TOK = 319,
129 COLDCC_TOK = 320,
130 RET = 321,
131 BR = 322,
132 SWITCH = 323,
133 INVOKE = 324,
134 UNWIND = 325,
135 UNREACHABLE = 326,
136 ADD = 327,
137 SUB = 328,
138 MUL = 329,
139 DIV = 330,
140 REM = 331,
141 AND = 332,
142 OR = 333,
143 XOR = 334,
144 SETLE = 335,
145 SETGE = 336,
146 SETLT = 337,
147 SETGT = 338,
148 SETEQ = 339,
149 SETNE = 340,
150 MALLOC = 341,
151 ALLOCA = 342,
152 FREE = 343,
153 LOAD = 344,
154 STORE = 345,
155 GETELEMENTPTR = 346,
156 PHI_TOK = 347,
157 CAST = 348,
158 SELECT = 349,
159 SHL = 350,
160 SHR = 351,
161 VAARG = 352,
162 EXTRACTELEMENT = 353,
163 INSERTELEMENT = 354,
164 SHUFFLEVECTOR = 355,
165 VAARG_old = 356,
166 VANEXT_old = 357
167 };
168#endif
169/* Tokens. */
170#define ESINT64VAL 258
171#define EUINT64VAL 259
172#define SINTVAL 260
173#define UINTVAL 261
174#define FPVAL 262
175#define VOID 263
176#define BOOL 264
177#define SBYTE 265
178#define UBYTE 266
179#define SHORT 267
180#define USHORT 268
181#define INT 269
182#define UINT 270
183#define LONG 271
184#define ULONG 272
185#define FLOAT 273
186#define DOUBLE 274
187#define TYPE 275
188#define LABEL 276
189#define VAR_ID 277
190#define LABELSTR 278
191#define STRINGCONSTANT 279
192#define IMPLEMENTATION 280
193#define ZEROINITIALIZER 281
194#define TRUETOK 282
195#define FALSETOK 283
196#define BEGINTOK 284
197#define ENDTOK 285
198#define DECLARE 286
199#define GLOBAL 287
200#define CONSTANT 288
201#define SECTION 289
202#define VOLATILE 290
203#define TO 291
204#define DOTDOTDOT 292
205#define NULL_TOK 293
206#define UNDEF 294
207#define CONST 295
208#define INTERNAL 296
209#define LINKONCE 297
210#define WEAK 298
211#define APPENDING 299
212#define OPAQUE 300
213#define NOT 301
214#define EXTERNAL 302
215#define TARGET 303
216#define TRIPLE 304
217#define ENDIAN 305
218#define POINTERSIZE 306
219#define LITTLE 307
220#define BIG 308
221#define ALIGN 309
222#define DEPLIBS 310
223#define CALL 311
224#define TAIL 312
225#define ASM_TOK 313
226#define MODULE 314
227#define SIDEEFFECT 315
228#define CC_TOK 316
229#define CCC_TOK 317
230#define CSRETCC_TOK 318
231#define FASTCC_TOK 319
232#define COLDCC_TOK 320
233#define RET 321
234#define BR 322
235#define SWITCH 323
236#define INVOKE 324
237#define UNWIND 325
238#define UNREACHABLE 326
239#define ADD 327
240#define SUB 328
241#define MUL 329
242#define DIV 330
243#define REM 331
244#define AND 332
245#define OR 333
246#define XOR 334
247#define SETLE 335
248#define SETGE 336
249#define SETLT 337
250#define SETGT 338
251#define SETEQ 339
252#define SETNE 340
253#define MALLOC 341
254#define ALLOCA 342
255#define FREE 343
256#define LOAD 344
257#define STORE 345
258#define GETELEMENTPTR 346
259#define PHI_TOK 347
260#define CAST 348
261#define SELECT 349
262#define SHL 350
263#define SHR 351
264#define VAARG 352
265#define EXTRACTELEMENT 353
266#define INSERTELEMENT 354
267#define SHUFFLEVECTOR 355
268#define VAARG_old 356
269#define VANEXT_old 357
270
271
272
273
274/* Copy the first part of user declarations. */
275#line 14 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000276
277#include "ParserInternals.h"
278#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000279#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000280#include "llvm/Instructions.h"
281#include "llvm/Module.h"
282#include "llvm/SymbolTable.h"
Reid Spencer0b118202006-01-16 21:12:35 +0000283#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000284#include "llvm/Support/GetElementPtrTypeIterator.h"
285#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000286#include "llvm/Support/MathExtras.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000287#include <algorithm>
288#include <iostream>
289#include <list>
290#include <utility>
291
Reid Spencer61c83e02006-08-18 08:43:06 +0000292static bool TriggerError = false;
293#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYERROR; } }
294
295#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
296
Reid Spencer68a24bd2005-08-27 18:50:39 +0000297int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
298int yylex(); // declaration" of xxx warnings.
299int yyparse();
300
301namespace llvm {
302 std::string CurFilename;
303}
304using namespace llvm;
305
306static Module *ParserResult;
307
308// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
309// relating to upreferences in the input stream.
310//
311//#define DEBUG_UPREFS 1
312#ifdef DEBUG_UPREFS
313#define UR_OUT(X) std::cerr << X
314#else
315#define UR_OUT(X)
316#endif
317
318#define YYERROR_VERBOSE 1
319
320static bool ObsoleteVarArgs;
321static bool NewVarArgs;
Chris Lattnerb475c422005-11-12 18:22:38 +0000322static BasicBlock *CurBB;
323static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000324
325
326// This contains info used when building the body of a function. It is
327// destroyed when the function is completed.
328//
329typedef std::vector<Value *> ValueList; // Numbered defs
330static void
331ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
332 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
333
334static struct PerModuleInfo {
335 Module *CurrentModule;
336 std::map<const Type *, ValueList> Values; // Module level numbered definitions
337 std::map<const Type *,ValueList> LateResolveValues;
338 std::vector<PATypeHolder> Types;
339 std::map<ValID, PATypeHolder> LateResolveTypes;
340
341 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000342 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000343 /// that we can resolve them later and print error messages as appropriate.
344 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
345
346 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
347 // references to global values. Global values may be referenced before they
348 // are defined, and if so, the temporary object that they represent is held
349 // here. This is used for forward references of GlobalValues.
350 //
351 typedef std::map<std::pair<const PointerType *,
352 ValID>, GlobalValue*> GlobalRefsType;
353 GlobalRefsType GlobalRefs;
354
355 void ModuleDone() {
356 // If we could not resolve some functions at function compilation time
357 // (calls to functions before they are defined), resolve them now... Types
358 // are resolved when the constant pool has been completely parsed.
359 //
360 ResolveDefinitions(LateResolveValues);
361
362 // Check to make sure that all global value forward references have been
363 // resolved!
364 //
365 if (!GlobalRefs.empty()) {
366 std::string UndefinedReferences = "Unresolved global references exist:\n";
367
368 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
369 I != E; ++I) {
370 UndefinedReferences += " " + I->first.first->getDescription() + " " +
371 I->first.second.getName() + "\n";
372 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000373 GenerateError(UndefinedReferences);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000374 }
375
Reid Spencere812fb22006-01-19 01:21:04 +0000376 // Look for intrinsic functions and CallInst that need to be upgraded
Chris Lattnerd5efe842006-04-08 01:18:56 +0000377 for (Module::iterator FI = CurrentModule->begin(),
378 FE = CurrentModule->end(); FI != FE; )
Chris Lattnerc2c60382006-03-04 07:53:41 +0000379 UpgradeCallsToIntrinsic(FI++);
Reid Spencer0b118202006-01-16 21:12:35 +0000380
Reid Spencer68a24bd2005-08-27 18:50:39 +0000381 Values.clear(); // Clear out function local definitions
382 Types.clear();
383 CurrentModule = 0;
384 }
385
Reid Spencer68a24bd2005-08-27 18:50:39 +0000386 // GetForwardRefForGlobal - Check to see if there is a forward reference
387 // for this global. If so, remove it from the GlobalRefs map and return it.
388 // If not, just return null.
389 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
390 // Check to see if there is a forward reference to this global variable...
391 // if there is, eliminate it and patch the reference to use the new def'n.
392 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
393 GlobalValue *Ret = 0;
394 if (I != GlobalRefs.end()) {
395 Ret = I->second;
396 GlobalRefs.erase(I);
397 }
398 return Ret;
399 }
400} CurModule;
401
402static struct PerFunctionInfo {
403 Function *CurrentFunction; // Pointer to current function being created
404
405 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
406 std::map<const Type*, ValueList> LateResolveValues;
407 bool isDeclare; // Is this function a forward declararation?
408
409 /// BBForwardRefs - When we see forward references to basic blocks, keep
410 /// track of them here.
411 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
412 std::vector<BasicBlock*> NumberedBlocks;
413 unsigned NextBBNum;
414
415 inline PerFunctionInfo() {
416 CurrentFunction = 0;
417 isDeclare = false;
418 }
419
420 inline void FunctionStart(Function *M) {
421 CurrentFunction = M;
422 NextBBNum = 0;
423 }
424
425 void FunctionDone() {
426 NumberedBlocks.clear();
427
428 // Any forward referenced blocks left?
429 if (!BBForwardRefs.empty())
Reid Spencer61c83e02006-08-18 08:43:06 +0000430 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000431 BBForwardRefs.begin()->first->getName());
432
433 // Resolve all forward references now.
434 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
435
436 Values.clear(); // Clear out function local definitions
437 CurrentFunction = 0;
438 isDeclare = false;
439 }
440} CurFun; // Info for the current function...
441
442static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
443
444
445//===----------------------------------------------------------------------===//
446// Code to handle definitions of all the types
447//===----------------------------------------------------------------------===//
448
449static int InsertValue(Value *V,
450 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
451 if (V->hasName()) return -1; // Is this a numbered definition?
452
453 // Yes, insert the value into the value table...
454 ValueList &List = ValueTab[V->getType()];
455 List.push_back(V);
456 return List.size()-1;
457}
458
459static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
460 switch (D.Type) {
461 case ValID::NumberVal: // Is it a numbered definition?
462 // Module constants occupy the lowest numbered slots...
463 if ((unsigned)D.Num < CurModule.Types.size())
464 return CurModule.Types[(unsigned)D.Num];
465 break;
466 case ValID::NameVal: // Is it a named definition?
467 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
468 D.destroy(); // Free old strdup'd memory...
469 return N;
470 }
471 break;
472 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000473 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000474 }
475
476 // If we reached here, we referenced either a symbol that we don't know about
477 // or an id number that hasn't been read yet. We may be referencing something
478 // forward, so just create an entry to be resolved later and get to it...
479 //
480 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
481
482
483 if (inFunctionScope()) {
484 if (D.Type == ValID::NameVal)
Reid Spencer61c83e02006-08-18 08:43:06 +0000485 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000486 else
Reid Spencer61c83e02006-08-18 08:43:06 +0000487 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer68a24bd2005-08-27 18:50:39 +0000488 }
489
490 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
491 if (I != CurModule.LateResolveTypes.end())
492 return I->second;
493
494 Type *Typ = OpaqueType::get();
495 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
496 return Typ;
497 }
498
499static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
500 SymbolTable &SymTab =
501 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
502 CurModule.CurrentModule->getSymbolTable();
503 return SymTab.lookup(Ty, Name);
504}
505
506// getValNonImprovising - Look up the value specified by the provided type and
507// the provided ValID. If the value exists and has already been defined, return
508// it. Otherwise return null.
509//
510static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
511 if (isa<FunctionType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +0000512 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000513 "must be referenced as pointers");
514
515 switch (D.Type) {
516 case ValID::NumberVal: { // Is it a numbered definition?
517 unsigned Num = (unsigned)D.Num;
518
519 // Module constants occupy the lowest numbered slots...
520 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
521 if (VI != CurModule.Values.end()) {
522 if (Num < VI->second.size())
523 return VI->second[Num];
524 Num -= VI->second.size();
525 }
526
527 // Make sure that our type is within bounds
528 VI = CurFun.Values.find(Ty);
529 if (VI == CurFun.Values.end()) return 0;
530
531 // Check that the number is within bounds...
532 if (VI->second.size() <= Num) return 0;
533
534 return VI->second[Num];
535 }
536
537 case ValID::NameVal: { // Is it a named definition?
538 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
539 if (N == 0) return 0;
540
541 D.destroy(); // Free old strdup'd memory...
542 return N;
543 }
544
545 // Check to make sure that "Ty" is an integral type, and that our
546 // value will fit into the specified type...
547 case ValID::ConstSIntVal: // Is it a constant pool reference??
548 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
Reid Spencer61c83e02006-08-18 08:43:06 +0000549 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000550 itostr(D.ConstPool64) + "' is invalid for type '" +
551 Ty->getDescription() + "'!");
552 return ConstantSInt::get(Ty, D.ConstPool64);
553
554 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
555 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
556 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000557 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000558 "' is invalid or out of range!");
559 } else { // This is really a signed reference. Transmogrify.
560 return ConstantSInt::get(Ty, D.ConstPool64);
561 }
562 } else {
563 return ConstantUInt::get(Ty, D.UConstPool64);
564 }
565
566 case ValID::ConstFPVal: // Is it a floating point const pool reference?
567 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
Reid Spencer61c83e02006-08-18 08:43:06 +0000568 GenerateError("FP constant invalid for type!!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000569 return ConstantFP::get(Ty, D.ConstPoolFP);
570
571 case ValID::ConstNullVal: // Is it a null value?
572 if (!isa<PointerType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +0000573 GenerateError("Cannot create a a non pointer null!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000574 return ConstantPointerNull::get(cast<PointerType>(Ty));
575
576 case ValID::ConstUndefVal: // Is it an undef value?
577 return UndefValue::get(Ty);
578
Chris Lattner7aa61892005-12-21 17:53:23 +0000579 case ValID::ConstZeroVal: // Is it a zero value?
580 return Constant::getNullValue(Ty);
581
Reid Spencer68a24bd2005-08-27 18:50:39 +0000582 case ValID::ConstantVal: // Fully resolved constant?
583 if (D.ConstantValue->getType() != Ty)
Reid Spencer61c83e02006-08-18 08:43:06 +0000584 GenerateError("Constant expression type different from required type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000585 return D.ConstantValue;
586
Chris Lattner0e9c3762006-01-25 22:27:16 +0000587 case ValID::InlineAsmVal: { // Inline asm expression
588 const PointerType *PTy = dyn_cast<PointerType>(Ty);
589 const FunctionType *FTy =
590 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
591 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
Reid Spencer61c83e02006-08-18 08:43:06 +0000592 GenerateError("Invalid type for asm constraint string!");
Chris Lattner0e9c3762006-01-25 22:27:16 +0000593 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
594 D.IAD->HasSideEffects);
595 D.destroy(); // Free InlineAsmDescriptor.
596 return IA;
597 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000598 default:
599 assert(0 && "Unhandled case!");
600 return 0;
601 } // End of switch
602
603 assert(0 && "Unhandled case!");
604 return 0;
605}
606
607// getVal - This function is identical to getValNonImprovising, except that if a
608// value is not already defined, it "improvises" by creating a placeholder var
609// that looks and acts just like the requested variable. When the value is
610// defined later, all uses of the placeholder variable are replaced with the
611// real thing.
612//
613static Value *getVal(const Type *Ty, const ValID &ID) {
614 if (Ty == Type::LabelTy)
Reid Spencer61c83e02006-08-18 08:43:06 +0000615 GenerateError("Cannot use a basic block here");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000616
617 // See if the value has already been defined.
618 Value *V = getValNonImprovising(Ty, ID);
619 if (V) return V;
620
621 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +0000622 GenerateError("Invalid use of a composite type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000623
624 // If we reached here, we referenced either a symbol that we don't know about
625 // or an id number that hasn't been read yet. We may be referencing something
626 // forward, so just create an entry to be resolved later and get to it...
627 //
628 V = new Argument(Ty);
629
630 // Remember where this forward reference came from. FIXME, shouldn't we try
631 // to recycle these things??
632 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
633 llvmAsmlineno)));
634
635 if (inFunctionScope())
636 InsertValue(V, CurFun.LateResolveValues);
637 else
638 InsertValue(V, CurModule.LateResolveValues);
639 return V;
640}
641
642/// getBBVal - This is used for two purposes:
643/// * If isDefinition is true, a new basic block with the specified ID is being
644/// defined.
645/// * If isDefinition is true, this is a reference to a basic block, which may
646/// or may not be a forward reference.
647///
648static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
649 assert(inFunctionScope() && "Can't get basic block at global scope!");
650
651 std::string Name;
652 BasicBlock *BB = 0;
653 switch (ID.Type) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000654 default: GenerateError("Illegal label reference " + ID.getName());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000655 case ValID::NumberVal: // Is it a numbered definition?
656 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
657 CurFun.NumberedBlocks.resize(ID.Num+1);
658 BB = CurFun.NumberedBlocks[ID.Num];
659 break;
660 case ValID::NameVal: // Is it a named definition?
661 Name = ID.Name;
662 if (Value *N = CurFun.CurrentFunction->
663 getSymbolTable().lookup(Type::LabelTy, Name))
664 BB = cast<BasicBlock>(N);
665 break;
666 }
667
668 // See if the block has already been defined.
669 if (BB) {
670 // If this is the definition of the block, make sure the existing value was
671 // just a forward reference. If it was a forward reference, there will be
672 // an entry for it in the PlaceHolderInfo map.
673 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
674 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000675 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000676
677 ID.destroy(); // Free strdup'd memory.
678 return BB;
679 }
680
681 // Otherwise this block has not been seen before.
682 BB = new BasicBlock("", CurFun.CurrentFunction);
683 if (ID.Type == ValID::NameVal) {
684 BB->setName(ID.Name);
685 } else {
686 CurFun.NumberedBlocks[ID.Num] = BB;
687 }
688
689 // If this is not a definition, keep track of it so we can use it as a forward
690 // reference.
691 if (!isDefinition) {
692 // Remember where this forward reference came from.
693 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
694 } else {
695 // The forward declaration could have been inserted anywhere in the
696 // function: insert it into the correct place now.
697 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
698 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
699 }
700 ID.destroy();
701 return BB;
702}
703
704
705//===----------------------------------------------------------------------===//
706// Code to handle forward references in instructions
707//===----------------------------------------------------------------------===//
708//
709// This code handles the late binding needed with statements that reference
710// values not defined yet... for example, a forward branch, or the PHI node for
711// a loop body.
712//
713// This keeps a table (CurFun.LateResolveValues) of all such forward references
714// and back patchs after we are done.
715//
716
717// ResolveDefinitions - If we could not resolve some defs at parsing
718// time (forward branches, phi functions for loops, etc...) resolve the
719// defs now...
720//
721static void
722ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
723 std::map<const Type*,ValueList> *FutureLateResolvers) {
724 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
725 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
726 E = LateResolvers.end(); LRI != E; ++LRI) {
727 ValueList &List = LRI->second;
728 while (!List.empty()) {
729 Value *V = List.back();
730 List.pop_back();
731
732 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
733 CurModule.PlaceHolderInfo.find(V);
734 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
735
736 ValID &DID = PHI->second.first;
737
738 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
739 if (TheRealValue) {
740 V->replaceAllUsesWith(TheRealValue);
741 delete V;
742 CurModule.PlaceHolderInfo.erase(PHI);
743 } else if (FutureLateResolvers) {
744 // Functions have their unresolved items forwarded to the module late
745 // resolver table
746 InsertValue(V, *FutureLateResolvers);
747 } else {
748 if (DID.Type == ValID::NameVal)
Reid Spencer61c83e02006-08-18 08:43:06 +0000749 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000750 "' of type '" + V->getType()->getDescription() + "'",
751 PHI->second.second);
752 else
Reid Spencer61c83e02006-08-18 08:43:06 +0000753 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000754 itostr(DID.Num) + " of type '" +
755 V->getType()->getDescription() + "'",
756 PHI->second.second);
757 }
758 }
759 }
760
761 LateResolvers.clear();
762}
763
764// ResolveTypeTo - A brand new type was just declared. This means that (if
765// name is not null) things referencing Name can be resolved. Otherwise, things
766// refering to the number can be resolved. Do this now.
767//
768static void ResolveTypeTo(char *Name, const Type *ToTy) {
769 ValID D;
770 if (Name) D = ValID::create(Name);
771 else D = ValID::create((int)CurModule.Types.size());
772
773 std::map<ValID, PATypeHolder>::iterator I =
774 CurModule.LateResolveTypes.find(D);
775 if (I != CurModule.LateResolveTypes.end()) {
776 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
777 CurModule.LateResolveTypes.erase(I);
778 }
779}
780
781// setValueName - Set the specified value to the name given. The name may be
782// null potentially, in which case this is a noop. The string passed in is
783// assumed to be a malloc'd string buffer, and is free'd by this function.
784//
785static void setValueName(Value *V, char *NameStr) {
786 if (NameStr) {
787 std::string Name(NameStr); // Copy string
788 free(NameStr); // Free old string
789
790 if (V->getType() == Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +0000791 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000792
793 assert(inFunctionScope() && "Must be in function scope!");
794 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
795 if (ST.lookup(V->getType(), Name))
Reid Spencer61c83e02006-08-18 08:43:06 +0000796 GenerateError("Redefinition of value named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000797 V->getType()->getDescription() + "' type plane!");
798
799 // Set the name.
800 V->setName(Name);
801 }
802}
803
804/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
805/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000806static GlobalVariable *
807ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
808 bool isConstantGlobal, const Type *Ty,
809 Constant *Initializer) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000810 if (isa<FunctionType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +0000811 GenerateError("Cannot declare global vars of function type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000812
813 const PointerType *PTy = PointerType::get(Ty);
814
815 std::string Name;
816 if (NameStr) {
817 Name = NameStr; // Copy string
818 free(NameStr); // Free old string
819 }
820
821 // See if this global value was forward referenced. If so, recycle the
822 // object.
823 ValID ID;
824 if (!Name.empty()) {
825 ID = ValID::create((char*)Name.c_str());
826 } else {
827 ID = ValID::create((int)CurModule.Values[PTy].size());
828 }
829
830 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
831 // Move the global to the end of the list, from whereever it was
832 // previously inserted.
833 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
834 CurModule.CurrentModule->getGlobalList().remove(GV);
835 CurModule.CurrentModule->getGlobalList().push_back(GV);
836 GV->setInitializer(Initializer);
837 GV->setLinkage(Linkage);
838 GV->setConstant(isConstantGlobal);
839 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000840 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000841 }
842
843 // If this global has a name, check to see if there is already a definition
844 // of this global in the module. If so, merge as appropriate. Note that
845 // this is really just a hack around problems in the CFE. :(
846 if (!Name.empty()) {
847 // We are a simple redefinition of a value, check to see if it is defined
848 // the same as the old one.
849 if (GlobalVariable *EGV =
850 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
851 // We are allowed to redefine a global variable in two circumstances:
852 // 1. If at least one of the globals is uninitialized or
853 // 2. If both initializers have the same value.
854 //
855 if (!EGV->hasInitializer() || !Initializer ||
856 EGV->getInitializer() == Initializer) {
857
858 // Make sure the existing global version gets the initializer! Make
859 // sure that it also gets marked const if the new version is.
860 if (Initializer && !EGV->hasInitializer())
861 EGV->setInitializer(Initializer);
862 if (isConstantGlobal)
863 EGV->setConstant(true);
864 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +0000865 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000866 }
867
Reid Spencer61c83e02006-08-18 08:43:06 +0000868 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000869 "' in the '" + Ty->getDescription() + "' type plane!");
870 }
871 }
872
873 // Otherwise there is no existing GV to use, create one now.
874 GlobalVariable *GV =
875 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
876 CurModule.CurrentModule);
877 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000878 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000879}
880
881// setTypeName - Set the specified type to the name given. The name may be
882// null potentially, in which case this is a noop. The string passed in is
883// assumed to be a malloc'd string buffer, and is freed by this function.
884//
885// This function returns true if the type has already been defined, but is
886// allowed to be redefined in the specified context. If the name is a new name
887// for the type plane, it is inserted and false is returned.
888static bool setTypeName(const Type *T, char *NameStr) {
889 assert(!inFunctionScope() && "Can't give types function-local names!");
890 if (NameStr == 0) return false;
891
892 std::string Name(NameStr); // Copy string
893 free(NameStr); // Free old string
894
895 // We don't allow assigning names to void type
896 if (T == Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +0000897 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000898
899 // Set the type name, checking for conflicts as we do so.
900 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
901
902 if (AlreadyExists) { // Inserting a name that is already defined???
903 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
904 assert(Existing && "Conflict but no matching type?");
905
906 // There is only one case where this is allowed: when we are refining an
907 // opaque type. In this case, Existing will be an opaque type.
908 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
909 // We ARE replacing an opaque type!
910 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
911 return true;
912 }
913
914 // Otherwise, this is an attempt to redefine a type. That's okay if
915 // the redefinition is identical to the original. This will be so if
916 // Existing and T point to the same Type object. In this one case we
917 // allow the equivalent redefinition.
918 if (Existing == T) return true; // Yes, it's equal.
919
920 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer61c83e02006-08-18 08:43:06 +0000921 GenerateError("Redefinition of type named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000922 T->getDescription() + "' type plane!");
923 }
924
925 return false;
926}
927
928//===----------------------------------------------------------------------===//
929// Code for handling upreferences in type names...
930//
931
932// TypeContains - Returns true if Ty directly contains E in it.
933//
934static bool TypeContains(const Type *Ty, const Type *E) {
935 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
936 E) != Ty->subtype_end();
937}
938
939namespace {
940 struct UpRefRecord {
941 // NestingLevel - The number of nesting levels that need to be popped before
942 // this type is resolved.
943 unsigned NestingLevel;
944
945 // LastContainedTy - This is the type at the current binding level for the
946 // type. Every time we reduce the nesting level, this gets updated.
947 const Type *LastContainedTy;
948
949 // UpRefTy - This is the actual opaque type that the upreference is
950 // represented with.
951 OpaqueType *UpRefTy;
952
953 UpRefRecord(unsigned NL, OpaqueType *URTy)
954 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
955 };
956}
957
958// UpRefs - A list of the outstanding upreferences that need to be resolved.
959static std::vector<UpRefRecord> UpRefs;
960
961/// HandleUpRefs - Every time we finish a new layer of types, this function is
962/// called. It loops through the UpRefs vector, which is a list of the
963/// currently active types. For each type, if the up reference is contained in
964/// the newly completed type, we decrement the level count. When the level
965/// count reaches zero, the upreferenced type is the type that is passed in:
966/// thus we can complete the cycle.
967///
968static PATypeHolder HandleUpRefs(const Type *ty) {
969 if (!ty->isAbstract()) return ty;
970 PATypeHolder Ty(ty);
971 UR_OUT("Type '" << Ty->getDescription() <<
972 "' newly formed. Resolving upreferences.\n" <<
973 UpRefs.size() << " upreferences active!\n");
974
975 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
976 // to zero), we resolve them all together before we resolve them to Ty. At
977 // the end of the loop, if there is anything to resolve to Ty, it will be in
978 // this variable.
979 OpaqueType *TypeToResolve = 0;
980
981 for (unsigned i = 0; i != UpRefs.size(); ++i) {
982 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
983 << UpRefs[i].second->getDescription() << ") = "
984 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
985 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
986 // Decrement level of upreference
987 unsigned Level = --UpRefs[i].NestingLevel;
988 UpRefs[i].LastContainedTy = Ty;
989 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
990 if (Level == 0) { // Upreference should be resolved!
991 if (!TypeToResolve) {
992 TypeToResolve = UpRefs[i].UpRefTy;
993 } else {
994 UR_OUT(" * Resolving upreference for "
995 << UpRefs[i].second->getDescription() << "\n";
996 std::string OldName = UpRefs[i].UpRefTy->getDescription());
997 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
998 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
999 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1000 }
1001 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1002 --i; // Do not skip the next element...
1003 }
1004 }
1005 }
1006
1007 if (TypeToResolve) {
1008 UR_OUT(" * Resolving upreference for "
1009 << UpRefs[i].second->getDescription() << "\n";
1010 std::string OldName = TypeToResolve->getDescription());
1011 TypeToResolve->refineAbstractTypeTo(Ty);
1012 }
1013
1014 return Ty;
1015}
1016
1017
1018// common code from the two 'RunVMAsmParser' functions
1019 static Module * RunParser(Module * M) {
1020
1021 llvmAsmlineno = 1; // Reset the current line number...
1022 ObsoleteVarArgs = false;
1023 NewVarArgs = false;
1024
1025 CurModule.CurrentModule = M;
1026 yyparse(); // Parse the file, potentially throwing exception
Reid Spencer61c83e02006-08-18 08:43:06 +00001027 if (!ParserResult)
1028 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001029
1030 Module *Result = ParserResult;
1031 ParserResult = 0;
1032
1033 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1034 {
1035 Function* F;
1036 if ((F = Result->getNamedFunction("llvm.va_start"))
1037 && F->getFunctionType()->getNumParams() == 0)
1038 ObsoleteVarArgs = true;
1039 if((F = Result->getNamedFunction("llvm.va_copy"))
1040 && F->getFunctionType()->getNumParams() == 1)
1041 ObsoleteVarArgs = true;
1042 }
1043
1044 if (ObsoleteVarArgs && NewVarArgs)
Reid Spencer61c83e02006-08-18 08:43:06 +00001045 GenerateError("This file is corrupt: it uses both new and old style varargs");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001046
1047 if(ObsoleteVarArgs) {
1048 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1049 if (F->arg_size() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00001050 GenerateError("Obsolete va_start takes 0 argument!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001051
1052 //foo = va_start()
1053 // ->
1054 //bar = alloca typeof(foo)
1055 //va_start(bar)
1056 //foo = load bar
1057
1058 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1059 const Type* ArgTy = F->getFunctionType()->getReturnType();
1060 const Type* ArgTyPtr = PointerType::get(ArgTy);
1061 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001062 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001063
1064 while (!F->use_empty()) {
1065 CallInst* CI = cast<CallInst>(F->use_back());
1066 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1067 new CallInst(NF, bar, "", CI);
1068 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1069 CI->replaceAllUsesWith(foo);
1070 CI->getParent()->getInstList().erase(CI);
1071 }
1072 Result->getFunctionList().erase(F);
1073 }
1074
1075 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1076 if(F->arg_size() != 1)
Reid Spencer61c83e02006-08-18 08:43:06 +00001077 GenerateError("Obsolete va_end takes 1 argument!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001078
1079 //vaend foo
1080 // ->
1081 //bar = alloca 1 of typeof(foo)
1082 //vaend bar
1083 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1084 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1085 const Type* ArgTyPtr = PointerType::get(ArgTy);
1086 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001087 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001088
1089 while (!F->use_empty()) {
1090 CallInst* CI = cast<CallInst>(F->use_back());
1091 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1092 new StoreInst(CI->getOperand(1), bar, CI);
1093 new CallInst(NF, bar, "", CI);
1094 CI->getParent()->getInstList().erase(CI);
1095 }
1096 Result->getFunctionList().erase(F);
1097 }
1098
1099 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1100 if(F->arg_size() != 1)
Reid Spencer61c83e02006-08-18 08:43:06 +00001101 GenerateError("Obsolete va_copy takes 1 argument!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001102 //foo = vacopy(bar)
1103 // ->
1104 //a = alloca 1 of typeof(foo)
1105 //b = alloca 1 of typeof(foo)
1106 //store bar -> b
1107 //vacopy(a, b)
1108 //foo = load a
1109
1110 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1111 const Type* ArgTy = F->getFunctionType()->getReturnType();
1112 const Type* ArgTyPtr = PointerType::get(ArgTy);
1113 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001114 RetTy, ArgTyPtr, ArgTyPtr,
1115 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001116
1117 while (!F->use_empty()) {
1118 CallInst* CI = cast<CallInst>(F->use_back());
1119 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1120 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1121 new StoreInst(CI->getOperand(1), b, CI);
1122 new CallInst(NF, a, b, "", CI);
1123 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1124 CI->replaceAllUsesWith(foo);
1125 CI->getParent()->getInstList().erase(CI);
1126 }
1127 Result->getFunctionList().erase(F);
1128 }
1129 }
1130
1131 return Result;
1132
1133 }
1134
1135//===----------------------------------------------------------------------===//
1136// RunVMAsmParser - Define an interface to this parser
1137//===----------------------------------------------------------------------===//
1138//
1139Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1140 set_scan_file(F);
1141
1142 CurFilename = Filename;
1143 return RunParser(new Module(CurFilename));
1144}
1145
1146Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1147 set_scan_string(AsmString);
1148
1149 CurFilename = "from_memory";
1150 if (M == NULL) {
1151 return RunParser(new Module (CurFilename));
1152 } else {
1153 return RunParser(M);
1154 }
1155}
1156
1157
Reid Spencer61c83e02006-08-18 08:43:06 +00001158
1159/* Enabling traces. */
1160#ifndef YYDEBUG
1161# define YYDEBUG 0
1162#endif
1163
1164/* Enabling verbose error messages. */
1165#ifdef YYERROR_VERBOSE
1166# undef YYERROR_VERBOSE
1167# define YYERROR_VERBOSE 1
1168#else
1169# define YYERROR_VERBOSE 0
1170#endif
1171
1172/* Enabling the token table. */
1173#ifndef YYTOKEN_TABLE
1174# define YYTOKEN_TABLE 0
1175#endif
1176
1177#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1178#line 897 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
1179typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001180 llvm::Module *ModuleVal;
1181 llvm::Function *FunctionVal;
1182 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
1183 llvm::BasicBlock *BasicBlockVal;
1184 llvm::TerminatorInst *TermInstVal;
1185 llvm::Instruction *InstVal;
1186 llvm::Constant *ConstVal;
1187
1188 const llvm::Type *PrimType;
1189 llvm::PATypeHolder *TypeVal;
1190 llvm::Value *ValueVal;
1191
1192 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1193 std::vector<llvm::Value*> *ValueList;
1194 std::list<llvm::PATypeHolder> *TypeList;
1195 // Represent the RHS of PHI node
1196 std::list<std::pair<llvm::Value*,
1197 llvm::BasicBlock*> > *PHIList;
1198 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1199 std::vector<llvm::Constant*> *ConstVector;
1200
1201 llvm::GlobalValue::LinkageTypes Linkage;
1202 int64_t SInt64Val;
1203 uint64_t UInt64Val;
1204 int SIntVal;
1205 unsigned UIntVal;
1206 double FPVal;
1207 bool BoolVal;
1208
1209 char *StrVal; // This memory is strdup'd!
1210 llvm::ValID ValIDVal; // strdup'd memory maybe!
1211
1212 llvm::Instruction::BinaryOps BinaryOpVal;
1213 llvm::Instruction::TermOps TermOpVal;
1214 llvm::Instruction::MemoryOps MemOpVal;
1215 llvm::Instruction::OtherOps OtherOpVal;
1216 llvm::Module::Endianness Endianness;
1217} YYSTYPE;
Reid Spencer61c83e02006-08-18 08:43:06 +00001218/* Line 196 of yacc.c. */
1219#line 1220 "llvmAsmParser.tab.c"
1220# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1221# define YYSTYPE_IS_DECLARED 1
1222# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001223#endif
1224
1225
1226
Reid Spencer61c83e02006-08-18 08:43:06 +00001227/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001228
1229
Reid Spencer61c83e02006-08-18 08:43:06 +00001230/* Line 219 of yacc.c. */
1231#line 1232 "llvmAsmParser.tab.c"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001232
Reid Spencer61c83e02006-08-18 08:43:06 +00001233#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1234# define YYSIZE_T __SIZE_TYPE__
1235#endif
1236#if ! defined (YYSIZE_T) && defined (size_t)
1237# define YYSIZE_T size_t
1238#endif
1239#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1240# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1241# define YYSIZE_T size_t
1242#endif
1243#if ! defined (YYSIZE_T)
1244# define YYSIZE_T unsigned int
1245#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001246
Reid Spencer61c83e02006-08-18 08:43:06 +00001247#ifndef YY_
1248# if YYENABLE_NLS
1249# if ENABLE_NLS
1250# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1251# define YY_(msgid) dgettext ("bison-runtime", msgid)
1252# endif
1253# endif
1254# ifndef YY_
1255# define YY_(msgid) msgid
1256# endif
1257#endif
1258
1259#if ! defined (yyoverflow) || YYERROR_VERBOSE
1260
1261/* The parser invokes alloca or malloc; define the necessary symbols. */
1262
1263# ifdef YYSTACK_USE_ALLOCA
1264# if YYSTACK_USE_ALLOCA
1265# ifdef __GNUC__
1266# define YYSTACK_ALLOC __builtin_alloca
1267# else
1268# define YYSTACK_ALLOC alloca
1269# if defined (__STDC__) || defined (__cplusplus)
1270# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1271# define YYINCLUDED_STDLIB_H
1272# endif
1273# endif
1274# endif
1275# endif
1276
1277# ifdef YYSTACK_ALLOC
1278 /* Pacify GCC's `empty if-body' warning. */
1279# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1280# ifndef YYSTACK_ALLOC_MAXIMUM
1281 /* The OS might guarantee only one guard page at the bottom of the stack,
1282 and a page size can be as small as 4096 bytes. So we cannot safely
1283 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1284 to allow for a few compiler-allocated temporary stack slots. */
1285# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1286# endif
1287# else
1288# define YYSTACK_ALLOC YYMALLOC
1289# define YYSTACK_FREE YYFREE
1290# ifndef YYSTACK_ALLOC_MAXIMUM
1291# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1292# endif
1293# ifdef __cplusplus
1294extern "C" {
1295# endif
1296# ifndef YYMALLOC
1297# define YYMALLOC malloc
1298# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1299 && (defined (__STDC__) || defined (__cplusplus)))
1300void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1301# endif
1302# endif
1303# ifndef YYFREE
1304# define YYFREE free
1305# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1306 && (defined (__STDC__) || defined (__cplusplus)))
1307void free (void *); /* INFRINGES ON USER NAME SPACE */
1308# endif
1309# endif
1310# ifdef __cplusplus
1311}
1312# endif
1313# endif
1314#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1315
1316
1317#if (! defined (yyoverflow) \
1318 && (! defined (__cplusplus) \
1319 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1320
1321/* A type that is properly aligned for any stack member. */
1322union yyalloc
1323{
1324 short int yyss;
1325 YYSTYPE yyvs;
1326 };
1327
1328/* The size of the maximum gap between one aligned stack and the next. */
1329# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1330
1331/* The size of an array large to enough to hold all stacks, each with
1332 N elements. */
1333# define YYSTACK_BYTES(N) \
1334 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1335 + YYSTACK_GAP_MAXIMUM)
1336
1337/* Copy COUNT objects from FROM to TO. The source and destination do
1338 not overlap. */
1339# ifndef YYCOPY
1340# if defined (__GNUC__) && 1 < __GNUC__
1341# define YYCOPY(To, From, Count) \
1342 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1343# else
1344# define YYCOPY(To, From, Count) \
1345 do \
1346 { \
1347 YYSIZE_T yyi; \
1348 for (yyi = 0; yyi < (Count); yyi++) \
1349 (To)[yyi] = (From)[yyi]; \
1350 } \
1351 while (0)
1352# endif
1353# endif
1354
1355/* Relocate STACK from its old location to the new one. The
1356 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1357 elements in the stack, and YYPTR gives the new location of the
1358 stack. Advance YYPTR to a properly aligned location for the next
1359 stack. */
1360# define YYSTACK_RELOCATE(Stack) \
1361 do \
1362 { \
1363 YYSIZE_T yynewbytes; \
1364 YYCOPY (&yyptr->Stack, Stack, yysize); \
1365 Stack = &yyptr->Stack; \
1366 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1367 yyptr += yynewbytes / sizeof (*yyptr); \
1368 } \
1369 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001370
1371#endif
1372
Reid Spencer61c83e02006-08-18 08:43:06 +00001373#if defined (__STDC__) || defined (__cplusplus)
1374 typedef signed char yysigned_char;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001375#else
Reid Spencer61c83e02006-08-18 08:43:06 +00001376 typedef short int yysigned_char;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001377#endif
1378
Reid Spencer61c83e02006-08-18 08:43:06 +00001379/* YYFINAL -- State number of the termination state. */
1380#define YYFINAL 4
1381/* YYLAST -- Last index in YYTABLE. */
1382#define YYLAST 1278
1383
1384/* YYNTOKENS -- Number of terminals. */
1385#define YYNTOKENS 117
1386/* YYNNTS -- Number of nonterminals. */
1387#define YYNNTS 72
1388/* YYNRULES -- Number of rules. */
1389#define YYNRULES 239
1390/* YYNRULES -- Number of states. */
1391#define YYNSTATES 496
1392
1393/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1394#define YYUNDEFTOK 2
1395#define YYMAXUTOK 357
1396
1397#define YYTRANSLATE(YYX) \
1398 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1399
1400/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1401static const unsigned char yytranslate[] =
1402{
1403 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1404 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1405 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1406 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1407 106, 107, 115, 2, 104, 2, 2, 2, 2, 2,
1408 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1409 111, 103, 112, 2, 2, 2, 2, 2, 2, 2,
1410 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1411 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1412 2, 108, 105, 110, 2, 2, 2, 2, 2, 116,
1413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1415 109, 2, 2, 113, 2, 114, 2, 2, 2, 2,
1416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1425 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1427 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1428 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1429 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1430 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1431 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1432 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1433 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1434 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1435 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1436 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1437 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1438 95, 96, 97, 98, 99, 100, 101, 102
1439};
1440
1441#if YYDEBUG
1442/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1443 YYRHS. */
1444static const unsigned short int yyprhs[] =
1445{
1446 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1447 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1448 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1449 59, 61, 63, 65, 67, 70, 71, 73, 75, 77,
1450 79, 80, 81, 83, 85, 87, 89, 92, 93, 96,
1451 97, 101, 104, 105, 107, 108, 112, 114, 117, 119,
1452 121, 123, 125, 127, 129, 131, 133, 135, 137, 139,
1453 141, 143, 145, 147, 149, 151, 153, 155, 157, 159,
1454 162, 167, 173, 179, 183, 186, 189, 191, 195, 197,
1455 201, 203, 204, 209, 213, 217, 222, 227, 231, 234,
1456 237, 240, 243, 246, 249, 252, 255, 258, 261, 268,
1457 274, 283, 290, 297, 304, 311, 318, 327, 336, 340,
1458 342, 344, 346, 348, 351, 354, 359, 362, 364, 369,
1459 372, 377, 378, 386, 387, 395, 399, 404, 405, 407,
1460 409, 411, 415, 419, 423, 427, 431, 433, 434, 436,
1461 438, 440, 441, 444, 448, 450, 452, 456, 458, 459,
1462 468, 470, 472, 476, 478, 480, 483, 484, 488, 489,
1463 491, 493, 495, 497, 499, 501, 503, 505, 507, 511,
1464 513, 519, 521, 523, 525, 527, 530, 533, 536, 540,
1465 543, 544, 546, 549, 552, 556, 566, 576, 585, 599,
1466 601, 603, 610, 616, 619, 626, 634, 636, 640, 642,
1467 643, 646, 648, 654, 660, 666, 669, 674, 679, 686,
1468 691, 696, 701, 706, 713, 720, 723, 731, 733, 736,
1469 737, 739, 740, 744, 751, 755, 762, 765, 770, 777
1470};
1471
1472/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1473static const short int yyrhs[] =
1474{
1475 148, 0, -1, 5, -1, 6, -1, 3, -1, 4,
1476 -1, 72, -1, 73, -1, 74, -1, 75, -1, 76,
1477 -1, 77, -1, 78, -1, 79, -1, 80, -1, 81,
1478 -1, 82, -1, 83, -1, 84, -1, 85, -1, 95,
1479 -1, 96, -1, 16, -1, 14, -1, 12, -1, 10,
1480 -1, 17, -1, 15, -1, 13, -1, 11, -1, 124,
1481 -1, 125, -1, 18, -1, 19, -1, 158, 103, -1,
1482 -1, 41, -1, 42, -1, 43, -1, 44, -1, -1,
1483 -1, 62, -1, 63, -1, 64, -1, 65, -1, 61,
1484 4, -1, -1, 54, 4, -1, -1, 104, 54, 4,
1485 -1, 34, 24, -1, -1, 133, -1, -1, 104, 136,
1486 135, -1, 133, -1, 54, 4, -1, 139, -1, 8,
1487 -1, 141, -1, 8, -1, 141, -1, 9, -1, 10,
1488 -1, 11, -1, 12, -1, 13, -1, 14, -1, 15,
1489 -1, 16, -1, 17, -1, 18, -1, 19, -1, 20,
1490 -1, 21, -1, 45, -1, 140, -1, 172, -1, 105,
1491 4, -1, 138, 106, 143, 107, -1, 108, 4, 109,
1492 141, 110, -1, 111, 4, 109, 141, 112, -1, 113,
1493 142, 114, -1, 113, 114, -1, 141, 115, -1, 141,
1494 -1, 142, 104, 141, -1, 142, -1, 142, 104, 37,
1495 -1, 37, -1, -1, 139, 108, 146, 110, -1, 139,
1496 108, 110, -1, 139, 116, 24, -1, 139, 111, 146,
1497 112, -1, 139, 113, 146, 114, -1, 139, 113, 114,
1498 -1, 139, 38, -1, 139, 39, -1, 139, 172, -1,
1499 139, 145, -1, 139, 26, -1, 124, 119, -1, 125,
1500 4, -1, 9, 27, -1, 9, 28, -1, 127, 7,
1501 -1, 93, 106, 144, 36, 139, 107, -1, 91, 106,
1502 144, 186, 107, -1, 94, 106, 144, 104, 144, 104,
1503 144, 107, -1, 120, 106, 144, 104, 144, 107, -1,
1504 121, 106, 144, 104, 144, 107, -1, 122, 106, 144,
1505 104, 144, 107, -1, 123, 106, 144, 104, 144, 107,
1506 -1, 98, 106, 144, 104, 144, 107, -1, 99, 106,
1507 144, 104, 144, 104, 144, 107, -1, 100, 106, 144,
1508 104, 144, 104, 144, 107, -1, 146, 104, 144, -1,
1509 144, -1, 32, -1, 33, -1, 149, -1, 149, 167,
1510 -1, 149, 168, -1, 149, 59, 58, 153, -1, 149,
1511 25, -1, 150, -1, 150, 128, 20, 137, -1, 150,
1512 168, -1, 150, 59, 58, 153, -1, -1, 150, 128,
1513 129, 147, 144, 151, 135, -1, -1, 150, 128, 47,
1514 147, 139, 152, 135, -1, 150, 48, 155, -1, 150,
1515 55, 103, 156, -1, -1, 24, -1, 53, -1, 52,
1516 -1, 50, 103, 154, -1, 51, 103, 4, -1, 49,
1517 103, 24, -1, 108, 157, 110, -1, 157, 104, 24,
1518 -1, 24, -1, -1, 22, -1, 24, -1, 158, -1,
1519 -1, 139, 159, -1, 161, 104, 160, -1, 160, -1,
1520 161, -1, 161, 104, 37, -1, 37, -1, -1, 130,
1521 137, 158, 106, 162, 107, 134, 131, -1, 29, -1,
1522 113, -1, 129, 163, 164, -1, 30, -1, 114, -1,
1523 175, 166, -1, -1, 31, 169, 163, -1, -1, 60,
1524 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
1525 -1, 38, -1, 39, -1, 26, -1, 111, 146, 112,
1526 -1, 145, -1, 58, 170, 24, 104, 24, -1, 118,
1527 -1, 158, -1, 172, -1, 171, -1, 139, 173, -1,
1528 175, 176, -1, 165, 176, -1, 177, 128, 178, -1,
1529 177, 180, -1, -1, 23, -1, 66, 174, -1, 66,
1530 8, -1, 67, 21, 173, -1, 67, 9, 173, 104,
1531 21, 173, 104, 21, 173, -1, 68, 126, 173, 104,
1532 21, 173, 108, 179, 110, -1, 68, 126, 173, 104,
1533 21, 173, 108, 110, -1, 69, 130, 137, 173, 106,
1534 183, 107, 36, 21, 173, 70, 21, 173, -1, 70,
1535 -1, 71, -1, 179, 126, 171, 104, 21, 173, -1,
1536 126, 171, 104, 21, 173, -1, 128, 185, -1, 139,
1537 108, 173, 104, 173, 110, -1, 181, 104, 108, 173,
1538 104, 173, 110, -1, 174, -1, 182, 104, 174, -1,
1539 182, -1, -1, 57, 56, -1, 56, -1, 120, 139,
1540 173, 104, 173, -1, 121, 139, 173, 104, 173, -1,
1541 122, 139, 173, 104, 173, -1, 46, 174, -1, 123,
1542 174, 104, 174, -1, 93, 174, 36, 139, -1, 94,
1543 174, 104, 174, 104, 174, -1, 97, 174, 104, 139,
1544 -1, 101, 174, 104, 139, -1, 102, 174, 104, 139,
1545 -1, 98, 174, 104, 174, -1, 99, 174, 104, 174,
1546 104, 174, -1, 100, 174, 104, 174, 104, 174, -1,
1547 92, 181, -1, 184, 130, 137, 173, 106, 183, 107,
1548 -1, 188, -1, 104, 182, -1, -1, 35, -1, -1,
1549 86, 139, 132, -1, 86, 139, 104, 15, 173, 132,
1550 -1, 87, 139, 132, -1, 87, 139, 104, 15, 173,
1551 132, -1, 88, 174, -1, 187, 89, 139, 173, -1,
1552 187, 90, 174, 104, 139, 173, -1, 91, 139, 173,
1553 186, -1
1554};
1555
1556/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1557static const unsigned short int yyrline[] =
1558{
1559 0, 1017, 1017, 1018, 1026, 1027, 1037, 1037, 1037, 1037,
1560 1037, 1038, 1038, 1038, 1039, 1039, 1039, 1039, 1039, 1039,
1561 1041, 1041, 1045, 1045, 1045, 1045, 1046, 1046, 1046, 1046,
1562 1047, 1047, 1048, 1048, 1051, 1055, 1060, 1061, 1062, 1063,
1563 1064, 1066, 1067, 1068, 1069, 1070, 1071, 1080, 1081, 1087,
1564 1088, 1096, 1104, 1105, 1110, 1111, 1112, 1117, 1131, 1131,
1565 1132, 1132, 1134, 1144, 1144, 1144, 1144, 1144, 1144, 1144,
1566 1145, 1145, 1145, 1145, 1145, 1145, 1146, 1150, 1154, 1161,
1567 1169, 1182, 1187, 1199, 1209, 1213, 1222, 1227, 1233, 1234,
1568 1238, 1242, 1253, 1279, 1293, 1323, 1349, 1370, 1383, 1393,
1569 1398, 1458, 1465, 1474, 1480, 1486, 1490, 1494, 1502, 1513,
1570 1545, 1553, 1575, 1586, 1592, 1600, 1606, 1612, 1621, 1625,
1571 1633, 1633, 1643, 1651, 1656, 1660, 1664, 1668, 1683, 1704,
1572 1707, 1710, 1710, 1717, 1717, 1725, 1728, 1731, 1735, 1748,
1573 1749, 1751, 1755, 1764, 1770, 1772, 1777, 1782, 1791, 1791,
1574 1792, 1792, 1794, 1801, 1807, 1814, 1818, 1824, 1829, 1834,
1575 1921, 1921, 1923, 1931, 1931, 1933, 1938, 1938, 1948, 1952,
1576 1957, 1961, 1965, 1969, 1973, 1977, 1981, 1985, 1989, 2014,
1577 2018, 2032, 2036, 2042, 2042, 2048, 2053, 2057, 2066, 2076,
1578 2081, 2092, 2104, 2108, 2112, 2116, 2120, 2135, 2140, 2194,
1579 2198, 2205, 2214, 2225, 2233, 2239, 2247, 2252, 2259, 2259,
1580 2261, 2265, 2272, 2285, 2297, 2308, 2321, 2329, 2337, 2345,
1581 2351, 2371, 2394, 2400, 2406, 2412, 2427, 2485, 2492, 2495,
1582 2500, 2504, 2511, 2516, 2521, 2526, 2531, 2539, 2550, 2564
1583};
1584#endif
1585
1586#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1587/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1588 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1589static const char *const yytname[] =
1590{
1591 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1592 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
1593 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
1594 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1595 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1596 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1597 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
1598 "WEAK", "APPENDING", "OPAQUE", "NOT", "EXTERNAL", "TARGET", "TRIPLE",
1599 "ENDIAN", "POINTERSIZE", "LITTLE", "BIG", "ALIGN", "DEPLIBS", "CALL",
1600 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1601 "CSRETCC_TOK", "FASTCC_TOK", "COLDCC_TOK", "RET", "BR", "SWITCH",
1602 "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "DIV", "REM",
1603 "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE",
1604 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
1605 "CAST", "SELECT", "SHL", "SHR", "VAARG", "EXTRACTELEMENT",
1606 "INSERTELEMENT", "SHUFFLEVECTOR", "VAARG_old", "VANEXT_old", "'='",
1607 "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'",
1608 "'}'", "'*'", "'c'", "$accept", "INTVAL", "EINT64VAL", "ArithmeticOps",
1609 "LogicalOps", "SetCondOps", "ShiftOps", "SIntType", "UIntType",
1610 "IntType", "FPType", "OptAssign", "OptLinkage", "OptCallingConv",
1611 "OptAlign", "OptCAlign", "SectionString", "OptSection",
1612 "GlobalVarAttributes", "GlobalVarAttribute", "TypesV", "UpRTypesV",
1613 "Types", "PrimType", "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal",
1614 "ConstExpr", "ConstVector", "GlobalType", "Module", "FunctionList",
1615 "ConstPool", "@1", "@2", "AsmBlock", "BigOrLittle", "TargetDefinition",
1616 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
1617 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
1618 "END", "Function", "FunctionProto", "@3", "OptSideEffect",
1619 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1620 "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
1621 "JumpTable", "Inst", "PHIList", "ValueRefList", "ValueRefListE",
1622 "OptTailCall", "InstVal", "IndexList", "OptVolatile", "MemoryInst", 0
1623};
1624#endif
1625
1626# ifdef YYPRINT
1627/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1628 token YYLEX-NUM. */
1629static const unsigned short int yytoknum[] =
1630{
1631 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1632 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1633 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1634 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1635 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1636 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1637 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1638 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1639 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1640 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1641 355, 356, 357, 61, 44, 92, 40, 41, 91, 120,
1642 93, 60, 62, 123, 125, 42, 99
1643};
1644# endif
1645
1646/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1647static const unsigned char yyr1[] =
1648{
1649 0, 117, 118, 118, 119, 119, 120, 120, 120, 120,
1650 120, 121, 121, 121, 122, 122, 122, 122, 122, 122,
1651 123, 123, 124, 124, 124, 124, 125, 125, 125, 125,
1652 126, 126, 127, 127, 128, 128, 129, 129, 129, 129,
1653 129, 130, 130, 130, 130, 130, 130, 131, 131, 132,
1654 132, 133, 134, 134, 135, 135, 136, 136, 137, 137,
1655 138, 138, 139, 140, 140, 140, 140, 140, 140, 140,
1656 140, 140, 140, 140, 140, 140, 141, 141, 141, 141,
1657 141, 141, 141, 141, 141, 141, 142, 142, 143, 143,
1658 143, 143, 144, 144, 144, 144, 144, 144, 144, 144,
1659 144, 144, 144, 144, 144, 144, 144, 144, 145, 145,
1660 145, 145, 145, 145, 145, 145, 145, 145, 146, 146,
1661 147, 147, 148, 149, 149, 149, 149, 149, 150, 150,
1662 150, 151, 150, 152, 150, 150, 150, 150, 153, 154,
1663 154, 155, 155, 155, 156, 157, 157, 157, 158, 158,
1664 159, 159, 160, 161, 161, 162, 162, 162, 162, 163,
1665 164, 164, 165, 166, 166, 167, 169, 168, 170, 170,
1666 171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
1667 171, 172, 172, 173, 173, 174, 175, 175, 176, 177,
1668 177, 177, 178, 178, 178, 178, 178, 178, 178, 178,
1669 178, 179, 179, 180, 181, 181, 182, 182, 183, 183,
1670 184, 184, 185, 185, 185, 185, 185, 185, 185, 185,
1671 185, 185, 185, 185, 185, 185, 185, 185, 186, 186,
1672 187, 187, 188, 188, 188, 188, 188, 188, 188, 188
1673};
1674
1675/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1676static const unsigned char yyr2[] =
1677{
1678 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1679 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1680 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1681 1, 1, 1, 1, 2, 0, 1, 1, 1, 1,
1682 0, 0, 1, 1, 1, 1, 2, 0, 2, 0,
1683 3, 2, 0, 1, 0, 3, 1, 2, 1, 1,
1684 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1685 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
1686 4, 5, 5, 3, 2, 2, 1, 3, 1, 3,
1687 1, 0, 4, 3, 3, 4, 4, 3, 2, 2,
1688 2, 2, 2, 2, 2, 2, 2, 2, 6, 5,
1689 8, 6, 6, 6, 6, 6, 8, 8, 3, 1,
1690 1, 1, 1, 2, 2, 4, 2, 1, 4, 2,
1691 4, 0, 7, 0, 7, 3, 4, 0, 1, 1,
1692 1, 3, 3, 3, 3, 3, 1, 0, 1, 1,
1693 1, 0, 2, 3, 1, 1, 3, 1, 0, 8,
1694 1, 1, 3, 1, 1, 2, 0, 3, 0, 1,
1695 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
1696 5, 1, 1, 1, 1, 2, 2, 2, 3, 2,
1697 0, 1, 2, 2, 3, 9, 9, 8, 13, 1,
1698 1, 6, 5, 2, 6, 7, 1, 3, 1, 0,
1699 2, 1, 5, 5, 5, 2, 4, 4, 6, 4,
1700 4, 4, 4, 6, 6, 2, 7, 1, 2, 0,
1701 1, 0, 3, 6, 3, 6, 2, 4, 6, 4
1702};
1703
1704/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1705 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1706 means the default is an error. */
1707static const unsigned char yydefact[] =
1708{
1709 137, 0, 40, 127, 1, 126, 166, 36, 37, 38,
1710 39, 0, 41, 190, 123, 124, 190, 148, 149, 0,
1711 0, 0, 40, 0, 129, 41, 0, 0, 42, 43,
1712 44, 45, 0, 0, 191, 187, 35, 163, 164, 165,
1713 186, 0, 0, 0, 135, 0, 0, 0, 0, 0,
1714 34, 167, 138, 125, 46, 2, 3, 59, 63, 64,
1715 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1716 75, 76, 0, 0, 0, 0, 181, 0, 0, 58,
1717 77, 62, 182, 78, 160, 161, 162, 231, 189, 0,
1718 0, 0, 147, 136, 130, 128, 120, 121, 0, 0,
1719 79, 0, 0, 61, 84, 86, 0, 0, 91, 85,
1720 230, 0, 211, 0, 0, 0, 0, 41, 199, 200,
1721 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1722 16, 17, 18, 19, 0, 0, 0, 0, 0, 0,
1723 0, 20, 21, 0, 0, 0, 0, 0, 0, 0,
1724 0, 0, 0, 188, 41, 203, 0, 227, 143, 140,
1725 139, 141, 142, 146, 0, 133, 63, 64, 65, 66,
1726 67, 68, 69, 70, 71, 72, 73, 0, 0, 0,
1727 0, 131, 0, 0, 0, 83, 158, 90, 88, 0,
1728 0, 215, 210, 193, 192, 0, 0, 25, 29, 24,
1729 28, 23, 27, 22, 26, 30, 31, 0, 0, 49,
1730 49, 236, 0, 0, 225, 0, 0, 0, 0, 0,
1731 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1732 0, 144, 54, 105, 106, 4, 5, 103, 104, 107,
1733 102, 98, 99, 0, 0, 0, 0, 0, 0, 0,
1734 0, 0, 0, 0, 0, 0, 0, 101, 100, 54,
1735 60, 60, 87, 157, 151, 154, 155, 0, 0, 80,
1736 170, 171, 172, 177, 173, 174, 175, 176, 168, 0,
1737 179, 184, 183, 185, 0, 194, 0, 0, 0, 232,
1738 0, 234, 229, 0, 0, 0, 0, 0, 0, 0,
1739 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1740 145, 0, 134, 0, 0, 0, 0, 0, 0, 93,
1741 119, 0, 0, 97, 0, 94, 0, 0, 0, 0,
1742 132, 81, 82, 150, 152, 0, 52, 89, 169, 0,
1743 0, 0, 0, 0, 0, 0, 0, 0, 239, 0,
1744 0, 217, 0, 219, 222, 0, 0, 220, 221, 0,
1745 0, 0, 216, 0, 237, 0, 0, 0, 56, 54,
1746 229, 0, 0, 0, 0, 0, 0, 92, 95, 96,
1747 0, 0, 0, 0, 156, 153, 53, 47, 0, 178,
1748 0, 0, 209, 49, 50, 49, 206, 228, 0, 0,
1749 0, 0, 0, 212, 213, 214, 209, 0, 51, 57,
1750 55, 0, 0, 0, 0, 0, 0, 118, 0, 0,
1751 0, 0, 0, 159, 0, 0, 0, 208, 0, 0,
1752 233, 235, 0, 0, 0, 218, 223, 224, 0, 238,
1753 109, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1754 48, 180, 0, 0, 0, 207, 204, 0, 226, 108,
1755 0, 115, 0, 0, 111, 112, 113, 114, 0, 197,
1756 0, 0, 0, 205, 0, 0, 0, 195, 0, 196,
1757 0, 0, 110, 116, 117, 0, 0, 0, 0, 0,
1758 0, 202, 0, 0, 201, 198
1759};
1760
1761/* YYDEFGOTO[NTERM-NUM]. */
1762static const short int yydefgoto[] =
1763{
1764 -1, 76, 237, 253, 254, 255, 256, 177, 178, 207,
1765 179, 22, 12, 32, 423, 289, 368, 387, 312, 369,
1766 77, 78, 180, 80, 81, 106, 189, 320, 280, 321,
1767 98, 1, 2, 3, 259, 232, 53, 161, 44, 93,
1768 164, 82, 334, 265, 266, 267, 33, 86, 13, 39,
1769 14, 15, 25, 339, 281, 83, 283, 396, 16, 35,
1770 36, 153, 471, 88, 214, 427, 428, 154, 155, 348,
1771 156, 157
1772};
1773
1774/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1775 STATE-NUM. */
1776#define YYPACT_NINF -442
1777static const short int yypact[] =
1778{
1779 -442, 25, 181, 372, -442, -442, -442, -442, -442, -442,
1780 -442, -16, 33, 42, -442, -442, -14, -442, -442, 12,
1781 -57, 18, 44, -25, -442, 33, 75, 106, -442, -442,
1782 -442, -442, 1012, -21, -442, -442, 4, -442, -442, -442,
1783 -442, 29, 32, 49, -442, 47, 75, 1012, 97, 97,
1784 -442, -442, -442, -442, -442, -442, -442, 63, -442, -442,
1785 -442, -442, -442, -442, -442, -442, -442, -442, -442, -442,
1786 -442, -442, 170, 171, 173, 524, -442, 4, 72, -442,
1787 -442, -84, -442, -442, -442, -442, -442, 1176, -442, 156,
1788 94, 175, 158, -442, -442, -442, -442, -442, 1050, 1088,
1789 -442, 74, 76, -442, -442, -84, -37, 78, 819, -442,
1790 -442, 1050, -442, 131, 1126, 14, 128, 33, -442, -442,
1791 -442, -442, -442, -442, -442, -442, -442, -442, -442, -442,
1792 -442, -442, -442, -442, 1050, 1050, 1050, 1050, 1050, 1050,
1793 1050, -442, -442, 1050, 1050, 1050, 1050, 1050, 1050, 1050,
1794 1050, 1050, 1050, -442, 33, -442, 60, -442, -442, -442,
1795 -442, -442, -442, -442, 23, -442, 129, 155, 190, 157,
1796 194, 159, 196, 167, 197, 195, 198, 169, 199, 200,
1797 406, -442, 1050, 1050, 1050, -442, 857, -442, 100, 101,
1798 617, -442, -442, 63, -442, 617, 617, -442, -442, -442,
1799 -442, -442, -442, -442, -442, -442, -442, 617, 1012, 105,
1800 107, -442, 617, 118, 109, 178, 111, 123, 132, 133,
1801 134, 135, 137, 617, 617, 617, 138, 1012, 1050, 1050,
1802 209, -442, 139, -442, -442, -442, -442, -442, -442, -442,
1803 -442, -442, -442, 140, 141, 144, 145, 146, 147, 895,
1804 1088, 566, 211, 148, 149, 150, 151, -442, -442, 139,
1805 -66, -88, -84, -442, 4, -442, 154, 152, 936, -442,
1806 -442, -442, -442, -442, -442, -442, -442, -442, 184, 1088,
1807 -442, -442, -442, -442, 168, -442, 172, 617, 5, -442,
1808 6, -442, 174, 617, 153, 1050, 1050, 1050, 1050, 1050,
1809 1050, 1050, 1050, 176, 177, 179, 1050, 617, 617, 180,
1810 -442, -20, -442, 1088, 1088, 1088, 1088, 1088, 1088, -442,
1811 -442, 24, -23, -442, -24, -442, 1088, 1088, 1088, 1088,
1812 -442, -442, -442, -442, -442, 974, 226, -442, -442, 221,
1813 -3, 241, 252, 182, 617, 271, 617, 1050, -442, 185,
1814 617, -442, 186, -442, -442, 188, 192, -442, -442, 617,
1815 617, 617, -442, 191, -442, 1050, 253, 278, -442, 139,
1816 174, 250, 201, 202, 203, 204, 1088, -442, -442, -442,
1817 205, 206, 207, 208, -442, -442, -442, 244, 210, -442,
1818 617, 617, 1050, 216, -442, 216, -442, 222, 617, 223,
1819 1050, 1050, 1050, -442, -442, -442, 1050, 617, -442, -442,
1820 -442, 227, 1050, 1088, 1088, 1088, 1088, -442, 1088, 1088,
1821 1088, 1088, 295, -442, 280, 224, 228, 222, 230, 259,
1822 -442, -442, 1050, 219, 617, -442, -442, -442, 234, -442,
1823 -442, 235, 231, 236, 240, 242, 238, 243, 245, 246,
1824 -442, -442, 309, 41, 311, -442, -442, 239, -442, -442,
1825 1088, -442, 1088, 1088, -442, -442, -442, -442, 617, -442,
1826 715, 58, 330, -442, 247, 248, 257, -442, 255, -442,
1827 715, 617, -442, -442, -442, 336, 263, 301, 617, 351,
1828 355, -442, 617, 617, -442, -442
1829};
1830
1831/* YYPGOTO[NTERM-NUM]. */
1832static const short int yypgoto[] =
1833{
1834 -442, -442, -442, 290, 292, 294, 296, -115, -113, -441,
1835 -442, 346, 362, -106, -442, -205, 50, -442, -246, -442,
1836 -41, -442, -32, -442, -58, 277, -442, -97, 213, -232,
1837 338, -442, -442, -442, -442, -442, 342, -442, -442, -442,
1838 -442, 7, -442, 62, -442, -442, 370, -442, -442, -442,
1839 -442, 395, -442, -442, -387, -59, 166, -107, -442, 383,
1840 -442, -442, -442, -442, -442, 54, -4, -442, -442, 36,
1841 -442, -442
1842};
1843
1844/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1845 positive, shift that token. If negative, reduce the rule which
1846 number is the opposite. If zero, do what YYDEFACT says.
1847 If YYTABLE_NINF, syntax error. */
1848#define YYTABLE_NINF -123
1849static const short int yytable[] =
1850{
1851 79, 205, 181, 206, 191, 291, 95, 194, 84, 34,
1852 23, 208, 470, 330, 366, 79, 37, 105, 322, 324,
1853 344, 346, -60, 195, 332, 4, 17, 109, 18, 211,
1854 480, 109, 215, 216, 367, 196, 217, 218, 219, 220,
1855 221, 222, 26, 23, 331, 226, 45, 340, 227, 109,
1856 105, 197, 198, 199, 200, 201, 202, 203, 204, 345,
1857 345, 41, 42, 43, 47, 34, 165, 184, 197, 198,
1858 199, 200, 201, 202, 203, 204, 46, 185, 50, 190,
1859 376, 376, 190, 478, 107, 7, 8, 9, 10, 378,
1860 379, 48, 85, 486, 27, 28, 29, 30, 31, 52,
1861 38, 376, 209, 210, 190, 212, 213, 190, 190, 389,
1862 54, 190, 190, 190, 190, 190, 190, 223, 224, 225,
1863 190, 258, 309, 410, 260, 261, 262, 230, 376, 96,
1864 97, 282, 89, 231, 377, 90, 282, 282, 197, 198,
1865 199, 200, 201, 202, 203, 204, 159, 160, 282, 228,
1866 229, 469, 91, 282, 264, 92, 233, 234, -25, -25,
1867 -24, -24, -23, -23, 282, 282, 282, 287, 479, -61,
1868 -22, -22, 235, 236, 100, 101, 79, 102, 108, 162,
1869 158, -122, 163, 182, 186, 183, 307, 192, 430, 352,
1870 431, 354, 355, 356, -29, 79, 308, 190, -28, 362,
1871 -27, -26, -32, 238, 268, -33, 5, 239, 269, 288,
1872 262, 290, 6, 294, 295, 296, 370, 371, 372, 373,
1873 374, 375, 7, 8, 9, 10, 293, 297, 282, 380,
1874 381, 382, 383, 310, 282, 325, 298, 299, 300, 301,
1875 11, 302, 306, 311, 338, 388, 313, 314, 282, 282,
1876 315, 316, 317, 318, 326, 327, 328, 329, 335, 336,
1877 366, 350, 390, 351, 190, 353, 190, 190, 190, 357,
1878 358, 333, 341, 391, 190, 394, 342, 408, 347, 417,
1879 359, 360, 409, 361, 365, 282, 412, 282, 392, 398,
1880 400, 282, 401, 435, 436, 437, 402, 406, 422, 450,
1881 282, 282, 282, 264, 451, 413, 414, 415, 416, 418,
1882 419, 420, 421, 345, 424, 190, 442, 443, 444, 445,
1883 429, 446, 447, 448, 449, 455, 432, 434, 452, 456,
1884 468, 282, 282, 407, 440, 460, 453, 454, 205, 282,
1885 206, 458, 459, 461, 462, 464, 463, 472, 282, 473,
1886 465, 481, 466, 467, 482, 483, 205, 488, 206, 485,
1887 190, 284, 285, 474, 484, 475, 476, 489, 190, 190,
1888 190, 490, 492, 286, 190, 282, 493, 149, 292, 150,
1889 441, 151, 87, 152, 49, 188, 386, 99, 94, 303,
1890 304, 305, -35, 257, 17, 51, 18, 385, 24, 40,
1891 190, 397, 438, 6, -35, -35, 411, 0, 0, 282,
1892 0, 55, 56, -35, -35, -35, -35, 0, 0, -35,
1893 19, 0, 282, 0, 0, 0, 0, 20, 17, 282,
1894 18, 21, 240, 282, 282, 0, 0, 0, 0, 0,
1895 0, 0, 0, 0, 241, 242, 0, 0, 0, 0,
1896 0, 0, 0, 343, 0, 0, 0, 0, 0, 349,
1897 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1898 0, 0, 0, 363, 364, 0, 0, 0, 120, 121,
1899 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
1900 132, 133, 0, 0, 0, 0, 0, 243, 0, 244,
1901 245, 141, 142, 0, 246, 247, 248, 0, 0, 0,
1902 393, 0, 395, 0, 249, 0, 399, 250, 0, 251,
1903 0, 0, 252, 0, 0, 403, 404, 405, 0, 55,
1904 56, 0, 103, 58, 59, 60, 61, 62, 63, 64,
1905 65, 66, 67, 68, 69, 70, 17, 0, 18, 0,
1906 0, 0, 0, 0, 0, 0, 425, 426, 0, 0,
1907 0, 0, 0, 0, 433, 0, 0, 0, 0, 71,
1908 0, 55, 56, 439, 103, 166, 167, 168, 169, 170,
1909 171, 172, 173, 174, 175, 176, 69, 70, 17, 0,
1910 18, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1911 457, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1912 0, 71, 0, 0, 0, 0, 0, 0, 0, 0,
1913 270, 271, 55, 56, 272, 0, 0, 0, 0, 72,
1914 0, 0, 73, 0, 477, 74, 0, 75, 104, 17,
1915 0, 18, 0, 273, 274, 275, 0, 487, 0, 0,
1916 0, 0, 0, 0, 491, 276, 277, 0, 494, 495,
1917 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1918 0, 72, 0, 0, 73, 278, 0, 74, 0, 75,
1919 323, 0, 0, 0, 0, 0, 0, 0, 0, 120,
1920 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
1921 131, 132, 133, 0, 0, 0, 0, 0, 243, 0,
1922 244, 245, 141, 142, 0, 246, 247, 248, 270, 271,
1923 0, 0, 272, 0, 0, 0, 0, 0, 279, 0,
1924 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1925 0, 273, 274, 275, 0, 0, 0, 0, 0, 0,
1926 0, 0, 0, 276, 277, 0, 0, 0, 0, 0,
1927 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1928 0, 0, 0, 278, 0, 0, 0, 0, 0, 0,
1929 0, 0, 0, 0, 0, 0, 0, 120, 121, 122,
1930 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
1931 133, 0, 0, 0, 0, 0, 243, 0, 244, 245,
1932 141, 142, 0, 246, 247, 248, 0, 0, 0, 0,
1933 0, 0, 0, 0, 55, 56, 279, 103, 58, 59,
1934 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
1935 70, 17, 0, 18, 0, 0, 0, 0, 0, 0,
1936 0, 0, 0, 0, 0, 0, 187, 0, 0, 0,
1937 0, 0, 55, 56, 71, 103, 58, 59, 60, 61,
1938 62, 63, 64, 65, 66, 67, 68, 69, 70, 17,
1939 0, 18, 0, 0, 0, 0, 0, 0, 0, 0,
1940 0, 0, 0, 0, 263, 0, 0, 0, 0, 0,
1941 55, 56, 71, 103, 166, 167, 168, 169, 170, 171,
1942 172, 173, 174, 175, 176, 69, 70, 17, 0, 18,
1943 0, 0, 0, 0, 72, 0, 0, 73, 0, 0,
1944 74, 0, 75, 0, 0, 0, 0, 0, 0, 0,
1945 71, 55, 56, 0, 103, 58, 59, 60, 61, 62,
1946 63, 64, 65, 66, 67, 68, 69, 70, 17, 0,
1947 18, 0, 72, 0, 0, 73, 0, 0, 74, 0,
1948 75, 0, 0, 337, 0, 0, 0, 0, 0, 55,
1949 56, 71, 103, 58, 59, 60, 61, 62, 63, 64,
1950 65, 66, 67, 68, 69, 70, 17, 0, 18, 0,
1951 72, 0, 0, 73, 0, 319, 74, 0, 75, 0,
1952 0, 384, 0, 0, 0, 0, 0, 55, 56, 71,
1953 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1954 67, 68, 69, 70, 17, 0, 18, 0, 0, 0,
1955 0, 72, 0, 0, 73, 0, 0, 74, 0, 75,
1956 0, 0, 0, 0, 0, 55, 56, 71, 103, 58,
1957 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
1958 69, 70, 17, 0, 18, 0, 0, 0, 0, 72,
1959 0, 0, 73, 0, 0, 74, 0, 75, 0, 0,
1960 0, 0, 0, 55, 56, 71, 103, 166, 167, 168,
1961 169, 170, 171, 172, 173, 174, 175, 176, 69, 70,
1962 17, 0, 18, 0, 0, 0, 0, 72, 0, 0,
1963 73, 0, 0, 74, 0, 75, 0, 0, 0, 0,
1964 0, 55, 56, 71, 193, 58, 59, 60, 61, 62,
1965 63, 64, 65, 66, 67, 68, 69, 70, 17, 0,
1966 18, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1967 0, 74, 0, 75, 0, 0, 0, 0, 0, 0,
1968 0, 71, 0, 0, 0, 0, 0, 0, 0, 0,
1969 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1970 0, 0, 0, 72, 0, 0, 73, 0, 0, 74,
1971 0, 75, 0, 0, 0, 0, 0, 0, 0, 0,
1972 0, 110, 0, 0, 0, 0, 0, 0, 0, 0,
1973 0, 0, 111, 0, 0, 0, 0, 0, 0, 0,
1974 0, 72, 112, 113, 73, 0, 0, 74, 0, 75,
1975 0, 0, 114, 115, 116, 117, 118, 119, 120, 121,
1976 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
1977 132, 133, 134, 135, 136, 0, 0, 137, 138, 139,
1978 140, 141, 142, 143, 144, 145, 146, 147, 148
1979};
1980
1981static const short int yycheck[] =
1982{
1983 32, 116, 99, 116, 111, 210, 47, 114, 29, 23,
1984 3, 117, 453, 259, 34, 47, 30, 75, 250, 251,
1985 15, 15, 106, 9, 112, 0, 22, 115, 24, 136,
1986 471, 115, 139, 140, 54, 21, 143, 144, 145, 146,
1987 147, 148, 58, 36, 110, 152, 103, 279, 154, 115,
1988 108, 10, 11, 12, 13, 14, 15, 16, 17, 54,
1989 54, 49, 50, 51, 20, 23, 98, 104, 10, 11,
1990 12, 13, 14, 15, 16, 17, 58, 114, 103, 111,
1991 104, 104, 114, 470, 77, 41, 42, 43, 44, 112,
1992 114, 47, 113, 480, 61, 62, 63, 64, 65, 24,
1993 114, 104, 134, 135, 136, 137, 138, 139, 140, 112,
1994 4, 143, 144, 145, 146, 147, 148, 149, 150, 151,
1995 152, 180, 229, 369, 182, 183, 184, 104, 104, 32,
1996 33, 190, 103, 110, 110, 103, 195, 196, 10, 11,
1997 12, 13, 14, 15, 16, 17, 52, 53, 207, 89,
1998 90, 110, 103, 212, 186, 108, 27, 28, 3, 4,
1999 3, 4, 3, 4, 223, 224, 225, 208, 110, 106,
2000 3, 4, 3, 4, 4, 4, 208, 4, 106, 4,
2001 24, 0, 24, 109, 106, 109, 227, 56, 393, 296,
2002 395, 298, 299, 300, 4, 227, 228, 229, 4, 306,
2003 4, 4, 7, 4, 104, 7, 25, 7, 107, 104,
2004 268, 104, 31, 104, 36, 104, 313, 314, 315, 316,
2005 317, 318, 41, 42, 43, 44, 108, 104, 287, 326,
2006 327, 328, 329, 24, 293, 24, 104, 104, 104, 104,
2007 59, 104, 104, 104, 60, 24, 106, 106, 307, 308,
2008 106, 106, 106, 106, 106, 106, 106, 106, 104, 107,
2009 34, 108, 21, 295, 296, 297, 298, 299, 300, 301,
2010 302, 264, 104, 21, 306, 4, 104, 24, 104, 376,
2011 104, 104, 4, 104, 104, 344, 36, 346, 106, 104,
2012 104, 350, 104, 400, 401, 402, 104, 106, 54, 4,
2013 359, 360, 361, 335, 24, 104, 104, 104, 104, 104,
2014 104, 104, 104, 54, 104, 347, 413, 414, 415, 416,
2015 104, 418, 419, 420, 421, 432, 104, 104, 104, 110,
2016 21, 390, 391, 365, 107, 104, 108, 107, 453, 398,
2017 453, 107, 107, 107, 104, 107, 104, 36, 407, 110,
2018 107, 21, 107, 107, 107, 107, 471, 21, 471, 104,
2019 392, 195, 196, 460, 107, 462, 463, 104, 400, 401,
2020 402, 70, 21, 207, 406, 434, 21, 87, 212, 87,
2021 412, 87, 36, 87, 22, 108, 336, 49, 46, 223,
2022 224, 225, 20, 180, 22, 25, 24, 335, 3, 16,
2023 432, 347, 406, 31, 32, 33, 370, -1, -1, 468,
2024 -1, 5, 6, 41, 42, 43, 44, -1, -1, 47,
2025 48, -1, 481, -1, -1, -1, -1, 55, 22, 488,
2026 24, 59, 26, 492, 493, -1, -1, -1, -1, -1,
2027 -1, -1, -1, -1, 38, 39, -1, -1, -1, -1,
2028 -1, -1, -1, 287, -1, -1, -1, -1, -1, 293,
2029 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2030 -1, -1, -1, 307, 308, -1, -1, -1, 72, 73,
2031 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2032 84, 85, -1, -1, -1, -1, -1, 91, -1, 93,
2033 94, 95, 96, -1, 98, 99, 100, -1, -1, -1,
2034 344, -1, 346, -1, 108, -1, 350, 111, -1, 113,
2035 -1, -1, 116, -1, -1, 359, 360, 361, -1, 5,
2036 6, -1, 8, 9, 10, 11, 12, 13, 14, 15,
2037 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
2038 -1, -1, -1, -1, -1, -1, 390, 391, -1, -1,
2039 -1, -1, -1, -1, 398, -1, -1, -1, -1, 45,
2040 -1, 5, 6, 407, 8, 9, 10, 11, 12, 13,
2041 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2042 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2043 434, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2044 -1, 45, -1, -1, -1, -1, -1, -1, -1, -1,
2045 3, 4, 5, 6, 7, -1, -1, -1, -1, 105,
2046 -1, -1, 108, -1, 468, 111, -1, 113, 114, 22,
2047 -1, 24, -1, 26, 27, 28, -1, 481, -1, -1,
2048 -1, -1, -1, -1, 488, 38, 39, -1, 492, 493,
2049 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2050 -1, 105, -1, -1, 108, 58, -1, 111, -1, 113,
2051 114, -1, -1, -1, -1, -1, -1, -1, -1, 72,
2052 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2053 83, 84, 85, -1, -1, -1, -1, -1, 91, -1,
2054 93, 94, 95, 96, -1, 98, 99, 100, 3, 4,
2055 -1, -1, 7, -1, -1, -1, -1, -1, 111, -1,
2056 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2057 -1, 26, 27, 28, -1, -1, -1, -1, -1, -1,
2058 -1, -1, -1, 38, 39, -1, -1, -1, -1, -1,
2059 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2060 -1, -1, -1, 58, -1, -1, -1, -1, -1, -1,
2061 -1, -1, -1, -1, -1, -1, -1, 72, 73, 74,
2062 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2063 85, -1, -1, -1, -1, -1, 91, -1, 93, 94,
2064 95, 96, -1, 98, 99, 100, -1, -1, -1, -1,
2065 -1, -1, -1, -1, 5, 6, 111, 8, 9, 10,
2066 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2067 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2068 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2069 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
2070 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
2071 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2072 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
2073 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
2074 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
2075 -1, -1, -1, -1, 105, -1, -1, 108, -1, -1,
2076 111, -1, 113, -1, -1, -1, -1, -1, -1, -1,
2077 45, 5, 6, -1, 8, 9, 10, 11, 12, 13,
2078 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2079 24, -1, 105, -1, -1, 108, -1, -1, 111, -1,
2080 113, -1, -1, 37, -1, -1, -1, -1, -1, 5,
2081 6, 45, 8, 9, 10, 11, 12, 13, 14, 15,
2082 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
2083 105, -1, -1, 108, -1, 110, 111, -1, 113, -1,
2084 -1, 37, -1, -1, -1, -1, -1, 5, 6, 45,
2085 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2086 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
2087 -1, 105, -1, -1, 108, -1, -1, 111, -1, 113,
2088 -1, -1, -1, -1, -1, 5, 6, 45, 8, 9,
2089 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2090 20, 21, 22, -1, 24, -1, -1, -1, -1, 105,
2091 -1, -1, 108, -1, -1, 111, -1, 113, -1, -1,
2092 -1, -1, -1, 5, 6, 45, 8, 9, 10, 11,
2093 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
2094 22, -1, 24, -1, -1, -1, -1, 105, -1, -1,
2095 108, -1, -1, 111, -1, 113, -1, -1, -1, -1,
2096 -1, 5, 6, 45, 8, 9, 10, 11, 12, 13,
2097 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2098 24, -1, -1, -1, -1, 105, -1, -1, 108, -1,
2099 -1, 111, -1, 113, -1, -1, -1, -1, -1, -1,
2100 -1, 45, -1, -1, -1, -1, -1, -1, -1, -1,
2101 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2102 -1, -1, -1, 105, -1, -1, 108, -1, -1, 111,
2103 -1, 113, -1, -1, -1, -1, -1, -1, -1, -1,
2104 -1, 35, -1, -1, -1, -1, -1, -1, -1, -1,
2105 -1, -1, 46, -1, -1, -1, -1, -1, -1, -1,
2106 -1, 105, 56, 57, 108, -1, -1, 111, -1, 113,
2107 -1, -1, 66, 67, 68, 69, 70, 71, 72, 73,
2108 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2109 84, 85, 86, 87, 88, -1, -1, 91, 92, 93,
2110 94, 95, 96, 97, 98, 99, 100, 101, 102
2111};
2112
2113/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2114 symbol of state STATE-NUM. */
2115static const unsigned char yystos[] =
2116{
2117 0, 148, 149, 150, 0, 25, 31, 41, 42, 43,
2118 44, 59, 129, 165, 167, 168, 175, 22, 24, 48,
2119 55, 59, 128, 158, 168, 169, 58, 61, 62, 63,
2120 64, 65, 130, 163, 23, 176, 177, 30, 114, 166,
2121 176, 49, 50, 51, 155, 103, 58, 20, 47, 129,
2122 103, 163, 24, 153, 4, 5, 6, 8, 9, 10,
2123 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2124 21, 45, 105, 108, 111, 113, 118, 137, 138, 139,
2125 140, 141, 158, 172, 29, 113, 164, 128, 180, 103,
2126 103, 103, 108, 156, 153, 137, 32, 33, 147, 147,
2127 4, 4, 4, 8, 114, 141, 142, 158, 106, 115,
2128 35, 46, 56, 57, 66, 67, 68, 69, 70, 71,
2129 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2130 82, 83, 84, 85, 86, 87, 88, 91, 92, 93,
2131 94, 95, 96, 97, 98, 99, 100, 101, 102, 120,
2132 121, 122, 123, 178, 184, 185, 187, 188, 24, 52,
2133 53, 154, 4, 24, 157, 139, 9, 10, 11, 12,
2134 13, 14, 15, 16, 17, 18, 19, 124, 125, 127,
2135 139, 144, 109, 109, 104, 114, 106, 37, 142, 143,
2136 139, 174, 56, 8, 174, 9, 21, 10, 11, 12,
2137 13, 14, 15, 16, 17, 124, 125, 126, 130, 139,
2138 139, 174, 139, 139, 181, 174, 174, 174, 174, 174,
2139 174, 174, 174, 139, 139, 139, 174, 130, 89, 90,
2140 104, 110, 152, 27, 28, 3, 4, 119, 4, 7,
2141 26, 38, 39, 91, 93, 94, 98, 99, 100, 108,
2142 111, 113, 116, 120, 121, 122, 123, 145, 172, 151,
2143 141, 141, 141, 37, 139, 160, 161, 162, 104, 107,
2144 3, 4, 7, 26, 27, 28, 38, 39, 58, 111,
2145 145, 171, 172, 173, 173, 173, 173, 137, 104, 132,
2146 104, 132, 173, 108, 104, 36, 104, 104, 104, 104,
2147 104, 104, 104, 173, 173, 173, 104, 137, 139, 174,
2148 24, 104, 135, 106, 106, 106, 106, 106, 106, 110,
2149 144, 146, 146, 114, 146, 24, 106, 106, 106, 106,
2150 135, 110, 112, 158, 159, 104, 107, 37, 60, 170,
2151 146, 104, 104, 173, 15, 54, 15, 104, 186, 173,
2152 108, 139, 174, 139, 174, 174, 174, 139, 139, 104,
2153 104, 104, 174, 173, 173, 104, 34, 54, 133, 136,
2154 144, 144, 144, 144, 144, 144, 104, 110, 112, 114,
2155 144, 144, 144, 144, 37, 160, 133, 134, 24, 112,
2156 21, 21, 106, 173, 4, 173, 174, 182, 104, 173,
2157 104, 104, 104, 173, 173, 173, 106, 139, 24, 4,
2158 135, 186, 36, 104, 104, 104, 104, 144, 104, 104,
2159 104, 104, 54, 131, 104, 173, 173, 182, 183, 104,
2160 132, 132, 104, 173, 104, 174, 174, 174, 183, 173,
2161 107, 139, 144, 144, 144, 144, 144, 144, 144, 144,
2162 4, 24, 104, 108, 107, 174, 110, 173, 107, 107,
2163 104, 107, 104, 104, 107, 107, 107, 107, 21, 110,
2164 126, 179, 36, 110, 144, 144, 144, 173, 171, 110,
2165 126, 21, 107, 107, 107, 104, 171, 173, 21, 104,
2166 70, 173, 21, 21, 173, 173
2167};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002168
2169#define yyerrok (yyerrstatus = 0)
2170#define yyclearin (yychar = YYEMPTY)
Reid Spencer61c83e02006-08-18 08:43:06 +00002171#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002172#define YYEOF 0
Reid Spencer61c83e02006-08-18 08:43:06 +00002173
Reid Spencer68a24bd2005-08-27 18:50:39 +00002174#define YYACCEPT goto yyacceptlab
Reid Spencer61c83e02006-08-18 08:43:06 +00002175#define YYABORT goto yyabortlab
2176#define YYERROR goto yyerrorlab
2177
2178
2179/* Like YYERROR except do call yyerror. This remains here temporarily
2180 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002181 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer61c83e02006-08-18 08:43:06 +00002182
Reid Spencer68a24bd2005-08-27 18:50:39 +00002183#define YYFAIL goto yyerrlab
Reid Spencer61c83e02006-08-18 08:43:06 +00002184
Reid Spencer68a24bd2005-08-27 18:50:39 +00002185#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer61c83e02006-08-18 08:43:06 +00002186
2187#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002188do \
2189 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer61c83e02006-08-18 08:43:06 +00002190 { \
2191 yychar = (Token); \
2192 yylval = (Value); \
2193 yytoken = YYTRANSLATE (yychar); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002194 YYPOPSTACK; \
2195 goto yybackup; \
2196 } \
2197 else \
Reid Spencer61c83e02006-08-18 08:43:06 +00002198 { \
2199 yyerror (YY_("syntax error: cannot back up")); \
2200 YYERROR; \
2201 } \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002202while (0)
2203
Reid Spencer61c83e02006-08-18 08:43:06 +00002204
Reid Spencer68a24bd2005-08-27 18:50:39 +00002205#define YYTERROR 1
2206#define YYERRCODE 256
2207
Reid Spencer61c83e02006-08-18 08:43:06 +00002208
2209/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2210 If N is 0, then set CURRENT to the empty location which ends
2211 the previous symbol: RHS[0] (always defined). */
2212
2213#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2214#ifndef YYLLOC_DEFAULT
2215# define YYLLOC_DEFAULT(Current, Rhs, N) \
2216 do \
2217 if (N) \
2218 { \
2219 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2220 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2221 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2222 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2223 } \
2224 else \
2225 { \
2226 (Current).first_line = (Current).last_line = \
2227 YYRHSLOC (Rhs, 0).last_line; \
2228 (Current).first_column = (Current).last_column = \
2229 YYRHSLOC (Rhs, 0).last_column; \
2230 } \
2231 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002232#endif
2233
Reid Spencer61c83e02006-08-18 08:43:06 +00002234
2235/* YY_LOCATION_PRINT -- Print the location on the stream.
2236 This macro was not mandated originally: define only if we know
2237 we won't break user code: when these are the locations we know. */
2238
2239#ifndef YY_LOCATION_PRINT
2240# if YYLTYPE_IS_TRIVIAL
2241# define YY_LOCATION_PRINT(File, Loc) \
2242 fprintf (File, "%d.%d-%d.%d", \
2243 (Loc).first_line, (Loc).first_column, \
2244 (Loc).last_line, (Loc).last_column)
2245# else
2246# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2247# endif
2248#endif
2249
2250
2251/* YYLEX -- calling `yylex' with the right arguments. */
2252
Reid Spencer68a24bd2005-08-27 18:50:39 +00002253#ifdef YYLEX_PARAM
Reid Spencer61c83e02006-08-18 08:43:06 +00002254# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002255#else
Reid Spencer61c83e02006-08-18 08:43:06 +00002256# define YYLEX yylex ()
Chris Lattner8335e842006-01-23 23:05:42 +00002257#endif
Reid Spencer61c83e02006-08-18 08:43:06 +00002258
2259/* Enable debugging if requested. */
2260#if YYDEBUG
2261
2262# ifndef YYFPRINTF
2263# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2264# define YYFPRINTF fprintf
2265# endif
2266
2267# define YYDPRINTF(Args) \
2268do { \
2269 if (yydebug) \
2270 YYFPRINTF Args; \
2271} while (0)
2272
2273# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2274do { \
2275 if (yydebug) \
2276 { \
2277 YYFPRINTF (stderr, "%s ", Title); \
2278 yysymprint (stderr, \
2279 Type, Value); \
2280 YYFPRINTF (stderr, "\n"); \
2281 } \
2282} while (0)
2283
2284/*------------------------------------------------------------------.
2285| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2286| TOP (included). |
2287`------------------------------------------------------------------*/
2288
2289#if defined (__STDC__) || defined (__cplusplus)
2290static void
2291yy_stack_print (short int *bottom, short int *top)
Chris Lattner8335e842006-01-23 23:05:42 +00002292#else
Reid Spencer61c83e02006-08-18 08:43:06 +00002293static void
2294yy_stack_print (bottom, top)
2295 short int *bottom;
2296 short int *top;
Chris Lattner8335e842006-01-23 23:05:42 +00002297#endif
Reid Spencer61c83e02006-08-18 08:43:06 +00002298{
2299 YYFPRINTF (stderr, "Stack now");
2300 for (/* Nothing. */; bottom <= top; ++bottom)
2301 YYFPRINTF (stderr, " %d", *bottom);
2302 YYFPRINTF (stderr, "\n");
2303}
2304
2305# define YY_STACK_PRINT(Bottom, Top) \
2306do { \
2307 if (yydebug) \
2308 yy_stack_print ((Bottom), (Top)); \
2309} while (0)
2310
2311
2312/*------------------------------------------------.
2313| Report that the YYRULE is going to be reduced. |
2314`------------------------------------------------*/
2315
2316#if defined (__STDC__) || defined (__cplusplus)
2317static void
2318yy_reduce_print (int yyrule)
2319#else
2320static void
2321yy_reduce_print (yyrule)
2322 int yyrule;
Robert Bocchino2def1b32006-01-17 20:06:25 +00002323#endif
Reid Spencer61c83e02006-08-18 08:43:06 +00002324{
2325 int yyi;
2326 unsigned long int yylno = yyrline[yyrule];
2327 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2328 yyrule - 1, yylno);
2329 /* Print the symbols being reduced, and their result. */
2330 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2331 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2332 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2333}
Reid Spencere812fb22006-01-19 01:21:04 +00002334
Reid Spencer61c83e02006-08-18 08:43:06 +00002335# define YY_REDUCE_PRINT(Rule) \
2336do { \
2337 if (yydebug) \
2338 yy_reduce_print (Rule); \
2339} while (0)
Reid Spencere812fb22006-01-19 01:21:04 +00002340
Reid Spencer61c83e02006-08-18 08:43:06 +00002341/* Nonzero means print parse trace. It is left uninitialized so that
2342 multiple parsers can coexist. */
2343int yydebug;
2344#else /* !YYDEBUG */
2345# define YYDPRINTF(Args)
2346# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2347# define YY_STACK_PRINT(Bottom, Top)
2348# define YY_REDUCE_PRINT(Rule)
2349#endif /* !YYDEBUG */
Reid Spencere812fb22006-01-19 01:21:04 +00002350
Reid Spencere812fb22006-01-19 01:21:04 +00002351
Reid Spencer61c83e02006-08-18 08:43:06 +00002352/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002353#ifndef YYINITDEPTH
Reid Spencer61c83e02006-08-18 08:43:06 +00002354# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002355#endif
2356
Reid Spencer61c83e02006-08-18 08:43:06 +00002357/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2358 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002359
Reid Spencer61c83e02006-08-18 08:43:06 +00002360 Do not make this value too large; the results are undefined if
2361 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2362 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002363
2364#ifndef YYMAXDEPTH
Reid Spencer61c83e02006-08-18 08:43:06 +00002365# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002366#endif
Reid Spencer61c83e02006-08-18 08:43:06 +00002367
Reid Spencer68a24bd2005-08-27 18:50:39 +00002368
2369
Reid Spencer61c83e02006-08-18 08:43:06 +00002370#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002371
Reid Spencer61c83e02006-08-18 08:43:06 +00002372# ifndef yystrlen
2373# if defined (__GLIBC__) && defined (_STRING_H)
2374# define yystrlen strlen
2375# else
2376/* Return the length of YYSTR. */
2377static YYSIZE_T
2378# if defined (__STDC__) || defined (__cplusplus)
2379yystrlen (const char *yystr)
2380# else
2381yystrlen (yystr)
2382 const char *yystr;
2383# endif
Chris Lattner8335e842006-01-23 23:05:42 +00002384{
Reid Spencer61c83e02006-08-18 08:43:06 +00002385 const char *yys = yystr;
Chris Lattner8335e842006-01-23 23:05:42 +00002386
Reid Spencer61c83e02006-08-18 08:43:06 +00002387 while (*yys++ != '\0')
2388 continue;
2389
2390 return yys - yystr - 1;
Chris Lattner8335e842006-01-23 23:05:42 +00002391}
Reid Spencer61c83e02006-08-18 08:43:06 +00002392# endif
2393# endif
Chris Lattner8335e842006-01-23 23:05:42 +00002394
Reid Spencer61c83e02006-08-18 08:43:06 +00002395# ifndef yystpcpy
2396# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2397# define yystpcpy stpcpy
2398# else
2399/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2400 YYDEST. */
2401static char *
2402# if defined (__STDC__) || defined (__cplusplus)
2403yystpcpy (char *yydest, const char *yysrc)
2404# else
2405yystpcpy (yydest, yysrc)
2406 char *yydest;
2407 const char *yysrc;
2408# endif
Chris Lattner8335e842006-01-23 23:05:42 +00002409{
Reid Spencer61c83e02006-08-18 08:43:06 +00002410 char *yyd = yydest;
2411 const char *yys = yysrc;
Chris Lattner8335e842006-01-23 23:05:42 +00002412
Reid Spencer61c83e02006-08-18 08:43:06 +00002413 while ((*yyd++ = *yys++) != '\0')
2414 continue;
2415
2416 return yyd - 1;
Chris Lattner8335e842006-01-23 23:05:42 +00002417}
Reid Spencer61c83e02006-08-18 08:43:06 +00002418# endif
2419# endif
Chris Lattner8335e842006-01-23 23:05:42 +00002420
Reid Spencer61c83e02006-08-18 08:43:06 +00002421# ifndef yytnamerr
2422/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2423 quotes and backslashes, so that it's suitable for yyerror. The
2424 heuristic is that double-quoting is unnecessary unless the string
2425 contains an apostrophe, a comma, or backslash (other than
2426 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2427 null, do not copy; instead, return the length of what the result
2428 would have been. */
2429static YYSIZE_T
2430yytnamerr (char *yyres, const char *yystr)
2431{
2432 if (*yystr == '"')
2433 {
2434 size_t yyn = 0;
2435 char const *yyp = yystr;
2436
2437 for (;;)
2438 switch (*++yyp)
2439 {
2440 case '\'':
2441 case ',':
2442 goto do_not_strip_quotes;
2443
2444 case '\\':
2445 if (*++yyp != '\\')
2446 goto do_not_strip_quotes;
2447 /* Fall through. */
2448 default:
2449 if (yyres)
2450 yyres[yyn] = *yyp;
2451 yyn++;
2452 break;
2453
2454 case '"':
2455 if (yyres)
2456 yyres[yyn] = '\0';
2457 return yyn;
2458 }
2459 do_not_strip_quotes: ;
2460 }
2461
2462 if (! yyres)
2463 return yystrlen (yystr);
2464
2465 return yystpcpy (yyres, yystr) - yyres;
2466}
2467# endif
2468
2469#endif /* YYERROR_VERBOSE */
2470
Reid Spencere812fb22006-01-19 01:21:04 +00002471
2472
Reid Spencer61c83e02006-08-18 08:43:06 +00002473#if YYDEBUG
2474/*--------------------------------.
2475| Print this symbol on YYOUTPUT. |
2476`--------------------------------*/
Reid Spencere812fb22006-01-19 01:21:04 +00002477
Reid Spencer61c83e02006-08-18 08:43:06 +00002478#if defined (__STDC__) || defined (__cplusplus)
2479static void
2480yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner8335e842006-01-23 23:05:42 +00002481#else
Reid Spencer61c83e02006-08-18 08:43:06 +00002482static void
2483yysymprint (yyoutput, yytype, yyvaluep)
2484 FILE *yyoutput;
2485 int yytype;
2486 YYSTYPE *yyvaluep;
2487#endif
2488{
2489 /* Pacify ``unused variable'' warnings. */
2490 (void) yyvaluep;
2491
2492 if (yytype < YYNTOKENS)
2493 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2494 else
2495 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2496
2497
2498# ifdef YYPRINT
2499 if (yytype < YYNTOKENS)
2500 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2501# endif
2502 switch (yytype)
2503 {
2504 default:
2505 break;
2506 }
2507 YYFPRINTF (yyoutput, ")");
2508}
2509
2510#endif /* ! YYDEBUG */
2511/*-----------------------------------------------.
2512| Release the memory associated to this symbol. |
2513`-----------------------------------------------*/
2514
2515#if defined (__STDC__) || defined (__cplusplus)
2516static void
2517yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2518#else
2519static void
2520yydestruct (yymsg, yytype, yyvaluep)
2521 const char *yymsg;
2522 int yytype;
2523 YYSTYPE *yyvaluep;
2524#endif
2525{
2526 /* Pacify ``unused variable'' warnings. */
2527 (void) yyvaluep;
2528
2529 if (!yymsg)
2530 yymsg = "Deleting";
2531 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2532
2533 switch (yytype)
2534 {
2535
2536 default:
2537 break;
2538 }
2539}
2540
2541
2542/* Prevent warnings from -Wmissing-prototypes. */
2543
2544#ifdef YYPARSE_PARAM
2545# if defined (__STDC__) || defined (__cplusplus)
2546int yyparse (void *YYPARSE_PARAM);
2547# else
2548int yyparse ();
2549# endif
2550#else /* ! YYPARSE_PARAM */
2551#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002552int yyparse (void);
Chris Lattner8335e842006-01-23 23:05:42 +00002553#else
Reid Spencer61c83e02006-08-18 08:43:06 +00002554int yyparse ();
2555#endif
2556#endif /* ! YYPARSE_PARAM */
2557
2558
2559
2560/* The look-ahead symbol. */
2561int yychar;
2562
2563/* The semantic value of the look-ahead symbol. */
2564YYSTYPE yylval;
2565
2566/* Number of syntax errors so far. */
2567int yynerrs;
2568
2569
2570
2571/*----------.
2572| yyparse. |
2573`----------*/
2574
2575#ifdef YYPARSE_PARAM
2576# if defined (__STDC__) || defined (__cplusplus)
2577int yyparse (void *YYPARSE_PARAM)
2578# else
2579int yyparse (YYPARSE_PARAM)
2580 void *YYPARSE_PARAM;
2581# endif
2582#else /* ! YYPARSE_PARAM */
2583#if defined (__STDC__) || defined (__cplusplus)
2584int
2585yyparse (void)
2586#else
2587int
2588yyparse ()
2589
2590#endif
2591#endif
2592{
2593
2594 int yystate;
2595 int yyn;
2596 int yyresult;
2597 /* Number of tokens to shift before error messages enabled. */
2598 int yyerrstatus;
2599 /* Look-ahead token as an internal (translated) token number. */
2600 int yytoken = 0;
2601
2602 /* Three stacks and their tools:
2603 `yyss': related to states,
2604 `yyvs': related to semantic values,
2605 `yyls': related to locations.
2606
2607 Refer to the stacks thru separate pointers, to allow yyoverflow
2608 to reallocate them elsewhere. */
2609
2610 /* The state stack. */
2611 short int yyssa[YYINITDEPTH];
2612 short int *yyss = yyssa;
2613 short int *yyssp;
2614
2615 /* The semantic value stack. */
2616 YYSTYPE yyvsa[YYINITDEPTH];
2617 YYSTYPE *yyvs = yyvsa;
2618 YYSTYPE *yyvsp;
2619
2620
2621
Reid Spencer68a24bd2005-08-27 18:50:39 +00002622#define YYPOPSTACK (yyvsp--, yyssp--)
2623
Reid Spencer61c83e02006-08-18 08:43:06 +00002624 YYSIZE_T yystacksize = YYINITDEPTH;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002625
Reid Spencer61c83e02006-08-18 08:43:06 +00002626 /* The variables used to return semantic value and location from the
2627 action routines. */
2628 YYSTYPE yyval;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002629
2630
Reid Spencer61c83e02006-08-18 08:43:06 +00002631 /* When reducing, the number of symbols on the RHS of the reduced
2632 rule. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002633 int yylen;
2634
Reid Spencer61c83e02006-08-18 08:43:06 +00002635 YYDPRINTF ((stderr, "Starting parse\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002636
2637 yystate = 0;
2638 yyerrstatus = 0;
2639 yynerrs = 0;
2640 yychar = YYEMPTY; /* Cause a token to be read. */
2641
2642 /* Initialize stack pointers.
2643 Waste one element of value and location stack
2644 so that they stay on the same level as the state stack.
2645 The wasted elements are never initialized. */
2646
Reid Spencer61c83e02006-08-18 08:43:06 +00002647 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002648 yyvsp = yyvs;
2649
Reid Spencer61c83e02006-08-18 08:43:06 +00002650 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002651
Reid Spencer61c83e02006-08-18 08:43:06 +00002652/*------------------------------------------------------------.
2653| yynewstate -- Push a new state, which is found in yystate. |
2654`------------------------------------------------------------*/
2655 yynewstate:
2656 /* In all cases, when you get here, the value and location stacks
2657 have just been pushed. so pushing a state here evens the stacks.
2658 */
2659 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002660
Reid Spencer61c83e02006-08-18 08:43:06 +00002661 yysetstate:
2662 *yyssp = yystate;
2663
2664 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002665 {
2666 /* Get the current used size of the three stacks, in elements. */
Reid Spencer61c83e02006-08-18 08:43:06 +00002667 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002668
2669#ifdef yyoverflow
Reid Spencer61c83e02006-08-18 08:43:06 +00002670 {
2671 /* Give user a chance to reallocate the stack. Use copies of
2672 these so that the &'s don't force the real ones into
2673 memory. */
2674 YYSTYPE *yyvs1 = yyvs;
2675 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002676
Reid Spencer61c83e02006-08-18 08:43:06 +00002677
2678 /* Each stack pointer address is followed by the size of the
2679 data in use in that stack, in bytes. This used to be a
2680 conditional around just the two extra args, but that might
2681 be undefined if yyoverflow is a macro. */
2682 yyoverflow (YY_("memory exhausted"),
2683 &yyss1, yysize * sizeof (*yyssp),
2684 &yyvs1, yysize * sizeof (*yyvsp),
2685
2686 &yystacksize);
2687
2688 yyss = yyss1;
2689 yyvs = yyvs1;
2690 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002691#else /* no yyoverflow */
Reid Spencer61c83e02006-08-18 08:43:06 +00002692# ifndef YYSTACK_RELOCATE
2693 goto yyexhaustedlab;
2694# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002695 /* Extend the stack our own way. */
Reid Spencer61c83e02006-08-18 08:43:06 +00002696 if (YYMAXDEPTH <= yystacksize)
2697 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002698 yystacksize *= 2;
Reid Spencer61c83e02006-08-18 08:43:06 +00002699 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002700 yystacksize = YYMAXDEPTH;
Reid Spencer61c83e02006-08-18 08:43:06 +00002701
2702 {
2703 short int *yyss1 = yyss;
2704 union yyalloc *yyptr =
2705 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2706 if (! yyptr)
2707 goto yyexhaustedlab;
2708 YYSTACK_RELOCATE (yyss);
2709 YYSTACK_RELOCATE (yyvs);
2710
2711# undef YYSTACK_RELOCATE
2712 if (yyss1 != yyssa)
2713 YYSTACK_FREE (yyss1);
2714 }
2715# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002716#endif /* no yyoverflow */
2717
Reid Spencer61c83e02006-08-18 08:43:06 +00002718 yyssp = yyss + yysize - 1;
2719 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002720
2721
Reid Spencer61c83e02006-08-18 08:43:06 +00002722 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2723 (unsigned long int) yystacksize));
2724
2725 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002726 YYABORT;
2727 }
2728
Reid Spencer61c83e02006-08-18 08:43:06 +00002729 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002730
2731 goto yybackup;
Reid Spencer61c83e02006-08-18 08:43:06 +00002732
2733/*-----------.
2734| yybackup. |
2735`-----------*/
2736yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002737
2738/* Do appropriate processing given the current state. */
Reid Spencer61c83e02006-08-18 08:43:06 +00002739/* Read a look-ahead token if we need one and don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002740/* yyresume: */
2741
Reid Spencer61c83e02006-08-18 08:43:06 +00002742 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002743
2744 yyn = yypact[yystate];
Reid Spencer61c83e02006-08-18 08:43:06 +00002745 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002746 goto yydefault;
2747
Reid Spencer61c83e02006-08-18 08:43:06 +00002748 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002749
Reid Spencer61c83e02006-08-18 08:43:06 +00002750 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002751 if (yychar == YYEMPTY)
2752 {
Reid Spencer61c83e02006-08-18 08:43:06 +00002753 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002754 yychar = YYLEX;
2755 }
2756
Reid Spencer61c83e02006-08-18 08:43:06 +00002757 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002758 {
Reid Spencer61c83e02006-08-18 08:43:06 +00002759 yychar = yytoken = YYEOF;
2760 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002761 }
2762 else
2763 {
Reid Spencer61c83e02006-08-18 08:43:06 +00002764 yytoken = YYTRANSLATE (yychar);
2765 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002766 }
2767
Reid Spencer61c83e02006-08-18 08:43:06 +00002768 /* If the proper action on seeing token YYTOKEN is to reduce or to
2769 detect an error, take that action. */
2770 yyn += yytoken;
2771 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002772 goto yydefault;
2773 yyn = yytable[yyn];
Reid Spencer61c83e02006-08-18 08:43:06 +00002774 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002775 {
Reid Spencer61c83e02006-08-18 08:43:06 +00002776 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002777 goto yyerrlab;
2778 yyn = -yyn;
2779 goto yyreduce;
2780 }
2781
2782 if (yyn == YYFINAL)
2783 YYACCEPT;
2784
Reid Spencer61c83e02006-08-18 08:43:06 +00002785 /* Shift the look-ahead token. */
2786 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002787
2788 /* Discard the token being shifted unless it is eof. */
2789 if (yychar != YYEOF)
2790 yychar = YYEMPTY;
2791
2792 *++yyvsp = yylval;
2793
Reid Spencer61c83e02006-08-18 08:43:06 +00002794
2795 /* Count tokens shifted since error; after three, turn off error
2796 status. */
2797 if (yyerrstatus)
2798 yyerrstatus--;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002799
2800 yystate = yyn;
2801 goto yynewstate;
2802
Chris Lattner8335e842006-01-23 23:05:42 +00002803
Reid Spencer61c83e02006-08-18 08:43:06 +00002804/*-----------------------------------------------------------.
2805| yydefault -- do the default action for the current state. |
2806`-----------------------------------------------------------*/
2807yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002808 yyn = yydefact[yystate];
2809 if (yyn == 0)
2810 goto yyerrlab;
Reid Spencer61c83e02006-08-18 08:43:06 +00002811 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002812
Reid Spencer61c83e02006-08-18 08:43:06 +00002813
2814/*-----------------------------.
2815| yyreduce -- Do a reduction. |
2816`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00002817yyreduce:
Reid Spencer61c83e02006-08-18 08:43:06 +00002818 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002819 yylen = yyr2[yyn];
2820
Reid Spencer61c83e02006-08-18 08:43:06 +00002821 /* If YYLEN is nonzero, implement the default value of the action:
2822 `$$ = $1'.
2823
2824 Otherwise, the following line sets YYVAL to garbage.
2825 This behavior is undocumented and Bison
2826 users should not rely upon it. Assigning to YYVAL
2827 unconditionally makes the parser a bit smaller, and it avoids a
2828 GCC warning that YYVAL may be used uninitialized. */
2829 yyval = yyvsp[1-yylen];
2830
2831
2832 YY_REDUCE_PRINT (yyn);
2833 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002834 {
Reid Spencer61c83e02006-08-18 08:43:06 +00002835 case 3:
2836#line 1018 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2837 {
2838 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
2839 GEN_ERROR("Value too large for type!");
2840 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
2841 CHECK_FOR_ERROR
2842;}
2843 break;
Chris Lattner8335e842006-01-23 23:05:42 +00002844
Reid Spencer61c83e02006-08-18 08:43:06 +00002845 case 5:
2846#line 1027 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2847 {
2848 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
2849 GEN_ERROR("Value too large for type!");
2850 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
2851 CHECK_FOR_ERROR
2852;}
2853 break;
Chris Lattner8335e842006-01-23 23:05:42 +00002854
Reid Spencer61c83e02006-08-18 08:43:06 +00002855 case 34:
2856#line 1051 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2857 {
2858 (yyval.StrVal) = (yyvsp[-1].StrVal);
2859 CHECK_FOR_ERROR
2860 ;}
2861 break;
Chris Lattner8335e842006-01-23 23:05:42 +00002862
Reid Spencer61c83e02006-08-18 08:43:06 +00002863 case 35:
2864#line 1055 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2865 {
2866 (yyval.StrVal) = 0;
2867 CHECK_FOR_ERROR
2868 ;}
2869 break;
Chris Lattner8335e842006-01-23 23:05:42 +00002870
Reid Spencer61c83e02006-08-18 08:43:06 +00002871 case 36:
2872#line 1060 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2873 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
2874 break;
Chris Lattner8335e842006-01-23 23:05:42 +00002875
Reid Spencer61c83e02006-08-18 08:43:06 +00002876 case 37:
2877#line 1061 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2878 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
2879 break;
2880
2881 case 38:
2882#line 1062 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2883 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
2884 break;
2885
2886 case 39:
2887#line 1063 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2888 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
2889 break;
2890
2891 case 40:
2892#line 1064 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2893 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
2894 break;
2895
2896 case 41:
2897#line 1066 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2898 { (yyval.UIntVal) = CallingConv::C; ;}
2899 break;
2900
2901 case 42:
2902#line 1067 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2903 { (yyval.UIntVal) = CallingConv::C; ;}
2904 break;
2905
2906 case 43:
2907#line 1068 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2908 { (yyval.UIntVal) = CallingConv::CSRet; ;}
2909 break;
2910
2911 case 44:
2912#line 1069 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2913 { (yyval.UIntVal) = CallingConv::Fast; ;}
2914 break;
2915
2916 case 45:
2917#line 1070 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2918 { (yyval.UIntVal) = CallingConv::Cold; ;}
2919 break;
2920
2921 case 46:
2922#line 1071 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2923 {
2924 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
2925 GEN_ERROR("Calling conv too large!");
2926 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
2927 CHECK_FOR_ERROR
2928 ;}
2929 break;
2930
2931 case 47:
2932#line 1080 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2933 { (yyval.UIntVal) = 0; ;}
2934 break;
2935
2936 case 48:
2937#line 1081 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2938 {
2939 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
2940 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
2941 GEN_ERROR("Alignment must be a power of two!");
2942 CHECK_FOR_ERROR
2943;}
2944 break;
2945
2946 case 49:
2947#line 1087 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2948 { (yyval.UIntVal) = 0; ;}
2949 break;
2950
2951 case 50:
2952#line 1088 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2953 {
2954 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
2955 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
2956 GEN_ERROR("Alignment must be a power of two!");
2957 CHECK_FOR_ERROR
2958;}
2959 break;
2960
2961 case 51:
2962#line 1096 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2963 {
2964 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
2965 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
2966 GEN_ERROR("Invalid character in section name!");
2967 (yyval.StrVal) = (yyvsp[0].StrVal);
2968 CHECK_FOR_ERROR
2969;}
2970 break;
2971
2972 case 52:
2973#line 1104 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2974 { (yyval.StrVal) = 0; ;}
2975 break;
2976
2977 case 53:
2978#line 1105 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2979 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
2980 break;
2981
2982 case 54:
2983#line 1110 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2984 {;}
2985 break;
2986
2987 case 55:
2988#line 1111 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2989 {;}
2990 break;
2991
2992 case 56:
2993#line 1112 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
2994 {
2995 CurGV->setSection((yyvsp[0].StrVal));
2996 free((yyvsp[0].StrVal));
2997 CHECK_FOR_ERROR
2998 ;}
2999 break;
3000
3001 case 57:
3002#line 1117 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3003 {
3004 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
3005 GEN_ERROR("Alignment must be a power of two!");
3006 CurGV->setAlignment((yyvsp[0].UInt64Val));
3007 CHECK_FOR_ERROR
3008 ;}
3009 break;
3010
3011 case 59:
3012#line 1131 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3013 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
3014 break;
3015
3016 case 61:
3017#line 1132 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3018 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
3019 break;
3020
3021 case 62:
3022#line 1134 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3023 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003024 if (!UpRefs.empty())
Reid Spencer61c83e02006-08-18 08:43:06 +00003025 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3026 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3027 CHECK_FOR_ERROR
3028 ;}
3029 break;
3030
3031 case 76:
3032#line 1146 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3033 {
3034 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
3035 CHECK_FOR_ERROR
3036 ;}
3037 break;
3038
3039 case 77:
3040#line 1150 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3041 {
3042 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
3043 CHECK_FOR_ERROR
3044 ;}
3045 break;
3046
3047 case 78:
3048#line 1154 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3049 { // Named types are also simple types...
3050 (yyval.TypeVal) = new PATypeHolder(getTypeVal((yyvsp[0].ValIDVal)));
3051 CHECK_FOR_ERROR
3052;}
3053 break;
3054
3055 case 79:
3056#line 1161 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3057 { // Type UpReference
3058 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003059 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer61c83e02006-08-18 08:43:06 +00003060 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3061 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003062 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00003063 CHECK_FOR_ERROR
3064 ;}
3065 break;
3066
3067 case 80:
3068#line 1169 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3069 { // Function derived type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003070 std::vector<const Type*> Params;
Reid Spencer61c83e02006-08-18 08:43:06 +00003071 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3072 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003073 Params.push_back(*I);
3074 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3075 if (isVarArg) Params.pop_back();
3076
Reid Spencer61c83e02006-08-18 08:43:06 +00003077 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[-3].TypeVal),Params,isVarArg)));
3078 delete (yyvsp[-1].TypeList); // Delete the argument list
3079 delete (yyvsp[-3].TypeVal); // Delete the return type handle
3080 CHECK_FOR_ERROR
3081 ;}
3082 break;
3083
3084 case 81:
3085#line 1182 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3086 { // Sized array type?
3087 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3088 delete (yyvsp[-1].TypeVal);
3089 CHECK_FOR_ERROR
3090 ;}
3091 break;
3092
3093 case 82:
3094#line 1187 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3095 { // Packed array type?
3096 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3097 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
3098 GEN_ERROR("Unsigned result not equal to signed result");
Chris Lattner9547d7f2005-11-10 01:42:43 +00003099 if (!ElemTy->isPrimitiveType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003100 GEN_ERROR("Elemental type of a PackedType must be primitive");
3101 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
3102 GEN_ERROR("Vector length should be a power of 2!");
3103 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3104 delete (yyvsp[-1].TypeVal);
3105 CHECK_FOR_ERROR
3106 ;}
3107 break;
3108
3109 case 83:
3110#line 1199 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3111 { // Structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003112 std::vector<const Type*> Elements;
Reid Spencer61c83e02006-08-18 08:43:06 +00003113 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3114 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003115 Elements.push_back(*I);
3116
Reid Spencer61c83e02006-08-18 08:43:06 +00003117 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3118 delete (yyvsp[-1].TypeList);
3119 CHECK_FOR_ERROR
3120 ;}
3121 break;
3122
3123 case 84:
3124#line 1209 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3125 { // Empty structure type?
3126 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
3127 CHECK_FOR_ERROR
3128 ;}
3129 break;
3130
3131 case 85:
3132#line 1213 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3133 { // Pointer type?
3134 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3135 delete (yyvsp[-1].TypeVal);
3136 CHECK_FOR_ERROR
3137 ;}
3138 break;
3139
3140 case 86:
3141#line 1222 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3142 {
3143 (yyval.TypeList) = new std::list<PATypeHolder>();
3144 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
3145 CHECK_FOR_ERROR
3146 ;}
3147 break;
3148
3149 case 87:
3150#line 1227 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3151 {
3152 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
3153 CHECK_FOR_ERROR
3154 ;}
3155 break;
3156
3157 case 89:
3158#line 1234 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3159 {
3160 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy);
3161 CHECK_FOR_ERROR
3162 ;}
3163 break;
3164
3165 case 90:
3166#line 1238 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3167 {
3168 ((yyval.TypeList) = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
3169 CHECK_FOR_ERROR
3170 ;}
3171 break;
3172
3173 case 91:
3174#line 1242 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3175 {
3176 (yyval.TypeList) = new std::list<PATypeHolder>();
3177 CHECK_FOR_ERROR
3178 ;}
3179 break;
3180
3181 case 92:
3182#line 1253 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3183 { // Nonempty unsized arr
3184 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003185 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003186 GEN_ERROR("Cannot make array constant with type: '" +
3187 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003188 const Type *ETy = ATy->getElementType();
3189 int NumElements = ATy->getNumElements();
3190
3191 // Verify that we have the correct size...
Reid Spencer61c83e02006-08-18 08:43:06 +00003192 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
3193 GEN_ERROR("Type mismatch: constant sized array initialized with " +
3194 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003195 itostr(NumElements) + "!");
3196
3197 // Verify all elements are correct type!
Reid Spencer61c83e02006-08-18 08:43:06 +00003198 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3199 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
3200 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003201 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer61c83e02006-08-18 08:43:06 +00003202 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003203 }
3204
Reid Spencer61c83e02006-08-18 08:43:06 +00003205 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3206 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
3207 CHECK_FOR_ERROR
3208 ;}
3209 break;
3210
3211 case 93:
3212#line 1279 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3213 {
3214 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003215 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003216 GEN_ERROR("Cannot make array constant with type: '" +
3217 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003218
3219 int NumElements = ATy->getNumElements();
3220 if (NumElements != -1 && NumElements != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003221 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003222 " arguments, but has size of " + itostr(NumElements) +"!");
Reid Spencer61c83e02006-08-18 08:43:06 +00003223 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3224 delete (yyvsp[-2].TypeVal);
3225 CHECK_FOR_ERROR
3226 ;}
3227 break;
3228
3229 case 94:
3230#line 1293 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3231 {
3232 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003233 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003234 GEN_ERROR("Cannot make array constant with type: '" +
3235 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003236
3237 int NumElements = ATy->getNumElements();
3238 const Type *ETy = ATy->getElementType();
Reid Spencer61c83e02006-08-18 08:43:06 +00003239 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3240 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
3241 GEN_ERROR("Can't build string constant of size " +
3242 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003243 " when array has size " + itostr(NumElements) + "!");
3244 std::vector<Constant*> Vals;
3245 if (ETy == Type::SByteTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +00003246 for (signed char *C = (signed char *)(yyvsp[0].StrVal); C != (signed char *)EndStr; ++C)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003247 Vals.push_back(ConstantSInt::get(ETy, *C));
3248 } else if (ETy == Type::UByteTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +00003249 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003250 C != (unsigned char*)EndStr; ++C)
3251 Vals.push_back(ConstantUInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003252 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +00003253 free((yyvsp[0].StrVal));
3254 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003255 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003256 free((yyvsp[0].StrVal));
3257 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3258 delete (yyvsp[-2].TypeVal);
3259 CHECK_FOR_ERROR
3260 ;}
3261 break;
3262
3263 case 95:
3264#line 1323 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3265 { // Nonempty unsized arr
3266 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003267 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003268 GEN_ERROR("Cannot make packed constant with type: '" +
3269 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003270 const Type *ETy = PTy->getElementType();
3271 int NumElements = PTy->getNumElements();
3272
3273 // Verify that we have the correct size...
Reid Spencer61c83e02006-08-18 08:43:06 +00003274 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
3275 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
3276 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003277 itostr(NumElements) + "!");
3278
3279 // Verify all elements are correct type!
Reid Spencer61c83e02006-08-18 08:43:06 +00003280 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3281 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
3282 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003283 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer61c83e02006-08-18 08:43:06 +00003284 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003285 }
3286
Reid Spencer61c83e02006-08-18 08:43:06 +00003287 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector));
3288 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
3289 CHECK_FOR_ERROR
3290 ;}
3291 break;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003292
Reid Spencer61c83e02006-08-18 08:43:06 +00003293 case 96:
3294#line 1349 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3295 {
3296 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
3297 if (STy == 0)
3298 GEN_ERROR("Cannot make struct constant with type: '" +
3299 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
3300
3301 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
3302 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003303
3304 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer61c83e02006-08-18 08:43:06 +00003305 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3306 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
3307 GEN_ERROR("Expected type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003308 STy->getElementType(i)->getDescription() +
3309 "' for element #" + utostr(i) +
3310 " of structure initializer!");
3311
Reid Spencer61c83e02006-08-18 08:43:06 +00003312 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3313 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
3314 CHECK_FOR_ERROR
3315 ;}
3316 break;
3317
3318 case 97:
3319#line 1370 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3320 {
3321 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003322 if (STy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003323 GEN_ERROR("Cannot make struct constant with type: '" +
3324 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003325
3326 if (STy->getNumContainedTypes() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003327 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003328
Reid Spencer61c83e02006-08-18 08:43:06 +00003329 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3330 delete (yyvsp[-2].TypeVal);
3331 CHECK_FOR_ERROR
3332 ;}
3333 break;
3334
3335 case 98:
3336#line 1383 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3337 {
3338 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003339 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003340 GEN_ERROR("Cannot make null pointer constant with type: '" +
3341 (*(yyvsp[-1].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003342
Reid Spencer61c83e02006-08-18 08:43:06 +00003343 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3344 delete (yyvsp[-1].TypeVal);
3345 CHECK_FOR_ERROR
3346 ;}
3347 break;
3348
3349 case 99:
3350#line 1393 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3351 {
3352 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3353 delete (yyvsp[-1].TypeVal);
3354 CHECK_FOR_ERROR
3355 ;}
3356 break;
3357
3358 case 100:
3359#line 1398 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3360 {
3361 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003362 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003363 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003364
3365 // ConstExprs can exist in the body of a function, thus creating
3366 // GlobalValues whenever they refer to a variable. Because we are in
3367 // the context of a function, getValNonImprovising will search the functions
3368 // symbol table instead of the module symbol table for the global symbol,
3369 // which throws things all off. To get around this, we just tell
3370 // getValNonImprovising that we are at global scope here.
3371 //
3372 Function *SavedCurFn = CurFun.CurrentFunction;
3373 CurFun.CurrentFunction = 0;
3374
Reid Spencer61c83e02006-08-18 08:43:06 +00003375 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003376
3377 CurFun.CurrentFunction = SavedCurFn;
3378
3379 // If this is an initializer for a constant pointer, which is referencing a
3380 // (currently) undefined variable, create a stub now that shall be replaced
3381 // in the future with the right type of variable.
3382 //
3383 if (V == 0) {
3384 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3385 const PointerType *PT = cast<PointerType>(Ty);
3386
3387 // First check to see if the forward references value is already created!
3388 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer61c83e02006-08-18 08:43:06 +00003389 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003390
3391 if (I != CurModule.GlobalRefs.end()) {
3392 V = I->second; // Placeholder already exists, use it...
Reid Spencer61c83e02006-08-18 08:43:06 +00003393 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003394 } else {
3395 std::string Name;
Reid Spencer61c83e02006-08-18 08:43:06 +00003396 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003397
3398 // Create the forward referenced global.
3399 GlobalValue *GV;
3400 if (const FunctionType *FTy =
3401 dyn_cast<FunctionType>(PT->getElementType())) {
3402 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3403 CurModule.CurrentModule);
3404 } else {
3405 GV = new GlobalVariable(PT->getElementType(), false,
3406 GlobalValue::ExternalLinkage, 0,
3407 Name, CurModule.CurrentModule);
3408 }
3409
3410 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer61c83e02006-08-18 08:43:06 +00003411 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003412 V = GV;
3413 }
3414 }
3415
Reid Spencer61c83e02006-08-18 08:43:06 +00003416 (yyval.ConstVal) = cast<GlobalValue>(V);
3417 delete (yyvsp[-1].TypeVal); // Free the type handle
3418 CHECK_FOR_ERROR
3419 ;}
3420 break;
3421
3422 case 101:
3423#line 1458 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3424 {
3425 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
3426 GEN_ERROR("Mismatched types for constant expression!");
3427 (yyval.ConstVal) = (yyvsp[0].ConstVal);
3428 delete (yyvsp[-1].TypeVal);
3429 CHECK_FOR_ERROR
3430 ;}
3431 break;
3432
3433 case 102:
3434#line 1465 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3435 {
3436 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003437 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +00003438 GEN_ERROR("Cannot create a null initialized value of this type!");
3439 (yyval.ConstVal) = Constant::getNullValue(Ty);
3440 delete (yyvsp[-1].TypeVal);
3441 CHECK_FOR_ERROR
3442 ;}
3443 break;
3444
3445 case 103:
3446#line 1474 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3447 { // integral constants
3448 if (!ConstantSInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
3449 GEN_ERROR("Constant value doesn't fit in type!");
3450 (yyval.ConstVal) = ConstantSInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
3451 CHECK_FOR_ERROR
3452 ;}
3453 break;
3454
3455 case 104:
3456#line 1480 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3457 { // integral constants
3458 if (!ConstantUInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
3459 GEN_ERROR("Constant value doesn't fit in type!");
3460 (yyval.ConstVal) = ConstantUInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
3461 CHECK_FOR_ERROR
3462 ;}
3463 break;
3464
3465 case 105:
3466#line 1486 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3467 { // Boolean constants
3468 (yyval.ConstVal) = ConstantBool::True;
3469 CHECK_FOR_ERROR
3470 ;}
3471 break;
3472
3473 case 106:
3474#line 1490 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3475 { // Boolean constants
3476 (yyval.ConstVal) = ConstantBool::False;
3477 CHECK_FOR_ERROR
3478 ;}
3479 break;
3480
3481 case 107:
3482#line 1494 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3483 { // Float & Double constants
3484 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
3485 GEN_ERROR("Floating point constant invalid for type!!");
3486 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
3487 CHECK_FOR_ERROR
3488 ;}
3489 break;
3490
3491 case 108:
3492#line 1502 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3493 {
3494 if (!(yyvsp[-3].ConstVal)->getType()->isFirstClassType())
3495 GEN_ERROR("cast constant expression from a non-primitive type: '" +
3496 (yyvsp[-3].ConstVal)->getType()->getDescription() + "'!");
3497 if (!(yyvsp[-1].TypeVal)->get()->isFirstClassType())
3498 GEN_ERROR("cast constant expression to a non-primitive type: '" +
3499 (yyvsp[-1].TypeVal)->get()->getDescription() + "'!");
3500 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get());
3501 delete (yyvsp[-1].TypeVal);
3502 CHECK_FOR_ERROR
3503 ;}
3504 break;
3505
3506 case 109:
3507#line 1513 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3508 {
3509 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
3510 GEN_ERROR("GetElementPtr requires a pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003511
3512 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3513 // indices to uint struct indices for compatibility.
3514 generic_gep_type_iterator<std::vector<Value*>::iterator>
Reid Spencer61c83e02006-08-18 08:43:06 +00003515 GTI = gep_type_begin((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()),
3516 GTE = gep_type_end((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end());
3517 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003518 if (isa<StructType>(*GTI)) // Only change struct indices
Reid Spencer61c83e02006-08-18 08:43:06 +00003519 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*(yyvsp[-1].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003520 if (CUI->getType() == Type::UByteTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003521 (*(yyvsp[-1].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003522
3523 const Type *IdxTy =
Reid Spencer61c83e02006-08-18 08:43:06 +00003524 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003525 if (!IdxTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003526 GEN_ERROR("Index list invalid for constant getelementptr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003527
3528 std::vector<Constant*> IdxVec;
Reid Spencer61c83e02006-08-18 08:43:06 +00003529 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
3530 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003531 IdxVec.push_back(C);
3532 else
Reid Spencer61c83e02006-08-18 08:43:06 +00003533 GEN_ERROR("Indices to constant getelementptr must be constants!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003534
Reid Spencer61c83e02006-08-18 08:43:06 +00003535 delete (yyvsp[-1].ValueList);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003536
Reid Spencer61c83e02006-08-18 08:43:06 +00003537 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec);
3538 CHECK_FOR_ERROR
3539 ;}
3540 break;
3541
3542 case 110:
3543#line 1545 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3544 {
3545 if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy)
3546 GEN_ERROR("Select condition must be of boolean type!");
3547 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3548 GEN_ERROR("Select operand types must match!");
3549 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3550 CHECK_FOR_ERROR
3551 ;}
3552 break;
3553
3554 case 111:
3555#line 1553 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3556 {
3557 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3558 GEN_ERROR("Binary operator types must match!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003559 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3560 // To retain backward compatibility with these early compilers, we emit a
3561 // cast to the appropriate integer type automatically if we are in the
3562 // broken case. See PR424 for more information.
Reid Spencer61c83e02006-08-18 08:43:06 +00003563 if (!isa<PointerType>((yyvsp[-3].ConstVal)->getType())) {
3564 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003565 } else {
3566 const Type *IntPtrTy = 0;
3567 switch (CurModule.CurrentModule->getPointerSize()) {
3568 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3569 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
Reid Spencer61c83e02006-08-18 08:43:06 +00003570 default: GEN_ERROR("invalid pointer binary constant expr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003571 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003572 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), ConstantExpr::getCast((yyvsp[-3].ConstVal), IntPtrTy),
3573 ConstantExpr::getCast((yyvsp[-1].ConstVal), IntPtrTy));
3574 (yyval.ConstVal) = ConstantExpr::getCast((yyval.ConstVal), (yyvsp[-3].ConstVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003575 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003576 CHECK_FOR_ERROR
3577 ;}
3578 break;
3579
3580 case 112:
3581#line 1575 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3582 {
3583 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3584 GEN_ERROR("Logical operator types must match!");
3585 if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) {
3586 if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) ||
3587 !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral())
3588 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00003589 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003590 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3591 CHECK_FOR_ERROR
3592 ;}
3593 break;
3594
3595 case 113:
3596#line 1586 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3597 {
3598 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3599 GEN_ERROR("setcc operand types must match!");
3600 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3601 CHECK_FOR_ERROR
3602 ;}
3603 break;
3604
3605 case 114:
3606#line 1592 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3607 {
3608 if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy)
3609 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
3610 if (!(yyvsp[-3].ConstVal)->getType()->isInteger())
3611 GEN_ERROR("Shift constant expression requires integer operand!");
3612 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3613 CHECK_FOR_ERROR
3614 ;}
3615 break;
3616
3617 case 115:
3618#line 1600 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3619 {
3620 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
3621 GEN_ERROR("Invalid extractelement operands!");
3622 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3623 CHECK_FOR_ERROR
3624 ;}
3625 break;
3626
3627 case 116:
3628#line 1606 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3629 {
3630 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
3631 GEN_ERROR("Invalid insertelement operands!");
3632 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3633 CHECK_FOR_ERROR
3634 ;}
3635 break;
3636
3637 case 117:
3638#line 1612 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3639 {
3640 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
3641 GEN_ERROR("Invalid shufflevector operands!");
3642 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3643 CHECK_FOR_ERROR
3644 ;}
3645 break;
3646
3647 case 118:
3648#line 1621 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3649 {
3650 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
3651 CHECK_FOR_ERROR
3652 ;}
3653 break;
3654
3655 case 119:
3656#line 1625 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3657 {
3658 (yyval.ConstVector) = new std::vector<Constant*>();
3659 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
3660 CHECK_FOR_ERROR
3661 ;}
3662 break;
3663
3664 case 120:
3665#line 1633 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3666 { (yyval.BoolVal) = false; ;}
3667 break;
3668
3669 case 121:
3670#line 1633 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3671 { (yyval.BoolVal) = true; ;}
3672 break;
3673
3674 case 122:
3675#line 1643 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3676 {
3677 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003678 CurModule.ModuleDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00003679 CHECK_FOR_ERROR
3680;}
3681 break;
3682
3683 case 123:
3684#line 1651 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3685 {
3686 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003687 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00003688 CHECK_FOR_ERROR
3689 ;}
3690 break;
3691
3692 case 124:
3693#line 1656 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3694 {
3695 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
3696 CHECK_FOR_ERROR
3697 ;}
3698 break;
3699
3700 case 125:
3701#line 1660 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3702 {
3703 (yyval.ModuleVal) = (yyvsp[-3].ModuleVal);
3704 CHECK_FOR_ERROR
3705 ;}
3706 break;
3707
3708 case 126:
3709#line 1664 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3710 {
3711 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
3712 CHECK_FOR_ERROR
3713 ;}
3714 break;
3715
3716 case 127:
3717#line 1668 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3718 {
3719 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003720 // Emit an error if there are any unresolved types left.
3721 if (!CurModule.LateResolveTypes.empty()) {
3722 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00003723 if (DID.Type == ValID::NameVal) {
3724 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3725 } else {
3726 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3727 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003728 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003729 CHECK_FOR_ERROR
3730 ;}
3731 break;
3732
3733 case 128:
3734#line 1683 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3735 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003736 // Eagerly resolve types. This is not an optimization, this is a
3737 // requirement that is due to the fact that we could have this:
3738 //
3739 // %list = type { %list * }
3740 // %list = type { %list * } ; repeated type decl
3741 //
3742 // If types are not resolved eagerly, then the two types will not be
3743 // determined to be the same type!
3744 //
Reid Spencer61c83e02006-08-18 08:43:06 +00003745 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003746
Reid Spencer61c83e02006-08-18 08:43:06 +00003747 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003748 // If this is a named type that is not a redefinition, add it to the slot
3749 // table.
Reid Spencer61c83e02006-08-18 08:43:06 +00003750 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003751 }
3752
Reid Spencer61c83e02006-08-18 08:43:06 +00003753 delete (yyvsp[0].TypeVal);
3754 CHECK_FOR_ERROR
3755 ;}
3756 break;
3757
3758 case 129:
3759#line 1704 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3760 { // Function prototypes can be in const pool
3761 CHECK_FOR_ERROR
3762 ;}
3763 break;
3764
3765 case 130:
3766#line 1707 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3767 { // Asm blocks can be in the const pool
3768 CHECK_FOR_ERROR
3769 ;}
3770 break;
3771
3772 case 131:
3773#line 1710 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3774 {
3775 if ((yyvsp[0].ConstVal) == 0) GEN_ERROR("Global value initializer is not a constant!");
3776 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
3777 ;}
3778 break;
3779
3780 case 132:
3781#line 1713 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3782 {
Chris Lattnerb475c422005-11-12 18:22:38 +00003783 CurGV = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00003784 CHECK_FOR_ERROR
3785 ;}
3786 break;
3787
3788 case 133:
3789#line 1717 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3790 {
3791 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage,
3792 (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
3793 delete (yyvsp[0].TypeVal);
3794 ;}
3795 break;
3796
3797 case 134:
3798#line 1721 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3799 {
Chris Lattnerb475c422005-11-12 18:22:38 +00003800 CurGV = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00003801 CHECK_FOR_ERROR
3802 ;}
3803 break;
3804
3805 case 135:
3806#line 1725 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3807 {
3808 CHECK_FOR_ERROR
3809 ;}
3810 break;
3811
3812 case 136:
3813#line 1728 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3814 {
3815 CHECK_FOR_ERROR
3816 ;}
3817 break;
3818
3819 case 137:
3820#line 1731 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3821 {
3822 ;}
3823 break;
3824
3825 case 138:
3826#line 1735 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3827 {
Chris Lattner66316012006-01-24 04:14:29 +00003828 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer61c83e02006-08-18 08:43:06 +00003829 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3830 std::string NewAsm((yyvsp[0].StrVal), EndStr);
3831 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00003832
3833 if (AsmSoFar.empty())
3834 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3835 else
3836 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00003837 CHECK_FOR_ERROR
3838;}
3839 break;
3840
3841 case 139:
3842#line 1748 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3843 { (yyval.Endianness) = Module::BigEndian; ;}
3844 break;
3845
3846 case 140:
3847#line 1749 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3848 { (yyval.Endianness) = Module::LittleEndian; ;}
3849 break;
3850
3851 case 141:
3852#line 1751 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3853 {
3854 CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness));
3855 CHECK_FOR_ERROR
3856 ;}
3857 break;
3858
3859 case 142:
3860#line 1755 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3861 {
3862 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003863 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Reid Spencer61c83e02006-08-18 08:43:06 +00003864 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003865 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3866 else
Reid Spencer61c83e02006-08-18 08:43:06 +00003867 GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!");
3868 CHECK_FOR_ERROR
3869 ;}
3870 break;
3871
3872 case 143:
3873#line 1764 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3874 {
3875 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
3876 free((yyvsp[0].StrVal));
3877 CHECK_FOR_ERROR
3878 ;}
3879 break;
3880
3881 case 145:
3882#line 1772 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3883 {
3884 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
3885 free((yyvsp[0].StrVal));
3886 CHECK_FOR_ERROR
3887 ;}
3888 break;
3889
3890 case 146:
3891#line 1777 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3892 {
3893 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
3894 free((yyvsp[0].StrVal));
3895 CHECK_FOR_ERROR
3896 ;}
3897 break;
3898
3899 case 147:
3900#line 1782 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3901 {
3902 CHECK_FOR_ERROR
3903 ;}
3904 break;
3905
3906 case 151:
3907#line 1792 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3908 { (yyval.StrVal) = 0; ;}
3909 break;
3910
3911 case 152:
3912#line 1794 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3913 {
3914 if (*(yyvsp[-1].TypeVal) == Type::VoidTy)
3915 GEN_ERROR("void typed arguments are invalid!");
3916 (yyval.ArgVal) = new std::pair<PATypeHolder*, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
3917 CHECK_FOR_ERROR
3918;}
3919 break;
3920
3921 case 153:
3922#line 1801 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3923 {
3924 (yyval.ArgList) = (yyvsp[-2].ArgList);
3925 (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal));
3926 delete (yyvsp[0].ArgVal);
3927 CHECK_FOR_ERROR
3928 ;}
3929 break;
3930
3931 case 154:
3932#line 1807 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3933 {
3934 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
3935 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
3936 delete (yyvsp[0].ArgVal);
3937 CHECK_FOR_ERROR
3938 ;}
3939 break;
3940
3941 case 155:
3942#line 1814 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3943 {
3944 (yyval.ArgList) = (yyvsp[0].ArgList);
3945 CHECK_FOR_ERROR
3946 ;}
3947 break;
3948
3949 case 156:
3950#line 1818 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3951 {
3952 (yyval.ArgList) = (yyvsp[-2].ArgList);
3953 (yyval.ArgList)->push_back(std::pair<PATypeHolder*,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003954 char*>(new PATypeHolder(Type::VoidTy), 0));
Reid Spencer61c83e02006-08-18 08:43:06 +00003955 CHECK_FOR_ERROR
3956 ;}
3957 break;
3958
3959 case 157:
3960#line 1824 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3961 {
3962 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
3963 (yyval.ArgList)->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
3964 CHECK_FOR_ERROR
3965 ;}
3966 break;
3967
3968 case 158:
3969#line 1829 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3970 {
3971 (yyval.ArgList) = 0;
3972 CHECK_FOR_ERROR
3973 ;}
3974 break;
3975
3976 case 159:
3977#line 1835 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3978 {
3979 UnEscapeLexed((yyvsp[-5].StrVal));
3980 std::string FunctionName((yyvsp[-5].StrVal));
3981 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00003982
Reid Spencer61c83e02006-08-18 08:43:06 +00003983 if (!(*(yyvsp[-6].TypeVal))->isFirstClassType() && *(yyvsp[-6].TypeVal) != Type::VoidTy)
3984 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003985
3986 std::vector<const Type*> ParamTypeList;
Reid Spencer61c83e02006-08-18 08:43:06 +00003987 if ((yyvsp[-3].ArgList)) { // If there are arguments...
3988 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
3989 I != (yyvsp[-3].ArgList)->end(); ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003990 ParamTypeList.push_back(I->first->get());
3991 }
3992
3993 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3994 if (isVarArg) ParamTypeList.pop_back();
3995
Reid Spencer61c83e02006-08-18 08:43:06 +00003996 const FunctionType *FT = FunctionType::get(*(yyvsp[-6].TypeVal), ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003997 const PointerType *PFT = PointerType::get(FT);
Reid Spencer61c83e02006-08-18 08:43:06 +00003998 delete (yyvsp[-6].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003999
4000 ValID ID;
4001 if (!FunctionName.empty()) {
4002 ID = ValID::create((char*)FunctionName.c_str());
4003 } else {
4004 ID = ValID::create((int)CurModule.Values[PFT].size());
4005 }
4006
4007 Function *Fn = 0;
4008 // See if this function was forward referenced. If so, recycle the object.
4009 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4010 // Move the function to the end of the list, from whereever it was
4011 // previously inserted.
4012 Fn = cast<Function>(FWRef);
4013 CurModule.CurrentModule->getFunctionList().remove(Fn);
4014 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4015 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4016 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4017 // If this is the case, either we need to be a forward decl, or it needs
4018 // to be.
4019 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00004020 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004021
4022 // Make sure to strip off any argument names so we can't get conflicts.
4023 if (Fn->isExternal())
4024 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4025 AI != AE; ++AI)
4026 AI->setName("");
4027
4028 } else { // Not already defined?
4029 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4030 CurModule.CurrentModule);
4031 InsertValue(Fn, CurModule.Values);
4032 }
4033
4034 CurFun.FunctionStart(Fn);
Reid Spencer61c83e02006-08-18 08:43:06 +00004035 Fn->setCallingConv((yyvsp[-7].UIntVal));
4036 Fn->setAlignment((yyvsp[0].UIntVal));
4037 if ((yyvsp[-1].StrVal)) {
4038 Fn->setSection((yyvsp[-1].StrVal));
4039 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004040 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004041
4042 // Add all of the arguments we parsed to the function...
Reid Spencer61c83e02006-08-18 08:43:06 +00004043 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004044 if (isVarArg) { // Nuke the last entry
Reid Spencer61c83e02006-08-18 08:43:06 +00004045 assert((yyvsp[-3].ArgList)->back().first->get() == Type::VoidTy && (yyvsp[-3].ArgList)->back().second == 0&&
Reid Spencer68a24bd2005-08-27 18:50:39 +00004046 "Not a varargs marker!");
Reid Spencer61c83e02006-08-18 08:43:06 +00004047 delete (yyvsp[-3].ArgList)->back().first;
4048 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004049 }
4050 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencer61c83e02006-08-18 08:43:06 +00004051 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
4052 I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004053 delete I->first; // Delete the typeholder...
4054
4055 setValueName(ArgIt, I->second); // Insert arg into symtab...
4056 InsertValue(ArgIt);
4057 }
4058
Reid Spencer61c83e02006-08-18 08:43:06 +00004059 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004060 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004061 CHECK_FOR_ERROR
4062;}
4063 break;
4064
4065 case 162:
4066#line 1923 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4067 {
4068 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004069
4070 // Make sure that we keep track of the linkage type even if there was a
4071 // previous "declare".
Reid Spencer61c83e02006-08-18 08:43:06 +00004072 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
4073;}
4074 break;
4075
4076 case 165:
4077#line 1933 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4078 {
4079 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4080 CHECK_FOR_ERROR
4081;}
4082 break;
4083
4084 case 166:
4085#line 1938 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4086 { CurFun.isDeclare = true; ;}
4087 break;
4088
4089 case 167:
4090#line 1938 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4091 {
4092 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004093 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004094 CHECK_FOR_ERROR
4095;}
4096 break;
4097
4098 case 168:
4099#line 1948 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4100 {
4101 (yyval.BoolVal) = false;
4102 CHECK_FOR_ERROR
4103 ;}
4104 break;
4105
4106 case 169:
4107#line 1952 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4108 {
4109 (yyval.BoolVal) = true;
4110 CHECK_FOR_ERROR
4111 ;}
4112 break;
4113
4114 case 170:
4115#line 1957 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4116 { // A reference to a direct constant
4117 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
4118 CHECK_FOR_ERROR
4119 ;}
4120 break;
4121
4122 case 171:
4123#line 1961 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4124 {
4125 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
4126 CHECK_FOR_ERROR
4127 ;}
4128 break;
4129
4130 case 172:
4131#line 1965 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4132 { // Perhaps it's an FP constant?
4133 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
4134 CHECK_FOR_ERROR
4135 ;}
4136 break;
4137
4138 case 173:
4139#line 1969 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4140 {
4141 (yyval.ValIDVal) = ValID::create(ConstantBool::True);
4142 CHECK_FOR_ERROR
4143 ;}
4144 break;
4145
4146 case 174:
4147#line 1973 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4148 {
4149 (yyval.ValIDVal) = ValID::create(ConstantBool::False);
4150 CHECK_FOR_ERROR
4151 ;}
4152 break;
4153
4154 case 175:
4155#line 1977 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4156 {
4157 (yyval.ValIDVal) = ValID::createNull();
4158 CHECK_FOR_ERROR
4159 ;}
4160 break;
4161
4162 case 176:
4163#line 1981 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4164 {
4165 (yyval.ValIDVal) = ValID::createUndef();
4166 CHECK_FOR_ERROR
4167 ;}
4168 break;
4169
4170 case 177:
4171#line 1985 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4172 { // A vector zero constant.
4173 (yyval.ValIDVal) = ValID::createZeroInit();
4174 CHECK_FOR_ERROR
4175 ;}
4176 break;
4177
4178 case 178:
4179#line 1989 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4180 { // Nonempty unsized packed vector
4181 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4182 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004183
4184 PackedType* pt = PackedType::get(ETy, NumElements);
4185 PATypeHolder* PTy = new PATypeHolder(
4186 HandleUpRefs(
4187 PackedType::get(
4188 ETy,
4189 NumElements)
4190 )
4191 );
4192
4193 // Verify all elements are correct type!
Reid Spencer61c83e02006-08-18 08:43:06 +00004194 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4195 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
4196 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004197 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer61c83e02006-08-18 08:43:06 +00004198 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004199 }
4200
Reid Spencer61c83e02006-08-18 08:43:06 +00004201 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector)));
4202 delete PTy; delete (yyvsp[-1].ConstVector);
4203 CHECK_FOR_ERROR
4204 ;}
4205 break;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004206
Reid Spencer61c83e02006-08-18 08:43:06 +00004207 case 179:
4208#line 2014 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4209 {
4210 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
4211 CHECK_FOR_ERROR
4212 ;}
4213 break;
4214
4215 case 180:
4216#line 2018 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4217 {
4218 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4219 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4220 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4221 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4222 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4223 free((yyvsp[-2].StrVal));
4224 free((yyvsp[0].StrVal));
4225 CHECK_FOR_ERROR
4226 ;}
4227 break;
4228
4229 case 181:
4230#line 2032 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4231 { // Is it an integer reference...?
4232 (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal));
4233 CHECK_FOR_ERROR
4234 ;}
4235 break;
4236
4237 case 182:
4238#line 2036 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4239 { // Is it a named reference...?
4240 (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal));
4241 CHECK_FOR_ERROR
4242 ;}
4243 break;
4244
4245 case 185:
4246#line 2048 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4247 {
4248 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal);
4249 CHECK_FOR_ERROR
4250 ;}
4251 break;
4252
4253 case 186:
4254#line 2053 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4255 {
4256 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4257 CHECK_FOR_ERROR
4258 ;}
4259 break;
4260
4261 case 187:
4262#line 2057 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4263 { // Do not allow functions with 0 basic blocks
4264 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4265 CHECK_FOR_ERROR
4266 ;}
4267 break;
4268
4269 case 188:
4270#line 2066 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4271 {
4272 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
4273 InsertValue((yyvsp[0].TermInstVal));
4274
4275 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4276 InsertValue((yyvsp[-2].BasicBlockVal));
4277 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
4278 CHECK_FOR_ERROR
4279 ;}
4280 break;
4281
4282 case 189:
4283#line 2076 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4284 {
4285 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4286 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
4287 CHECK_FOR_ERROR
4288 ;}
4289 break;
4290
4291 case 190:
4292#line 2081 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4293 {
4294 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004295
4296 // Make sure to move the basic block to the correct location in the
4297 // function, instead of leaving it inserted wherever it was first
4298 // referenced.
4299 Function::BasicBlockListType &BBL =
4300 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer61c83e02006-08-18 08:43:06 +00004301 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
4302 CHECK_FOR_ERROR
4303 ;}
4304 break;
4305
4306 case 191:
4307#line 2092 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4308 {
4309 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004310
4311 // Make sure to move the basic block to the correct location in the
4312 // function, instead of leaving it inserted wherever it was first
4313 // referenced.
4314 Function::BasicBlockListType &BBL =
4315 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer61c83e02006-08-18 08:43:06 +00004316 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
4317 CHECK_FOR_ERROR
4318 ;}
4319 break;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004320
Reid Spencer61c83e02006-08-18 08:43:06 +00004321 case 192:
4322#line 2104 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4323 { // Return with a result...
4324 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
4325 CHECK_FOR_ERROR
4326 ;}
4327 break;
4328
4329 case 193:
4330#line 2108 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4331 { // Return with no result...
4332 (yyval.TermInstVal) = new ReturnInst();
4333 CHECK_FOR_ERROR
4334 ;}
4335 break;
4336
4337 case 194:
4338#line 2112 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4339 { // Unconditional Branch...
4340 (yyval.TermInstVal) = new BranchInst(getBBVal((yyvsp[0].ValIDVal)));
4341 CHECK_FOR_ERROR
4342 ;}
4343 break;
4344
4345 case 195:
4346#line 2116 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4347 {
4348 (yyval.TermInstVal) = new BranchInst(getBBVal((yyvsp[-3].ValIDVal)), getBBVal((yyvsp[0].ValIDVal)), getVal(Type::BoolTy, (yyvsp[-6].ValIDVal)));
4349 CHECK_FOR_ERROR
4350 ;}
4351 break;
4352
4353 case 196:
4354#line 2120 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4355 {
4356 SwitchInst *S = new SwitchInst(getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal)), getBBVal((yyvsp[-3].ValIDVal)), (yyvsp[-1].JumpTable)->size());
4357 (yyval.TermInstVal) = S;
4358
4359 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
4360 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004361 for (; I != E; ++I) {
4362 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4363 S->addCase(CI, I->second);
4364 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004365 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004366 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004367 delete (yyvsp[-1].JumpTable);
4368 CHECK_FOR_ERROR
4369 ;}
4370 break;
4371
4372 case 197:
4373#line 2135 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4374 {
4375 SwitchInst *S = new SwitchInst(getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal)), getBBVal((yyvsp[-2].ValIDVal)), 0);
4376 (yyval.TermInstVal) = S;
4377 CHECK_FOR_ERROR
4378 ;}
4379 break;
4380
4381 case 198:
4382#line 2141 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4383 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004384 const PointerType *PFTy;
4385 const FunctionType *Ty;
4386
Reid Spencer61c83e02006-08-18 08:43:06 +00004387 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004388 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4389 // Pull out the types of all of the arguments...
4390 std::vector<const Type*> ParamTypes;
Reid Spencer61c83e02006-08-18 08:43:06 +00004391 if ((yyvsp[-7].ValueList)) {
4392 for (std::vector<Value*>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004393 I != E; ++I)
4394 ParamTypes.push_back((*I)->getType());
4395 }
4396
4397 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4398 if (isVarArg) ParamTypes.pop_back();
4399
Reid Spencer61c83e02006-08-18 08:43:06 +00004400 Ty = FunctionType::get((yyvsp[-10].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004401 PFTy = PointerType::get(Ty);
4402 }
4403
Reid Spencer61c83e02006-08-18 08:43:06 +00004404 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004405
Reid Spencer61c83e02006-08-18 08:43:06 +00004406 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
4407 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004408
4409 // Create the call node...
Reid Spencer61c83e02006-08-18 08:43:06 +00004410 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
4411 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004412 } else { // Has arguments?
4413 // Loop through FunctionType's arguments and ensure they are specified
4414 // correctly!
4415 //
4416 FunctionType::param_iterator I = Ty->param_begin();
4417 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer61c83e02006-08-18 08:43:06 +00004418 std::vector<Value*>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004419
4420 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4421 if ((*ArgI)->getType() != *I)
Reid Spencer61c83e02006-08-18 08:43:06 +00004422 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004423 (*I)->getDescription() + "'!");
4424
4425 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004426 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004427
Reid Spencer61c83e02006-08-18 08:43:06 +00004428 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004429 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004430 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004431
Reid Spencer61c83e02006-08-18 08:43:06 +00004432 delete (yyvsp[-10].TypeVal);
4433 delete (yyvsp[-7].ValueList);
4434 CHECK_FOR_ERROR
4435 ;}
4436 break;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004437
Reid Spencer61c83e02006-08-18 08:43:06 +00004438 case 199:
4439#line 2194 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4440 {
4441 (yyval.TermInstVal) = new UnwindInst();
4442 CHECK_FOR_ERROR
4443 ;}
4444 break;
4445
4446 case 200:
4447#line 2198 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4448 {
4449 (yyval.TermInstVal) = new UnreachableInst();
4450 CHECK_FOR_ERROR
4451 ;}
4452 break;
4453
4454 case 201:
4455#line 2205 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4456 {
4457 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
4458 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
4459 if (V == 0)
4460 GEN_ERROR("May only switch on a constant pool value!");
4461
4462 (yyval.JumpTable)->push_back(std::make_pair(V, getBBVal((yyvsp[0].ValIDVal))));
4463 CHECK_FOR_ERROR
4464 ;}
4465 break;
4466
4467 case 202:
4468#line 2214 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4469 {
4470 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
4471 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004472
4473 if (V == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004474 GEN_ERROR("May only switch on a constant pool value!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004475
Reid Spencer61c83e02006-08-18 08:43:06 +00004476 (yyval.JumpTable)->push_back(std::make_pair(V, getBBVal((yyvsp[0].ValIDVal))));
4477 CHECK_FOR_ERROR
4478 ;}
4479 break;
4480
4481 case 203:
4482#line 2225 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4483 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004484 // Is this definition named?? if so, assign the name...
Reid Spencer61c83e02006-08-18 08:43:06 +00004485 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
4486 InsertValue((yyvsp[0].InstVal));
4487 (yyval.InstVal) = (yyvsp[0].InstVal);
4488 CHECK_FOR_ERROR
4489;}
4490 break;
4491
4492 case 204:
4493#line 2233 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4494 { // Used for PHI nodes
4495 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
4496 (yyval.PHIList)->push_back(std::make_pair(getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal)), getBBVal((yyvsp[-1].ValIDVal))));
4497 delete (yyvsp[-5].TypeVal);
4498 CHECK_FOR_ERROR
4499 ;}
4500 break;
4501
4502 case 205:
4503#line 2239 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4504 {
4505 (yyval.PHIList) = (yyvsp[-6].PHIList);
4506 (yyvsp[-6].PHIList)->push_back(std::make_pair(getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal)),
4507 getBBVal((yyvsp[-1].ValIDVal))));
4508 CHECK_FOR_ERROR
4509 ;}
4510 break;
4511
4512 case 206:
4513#line 2247 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4514 { // Used for call statements, and memory insts...
4515 (yyval.ValueList) = new std::vector<Value*>();
4516 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
4517 CHECK_FOR_ERROR
4518 ;}
4519 break;
4520
4521 case 207:
4522#line 2252 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4523 {
4524 (yyval.ValueList) = (yyvsp[-2].ValueList);
4525 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
4526 CHECK_FOR_ERROR
4527 ;}
4528 break;
4529
4530 case 209:
4531#line 2259 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4532 { (yyval.ValueList) = 0; ;}
4533 break;
4534
4535 case 210:
4536#line 2261 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4537 {
4538 (yyval.BoolVal) = true;
4539 CHECK_FOR_ERROR
4540 ;}
4541 break;
4542
4543 case 211:
4544#line 2265 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4545 {
4546 (yyval.BoolVal) = false;
4547 CHECK_FOR_ERROR
4548 ;}
4549 break;
4550
4551 case 212:
4552#line 2272 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4553 {
4554 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
4555 !isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
4556 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00004557 "Arithmetic operator requires integer, FP, or packed operands!");
Reid Spencer61c83e02006-08-18 08:43:06 +00004558 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) && (yyvsp[-4].BinaryOpVal) == Instruction::Rem)
4559 GEN_ERROR("Rem not supported on packed types!");
4560 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)), getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)));
4561 if ((yyval.InstVal) == 0)
4562 GEN_ERROR("binary operator returned null!");
4563 delete (yyvsp[-3].TypeVal);
4564 CHECK_FOR_ERROR
4565 ;}
4566 break;
4567
4568 case 213:
4569#line 2285 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4570 {
4571 if (!(*(yyvsp[-3].TypeVal))->isIntegral()) {
4572 if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) ||
4573 !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral())
4574 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00004575 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004576 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)), getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)));
4577 if ((yyval.InstVal) == 0)
4578 GEN_ERROR("binary operator returned null!");
4579 delete (yyvsp[-3].TypeVal);
4580 CHECK_FOR_ERROR
4581 ;}
4582 break;
4583
4584 case 214:
4585#line 2297 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4586 {
4587 if(isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) {
4588 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00004589 "PackedTypes currently not supported in setcc instructions!");
4590 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004591 (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal), getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)), getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)));
4592 if ((yyval.InstVal) == 0)
4593 GEN_ERROR("binary operator returned null!");
4594 delete (yyvsp[-3].TypeVal);
4595 CHECK_FOR_ERROR
4596 ;}
4597 break;
4598
4599 case 215:
4600#line 2308 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4601 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004602 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
4603 << " Replacing with 'xor'.\n";
4604
Reid Spencer61c83e02006-08-18 08:43:06 +00004605 Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004606 if (Ones == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004607 GEN_ERROR("Expected integral type for not instruction!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004608
Reid Spencer61c83e02006-08-18 08:43:06 +00004609 (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones);
4610 if ((yyval.InstVal) == 0)
4611 GEN_ERROR("Could not create a xor instruction!");
4612 CHECK_FOR_ERROR
4613 ;}
4614 break;
4615
4616 case 216:
4617#line 2321 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4618 {
4619 if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy)
4620 GEN_ERROR("Shift amount must be ubyte!");
4621 if (!(yyvsp[-2].ValueVal)->getType()->isInteger())
4622 GEN_ERROR("Shift constant expression requires integer operand!");
4623 (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
4624 CHECK_FOR_ERROR
4625 ;}
4626 break;
4627
4628 case 217:
4629#line 2329 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4630 {
4631 if (!(yyvsp[0].TypeVal)->get()->isFirstClassType())
4632 GEN_ERROR("cast instruction to a non-primitive type: '" +
4633 (yyvsp[0].TypeVal)->get()->getDescription() + "'!");
4634 (yyval.InstVal) = new CastInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
4635 delete (yyvsp[0].TypeVal);
4636 CHECK_FOR_ERROR
4637 ;}
4638 break;
4639
4640 case 218:
4641#line 2337 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4642 {
4643 if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy)
4644 GEN_ERROR("select condition must be boolean!");
4645 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
4646 GEN_ERROR("select value types should match!");
4647 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
4648 CHECK_FOR_ERROR
4649 ;}
4650 break;
4651
4652 case 219:
4653#line 2345 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4654 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004655 NewVarArgs = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004656 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
4657 delete (yyvsp[0].TypeVal);
4658 CHECK_FOR_ERROR
4659 ;}
4660 break;
4661
4662 case 220:
4663#line 2351 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4664 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004665 ObsoleteVarArgs = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004666 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004667 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004668 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004669
4670 //b = vaarg a, t ->
4671 //foo = alloca 1 of t
4672 //bar = vacopy a
4673 //store bar -> foo
4674 //b = vaarg foo, t
4675 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
4676 CurBB->getInstList().push_back(foo);
Reid Spencer61c83e02006-08-18 08:43:06 +00004677 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004678 CurBB->getInstList().push_back(bar);
4679 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer61c83e02006-08-18 08:43:06 +00004680 (yyval.InstVal) = new VAArgInst(foo, *(yyvsp[0].TypeVal));
4681 delete (yyvsp[0].TypeVal);
4682 CHECK_FOR_ERROR
4683 ;}
4684 break;
4685
4686 case 221:
4687#line 2371 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4688 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004689 ObsoleteVarArgs = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004690 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004691 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004692 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004693
4694 //b = vanext a, t ->
4695 //foo = alloca 1 of t
4696 //bar = vacopy a
4697 //store bar -> foo
4698 //tmp = vaarg foo, t
4699 //b = load foo
4700 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
4701 CurBB->getInstList().push_back(foo);
Reid Spencer61c83e02006-08-18 08:43:06 +00004702 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004703 CurBB->getInstList().push_back(bar);
4704 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer61c83e02006-08-18 08:43:06 +00004705 Instruction* tmp = new VAArgInst(foo, *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004706 CurBB->getInstList().push_back(tmp);
Reid Spencer61c83e02006-08-18 08:43:06 +00004707 (yyval.InstVal) = new LoadInst(foo);
4708 delete (yyvsp[0].TypeVal);
4709 CHECK_FOR_ERROR
4710 ;}
4711 break;
4712
4713 case 222:
4714#line 2394 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4715 {
4716 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
4717 GEN_ERROR("Invalid extractelement operands!");
4718 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
4719 CHECK_FOR_ERROR
4720 ;}
4721 break;
4722
4723 case 223:
4724#line 2400 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4725 {
4726 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
4727 GEN_ERROR("Invalid insertelement operands!");
4728 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
4729 CHECK_FOR_ERROR
4730 ;}
4731 break;
4732
4733 case 224:
4734#line 2406 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4735 {
4736 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
4737 GEN_ERROR("Invalid shufflevector operands!");
4738 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
4739 CHECK_FOR_ERROR
4740 ;}
4741 break;
4742
4743 case 225:
4744#line 2412 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4745 {
4746 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004747 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004748 GEN_ERROR("PHI node operands must be of first class type!");
4749 (yyval.InstVal) = new PHINode(Ty);
4750 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
4751 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
4752 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
4753 GEN_ERROR("All elements of a PHI node must be of the same type!");
4754 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
4755 (yyvsp[0].PHIList)->pop_front();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004756 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004757 delete (yyvsp[0].PHIList); // Free the list...
4758 CHECK_FOR_ERROR
4759 ;}
4760 break;
4761
4762 case 226:
4763#line 2427 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4764 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004765 const PointerType *PFTy;
4766 const FunctionType *Ty;
4767
Reid Spencer61c83e02006-08-18 08:43:06 +00004768 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004769 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4770 // Pull out the types of all of the arguments...
4771 std::vector<const Type*> ParamTypes;
Reid Spencer61c83e02006-08-18 08:43:06 +00004772 if ((yyvsp[-1].ValueList)) {
4773 for (std::vector<Value*>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004774 I != E; ++I)
4775 ParamTypes.push_back((*I)->getType());
4776 }
4777
4778 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4779 if (isVarArg) ParamTypes.pop_back();
4780
Reid Spencer61c83e02006-08-18 08:43:06 +00004781 if (!(*(yyvsp[-4].TypeVal))->isFirstClassType() && *(yyvsp[-4].TypeVal) != Type::VoidTy)
4782 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004783
Reid Spencer61c83e02006-08-18 08:43:06 +00004784 Ty = FunctionType::get((yyvsp[-4].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004785 PFTy = PointerType::get(Ty);
4786 }
4787
Reid Spencer61c83e02006-08-18 08:43:06 +00004788 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); // Get the function we're calling...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004789
4790 // Create the call node...
Reid Spencer61c83e02006-08-18 08:43:06 +00004791 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer68a24bd2005-08-27 18:50:39 +00004792 // Make sure no arguments is a good thing!
4793 if (Ty->getNumParams() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004794 GEN_ERROR("No arguments passed to a function that "
Reid Spencer68a24bd2005-08-27 18:50:39 +00004795 "expects arguments!");
4796
Reid Spencer61c83e02006-08-18 08:43:06 +00004797 (yyval.InstVal) = new CallInst(V, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004798 } else { // Has arguments?
4799 // Loop through FunctionType's arguments and ensure they are specified
4800 // correctly!
4801 //
4802 FunctionType::param_iterator I = Ty->param_begin();
4803 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer61c83e02006-08-18 08:43:06 +00004804 std::vector<Value*>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004805
4806 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4807 if ((*ArgI)->getType() != *I)
Reid Spencer61c83e02006-08-18 08:43:06 +00004808 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004809 (*I)->getDescription() + "'!");
4810
4811 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004812 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004813
Reid Spencer61c83e02006-08-18 08:43:06 +00004814 (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004815 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004816 cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal));
4817 cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal));
4818 delete (yyvsp[-4].TypeVal);
4819 delete (yyvsp[-1].ValueList);
4820 CHECK_FOR_ERROR
4821 ;}
4822 break;
4823
4824 case 227:
4825#line 2485 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4826 {
4827 (yyval.InstVal) = (yyvsp[0].InstVal);
4828 CHECK_FOR_ERROR
4829 ;}
4830 break;
4831
4832 case 228:
4833#line 2492 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4834 {
4835 (yyval.ValueList) = (yyvsp[0].ValueList);
4836 CHECK_FOR_ERROR
4837 ;}
4838 break;
4839
4840 case 229:
4841#line 2495 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4842 {
4843 (yyval.ValueList) = new std::vector<Value*>();
4844 CHECK_FOR_ERROR
4845 ;}
4846 break;
4847
4848 case 230:
4849#line 2500 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4850 {
4851 (yyval.BoolVal) = true;
4852 CHECK_FOR_ERROR
4853 ;}
4854 break;
4855
4856 case 231:
4857#line 2504 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4858 {
4859 (yyval.BoolVal) = false;
4860 CHECK_FOR_ERROR
4861 ;}
4862 break;
4863
4864 case 232:
4865#line 2511 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4866 {
4867 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
4868 delete (yyvsp[-1].TypeVal);
4869 CHECK_FOR_ERROR
4870 ;}
4871 break;
4872
4873 case 233:
4874#line 2516 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4875 {
4876 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
4877 delete (yyvsp[-4].TypeVal);
4878 CHECK_FOR_ERROR
4879 ;}
4880 break;
4881
4882 case 234:
4883#line 2521 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4884 {
4885 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
4886 delete (yyvsp[-1].TypeVal);
4887 CHECK_FOR_ERROR
4888 ;}
4889 break;
4890
4891 case 235:
4892#line 2526 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4893 {
4894 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
4895 delete (yyvsp[-4].TypeVal);
4896 CHECK_FOR_ERROR
4897 ;}
4898 break;
4899
4900 case 236:
4901#line 2531 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4902 {
4903 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
4904 GEN_ERROR("Trying to free nonpointer type " +
4905 (yyvsp[0].ValueVal)->getType()->getDescription() + "!");
4906 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
4907 CHECK_FOR_ERROR
4908 ;}
4909 break;
4910
4911 case 237:
4912#line 2539 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4913 {
4914 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
4915 GEN_ERROR("Can't load from nonpointer type: " +
4916 (*(yyvsp[-1].TypeVal))->getDescription());
4917 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
4918 GEN_ERROR("Can't load from pointer of non-first-class type: " +
4919 (*(yyvsp[-1].TypeVal))->getDescription());
4920 (yyval.InstVal) = new LoadInst(getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)), "", (yyvsp[-3].BoolVal));
4921 delete (yyvsp[-1].TypeVal);
4922 CHECK_FOR_ERROR
4923 ;}
4924 break;
4925
4926 case 238:
4927#line 2550 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4928 {
4929 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004930 if (!PT)
Reid Spencer61c83e02006-08-18 08:43:06 +00004931 GEN_ERROR("Can't store to a nonpointer type: " +
4932 (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004933 const Type *ElTy = PT->getElementType();
Reid Spencer61c83e02006-08-18 08:43:06 +00004934 if (ElTy != (yyvsp[-3].ValueVal)->getType())
4935 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004936 "' into space of type '" + ElTy->getDescription() + "'!");
4937
Reid Spencer61c83e02006-08-18 08:43:06 +00004938 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)), (yyvsp[-5].BoolVal));
4939 delete (yyvsp[-1].TypeVal);
4940 CHECK_FOR_ERROR
4941 ;}
4942 break;
4943
4944 case 239:
4945#line 2564 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4946 {
4947 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
4948 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004949
4950 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4951 // indices to uint struct indices for compatibility.
4952 generic_gep_type_iterator<std::vector<Value*>::iterator>
Reid Spencer61c83e02006-08-18 08:43:06 +00004953 GTI = gep_type_begin((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()),
4954 GTE = gep_type_end((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end());
4955 for (unsigned i = 0, e = (yyvsp[0].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004956 if (isa<StructType>(*GTI)) // Only change struct indices
Reid Spencer61c83e02006-08-18 08:43:06 +00004957 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*(yyvsp[0].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00004958 if (CUI->getType() == Type::UByteTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004959 (*(yyvsp[0].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004960
Reid Spencer61c83e02006-08-18 08:43:06 +00004961 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true))
4962 GEN_ERROR("Invalid getelementptr indices for type '" +
4963 (*(yyvsp[-2].TypeVal))->getDescription()+ "'!");
4964 (yyval.InstVal) = new GetElementPtrInst(getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal)), *(yyvsp[0].ValueList));
4965 delete (yyvsp[-2].TypeVal); delete (yyvsp[0].ValueList);
4966 CHECK_FOR_ERROR
4967 ;}
4968 break;
4969
4970
4971 default: break;
4972 }
4973
4974/* Line 1126 of yacc.c. */
4975#line 4976 "llvmAsmParser.tab.c"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004976
4977 yyvsp -= yylen;
4978 yyssp -= yylen;
4979
Reid Spencer61c83e02006-08-18 08:43:06 +00004980
4981 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004982
4983 *++yyvsp = yyval;
4984
4985
Reid Spencer61c83e02006-08-18 08:43:06 +00004986 /* Now `shift' the result of the reduction. Determine what state
4987 that goes to, based on the state we popped back to and the rule
4988 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004989
4990 yyn = yyr1[yyn];
4991
Reid Spencer61c83e02006-08-18 08:43:06 +00004992 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
4993 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004994 yystate = yytable[yystate];
4995 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004996 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00004997
4998 goto yynewstate;
4999
5000
Reid Spencer61c83e02006-08-18 08:43:06 +00005001/*------------------------------------.
5002| yyerrlab -- here on detecting error |
5003`------------------------------------*/
5004yyerrlab:
5005 /* If not already recovering from an error, report this error. */
5006 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005007 {
5008 ++yynerrs;
Reid Spencer61c83e02006-08-18 08:43:06 +00005009#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00005010 yyn = yypact[yystate];
5011
Reid Spencer61c83e02006-08-18 08:43:06 +00005012 if (YYPACT_NINF < yyn && yyn < YYLAST)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005013 {
Reid Spencer61c83e02006-08-18 08:43:06 +00005014 int yytype = YYTRANSLATE (yychar);
5015 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5016 YYSIZE_T yysize = yysize0;
5017 YYSIZE_T yysize1;
5018 int yysize_overflow = 0;
5019 char *yymsg = 0;
5020# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5021 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5022 int yyx;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005023
Reid Spencer61c83e02006-08-18 08:43:06 +00005024#if 0
5025 /* This is so xgettext sees the translatable formats that are
5026 constructed on the fly. */
5027 YY_("syntax error, unexpected %s");
5028 YY_("syntax error, unexpected %s, expecting %s");
5029 YY_("syntax error, unexpected %s, expecting %s or %s");
5030 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5031 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5032#endif
5033 char *yyfmt;
5034 char const *yyf;
5035 static char const yyunexpected[] = "syntax error, unexpected %s";
5036 static char const yyexpecting[] = ", expecting %s";
5037 static char const yyor[] = " or %s";
5038 char yyformat[sizeof yyunexpected
5039 + sizeof yyexpecting - 1
5040 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5041 * (sizeof yyor - 1))];
5042 char const *yyprefix = yyexpecting;
5043
5044 /* Start YYX at -YYN if negative to avoid negative indexes in
5045 YYCHECK. */
5046 int yyxbegin = yyn < 0 ? -yyn : 0;
5047
5048 /* Stay within bounds of both yycheck and yytname. */
5049 int yychecklim = YYLAST - yyn;
5050 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5051 int yycount = 1;
5052
5053 yyarg[0] = yytname[yytype];
5054 yyfmt = yystpcpy (yyformat, yyunexpected);
5055
5056 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5057 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5058 {
5059 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5060 {
5061 yycount = 1;
5062 yysize = yysize0;
5063 yyformat[sizeof yyunexpected - 1] = '\0';
5064 break;
5065 }
5066 yyarg[yycount++] = yytname[yyx];
5067 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5068 yysize_overflow |= yysize1 < yysize;
5069 yysize = yysize1;
5070 yyfmt = yystpcpy (yyfmt, yyprefix);
5071 yyprefix = yyor;
5072 }
5073
5074 yyf = YY_(yyformat);
5075 yysize1 = yysize + yystrlen (yyf);
5076 yysize_overflow |= yysize1 < yysize;
5077 yysize = yysize1;
5078
5079 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5080 yymsg = (char *) YYSTACK_ALLOC (yysize);
5081 if (yymsg)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005082 {
Reid Spencer61c83e02006-08-18 08:43:06 +00005083 /* Avoid sprintf, as that infringes on the user's name space.
5084 Don't have undefined behavior even if the translation
5085 produced a string with the wrong number of "%s"s. */
5086 char *yyp = yymsg;
5087 int yyi = 0;
5088 while ((*yyp = *yyf))
Reid Spencer68a24bd2005-08-27 18:50:39 +00005089 {
Reid Spencer61c83e02006-08-18 08:43:06 +00005090 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5091 {
5092 yyp += yytnamerr (yyp, yyarg[yyi++]);
5093 yyf += 2;
5094 }
5095 else
5096 {
5097 yyp++;
5098 yyf++;
5099 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005100 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005101 yyerror (yymsg);
5102 YYSTACK_FREE (yymsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005103 }
5104 else
Reid Spencer61c83e02006-08-18 08:43:06 +00005105 {
5106 yyerror (YY_("syntax error"));
5107 goto yyexhaustedlab;
5108 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005109 }
5110 else
5111#endif /* YYERROR_VERBOSE */
Reid Spencer61c83e02006-08-18 08:43:06 +00005112 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005113 }
5114
Reid Spencer61c83e02006-08-18 08:43:06 +00005115
Reid Spencer68a24bd2005-08-27 18:50:39 +00005116
5117 if (yyerrstatus == 3)
5118 {
Reid Spencer61c83e02006-08-18 08:43:06 +00005119 /* If just tried and failed to reuse look-ahead token after an
5120 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005121
Reid Spencer61c83e02006-08-18 08:43:06 +00005122 if (yychar <= YYEOF)
5123 {
5124 /* Return failure if at end of input. */
5125 if (yychar == YYEOF)
5126 YYABORT;
5127 }
5128 else
5129 {
5130 yydestruct ("Error: discarding", yytoken, &yylval);
5131 yychar = YYEMPTY;
5132 }
5133 }
5134
5135 /* Else will try to reuse look-ahead token after shifting the error
5136 token. */
5137 goto yyerrlab1;
5138
5139
5140/*---------------------------------------------------.
5141| yyerrorlab -- error raised explicitly by YYERROR. |
5142`---------------------------------------------------*/
5143yyerrorlab:
5144
5145 /* Pacify compilers like GCC when the user code never invokes
5146 YYERROR and the label yyerrorlab therefore never appears in user
5147 code. */
5148 if (0)
5149 goto yyerrorlab;
5150
5151yyvsp -= yylen;
5152 yyssp -= yylen;
5153 yystate = *yyssp;
5154 goto yyerrlab1;
5155
5156
5157/*-------------------------------------------------------------.
5158| yyerrlab1 -- common code for both syntax error and YYERROR. |
5159`-------------------------------------------------------------*/
5160yyerrlab1:
5161 yyerrstatus = 3; /* Each real token shifted decrements this. */
5162
5163 for (;;)
5164 {
5165 yyn = yypact[yystate];
5166 if (yyn != YYPACT_NINF)
5167 {
5168 yyn += YYTERROR;
5169 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5170 {
5171 yyn = yytable[yyn];
5172 if (0 < yyn)
5173 break;
5174 }
5175 }
5176
5177 /* Pop the current state because it cannot handle the error token. */
5178 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005179 YYABORT;
5180
Chris Lattner8335e842006-01-23 23:05:42 +00005181
Reid Spencer61c83e02006-08-18 08:43:06 +00005182 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5183 YYPOPSTACK;
5184 yystate = *yyssp;
5185 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005186 }
5187
5188 if (yyn == YYFINAL)
5189 YYACCEPT;
5190
Reid Spencer68a24bd2005-08-27 18:50:39 +00005191 *++yyvsp = yylval;
Reid Spencer61c83e02006-08-18 08:43:06 +00005192
5193
5194 /* Shift the error token. */
5195 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005196
5197 yystate = yyn;
5198 goto yynewstate;
5199
Reid Spencere812fb22006-01-19 01:21:04 +00005200
Reid Spencer61c83e02006-08-18 08:43:06 +00005201/*-------------------------------------.
5202| yyacceptlab -- YYACCEPT comes here. |
5203`-------------------------------------*/
5204yyacceptlab:
5205 yyresult = 0;
5206 goto yyreturn;
5207
5208/*-----------------------------------.
5209| yyabortlab -- YYABORT comes here. |
5210`-----------------------------------*/
5211yyabortlab:
5212 yyresult = 1;
5213 goto yyreturn;
5214
5215#ifndef yyoverflow
5216/*-------------------------------------------------.
5217| yyexhaustedlab -- memory exhaustion comes here. |
5218`-------------------------------------------------*/
5219yyexhaustedlab:
5220 yyerror (YY_("memory exhausted"));
5221 yyresult = 2;
5222 /* Fall through. */
Reid Spencere812fb22006-01-19 01:21:04 +00005223#endif
Reid Spencer61c83e02006-08-18 08:43:06 +00005224
5225yyreturn:
5226 if (yychar != YYEOF && yychar != YYEMPTY)
5227 yydestruct ("Cleanup: discarding lookahead",
5228 yytoken, &yylval);
5229 while (yyssp != yyss)
5230 {
5231 yydestruct ("Cleanup: popping",
5232 yystos[*yyssp], yyvsp);
5233 YYPOPSTACK;
Chris Lattner8335e842006-01-23 23:05:42 +00005234 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005235#ifndef yyoverflow
5236 if (yyss != yyssa)
5237 YYSTACK_FREE (yyss);
5238#endif
5239 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005240}
Reid Spencer61c83e02006-08-18 08:43:06 +00005241
5242
5243#line 2588 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
5244
5245
5246void llvm::GenerateError(const std::string &message, int LineNo) {
5247 if (LineNo == -1) LineNo = llvmAsmlineno;
5248 // TODO: column number in exception
5249 if (TheParseError)
5250 TheParseError->setError(CurFilename, message, LineNo);
5251 TriggerError = 1;
5252}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005253
5254int yyerror(const char *ErrorMsg) {
5255 std::string where
5256 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5257 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5258 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5259 if (yychar == YYEMPTY || yychar == 0)
5260 errMsg += "end-of-file.";
5261 else
5262 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005263 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005264 return 0;
5265}
Reid Spencer61c83e02006-08-18 08:43:06 +00005266