blob: 92e0a39462714341f754505c5f036cc1a774d70f [file] [log] [blame]
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001/* A Bison parser, made by GNU Bison 1.875d. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
3/* Skeleton parser for Yacc-like parsing with Bison,
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005
6 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.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
37#define YYBISON 1
38
39/* Skeleton name. */
40#define YYSKELETON_NAME "yacc.c"
41
42/* Pure parsers. */
43#define YYPURE 0
44
45/* Using locations. */
46#define YYLSP_NEEDED 0
47
48/* If NAME_PREFIX is specified substitute the variables and functions
49 names. */
50#define yyparse llvmAsmparse
51#define yylex llvmAsmlex
52#define yyerror llvmAsmerror
53#define yylval llvmAsmlval
54#define yychar llvmAsmchar
55#define yydebug llvmAsmdebug
56#define yynerrs llvmAsmnerrs
57
58
59/* Tokens. */
60#ifndef YYTOKENTYPE
61# define YYTOKENTYPE
62 /* Put the tokens into the symbol table, so that GDB and other debuggers
63 know about them. */
64 enum yytokentype {
65 ESINT64VAL = 258,
66 EUINT64VAL = 259,
67 SINTVAL = 260,
68 UINTVAL = 261,
69 FPVAL = 262,
70 VOID = 263,
71 BOOL = 264,
72 SBYTE = 265,
73 UBYTE = 266,
74 SHORT = 267,
75 USHORT = 268,
76 INT = 269,
77 UINT = 270,
78 LONG = 271,
79 ULONG = 272,
80 FLOAT = 273,
81 DOUBLE = 274,
82 TYPE = 275,
83 LABEL = 276,
84 VAR_ID = 277,
85 LABELSTR = 278,
86 STRINGCONSTANT = 279,
87 IMPLEMENTATION = 280,
88 ZEROINITIALIZER = 281,
89 TRUETOK = 282,
90 FALSETOK = 283,
91 BEGINTOK = 284,
92 ENDTOK = 285,
93 DECLARE = 286,
94 GLOBAL = 287,
95 CONSTANT = 288,
96 VOLATILE = 289,
97 TO = 290,
98 DOTDOTDOT = 291,
99 NULL_TOK = 292,
100 UNDEF = 293,
101 CONST = 294,
102 INTERNAL = 295,
103 LINKONCE = 296,
104 WEAK = 297,
105 APPENDING = 298,
106 OPAQUE = 299,
107 NOT = 300,
108 EXTERNAL = 301,
109 TARGET = 302,
110 TRIPLE = 303,
111 ENDIAN = 304,
112 POINTERSIZE = 305,
113 LITTLE = 306,
114 BIG = 307,
115 DEPLIBS = 308,
116 CALL = 309,
117 TAIL = 310,
118 CC_TOK = 311,
119 CCC_TOK = 312,
120 FASTCC_TOK = 313,
121 COLDCC_TOK = 314,
122 RET = 315,
123 BR = 316,
124 SWITCH = 317,
125 INVOKE = 318,
126 UNWIND = 319,
127 UNREACHABLE = 320,
128 ADD = 321,
129 SUB = 322,
130 MUL = 323,
131 DIV = 324,
132 REM = 325,
133 AND = 326,
134 OR = 327,
135 XOR = 328,
136 SETLE = 329,
137 SETGE = 330,
138 SETLT = 331,
139 SETGT = 332,
140 SETEQ = 333,
141 SETNE = 334,
142 MALLOC = 335,
143 ALLOCA = 336,
144 FREE = 337,
145 LOAD = 338,
146 STORE = 339,
147 GETELEMENTPTR = 340,
148 PHI_TOK = 341,
149 CAST = 342,
150 SELECT = 343,
151 SHL = 344,
152 SHR = 345,
153 VAARG = 346,
154 VAARG_old = 347,
155 VANEXT_old = 348
156 };
157#endif
158#define ESINT64VAL 258
159#define EUINT64VAL 259
160#define SINTVAL 260
161#define UINTVAL 261
162#define FPVAL 262
163#define VOID 263
164#define BOOL 264
165#define SBYTE 265
166#define UBYTE 266
167#define SHORT 267
168#define USHORT 268
169#define INT 269
170#define UINT 270
171#define LONG 271
172#define ULONG 272
173#define FLOAT 273
174#define DOUBLE 274
175#define TYPE 275
176#define LABEL 276
177#define VAR_ID 277
178#define LABELSTR 278
179#define STRINGCONSTANT 279
180#define IMPLEMENTATION 280
181#define ZEROINITIALIZER 281
182#define TRUETOK 282
183#define FALSETOK 283
184#define BEGINTOK 284
185#define ENDTOK 285
186#define DECLARE 286
187#define GLOBAL 287
188#define CONSTANT 288
189#define VOLATILE 289
190#define TO 290
191#define DOTDOTDOT 291
192#define NULL_TOK 292
193#define UNDEF 293
194#define CONST 294
195#define INTERNAL 295
196#define LINKONCE 296
197#define WEAK 297
198#define APPENDING 298
199#define OPAQUE 299
200#define NOT 300
201#define EXTERNAL 301
202#define TARGET 302
203#define TRIPLE 303
204#define ENDIAN 304
205#define POINTERSIZE 305
206#define LITTLE 306
207#define BIG 307
208#define DEPLIBS 308
209#define CALL 309
210#define TAIL 310
211#define CC_TOK 311
212#define CCC_TOK 312
213#define FASTCC_TOK 313
214#define COLDCC_TOK 314
215#define RET 315
216#define BR 316
217#define SWITCH 317
218#define INVOKE 318
219#define UNWIND 319
220#define UNREACHABLE 320
221#define ADD 321
222#define SUB 322
223#define MUL 323
224#define DIV 324
225#define REM 325
226#define AND 326
227#define OR 327
228#define XOR 328
229#define SETLE 329
230#define SETGE 330
231#define SETLT 331
232#define SETGT 332
233#define SETEQ 333
234#define SETNE 334
235#define MALLOC 335
236#define ALLOCA 336
237#define FREE 337
238#define LOAD 338
239#define STORE 339
240#define GETELEMENTPTR 340
241#define PHI_TOK 341
242#define CAST 342
243#define SELECT 343
244#define SHL 344
245#define SHR 345
246#define VAARG 346
247#define VAARG_old 347
248#define VANEXT_old 348
249
250
251
252
253/* Copy the first part of user declarations. */
Jeff Cohen66c5fd62005-10-23 04:37:20 +0000254#line 14 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000255
256#include "ParserInternals.h"
257#include "llvm/CallingConv.h"
258#include "llvm/Instructions.h"
259#include "llvm/Module.h"
260#include "llvm/SymbolTable.h"
261#include "llvm/Support/GetElementPtrTypeIterator.h"
262#include "llvm/ADT/STLExtras.h"
263#include <algorithm>
264#include <iostream>
265#include <list>
266#include <utility>
267
268int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
269int yylex(); // declaration" of xxx warnings.
270int yyparse();
271
272namespace llvm {
273 std::string CurFilename;
274}
275using namespace llvm;
276
277static Module *ParserResult;
278
279// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
280// relating to upreferences in the input stream.
281//
282//#define DEBUG_UPREFS 1
283#ifdef DEBUG_UPREFS
284#define UR_OUT(X) std::cerr << X
285#else
286#define UR_OUT(X)
287#endif
288
289#define YYERROR_VERBOSE 1
290
291static bool ObsoleteVarArgs;
292static bool NewVarArgs;
293static BasicBlock* CurBB;
294
295
296// This contains info used when building the body of a function. It is
297// destroyed when the function is completed.
298//
299typedef std::vector<Value *> ValueList; // Numbered defs
300static void
301ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
302 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
303
304static struct PerModuleInfo {
305 Module *CurrentModule;
306 std::map<const Type *, ValueList> Values; // Module level numbered definitions
307 std::map<const Type *,ValueList> LateResolveValues;
308 std::vector<PATypeHolder> Types;
309 std::map<ValID, PATypeHolder> LateResolveTypes;
310
311 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
312 /// how they were referenced and one which line of the input they came from so
313 /// that we can resolve them later and print error messages as appropriate.
314 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
315
316 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
317 // references to global values. Global values may be referenced before they
318 // are defined, and if so, the temporary object that they represent is held
319 // here. This is used for forward references of GlobalValues.
320 //
321 typedef std::map<std::pair<const PointerType *,
322 ValID>, GlobalValue*> GlobalRefsType;
323 GlobalRefsType GlobalRefs;
324
325 void ModuleDone() {
326 // If we could not resolve some functions at function compilation time
327 // (calls to functions before they are defined), resolve them now... Types
328 // are resolved when the constant pool has been completely parsed.
329 //
330 ResolveDefinitions(LateResolveValues);
331
332 // Check to make sure that all global value forward references have been
333 // resolved!
334 //
335 if (!GlobalRefs.empty()) {
336 std::string UndefinedReferences = "Unresolved global references exist:\n";
337
338 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
339 I != E; ++I) {
340 UndefinedReferences += " " + I->first.first->getDescription() + " " +
341 I->first.second.getName() + "\n";
342 }
343 ThrowException(UndefinedReferences);
344 }
345
346 Values.clear(); // Clear out function local definitions
347 Types.clear();
348 CurrentModule = 0;
349 }
350
351
352 // GetForwardRefForGlobal - Check to see if there is a forward reference
353 // for this global. If so, remove it from the GlobalRefs map and return it.
354 // If not, just return null.
355 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
356 // Check to see if there is a forward reference to this global variable...
357 // if there is, eliminate it and patch the reference to use the new def'n.
358 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
359 GlobalValue *Ret = 0;
360 if (I != GlobalRefs.end()) {
361 Ret = I->second;
362 GlobalRefs.erase(I);
363 }
364 return Ret;
365 }
366} CurModule;
367
368static struct PerFunctionInfo {
369 Function *CurrentFunction; // Pointer to current function being created
370
371 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
372 std::map<const Type*, ValueList> LateResolveValues;
373 bool isDeclare; // Is this function a forward declararation?
374
375 /// BBForwardRefs - When we see forward references to basic blocks, keep
376 /// track of them here.
377 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
378 std::vector<BasicBlock*> NumberedBlocks;
379 unsigned NextBBNum;
380
381 inline PerFunctionInfo() {
382 CurrentFunction = 0;
383 isDeclare = false;
384 }
385
386 inline void FunctionStart(Function *M) {
387 CurrentFunction = M;
388 NextBBNum = 0;
389 }
390
391 void FunctionDone() {
392 NumberedBlocks.clear();
393
394 // Any forward referenced blocks left?
395 if (!BBForwardRefs.empty())
396 ThrowException("Undefined reference to label " +
397 BBForwardRefs.begin()->first->getName());
398
399 // Resolve all forward references now.
400 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
401
402 Values.clear(); // Clear out function local definitions
403 CurrentFunction = 0;
404 isDeclare = false;
405 }
406} CurFun; // Info for the current function...
407
408static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
409
410
411//===----------------------------------------------------------------------===//
412// Code to handle definitions of all the types
413//===----------------------------------------------------------------------===//
414
415static int InsertValue(Value *V,
416 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
417 if (V->hasName()) return -1; // Is this a numbered definition?
418
419 // Yes, insert the value into the value table...
420 ValueList &List = ValueTab[V->getType()];
421 List.push_back(V);
422 return List.size()-1;
423}
424
425static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
426 switch (D.Type) {
427 case ValID::NumberVal: // Is it a numbered definition?
428 // Module constants occupy the lowest numbered slots...
429 if ((unsigned)D.Num < CurModule.Types.size())
430 return CurModule.Types[(unsigned)D.Num];
431 break;
432 case ValID::NameVal: // Is it a named definition?
433 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
434 D.destroy(); // Free old strdup'd memory...
435 return N;
436 }
437 break;
438 default:
439 ThrowException("Internal parser error: Invalid symbol type reference!");
440 }
441
442 // If we reached here, we referenced either a symbol that we don't know about
443 // or an id number that hasn't been read yet. We may be referencing something
444 // forward, so just create an entry to be resolved later and get to it...
445 //
446 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
447
448
449 if (inFunctionScope()) {
450 if (D.Type == ValID::NameVal)
451 ThrowException("Reference to an undefined type: '" + D.getName() + "'");
452 else
453 ThrowException("Reference to an undefined type: #" + itostr(D.Num));
454 }
455
456 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
457 if (I != CurModule.LateResolveTypes.end())
458 return I->second;
459
460 Type *Typ = OpaqueType::get();
461 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
462 return Typ;
463 }
464
465static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
466 SymbolTable &SymTab =
467 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
468 CurModule.CurrentModule->getSymbolTable();
469 return SymTab.lookup(Ty, Name);
470}
471
472// getValNonImprovising - Look up the value specified by the provided type and
473// the provided ValID. If the value exists and has already been defined, return
474// it. Otherwise return null.
475//
476static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
477 if (isa<FunctionType>(Ty))
478 ThrowException("Functions are not values and "
479 "must be referenced as pointers");
480
481 switch (D.Type) {
482 case ValID::NumberVal: { // Is it a numbered definition?
483 unsigned Num = (unsigned)D.Num;
484
485 // Module constants occupy the lowest numbered slots...
486 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
487 if (VI != CurModule.Values.end()) {
488 if (Num < VI->second.size())
489 return VI->second[Num];
490 Num -= VI->second.size();
491 }
492
493 // Make sure that our type is within bounds
494 VI = CurFun.Values.find(Ty);
495 if (VI == CurFun.Values.end()) return 0;
496
497 // Check that the number is within bounds...
498 if (VI->second.size() <= Num) return 0;
499
500 return VI->second[Num];
501 }
502
503 case ValID::NameVal: { // Is it a named definition?
504 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
505 if (N == 0) return 0;
506
507 D.destroy(); // Free old strdup'd memory...
508 return N;
509 }
510
511 // Check to make sure that "Ty" is an integral type, and that our
512 // value will fit into the specified type...
513 case ValID::ConstSIntVal: // Is it a constant pool reference??
514 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
515 ThrowException("Signed integral constant '" +
516 itostr(D.ConstPool64) + "' is invalid for type '" +
517 Ty->getDescription() + "'!");
518 return ConstantSInt::get(Ty, D.ConstPool64);
519
520 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
521 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
522 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
523 ThrowException("Integral constant '" + utostr(D.UConstPool64) +
524 "' is invalid or out of range!");
525 } else { // This is really a signed reference. Transmogrify.
526 return ConstantSInt::get(Ty, D.ConstPool64);
527 }
528 } else {
529 return ConstantUInt::get(Ty, D.UConstPool64);
530 }
531
532 case ValID::ConstFPVal: // Is it a floating point const pool reference?
533 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
534 ThrowException("FP constant invalid for type!!");
535 return ConstantFP::get(Ty, D.ConstPoolFP);
536
537 case ValID::ConstNullVal: // Is it a null value?
538 if (!isa<PointerType>(Ty))
539 ThrowException("Cannot create a a non pointer null!");
540 return ConstantPointerNull::get(cast<PointerType>(Ty));
541
542 case ValID::ConstUndefVal: // Is it an undef value?
543 return UndefValue::get(Ty);
544
545 case ValID::ConstantVal: // Fully resolved constant?
546 if (D.ConstantValue->getType() != Ty)
547 ThrowException("Constant expression type different from required type!");
548 return D.ConstantValue;
549
550 default:
551 assert(0 && "Unhandled case!");
552 return 0;
553 } // End of switch
554
555 assert(0 && "Unhandled case!");
556 return 0;
557}
558
559// getVal - This function is identical to getValNonImprovising, except that if a
560// value is not already defined, it "improvises" by creating a placeholder var
561// that looks and acts just like the requested variable. When the value is
562// defined later, all uses of the placeholder variable are replaced with the
563// real thing.
564//
565static Value *getVal(const Type *Ty, const ValID &ID) {
566 if (Ty == Type::LabelTy)
567 ThrowException("Cannot use a basic block here");
568
569 // See if the value has already been defined.
570 Value *V = getValNonImprovising(Ty, ID);
571 if (V) return V;
572
573 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
574 ThrowException("Invalid use of a composite type!");
575
576 // If we reached here, we referenced either a symbol that we don't know about
577 // or an id number that hasn't been read yet. We may be referencing something
578 // forward, so just create an entry to be resolved later and get to it...
579 //
580 V = new Argument(Ty);
581
582 // Remember where this forward reference came from. FIXME, shouldn't we try
583 // to recycle these things??
584 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
585 llvmAsmlineno)));
586
587 if (inFunctionScope())
588 InsertValue(V, CurFun.LateResolveValues);
589 else
590 InsertValue(V, CurModule.LateResolveValues);
591 return V;
592}
593
594/// getBBVal - This is used for two purposes:
595/// * If isDefinition is true, a new basic block with the specified ID is being
596/// defined.
597/// * If isDefinition is true, this is a reference to a basic block, which may
598/// or may not be a forward reference.
599///
600static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
601 assert(inFunctionScope() && "Can't get basic block at global scope!");
602
603 std::string Name;
604 BasicBlock *BB = 0;
605 switch (ID.Type) {
606 default: ThrowException("Illegal label reference " + ID.getName());
607 case ValID::NumberVal: // Is it a numbered definition?
608 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
609 CurFun.NumberedBlocks.resize(ID.Num+1);
610 BB = CurFun.NumberedBlocks[ID.Num];
611 break;
612 case ValID::NameVal: // Is it a named definition?
613 Name = ID.Name;
614 if (Value *N = CurFun.CurrentFunction->
615 getSymbolTable().lookup(Type::LabelTy, Name))
616 BB = cast<BasicBlock>(N);
617 break;
618 }
619
620 // See if the block has already been defined.
621 if (BB) {
622 // If this is the definition of the block, make sure the existing value was
623 // just a forward reference. If it was a forward reference, there will be
624 // an entry for it in the PlaceHolderInfo map.
625 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
626 // The existing value was a definition, not a forward reference.
627 ThrowException("Redefinition of label " + ID.getName());
628
629 ID.destroy(); // Free strdup'd memory.
630 return BB;
631 }
632
633 // Otherwise this block has not been seen before.
634 BB = new BasicBlock("", CurFun.CurrentFunction);
635 if (ID.Type == ValID::NameVal) {
636 BB->setName(ID.Name);
637 } else {
638 CurFun.NumberedBlocks[ID.Num] = BB;
639 }
640
641 // If this is not a definition, keep track of it so we can use it as a forward
642 // reference.
643 if (!isDefinition) {
644 // Remember where this forward reference came from.
645 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
646 } else {
647 // The forward declaration could have been inserted anywhere in the
648 // function: insert it into the correct place now.
649 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
650 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
651 }
652 ID.destroy();
653 return BB;
654}
655
656
657//===----------------------------------------------------------------------===//
658// Code to handle forward references in instructions
659//===----------------------------------------------------------------------===//
660//
661// This code handles the late binding needed with statements that reference
662// values not defined yet... for example, a forward branch, or the PHI node for
663// a loop body.
664//
665// This keeps a table (CurFun.LateResolveValues) of all such forward references
666// and back patchs after we are done.
667//
668
669// ResolveDefinitions - If we could not resolve some defs at parsing
670// time (forward branches, phi functions for loops, etc...) resolve the
671// defs now...
672//
673static void
674ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
675 std::map<const Type*,ValueList> *FutureLateResolvers) {
676 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
677 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
678 E = LateResolvers.end(); LRI != E; ++LRI) {
679 ValueList &List = LRI->second;
680 while (!List.empty()) {
681 Value *V = List.back();
682 List.pop_back();
683
684 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
685 CurModule.PlaceHolderInfo.find(V);
686 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
687
688 ValID &DID = PHI->second.first;
689
690 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
691 if (TheRealValue) {
692 V->replaceAllUsesWith(TheRealValue);
693 delete V;
694 CurModule.PlaceHolderInfo.erase(PHI);
695 } else if (FutureLateResolvers) {
696 // Functions have their unresolved items forwarded to the module late
697 // resolver table
698 InsertValue(V, *FutureLateResolvers);
699 } else {
700 if (DID.Type == ValID::NameVal)
701 ThrowException("Reference to an invalid definition: '" +DID.getName()+
702 "' of type '" + V->getType()->getDescription() + "'",
703 PHI->second.second);
704 else
705 ThrowException("Reference to an invalid definition: #" +
706 itostr(DID.Num) + " of type '" +
707 V->getType()->getDescription() + "'",
708 PHI->second.second);
709 }
710 }
711 }
712
713 LateResolvers.clear();
714}
715
716// ResolveTypeTo - A brand new type was just declared. This means that (if
717// name is not null) things referencing Name can be resolved. Otherwise, things
718// refering to the number can be resolved. Do this now.
719//
720static void ResolveTypeTo(char *Name, const Type *ToTy) {
721 ValID D;
722 if (Name) D = ValID::create(Name);
723 else D = ValID::create((int)CurModule.Types.size());
724
725 std::map<ValID, PATypeHolder>::iterator I =
726 CurModule.LateResolveTypes.find(D);
727 if (I != CurModule.LateResolveTypes.end()) {
728 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
729 CurModule.LateResolveTypes.erase(I);
730 }
731}
732
733// setValueName - Set the specified value to the name given. The name may be
734// null potentially, in which case this is a noop. The string passed in is
735// assumed to be a malloc'd string buffer, and is free'd by this function.
736//
737static void setValueName(Value *V, char *NameStr) {
738 if (NameStr) {
739 std::string Name(NameStr); // Copy string
740 free(NameStr); // Free old string
741
742 if (V->getType() == Type::VoidTy)
743 ThrowException("Can't assign name '" + Name+"' to value with void type!");
744
745 assert(inFunctionScope() && "Must be in function scope!");
746 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
747 if (ST.lookup(V->getType(), Name))
748 ThrowException("Redefinition of value named '" + Name + "' in the '" +
749 V->getType()->getDescription() + "' type plane!");
750
751 // Set the name.
752 V->setName(Name);
753 }
754}
755
756/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
757/// this is a declaration, otherwise it is a definition.
758static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
759 bool isConstantGlobal, const Type *Ty,
760 Constant *Initializer) {
761 if (isa<FunctionType>(Ty))
762 ThrowException("Cannot declare global vars of function type!");
763
764 const PointerType *PTy = PointerType::get(Ty);
765
766 std::string Name;
767 if (NameStr) {
768 Name = NameStr; // Copy string
769 free(NameStr); // Free old string
770 }
771
772 // See if this global value was forward referenced. If so, recycle the
773 // object.
774 ValID ID;
775 if (!Name.empty()) {
776 ID = ValID::create((char*)Name.c_str());
777 } else {
778 ID = ValID::create((int)CurModule.Values[PTy].size());
779 }
780
781 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
782 // Move the global to the end of the list, from whereever it was
783 // previously inserted.
784 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
785 CurModule.CurrentModule->getGlobalList().remove(GV);
786 CurModule.CurrentModule->getGlobalList().push_back(GV);
787 GV->setInitializer(Initializer);
788 GV->setLinkage(Linkage);
789 GV->setConstant(isConstantGlobal);
790 InsertValue(GV, CurModule.Values);
791 return;
792 }
793
794 // If this global has a name, check to see if there is already a definition
795 // of this global in the module. If so, merge as appropriate. Note that
796 // this is really just a hack around problems in the CFE. :(
797 if (!Name.empty()) {
798 // We are a simple redefinition of a value, check to see if it is defined
799 // the same as the old one.
800 if (GlobalVariable *EGV =
801 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
802 // We are allowed to redefine a global variable in two circumstances:
803 // 1. If at least one of the globals is uninitialized or
804 // 2. If both initializers have the same value.
805 //
806 if (!EGV->hasInitializer() || !Initializer ||
807 EGV->getInitializer() == Initializer) {
808
809 // Make sure the existing global version gets the initializer! Make
810 // sure that it also gets marked const if the new version is.
811 if (Initializer && !EGV->hasInitializer())
812 EGV->setInitializer(Initializer);
813 if (isConstantGlobal)
814 EGV->setConstant(true);
815 EGV->setLinkage(Linkage);
816 return;
817 }
818
819 ThrowException("Redefinition of global variable named '" + Name +
820 "' in the '" + Ty->getDescription() + "' type plane!");
821 }
822 }
823
824 // Otherwise there is no existing GV to use, create one now.
825 GlobalVariable *GV =
826 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
827 CurModule.CurrentModule);
828 InsertValue(GV, CurModule.Values);
829}
830
831// setTypeName - Set the specified type to the name given. The name may be
832// null potentially, in which case this is a noop. The string passed in is
833// assumed to be a malloc'd string buffer, and is freed by this function.
834//
835// This function returns true if the type has already been defined, but is
836// allowed to be redefined in the specified context. If the name is a new name
837// for the type plane, it is inserted and false is returned.
838static bool setTypeName(const Type *T, char *NameStr) {
839 assert(!inFunctionScope() && "Can't give types function-local names!");
840 if (NameStr == 0) return false;
841
842 std::string Name(NameStr); // Copy string
843 free(NameStr); // Free old string
844
845 // We don't allow assigning names to void type
846 if (T == Type::VoidTy)
847 ThrowException("Can't assign name '" + Name + "' to the void type!");
848
849 // Set the type name, checking for conflicts as we do so.
850 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
851
852 if (AlreadyExists) { // Inserting a name that is already defined???
853 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
854 assert(Existing && "Conflict but no matching type?");
855
856 // There is only one case where this is allowed: when we are refining an
857 // opaque type. In this case, Existing will be an opaque type.
858 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
859 // We ARE replacing an opaque type!
860 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
861 return true;
862 }
863
864 // Otherwise, this is an attempt to redefine a type. That's okay if
865 // the redefinition is identical to the original. This will be so if
866 // Existing and T point to the same Type object. In this one case we
867 // allow the equivalent redefinition.
868 if (Existing == T) return true; // Yes, it's equal.
869
870 // Any other kind of (non-equivalent) redefinition is an error.
871 ThrowException("Redefinition of type named '" + Name + "' in the '" +
872 T->getDescription() + "' type plane!");
873 }
874
875 return false;
876}
877
878//===----------------------------------------------------------------------===//
879// Code for handling upreferences in type names...
880//
881
882// TypeContains - Returns true if Ty directly contains E in it.
883//
884static bool TypeContains(const Type *Ty, const Type *E) {
885 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
886 E) != Ty->subtype_end();
887}
888
889namespace {
890 struct UpRefRecord {
891 // NestingLevel - The number of nesting levels that need to be popped before
892 // this type is resolved.
893 unsigned NestingLevel;
894
895 // LastContainedTy - This is the type at the current binding level for the
896 // type. Every time we reduce the nesting level, this gets updated.
897 const Type *LastContainedTy;
898
899 // UpRefTy - This is the actual opaque type that the upreference is
900 // represented with.
901 OpaqueType *UpRefTy;
902
903 UpRefRecord(unsigned NL, OpaqueType *URTy)
904 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
905 };
906}
907
908// UpRefs - A list of the outstanding upreferences that need to be resolved.
909static std::vector<UpRefRecord> UpRefs;
910
911/// HandleUpRefs - Every time we finish a new layer of types, this function is
912/// called. It loops through the UpRefs vector, which is a list of the
913/// currently active types. For each type, if the up reference is contained in
914/// the newly completed type, we decrement the level count. When the level
915/// count reaches zero, the upreferenced type is the type that is passed in:
916/// thus we can complete the cycle.
917///
918static PATypeHolder HandleUpRefs(const Type *ty) {
919 if (!ty->isAbstract()) return ty;
920 PATypeHolder Ty(ty);
921 UR_OUT("Type '" << Ty->getDescription() <<
922 "' newly formed. Resolving upreferences.\n" <<
923 UpRefs.size() << " upreferences active!\n");
924
925 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
926 // to zero), we resolve them all together before we resolve them to Ty. At
927 // the end of the loop, if there is anything to resolve to Ty, it will be in
928 // this variable.
929 OpaqueType *TypeToResolve = 0;
930
931 for (unsigned i = 0; i != UpRefs.size(); ++i) {
932 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
933 << UpRefs[i].second->getDescription() << ") = "
934 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
935 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
936 // Decrement level of upreference
937 unsigned Level = --UpRefs[i].NestingLevel;
938 UpRefs[i].LastContainedTy = Ty;
939 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
940 if (Level == 0) { // Upreference should be resolved!
941 if (!TypeToResolve) {
942 TypeToResolve = UpRefs[i].UpRefTy;
943 } else {
944 UR_OUT(" * Resolving upreference for "
945 << UpRefs[i].second->getDescription() << "\n";
946 std::string OldName = UpRefs[i].UpRefTy->getDescription());
947 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
948 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
949 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
950 }
951 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
952 --i; // Do not skip the next element...
953 }
954 }
955 }
956
957 if (TypeToResolve) {
958 UR_OUT(" * Resolving upreference for "
959 << UpRefs[i].second->getDescription() << "\n";
960 std::string OldName = TypeToResolve->getDescription());
961 TypeToResolve->refineAbstractTypeTo(Ty);
962 }
963
964 return Ty;
965}
966
967
968// common code from the two 'RunVMAsmParser' functions
969 static Module * RunParser(Module * M) {
970
971 llvmAsmlineno = 1; // Reset the current line number...
972 ObsoleteVarArgs = false;
973 NewVarArgs = false;
974
975 CurModule.CurrentModule = M;
976 yyparse(); // Parse the file, potentially throwing exception
977
978 Module *Result = ParserResult;
979 ParserResult = 0;
980
981 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
982 {
983 Function* F;
984 if ((F = Result->getNamedFunction("llvm.va_start"))
985 && F->getFunctionType()->getNumParams() == 0)
986 ObsoleteVarArgs = true;
987 if((F = Result->getNamedFunction("llvm.va_copy"))
988 && F->getFunctionType()->getNumParams() == 1)
989 ObsoleteVarArgs = true;
990 }
991
992 if (ObsoleteVarArgs && NewVarArgs)
993 ThrowException("This file is corrupt: it uses both new and old style varargs");
994
995 if(ObsoleteVarArgs) {
996 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
997 if (F->arg_size() != 0)
998 ThrowException("Obsolete va_start takes 0 argument!");
999
1000 //foo = va_start()
1001 // ->
1002 //bar = alloca typeof(foo)
1003 //va_start(bar)
1004 //foo = load bar
1005
1006 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1007 const Type* ArgTy = F->getFunctionType()->getReturnType();
1008 const Type* ArgTyPtr = PointerType::get(ArgTy);
1009 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001010 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001011
1012 while (!F->use_empty()) {
1013 CallInst* CI = cast<CallInst>(F->use_back());
1014 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1015 new CallInst(NF, bar, "", CI);
1016 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1017 CI->replaceAllUsesWith(foo);
1018 CI->getParent()->getInstList().erase(CI);
1019 }
1020 Result->getFunctionList().erase(F);
1021 }
1022
1023 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1024 if(F->arg_size() != 1)
1025 ThrowException("Obsolete va_end takes 1 argument!");
1026
1027 //vaend foo
1028 // ->
1029 //bar = alloca 1 of typeof(foo)
1030 //vaend bar
1031 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1032 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1033 const Type* ArgTyPtr = PointerType::get(ArgTy);
1034 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001035 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001036
1037 while (!F->use_empty()) {
1038 CallInst* CI = cast<CallInst>(F->use_back());
1039 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1040 new StoreInst(CI->getOperand(1), bar, CI);
1041 new CallInst(NF, bar, "", CI);
1042 CI->getParent()->getInstList().erase(CI);
1043 }
1044 Result->getFunctionList().erase(F);
1045 }
1046
1047 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1048 if(F->arg_size() != 1)
1049 ThrowException("Obsolete va_copy takes 1 argument!");
1050 //foo = vacopy(bar)
1051 // ->
1052 //a = alloca 1 of typeof(foo)
1053 //b = alloca 1 of typeof(foo)
1054 //store bar -> b
1055 //vacopy(a, b)
1056 //foo = load a
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_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001062 RetTy, ArgTyPtr, ArgTyPtr,
1063 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001064
1065 while (!F->use_empty()) {
1066 CallInst* CI = cast<CallInst>(F->use_back());
1067 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1068 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1069 new StoreInst(CI->getOperand(1), b, CI);
1070 new CallInst(NF, a, b, "", CI);
1071 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1072 CI->replaceAllUsesWith(foo);
1073 CI->getParent()->getInstList().erase(CI);
1074 }
1075 Result->getFunctionList().erase(F);
1076 }
1077 }
1078
1079 return Result;
1080
1081 }
1082
1083//===----------------------------------------------------------------------===//
1084// RunVMAsmParser - Define an interface to this parser
1085//===----------------------------------------------------------------------===//
1086//
1087Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1088 set_scan_file(F);
1089
1090 CurFilename = Filename;
1091 return RunParser(new Module(CurFilename));
1092}
1093
1094Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1095 set_scan_string(AsmString);
1096
1097 CurFilename = "from_memory";
1098 if (M == NULL) {
1099 return RunParser(new Module (CurFilename));
1100 } else {
1101 return RunParser(M);
1102 }
1103}
1104
1105
1106
1107/* Enabling traces. */
1108#ifndef YYDEBUG
1109# define YYDEBUG 0
1110#endif
1111
1112/* Enabling verbose error messages. */
1113#ifdef YYERROR_VERBOSE
1114# undef YYERROR_VERBOSE
1115# define YYERROR_VERBOSE 1
1116#else
1117# define YYERROR_VERBOSE 0
1118#endif
1119
1120#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001121#line 866 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001122typedef union YYSTYPE {
1123 llvm::Module *ModuleVal;
1124 llvm::Function *FunctionVal;
1125 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
1126 llvm::BasicBlock *BasicBlockVal;
1127 llvm::TerminatorInst *TermInstVal;
1128 llvm::Instruction *InstVal;
1129 llvm::Constant *ConstVal;
1130
1131 const llvm::Type *PrimType;
1132 llvm::PATypeHolder *TypeVal;
1133 llvm::Value *ValueVal;
1134
1135 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1136 std::vector<llvm::Value*> *ValueList;
1137 std::list<llvm::PATypeHolder> *TypeList;
1138 // Represent the RHS of PHI node
1139 std::list<std::pair<llvm::Value*,
1140 llvm::BasicBlock*> > *PHIList;
1141 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1142 std::vector<llvm::Constant*> *ConstVector;
1143
1144 llvm::GlobalValue::LinkageTypes Linkage;
1145 int64_t SInt64Val;
1146 uint64_t UInt64Val;
1147 int SIntVal;
1148 unsigned UIntVal;
1149 double FPVal;
1150 bool BoolVal;
1151
1152 char *StrVal; // This memory is strdup'd!
1153 llvm::ValID ValIDVal; // strdup'd memory maybe!
1154
1155 llvm::Instruction::BinaryOps BinaryOpVal;
1156 llvm::Instruction::TermOps TermOpVal;
1157 llvm::Instruction::MemoryOps MemOpVal;
1158 llvm::Instruction::OtherOps OtherOpVal;
1159 llvm::Module::Endianness Endianness;
1160} YYSTYPE;
1161/* Line 191 of yacc.c. */
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001162#line 1163 "llvmAsmParser.tab.c"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001163# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1164# define YYSTYPE_IS_DECLARED 1
1165# define YYSTYPE_IS_TRIVIAL 1
1166#endif
1167
1168
1169
1170/* Copy the second part of user declarations. */
1171
1172
1173/* Line 214 of yacc.c. */
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001174#line 1175 "llvmAsmParser.tab.c"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001175
1176#if ! defined (yyoverflow) || YYERROR_VERBOSE
1177
1178# ifndef YYFREE
1179# define YYFREE free
1180# endif
1181# ifndef YYMALLOC
1182# define YYMALLOC malloc
1183# endif
1184
1185/* The parser invokes alloca or malloc; define the necessary symbols. */
1186
1187# ifdef YYSTACK_USE_ALLOCA
1188# if YYSTACK_USE_ALLOCA
1189# define YYSTACK_ALLOC alloca
1190# endif
1191# else
1192# if defined (alloca) || defined (_ALLOCA_H)
1193# define YYSTACK_ALLOC alloca
1194# else
1195# ifdef __GNUC__
1196# define YYSTACK_ALLOC __builtin_alloca
1197# endif
1198# endif
1199# endif
1200
1201# ifdef YYSTACK_ALLOC
1202 /* Pacify GCC's `empty if-body' warning. */
1203# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1204# else
1205# if defined (__STDC__) || defined (__cplusplus)
1206# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1207# define YYSIZE_T size_t
1208# endif
1209# define YYSTACK_ALLOC YYMALLOC
1210# define YYSTACK_FREE YYFREE
1211# endif
1212#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1213
1214
1215#if (! defined (yyoverflow) \
1216 && (! defined (__cplusplus) \
1217 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1218
1219/* A type that is properly aligned for any stack member. */
1220union yyalloc
1221{
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001222 short int yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001223 YYSTYPE yyvs;
1224 };
1225
1226/* The size of the maximum gap between one aligned stack and the next. */
1227# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1228
1229/* The size of an array large to enough to hold all stacks, each with
1230 N elements. */
1231# define YYSTACK_BYTES(N) \
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001232 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001233 + YYSTACK_GAP_MAXIMUM)
1234
1235/* Copy COUNT objects from FROM to TO. The source and destination do
1236 not overlap. */
1237# ifndef YYCOPY
1238# if defined (__GNUC__) && 1 < __GNUC__
1239# define YYCOPY(To, From, Count) \
1240 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1241# else
1242# define YYCOPY(To, From, Count) \
1243 do \
1244 { \
1245 register YYSIZE_T yyi; \
1246 for (yyi = 0; yyi < (Count); yyi++) \
1247 (To)[yyi] = (From)[yyi]; \
1248 } \
1249 while (0)
1250# endif
1251# endif
1252
1253/* Relocate STACK from its old location to the new one. The
1254 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1255 elements in the stack, and YYPTR gives the new location of the
1256 stack. Advance YYPTR to a properly aligned location for the next
1257 stack. */
1258# define YYSTACK_RELOCATE(Stack) \
1259 do \
1260 { \
1261 YYSIZE_T yynewbytes; \
1262 YYCOPY (&yyptr->Stack, Stack, yysize); \
1263 Stack = &yyptr->Stack; \
1264 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1265 yyptr += yynewbytes / sizeof (*yyptr); \
1266 } \
1267 while (0)
1268
1269#endif
1270
1271#if defined (__STDC__) || defined (__cplusplus)
1272 typedef signed char yysigned_char;
1273#else
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001274 typedef short int yysigned_char;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001275#endif
1276
1277/* YYFINAL -- State number of the termination state. */
1278#define YYFINAL 4
1279/* YYLAST -- Last index in YYTABLE. */
1280#define YYLAST 1102
1281
1282/* YYNTOKENS -- Number of terminals. */
1283#define YYNTOKENS 108
1284/* YYNNTS -- Number of nonterminals. */
1285#define YYNNTS 62
1286/* YYNRULES -- Number of rules. */
1287#define YYNRULES 212
1288/* YYNRULES -- Number of states. */
1289#define YYNSTATES 419
1290
1291/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1292#define YYUNDEFTOK 2
1293#define YYMAXUTOK 348
1294
1295#define YYTRANSLATE(YYX) \
1296 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1297
1298/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1299static const unsigned char yytranslate[] =
1300{
1301 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1302 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1303 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1304 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1305 96, 97, 105, 2, 106, 2, 2, 2, 2, 2,
1306 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1307 101, 94, 102, 2, 2, 2, 2, 2, 2, 2,
1308 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1309 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1310 2, 98, 95, 100, 2, 2, 2, 2, 2, 107,
1311 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1312 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1313 99, 2, 2, 103, 2, 104, 2, 2, 2, 2,
1314 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1315 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1316 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1317 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1318 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1319 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1320 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1321 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1322 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1323 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1324 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1325 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1326 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1327 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1328 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1329 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1330 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1331 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1332 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1333 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1334 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1335 85, 86, 87, 88, 89, 90, 91, 92, 93
1336};
1337
1338#if YYDEBUG
1339/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1340 YYRHS. */
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001341static const unsigned short int yyprhs[] =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001342{
1343 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1344 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1345 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1346 59, 61, 63, 65, 67, 70, 71, 73, 75, 77,
1347 79, 80, 81, 83, 85, 87, 90, 92, 94, 96,
1348 98, 100, 102, 104, 106, 108, 110, 112, 114, 116,
1349 118, 120, 122, 124, 126, 128, 130, 132, 135, 140,
1350 146, 152, 156, 159, 162, 164, 168, 170, 174, 176,
1351 177, 182, 186, 190, 195, 200, 204, 207, 210, 213,
1352 216, 219, 222, 225, 228, 231, 234, 241, 247, 256,
1353 263, 270, 277, 284, 288, 290, 292, 294, 296, 299,
1354 302, 305, 307, 312, 315, 321, 327, 331, 336, 337,
1355 339, 341, 345, 349, 353, 357, 361, 363, 364, 366,
1356 368, 370, 371, 374, 378, 380, 382, 386, 388, 389,
1357 396, 398, 400, 404, 406, 408, 411, 412, 416, 418,
1358 420, 422, 424, 426, 428, 430, 434, 436, 438, 440,
1359 442, 444, 447, 450, 453, 457, 460, 461, 463, 466,
1360 469, 473, 483, 493, 502, 516, 518, 520, 527, 533,
1361 536, 543, 551, 553, 557, 559, 560, 563, 565, 571,
1362 577, 583, 586, 591, 596, 603, 608, 613, 618, 621,
1363 629, 631, 634, 635, 637, 638, 641, 647, 650, 656,
1364 659, 664, 671
1365};
1366
1367/* YYRHS -- A `-1'-separated list of the rules' RHS. */
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001368static const short int yyrhs[] =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001369{
1370 133, 0, -1, 5, -1, 6, -1, 3, -1, 4,
1371 -1, 66, -1, 67, -1, 68, -1, 69, -1, 70,
1372 -1, 71, -1, 72, -1, 73, -1, 74, -1, 75,
1373 -1, 76, -1, 77, -1, 78, -1, 79, -1, 89,
1374 -1, 90, -1, 16, -1, 14, -1, 12, -1, 10,
1375 -1, 17, -1, 15, -1, 13, -1, 11, -1, 115,
1376 -1, 116, -1, 18, -1, 19, -1, 140, 94, -1,
1377 -1, 40, -1, 41, -1, 42, -1, 43, -1, -1,
1378 -1, 57, -1, 58, -1, 59, -1, 56, 4, -1,
1379 124, -1, 8, -1, 126, -1, 8, -1, 126, -1,
1380 9, -1, 10, -1, 11, -1, 12, -1, 13, -1,
1381 14, -1, 15, -1, 16, -1, 17, -1, 18, -1,
1382 19, -1, 20, -1, 21, -1, 44, -1, 125, -1,
1383 153, -1, 95, 4, -1, 123, 96, 128, 97, -1,
1384 98, 4, 99, 126, 100, -1, 101, 4, 99, 126,
1385 102, -1, 103, 127, 104, -1, 103, 104, -1, 126,
1386 105, -1, 126, -1, 127, 106, 126, -1, 127, -1,
1387 127, 106, 36, -1, 36, -1, -1, 124, 98, 131,
1388 100, -1, 124, 98, 100, -1, 124, 107, 24, -1,
1389 124, 101, 131, 102, -1, 124, 103, 131, 104, -1,
1390 124, 103, 104, -1, 124, 37, -1, 124, 38, -1,
1391 124, 153, -1, 124, 130, -1, 124, 26, -1, 115,
1392 110, -1, 116, 4, -1, 9, 27, -1, 9, 28,
1393 -1, 118, 7, -1, 87, 96, 129, 35, 124, 97,
1394 -1, 85, 96, 129, 167, 97, -1, 88, 96, 129,
1395 106, 129, 106, 129, 97, -1, 111, 96, 129, 106,
1396 129, 97, -1, 112, 96, 129, 106, 129, 97, -1,
1397 113, 96, 129, 106, 129, 97, -1, 114, 96, 129,
1398 106, 129, 97, -1, 131, 106, 129, -1, 129, -1,
1399 32, -1, 33, -1, 134, -1, 134, 149, -1, 134,
1400 150, -1, 134, 25, -1, 135, -1, 135, 119, 20,
1401 122, -1, 135, 150, -1, 135, 119, 120, 132, 129,
1402 -1, 135, 119, 46, 132, 124, -1, 135, 47, 137,
1403 -1, 135, 53, 94, 138, -1, -1, 52, -1, 51,
1404 -1, 49, 94, 136, -1, 50, 94, 4, -1, 48,
1405 94, 24, -1, 98, 139, 100, -1, 139, 106, 24,
1406 -1, 24, -1, -1, 22, -1, 24, -1, 140, -1,
1407 -1, 124, 141, -1, 143, 106, 142, -1, 142, -1,
1408 143, -1, 143, 106, 36, -1, 36, -1, -1, 121,
1409 122, 140, 96, 144, 97, -1, 29, -1, 103, -1,
1410 120, 145, 146, -1, 30, -1, 104, -1, 156, 148,
1411 -1, -1, 31, 151, 145, -1, 3, -1, 4, -1,
1412 7, -1, 27, -1, 28, -1, 37, -1, 38, -1,
1413 101, 131, 102, -1, 130, -1, 109, -1, 140, -1,
1414 153, -1, 152, -1, 124, 154, -1, 156, 157, -1,
1415 147, 157, -1, 158, 119, 159, -1, 158, 161, -1,
1416 -1, 23, -1, 60, 155, -1, 60, 8, -1, 61,
1417 21, 154, -1, 61, 9, 154, 106, 21, 154, 106,
1418 21, 154, -1, 62, 117, 154, 106, 21, 154, 98,
1419 160, 100, -1, 62, 117, 154, 106, 21, 154, 98,
1420 100, -1, 63, 121, 122, 154, 96, 164, 97, 35,
1421 21, 154, 64, 21, 154, -1, 64, -1, 65, -1,
1422 160, 117, 152, 106, 21, 154, -1, 117, 152, 106,
1423 21, 154, -1, 119, 166, -1, 124, 98, 154, 106,
1424 154, 100, -1, 162, 106, 98, 154, 106, 154, 100,
1425 -1, 155, -1, 163, 106, 155, -1, 163, -1, -1,
1426 55, 54, -1, 54, -1, 111, 124, 154, 106, 154,
1427 -1, 112, 124, 154, 106, 154, -1, 113, 124, 154,
1428 106, 154, -1, 45, 155, -1, 114, 155, 106, 155,
1429 -1, 87, 155, 35, 124, -1, 88, 155, 106, 155,
1430 106, 155, -1, 91, 155, 106, 124, -1, 92, 155,
1431 106, 124, -1, 93, 155, 106, 124, -1, 86, 162,
1432 -1, 165, 121, 122, 154, 96, 164, 97, -1, 169,
1433 -1, 106, 163, -1, -1, 34, -1, -1, 80, 124,
1434 -1, 80, 124, 106, 15, 154, -1, 81, 124, -1,
1435 81, 124, 106, 15, 154, -1, 82, 155, -1, 168,
1436 83, 124, 154, -1, 168, 84, 155, 106, 124, 154,
1437 -1, 85, 124, 154, 167, -1
1438};
1439
1440/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001441static const unsigned short int yyrline[] =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001442{
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001443 0, 983, 983, 984, 991, 992, 1001, 1001, 1001, 1001,
1444 1001, 1002, 1002, 1002, 1003, 1003, 1003, 1003, 1003, 1003,
1445 1005, 1005, 1009, 1009, 1009, 1009, 1010, 1010, 1010, 1010,
1446 1011, 1011, 1012, 1012, 1015, 1018, 1022, 1023, 1024, 1025,
1447 1026, 1028, 1029, 1030, 1031, 1032, 1045, 1045, 1046, 1046,
1448 1048, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1058, 1058,
1449 1058, 1058, 1058, 1058, 1059, 1062, 1065, 1071, 1078, 1090,
1450 1094, 1105, 1114, 1117, 1125, 1129, 1134, 1135, 1138, 1141,
1451 1151, 1176, 1189, 1217, 1242, 1262, 1274, 1283, 1287, 1346,
1452 1352, 1360, 1365, 1370, 1373, 1376, 1383, 1393, 1424, 1431,
1453 1452, 1459, 1464, 1474, 1477, 1484, 1484, 1494, 1501, 1505,
1454 1508, 1511, 1524, 1544, 1546, 1550, 1554, 1556, 1558, 1563,
1455 1564, 1566, 1569, 1577, 1582, 1584, 1588, 1592, 1600, 1600,
1456 1601, 1601, 1603, 1609, 1614, 1620, 1623, 1628, 1632, 1636,
1457 1716, 1716, 1718, 1726, 1726, 1728, 1732, 1732, 1741, 1744,
1458 1747, 1750, 1753, 1756, 1759, 1762, 1786, 1793, 1796, 1801,
1459 1801, 1807, 1811, 1814, 1822, 1831, 1835, 1845, 1856, 1859,
1460 1862, 1865, 1868, 1882, 1886, 1939, 1942, 1948, 1956, 1966,
1461 1973, 1978, 1985, 1989, 1995, 1995, 1997, 2000, 2006, 2018,
1462 2026, 2036, 2048, 2055, 2062, 2069, 2074, 2093, 2115, 2129,
1463 2186, 2192, 2194, 2198, 2201, 2207, 2211, 2215, 2219, 2223,
1464 2230, 2240, 2253
Reid Spencer68a24bd2005-08-27 18:50:39 +00001465};
1466#endif
1467
1468#if YYDEBUG || YYERROR_VERBOSE
1469/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1470 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1471static const char *const yytname[] =
1472{
1473 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1474 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
1475 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
1476 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1477 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1478 "DECLARE", "GLOBAL", "CONSTANT", "VOLATILE", "TO", "DOTDOTDOT",
1479 "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", "WEAK",
1480 "APPENDING", "OPAQUE", "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN",
1481 "POINTERSIZE", "LITTLE", "BIG", "DEPLIBS", "CALL", "TAIL", "CC_TOK",
1482 "CCC_TOK", "FASTCC_TOK", "COLDCC_TOK", "RET", "BR", "SWITCH", "INVOKE",
1483 "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "DIV", "REM", "AND", "OR",
1484 "XOR", "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "MALLOC",
1485 "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", "CAST",
1486 "SELECT", "SHL", "SHR", "VAARG", "VAARG_old", "VANEXT_old", "'='",
1487 "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'",
1488 "'*'", "','", "'c'", "$accept", "INTVAL", "EINT64VAL", "ArithmeticOps",
1489 "LogicalOps", "SetCondOps", "ShiftOps", "SIntType", "UIntType",
1490 "IntType", "FPType", "OptAssign", "OptLinkage", "OptCallingConv",
1491 "TypesV", "UpRTypesV", "Types", "PrimType", "UpRTypes", "TypeListI",
1492 "ArgTypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType",
1493 "Module", "FunctionList", "ConstPool", "BigOrLittle", "TargetDefinition",
1494 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
1495 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
1496 "END", "Function", "FunctionProto", "@1", "ConstValueRef",
1497 "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList",
1498 "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst",
1499 "PHIList", "ValueRefList", "ValueRefListE", "OptTailCall", "InstVal",
1500 "IndexList", "OptVolatile", "MemoryInst", 0
1501};
1502#endif
1503
1504# ifdef YYPRINT
1505/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1506 token YYLEX-NUM. */
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001507static const unsigned short int yytoknum[] =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001508{
1509 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1510 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1511 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1512 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1513 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1514 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1515 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1516 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1517 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1518 345, 346, 347, 348, 61, 92, 40, 41, 91, 120,
1519 93, 60, 62, 123, 125, 42, 44, 99
1520};
1521# endif
1522
1523/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1524static const unsigned char yyr1[] =
1525{
1526 0, 108, 109, 109, 110, 110, 111, 111, 111, 111,
1527 111, 112, 112, 112, 113, 113, 113, 113, 113, 113,
1528 114, 114, 115, 115, 115, 115, 116, 116, 116, 116,
1529 117, 117, 118, 118, 119, 119, 120, 120, 120, 120,
1530 120, 121, 121, 121, 121, 121, 122, 122, 123, 123,
1531 124, 125, 125, 125, 125, 125, 125, 125, 125, 125,
1532 125, 125, 125, 125, 126, 126, 126, 126, 126, 126,
1533 126, 126, 126, 126, 127, 127, 128, 128, 128, 128,
1534 129, 129, 129, 129, 129, 129, 129, 129, 129, 129,
1535 129, 129, 129, 129, 129, 129, 130, 130, 130, 130,
1536 130, 130, 130, 131, 131, 132, 132, 133, 134, 134,
1537 134, 134, 135, 135, 135, 135, 135, 135, 135, 136,
1538 136, 137, 137, 137, 138, 139, 139, 139, 140, 140,
1539 141, 141, 142, 143, 143, 144, 144, 144, 144, 145,
1540 146, 146, 147, 148, 148, 149, 151, 150, 152, 152,
1541 152, 152, 152, 152, 152, 152, 152, 153, 153, 154,
1542 154, 155, 156, 156, 157, 158, 158, 158, 159, 159,
1543 159, 159, 159, 159, 159, 159, 159, 160, 160, 161,
1544 162, 162, 163, 163, 164, 164, 165, 165, 166, 166,
1545 166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
1546 166, 167, 167, 168, 168, 169, 169, 169, 169, 169,
1547 169, 169, 169
1548};
1549
1550/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1551static const unsigned char yyr2[] =
1552{
1553 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1554 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1555 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1556 1, 1, 1, 1, 2, 0, 1, 1, 1, 1,
1557 0, 0, 1, 1, 1, 2, 1, 1, 1, 1,
1558 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1559 1, 1, 1, 1, 1, 1, 1, 2, 4, 5,
1560 5, 3, 2, 2, 1, 3, 1, 3, 1, 0,
1561 4, 3, 3, 4, 4, 3, 2, 2, 2, 2,
1562 2, 2, 2, 2, 2, 2, 6, 5, 8, 6,
1563 6, 6, 6, 3, 1, 1, 1, 1, 2, 2,
1564 2, 1, 4, 2, 5, 5, 3, 4, 0, 1,
1565 1, 3, 3, 3, 3, 3, 1, 0, 1, 1,
1566 1, 0, 2, 3, 1, 1, 3, 1, 0, 6,
1567 1, 1, 3, 1, 1, 2, 0, 3, 1, 1,
1568 1, 1, 1, 1, 1, 3, 1, 1, 1, 1,
1569 1, 2, 2, 2, 3, 2, 0, 1, 2, 2,
1570 3, 9, 9, 8, 13, 1, 1, 6, 5, 2,
1571 6, 7, 1, 3, 1, 0, 2, 1, 5, 5,
1572 5, 2, 4, 4, 6, 4, 4, 4, 2, 7,
1573 1, 2, 0, 1, 0, 2, 5, 2, 5, 2,
1574 4, 6, 4
1575};
1576
1577/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1578 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1579 means the default is an error. */
1580static const unsigned char yydefact[] =
1581{
1582 118, 0, 40, 111, 1, 110, 146, 36, 37, 38,
1583 39, 41, 166, 108, 109, 166, 128, 129, 0, 0,
1584 40, 0, 113, 41, 0, 42, 43, 44, 0, 0,
1585 167, 163, 35, 143, 144, 145, 162, 0, 0, 0,
1586 116, 0, 0, 0, 0, 34, 147, 45, 2, 3,
1587 47, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1588 60, 61, 62, 63, 64, 0, 0, 0, 0, 157,
1589 0, 0, 46, 65, 50, 158, 66, 140, 141, 142,
1590 204, 165, 0, 0, 0, 127, 117, 112, 105, 106,
1591 0, 0, 67, 0, 0, 49, 72, 74, 0, 0,
1592 79, 73, 203, 0, 187, 0, 0, 0, 0, 41,
1593 175, 176, 6, 7, 8, 9, 10, 11, 12, 13,
1594 14, 15, 16, 17, 18, 19, 0, 0, 0, 0,
1595 0, 0, 0, 20, 21, 0, 0, 0, 0, 0,
1596 0, 0, 164, 41, 179, 0, 200, 123, 120, 119,
1597 121, 122, 126, 0, 115, 51, 52, 53, 54, 55,
1598 56, 57, 58, 59, 60, 61, 0, 0, 0, 0,
1599 114, 0, 0, 71, 0, 138, 78, 76, 0, 0,
1600 191, 186, 169, 168, 0, 0, 25, 29, 24, 28,
1601 23, 27, 22, 26, 30, 31, 0, 0, 205, 207,
1602 209, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1603 0, 0, 0, 0, 0, 0, 124, 0, 93, 94,
1604 4, 5, 91, 92, 95, 90, 86, 87, 0, 0,
1605 0, 0, 0, 0, 0, 0, 0, 0, 0, 89,
1606 88, 48, 48, 75, 137, 131, 134, 135, 0, 0,
1607 68, 148, 149, 150, 151, 152, 153, 154, 0, 156,
1608 160, 159, 161, 0, 170, 0, 0, 0, 0, 202,
1609 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1610 0, 0, 0, 0, 125, 0, 0, 0, 81, 104,
1611 0, 0, 85, 0, 82, 0, 0, 0, 0, 69,
1612 70, 130, 132, 0, 139, 77, 0, 0, 0, 0,
1613 0, 0, 0, 212, 0, 0, 193, 0, 195, 196,
1614 197, 0, 0, 0, 192, 0, 210, 0, 202, 0,
1615 0, 80, 0, 83, 84, 0, 0, 0, 0, 136,
1616 133, 155, 0, 0, 185, 206, 208, 182, 201, 0,
1617 0, 0, 188, 189, 190, 185, 0, 0, 0, 0,
1618 103, 0, 0, 0, 0, 0, 0, 184, 0, 0,
1619 0, 0, 194, 0, 211, 97, 0, 0, 0, 0,
1620 0, 0, 0, 0, 0, 183, 180, 0, 199, 96,
1621 0, 99, 100, 101, 102, 0, 173, 0, 0, 0,
1622 181, 0, 171, 0, 172, 0, 0, 98, 0, 0,
1623 0, 0, 0, 0, 178, 0, 0, 177, 174
1624};
1625
1626/* YYDEFGOTO[NTERM-NUM]. */
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001627static const short int yydefgoto[] =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001628{
1629 -1, 69, 222, 235, 236, 237, 238, 166, 167, 196,
1630 168, 20, 11, 28, 70, 71, 169, 73, 74, 98,
1631 178, 289, 259, 290, 90, 1, 2, 3, 150, 40,
1632 86, 153, 75, 302, 246, 247, 248, 29, 79, 12,
1633 35, 13, 14, 23, 260, 76, 262, 347, 15, 31,
1634 32, 142, 398, 81, 203, 367, 368, 143, 144, 313,
1635 145, 146
1636};
1637
1638/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1639 STATE-NUM. */
1640#define YYPACT_NINF -383
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001641static const short int yypact[] =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001642{
1643 -383, 48, 136, 517, -383, -383, -383, -383, -383, -383,
1644 -383, 27, 36, -383, -383, -17, -383, -383, 46, -21,
1645 -3, 3, -383, 27, 73, -383, -383, -383, 879, -24,
1646 -383, -383, 113, -383, -383, -383, -383, 20, 51, 60,
1647 -383, 21, 879, -13, -13, -383, -383, -383, -383, -383,
1648 62, -383, -383, -383, -383, -383, -383, -383, -383, -383,
1649 -383, -383, -383, -383, -383, 156, 162, 164, 480, -383,
1650 113, 76, -383, -383, -25, -383, -383, -383, -383, -383,
1651 992, -383, 149, 37, 170, 157, -383, -383, -383, -383,
1652 900, 941, -383, 81, 83, -383, -383, -25, 34, 87,
1653 643, -383, -383, 900, -383, 130, 999, 32, 243, 27,
1654 -383, -383, -383, -383, -383, -383, -383, -383, -383, -383,
1655 -383, -383, -383, -383, -383, -383, 900, 900, 900, 900,
1656 900, 900, 900, -383, -383, 900, 900, 900, 900, 900,
1657 900, 900, -383, 27, -383, 22, -383, -383, -383, -383,
1658 -383, -383, -383, -82, -383, 122, 148, 184, 153, 185,
1659 159, 186, 161, 187, 191, 193, 167, 197, 195, 380,
1660 -383, 900, 900, -383, 900, 680, -383, 97, 114, 549,
1661 -383, -383, 62, -383, 549, 549, -383, -383, -383, -383,
1662 -383, -383, -383, -383, -383, -383, 549, 879, 108, 109,
1663 -383, 549, 118, 111, 183, 116, 117, 119, 121, 549,
1664 549, 549, 124, 879, 900, 900, -383, 196, -383, -383,
1665 -383, -383, -383, -383, -383, -383, -383, -383, 123, 132,
1666 135, 742, 941, 501, 208, 137, 144, 145, 147, -383,
1667 -383, -84, -12, -25, -383, 113, -383, 155, 154, 779,
1668 -383, -383, -383, -383, -383, -383, -383, -383, 941, -383,
1669 -383, -383, -383, 158, -383, 160, 549, 235, 247, 173,
1670 549, 165, 900, 900, 900, 900, 900, 174, 175, 176,
1671 900, 549, 549, 177, -383, 941, 941, 941, -383, -383,
1672 -54, -57, -383, 42, -383, 941, 941, 941, 941, -383,
1673 -383, -383, -383, 842, -383, -383, -30, 244, 246, 172,
1674 549, 549, 900, -383, 179, 549, -383, 180, -383, -383,
1675 -383, 549, 549, 549, -383, 194, -383, 900, 173, 241,
1676 181, -383, 941, -383, -383, 190, 198, 199, 202, -383,
1677 -383, -383, 549, 549, 900, -383, -383, -383, 205, 549,
1678 206, 900, -383, -383, -383, 900, 549, 192, 900, 941,
1679 -383, 941, 941, 941, 941, 207, 203, 205, 200, 900,
1680 214, 549, -383, 218, -383, -383, 220, 212, 222, 223,
1681 224, 225, 281, 17, 268, -383, -383, 226, -383, -383,
1682 941, -383, -383, -383, -383, 549, -383, 54, 53, 303,
1683 -383, 228, -383, 227, -383, 54, 549, -383, 307, 231,
1684 265, 549, 310, 311, -383, 549, 549, -383, -383
1685};
1686
1687/* YYPGOTO[NTERM-NUM]. */
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001688static const short int yypgoto[] =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001689{
1690 -383, -383, -383, 254, 262, 264, 272, -106, -105, -372,
1691 -383, 313, 333, -101, -38, -383, -28, -383, -56, 255,
1692 -383, -90, 188, -223, 312, -383, -383, -383, -383, -383,
1693 -383, -383, 4, -383, 55, -383, -383, 331, -383, -383,
1694 -383, -383, 356, -383, -382, 25, 28, -81, -383, 345,
1695 -383, -383, -383, -383, -383, 49, 7, -383, -383, 35,
1696 -383, -383
1697};
1698
1699/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1700 positive, shift that token. If negative, reduce the rule which
1701 number is the opposite. If zero, do what YYDEFACT says.
1702 If YYTABLE_NINF, syntax error. */
1703#define YYTABLE_NINF -108
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001704static const short int yytable[] =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001705{
1706 72, 170, 194, 195, 87, 77, 30, 21, 197, 291,
1707 293, 397, 97, 33, 72, 403, 299, 42, 216, 88,
1708 89, 101, 180, 409, 217, 183, 405, 186, 187, 188,
1709 189, 190, 191, 192, 193, 306, 21, 7, 8, 9,
1710 10, 184, 213, 43, 97, 333, 331, 200, 4, 332,
1711 204, 205, 332, 185, 206, 207, 208, 251, 252, 30,
1712 212, 253, 154, 186, 187, 188, 189, 190, 191, 192,
1713 193, -48, 341, 41, 99, 179, 332, 47, 179, 78,
1714 101, 254, 255, 24, 25, 26, 27, 34, 148, 149,
1715 300, 256, 257, 101, 37, 38, 39, 45, 198, 199,
1716 179, 201, 202, 179, 179, 214, 215, 179, 179, 179,
1717 209, 210, 211, 179, 82, 241, 242, 396, 243, 85,
1718 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
1719 122, 123, 124, 125, 283, 16, -107, 17, 173, 228,
1720 174, 229, 230, 133, 134, 83, 334, 245, 332, 218,
1721 219, -25, -25, 404, 84, 258, -24, -24, -49, 266,
1722 92, 5, -23, -23, -22, -22, 93, 6, 94, 72,
1723 220, 221, 100, 147, 151, 281, 7, 8, 9, 10,
1724 171, 152, 172, 175, 181, 72, 282, 179, -29, -28,
1725 -27, -26, 317, 243, 240, 328, 329, 330, -32, 324,
1726 -33, 223, 224, 249, 261, 335, 336, 337, 338, 261,
1727 261, 250, 263, 264, 267, 268, 270, 271, 272, 285,
1728 284, 261, 273, 274, 265, 275, 261, 276, 286, 269,
1729 280, 287, 294, 295, 261, 261, 261, 277, 278, 279,
1730 296, 297, 360, 298, 316, 179, 318, 319, 320, 301,
1731 310, 304, 179, 186, 187, 188, 189, 190, 191, 192,
1732 193, 303, 311, 315, 307, 342, 308, 343, 344, 377,
1733 372, 378, 379, 380, 381, 245, 358, 194, 195, 312,
1734 321, 322, 323, 327, 179, 349, 351, 359, 385, 375,
1735 355, 261, 194, 195, 309, 261, 361, 384, 314, 356,
1736 401, 383, 395, 399, 362, 363, 261, 261, 364, 325,
1737 326, 369, 371, 382, 386, 388, 179, 389, 390, 391,
1738 392, 393, 394, 179, 406, 407, 400, 179, 411, 413,
1739 376, 415, 416, 408, 138, 261, 261, 412, 345, 346,
1740 261, 179, 139, 350, 140, 80, 261, 261, 261, 352,
1741 353, 354, 141, 44, 46, 177, 91, 239, 340, 22,
1742 36, 348, 373, 357, 0, 0, 0, 261, 261, 0,
1743 365, 366, 0, 0, 261, 0, 0, 370, 0, 0,
1744 0, 261, 0, 0, 374, 48, 49, 0, 0, 0,
1745 0, 0, 0, 0, 0, 0, 261, 0, 0, 387,
1746 0, 0, 16, 0, 17, 0, 225, 0, 0, 0,
1747 0, 0, 0, 0, 0, 0, 0, 226, 227, 0,
1748 261, 0, 0, 402, 0, 0, 0, 0, 0, 0,
1749 0, 261, 0, 0, 410, 0, 261, 0, 0, 414,
1750 261, 261, 0, 417, 418, 0, 112, 113, 114, 115,
1751 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
1752 0, 0, 0, 0, 0, 228, 0, 229, 230, 133,
1753 134, 0, 0, 0, 0, 0, 0, 0, 231, 0,
1754 0, 232, 0, 233, 0, 48, 49, 234, 95, 51,
1755 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1756 62, 63, 16, 0, 17, 0, 48, 49, 0, 95,
1757 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
1758 165, 62, 63, 16, 64, 17, 0, 0, 0, 0,
1759 0, 0, 0, 0, 0, 0, 0, -35, 0, 16,
1760 0, 17, 0, 0, 0, 64, 0, 0, 6, -35,
1761 -35, 0, 251, 252, 48, 49, 253, -35, -35, -35,
1762 -35, 0, 0, -35, 18, 0, 0, 0, 0, 0,
1763 19, 16, 0, 17, 0, 65, 254, 255, 66, 0,
1764 0, 67, 0, 68, 96, 0, 256, 257, 0, 0,
1765 0, 0, 0, 0, 0, 0, 65, 0, 0, 66,
1766 0, 0, 67, 0, 68, 292, 0, 0, 0, 0,
1767 0, 0, 0, 0, 0, 112, 113, 114, 115, 116,
1768 117, 118, 119, 120, 121, 122, 123, 124, 125, 0,
1769 0, 0, 0, 0, 228, 0, 229, 230, 133, 134,
1770 0, 0, 0, 0, 0, 0, 0, 0, 48, 49,
1771 258, 95, 51, 52, 53, 54, 55, 56, 57, 58,
1772 59, 60, 61, 62, 63, 16, 0, 17, 0, 0,
1773 0, 0, 0, 0, 0, 0, 0, 0, 0, 176,
1774 0, 0, 0, 0, 0, 48, 49, 64, 95, 51,
1775 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1776 62, 63, 16, 0, 17, 0, 0, 0, 0, 0,
1777 0, 0, 0, 0, 0, 0, 244, 0, 0, 0,
1778 0, 0, 0, 0, 64, 0, 0, 0, 0, 0,
1779 0, 0, 0, 0, 0, 0, 0, 0, 65, 0,
1780 0, 66, 0, 0, 67, 0, 68, 48, 49, 0,
1781 95, 155, 156, 157, 158, 159, 160, 161, 162, 163,
1782 164, 165, 62, 63, 16, 0, 17, 0, 0, 0,
1783 0, 0, 0, 0, 0, 65, 0, 0, 66, 0,
1784 0, 67, 0, 68, 48, 49, 64, 95, 51, 52,
1785 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1786 63, 16, 0, 17, 0, 0, 0, 0, 0, 0,
1787 0, 0, 0, 0, 0, 305, 0, 0, 0, 0,
1788 0, 0, 0, 64, 0, 0, 0, 0, 0, 0,
1789 0, 0, 0, 0, 0, 0, 0, 65, 0, 0,
1790 66, 0, 288, 67, 0, 68, 0, 48, 49, 0,
1791 95, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1792 60, 61, 62, 63, 16, 0, 17, 0, 0, 0,
1793 0, 0, 0, 0, 65, 0, 0, 66, 339, 0,
1794 67, 0, 68, 0, 48, 49, 64, 50, 51, 52,
1795 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1796 63, 16, 0, 17, 0, 48, 49, 0, 95, 51,
1797 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
1798 62, 63, 16, 64, 17, 0, 0, 0, 0, 0,
1799 0, 0, 0, 0, 0, 0, 0, 65, 0, 0,
1800 66, 0, 0, 67, 64, 68, 48, 49, 0, 95,
1801 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
1802 165, 62, 63, 16, 0, 17, 0, 0, 0, 0,
1803 0, 0, 0, 0, 65, 0, 0, 66, 0, 0,
1804 67, 0, 68, 0, 0, 64, 0, 0, 0, 0,
1805 0, 0, 0, 0, 0, 65, 0, 0, 66, 0,
1806 0, 67, 0, 68, 48, 49, 0, 182, 51, 52,
1807 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
1808 63, 16, 0, 17, 0, 0, 102, 0, 0, 0,
1809 0, 0, 0, 0, 0, 0, 65, 103, 0, 66,
1810 0, 0, 67, 64, 68, 0, 104, 105, 0, 0,
1811 0, 0, 106, 107, 108, 109, 110, 111, 112, 113,
1812 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
1813 124, 125, 126, 127, 128, 0, 0, 129, 130, 131,
1814 132, 133, 134, 135, 136, 137, 0, 0, 0, 0,
1815 0, 0, 0, 0, 65, 0, 0, 66, 0, 0,
1816 67, 0, 68
1817};
1818
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001819static const short int yycheck[] =
Reid Spencer68a24bd2005-08-27 18:50:39 +00001820{
1821 28, 91, 108, 108, 42, 29, 23, 3, 109, 232,
1822 233, 383, 68, 30, 42, 397, 100, 20, 100, 32,
1823 33, 105, 103, 405, 106, 106, 398, 10, 11, 12,
1824 13, 14, 15, 16, 17, 258, 32, 40, 41, 42,
1825 43, 9, 143, 46, 100, 102, 100, 128, 0, 106,
1826 131, 132, 106, 21, 135, 136, 137, 3, 4, 23,
1827 141, 7, 90, 10, 11, 12, 13, 14, 15, 16,
1828 17, 96, 102, 94, 70, 103, 106, 4, 106, 103,
1829 105, 27, 28, 56, 57, 58, 59, 104, 51, 52,
1830 102, 37, 38, 105, 48, 49, 50, 94, 126, 127,
1831 128, 129, 130, 131, 132, 83, 84, 135, 136, 137,
1832 138, 139, 140, 141, 94, 171, 172, 100, 174, 98,
1833 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
1834 76, 77, 78, 79, 215, 22, 0, 24, 104, 85,
1835 106, 87, 88, 89, 90, 94, 104, 175, 106, 27,
1836 28, 3, 4, 100, 94, 101, 3, 4, 96, 197,
1837 4, 25, 3, 4, 3, 4, 4, 31, 4, 197,
1838 3, 4, 96, 24, 4, 213, 40, 41, 42, 43,
1839 99, 24, 99, 96, 54, 213, 214, 215, 4, 4,
1840 4, 4, 273, 249, 169, 285, 286, 287, 7, 280,
1841 7, 4, 7, 106, 179, 295, 296, 297, 298, 184,
1842 185, 97, 184, 185, 106, 106, 98, 106, 35, 96,
1843 24, 196, 106, 106, 196, 106, 201, 106, 96, 201,
1844 106, 96, 24, 96, 209, 210, 211, 209, 210, 211,
1845 96, 96, 332, 96, 272, 273, 274, 275, 276, 245,
1846 15, 97, 280, 10, 11, 12, 13, 14, 15, 16,
1847 17, 106, 15, 98, 106, 21, 106, 21, 96, 359,
1848 351, 361, 362, 363, 364, 303, 35, 383, 383, 106,
1849 106, 106, 106, 106, 312, 106, 106, 106, 369, 97,
1850 96, 266, 398, 398, 266, 270, 106, 97, 270, 327,
1851 390, 98, 21, 35, 106, 106, 281, 282, 106, 281,
1852 282, 106, 106, 106, 100, 97, 344, 97, 106, 97,
1853 97, 97, 97, 351, 21, 97, 100, 355, 21, 64,
1854 358, 21, 21, 106, 80, 310, 311, 106, 310, 311,
1855 315, 369, 80, 315, 80, 32, 321, 322, 323, 321,
1856 322, 323, 80, 20, 23, 100, 44, 169, 303, 3,
1857 15, 312, 355, 328, -1, -1, -1, 342, 343, -1,
1858 342, 343, -1, -1, 349, -1, -1, 349, -1, -1,
1859 -1, 356, -1, -1, 356, 5, 6, -1, -1, -1,
1860 -1, -1, -1, -1, -1, -1, 371, -1, -1, 371,
1861 -1, -1, 22, -1, 24, -1, 26, -1, -1, -1,
1862 -1, -1, -1, -1, -1, -1, -1, 37, 38, -1,
1863 395, -1, -1, 395, -1, -1, -1, -1, -1, -1,
1864 -1, 406, -1, -1, 406, -1, 411, -1, -1, 411,
1865 415, 416, -1, 415, 416, -1, 66, 67, 68, 69,
1866 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1867 -1, -1, -1, -1, -1, 85, -1, 87, 88, 89,
1868 90, -1, -1, -1, -1, -1, -1, -1, 98, -1,
1869 -1, 101, -1, 103, -1, 5, 6, 107, 8, 9,
1870 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1871 20, 21, 22, -1, 24, -1, 5, 6, -1, 8,
1872 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1873 19, 20, 21, 22, 44, 24, -1, -1, -1, -1,
1874 -1, -1, -1, -1, -1, -1, -1, 20, -1, 22,
1875 -1, 24, -1, -1, -1, 44, -1, -1, 31, 32,
1876 33, -1, 3, 4, 5, 6, 7, 40, 41, 42,
1877 43, -1, -1, 46, 47, -1, -1, -1, -1, -1,
1878 53, 22, -1, 24, -1, 95, 27, 28, 98, -1,
1879 -1, 101, -1, 103, 104, -1, 37, 38, -1, -1,
1880 -1, -1, -1, -1, -1, -1, 95, -1, -1, 98,
1881 -1, -1, 101, -1, 103, 104, -1, -1, -1, -1,
1882 -1, -1, -1, -1, -1, 66, 67, 68, 69, 70,
1883 71, 72, 73, 74, 75, 76, 77, 78, 79, -1,
1884 -1, -1, -1, -1, 85, -1, 87, 88, 89, 90,
1885 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
1886 101, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1887 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1888 -1, -1, -1, -1, -1, -1, -1, -1, -1, 36,
1889 -1, -1, -1, -1, -1, 5, 6, 44, 8, 9,
1890 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1891 20, 21, 22, -1, 24, -1, -1, -1, -1, -1,
1892 -1, -1, -1, -1, -1, -1, 36, -1, -1, -1,
1893 -1, -1, -1, -1, 44, -1, -1, -1, -1, -1,
1894 -1, -1, -1, -1, -1, -1, -1, -1, 95, -1,
1895 -1, 98, -1, -1, 101, -1, 103, 5, 6, -1,
1896 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1897 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1898 -1, -1, -1, -1, -1, 95, -1, -1, 98, -1,
1899 -1, 101, -1, 103, 5, 6, 44, 8, 9, 10,
1900 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1901 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
1902 -1, -1, -1, -1, -1, 36, -1, -1, -1, -1,
1903 -1, -1, -1, 44, -1, -1, -1, -1, -1, -1,
1904 -1, -1, -1, -1, -1, -1, -1, 95, -1, -1,
1905 98, -1, 100, 101, -1, 103, -1, 5, 6, -1,
1906 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1907 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1908 -1, -1, -1, -1, 95, -1, -1, 98, 36, -1,
1909 101, -1, 103, -1, 5, 6, 44, 8, 9, 10,
1910 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1911 21, 22, -1, 24, -1, 5, 6, -1, 8, 9,
1912 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1913 20, 21, 22, 44, 24, -1, -1, -1, -1, -1,
1914 -1, -1, -1, -1, -1, -1, -1, 95, -1, -1,
1915 98, -1, -1, 101, 44, 103, 5, 6, -1, 8,
1916 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1917 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1918 -1, -1, -1, -1, 95, -1, -1, 98, -1, -1,
1919 101, -1, 103, -1, -1, 44, -1, -1, -1, -1,
1920 -1, -1, -1, -1, -1, 95, -1, -1, 98, -1,
1921 -1, 101, -1, 103, 5, 6, -1, 8, 9, 10,
1922 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1923 21, 22, -1, 24, -1, -1, 34, -1, -1, -1,
1924 -1, -1, -1, -1, -1, -1, 95, 45, -1, 98,
1925 -1, -1, 101, 44, 103, -1, 54, 55, -1, -1,
1926 -1, -1, 60, 61, 62, 63, 64, 65, 66, 67,
1927 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1928 78, 79, 80, 81, 82, -1, -1, 85, 86, 87,
1929 88, 89, 90, 91, 92, 93, -1, -1, -1, -1,
1930 -1, -1, -1, -1, 95, -1, -1, 98, -1, -1,
1931 101, -1, 103
1932};
1933
1934/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1935 symbol of state STATE-NUM. */
1936static const unsigned char yystos[] =
1937{
1938 0, 133, 134, 135, 0, 25, 31, 40, 41, 42,
1939 43, 120, 147, 149, 150, 156, 22, 24, 47, 53,
1940 119, 140, 150, 151, 56, 57, 58, 59, 121, 145,
1941 23, 157, 158, 30, 104, 148, 157, 48, 49, 50,
1942 137, 94, 20, 46, 120, 94, 145, 4, 5, 6,
1943 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1944 18, 19, 20, 21, 44, 95, 98, 101, 103, 109,
1945 122, 123, 124, 125, 126, 140, 153, 29, 103, 146,
1946 119, 161, 94, 94, 94, 98, 138, 122, 32, 33,
1947 132, 132, 4, 4, 4, 8, 104, 126, 127, 140,
1948 96, 105, 34, 45, 54, 55, 60, 61, 62, 63,
1949 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
1950 74, 75, 76, 77, 78, 79, 80, 81, 82, 85,
1951 86, 87, 88, 89, 90, 91, 92, 93, 111, 112,
1952 113, 114, 159, 165, 166, 168, 169, 24, 51, 52,
1953 136, 4, 24, 139, 124, 9, 10, 11, 12, 13,
1954 14, 15, 16, 17, 18, 19, 115, 116, 118, 124,
1955 129, 99, 99, 104, 106, 96, 36, 127, 128, 124,
1956 155, 54, 8, 155, 9, 21, 10, 11, 12, 13,
1957 14, 15, 16, 17, 115, 116, 117, 121, 124, 124,
1958 155, 124, 124, 162, 155, 155, 155, 155, 155, 124,
1959 124, 124, 155, 121, 83, 84, 100, 106, 27, 28,
1960 3, 4, 110, 4, 7, 26, 37, 38, 85, 87,
1961 88, 98, 101, 103, 107, 111, 112, 113, 114, 130,
1962 153, 126, 126, 126, 36, 124, 142, 143, 144, 106,
1963 97, 3, 4, 7, 27, 28, 37, 38, 101, 130,
1964 152, 153, 154, 154, 154, 154, 122, 106, 106, 154,
1965 98, 106, 35, 106, 106, 106, 106, 154, 154, 154,
1966 106, 122, 124, 155, 24, 96, 96, 96, 100, 129,
1967 131, 131, 104, 131, 24, 96, 96, 96, 96, 100,
1968 102, 140, 141, 106, 97, 36, 131, 106, 106, 154,
1969 15, 15, 106, 167, 154, 98, 124, 155, 124, 124,
1970 124, 106, 106, 106, 155, 154, 154, 106, 129, 129,
1971 129, 100, 106, 102, 104, 129, 129, 129, 129, 36,
1972 142, 102, 21, 21, 96, 154, 154, 155, 163, 106,
1973 154, 106, 154, 154, 154, 96, 124, 167, 35, 106,
1974 129, 106, 106, 106, 106, 154, 154, 163, 164, 106,
1975 154, 106, 155, 164, 154, 97, 124, 129, 129, 129,
1976 129, 129, 106, 98, 97, 155, 100, 154, 97, 97,
1977 106, 97, 97, 97, 97, 21, 100, 117, 160, 35,
1978 100, 129, 154, 152, 100, 117, 21, 97, 106, 152,
1979 154, 21, 106, 64, 154, 21, 21, 154, 154
1980};
1981
1982#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1983# define YYSIZE_T __SIZE_TYPE__
1984#endif
1985#if ! defined (YYSIZE_T) && defined (size_t)
1986# define YYSIZE_T size_t
1987#endif
1988#if ! defined (YYSIZE_T)
1989# if defined (__STDC__) || defined (__cplusplus)
1990# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1991# define YYSIZE_T size_t
1992# endif
1993#endif
1994#if ! defined (YYSIZE_T)
1995# define YYSIZE_T unsigned int
1996#endif
1997
1998#define yyerrok (yyerrstatus = 0)
1999#define yyclearin (yychar = YYEMPTY)
2000#define YYEMPTY (-2)
2001#define YYEOF 0
2002
2003#define YYACCEPT goto yyacceptlab
2004#define YYABORT goto yyabortlab
2005#define YYERROR goto yyerrorlab
2006
2007
2008/* Like YYERROR except do call yyerror. This remains here temporarily
2009 to ease the transition to the new meaning of YYERROR, for GCC.
2010 Once GCC version 2 has supplanted version 1, this can go. */
2011
2012#define YYFAIL goto yyerrlab
2013
2014#define YYRECOVERING() (!!yyerrstatus)
2015
2016#define YYBACKUP(Token, Value) \
2017do \
2018 if (yychar == YYEMPTY && yylen == 1) \
2019 { \
2020 yychar = (Token); \
2021 yylval = (Value); \
2022 yytoken = YYTRANSLATE (yychar); \
2023 YYPOPSTACK; \
2024 goto yybackup; \
2025 } \
2026 else \
2027 { \
2028 yyerror ("syntax error: cannot back up");\
2029 YYERROR; \
2030 } \
2031while (0)
2032
2033#define YYTERROR 1
2034#define YYERRCODE 256
2035
2036/* YYLLOC_DEFAULT -- Compute the default location (before the actions
2037 are run). */
2038
2039#ifndef YYLLOC_DEFAULT
2040# define YYLLOC_DEFAULT(Current, Rhs, N) \
2041 ((Current).first_line = (Rhs)[1].first_line, \
2042 (Current).first_column = (Rhs)[1].first_column, \
2043 (Current).last_line = (Rhs)[N].last_line, \
2044 (Current).last_column = (Rhs)[N].last_column)
2045#endif
2046
2047/* YYLEX -- calling `yylex' with the right arguments. */
2048
2049#ifdef YYLEX_PARAM
2050# define YYLEX yylex (YYLEX_PARAM)
2051#else
2052# define YYLEX yylex ()
2053#endif
2054
2055/* Enable debugging if requested. */
2056#if YYDEBUG
2057
2058# ifndef YYFPRINTF
2059# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2060# define YYFPRINTF fprintf
2061# endif
2062
2063# define YYDPRINTF(Args) \
2064do { \
2065 if (yydebug) \
2066 YYFPRINTF Args; \
2067} while (0)
2068
2069# define YYDSYMPRINT(Args) \
2070do { \
2071 if (yydebug) \
2072 yysymprint Args; \
2073} while (0)
2074
2075# define YYDSYMPRINTF(Title, Token, Value, Location) \
2076do { \
2077 if (yydebug) \
2078 { \
2079 YYFPRINTF (stderr, "%s ", Title); \
2080 yysymprint (stderr, \
2081 Token, Value); \
2082 YYFPRINTF (stderr, "\n"); \
2083 } \
2084} while (0)
2085
2086/*------------------------------------------------------------------.
2087| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2088| TOP (included). |
2089`------------------------------------------------------------------*/
2090
2091#if defined (__STDC__) || defined (__cplusplus)
2092static void
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002093yy_stack_print (short int *bottom, short int *top)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002094#else
2095static void
2096yy_stack_print (bottom, top)
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002097 short int *bottom;
2098 short int *top;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002099#endif
2100{
2101 YYFPRINTF (stderr, "Stack now");
2102 for (/* Nothing. */; bottom <= top; ++bottom)
2103 YYFPRINTF (stderr, " %d", *bottom);
2104 YYFPRINTF (stderr, "\n");
2105}
2106
2107# define YY_STACK_PRINT(Bottom, Top) \
2108do { \
2109 if (yydebug) \
2110 yy_stack_print ((Bottom), (Top)); \
2111} while (0)
2112
2113
2114/*------------------------------------------------.
2115| Report that the YYRULE is going to be reduced. |
2116`------------------------------------------------*/
2117
2118#if defined (__STDC__) || defined (__cplusplus)
2119static void
2120yy_reduce_print (int yyrule)
2121#else
2122static void
2123yy_reduce_print (yyrule)
2124 int yyrule;
2125#endif
2126{
2127 int yyi;
2128 unsigned int yylno = yyrline[yyrule];
2129 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
2130 yyrule - 1, yylno);
2131 /* Print the symbols being reduced, and their result. */
2132 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2133 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
2134 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
2135}
2136
2137# define YY_REDUCE_PRINT(Rule) \
2138do { \
2139 if (yydebug) \
2140 yy_reduce_print (Rule); \
2141} while (0)
2142
2143/* Nonzero means print parse trace. It is left uninitialized so that
2144 multiple parsers can coexist. */
2145int yydebug;
2146#else /* !YYDEBUG */
2147# define YYDPRINTF(Args)
2148# define YYDSYMPRINT(Args)
2149# define YYDSYMPRINTF(Title, Token, Value, Location)
2150# define YY_STACK_PRINT(Bottom, Top)
2151# define YY_REDUCE_PRINT(Rule)
2152#endif /* !YYDEBUG */
2153
2154
2155/* YYINITDEPTH -- initial size of the parser's stacks. */
2156#ifndef YYINITDEPTH
2157# define YYINITDEPTH 200
2158#endif
2159
2160/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2161 if the built-in stack extension method is used).
2162
2163 Do not make this value too large; the results are undefined if
2164 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
2165 evaluated with infinite-precision integer arithmetic. */
2166
2167#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
2168# undef YYMAXDEPTH
2169#endif
2170
2171#ifndef YYMAXDEPTH
2172# define YYMAXDEPTH 10000
2173#endif
2174
2175
2176
2177#if YYERROR_VERBOSE
2178
2179# ifndef yystrlen
2180# if defined (__GLIBC__) && defined (_STRING_H)
2181# define yystrlen strlen
2182# else
2183/* Return the length of YYSTR. */
2184static YYSIZE_T
2185# if defined (__STDC__) || defined (__cplusplus)
2186yystrlen (const char *yystr)
2187# else
2188yystrlen (yystr)
2189 const char *yystr;
2190# endif
2191{
2192 register const char *yys = yystr;
2193
2194 while (*yys++ != '\0')
2195 continue;
2196
2197 return yys - yystr - 1;
2198}
2199# endif
2200# endif
2201
2202# ifndef yystpcpy
2203# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2204# define yystpcpy stpcpy
2205# else
2206/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2207 YYDEST. */
2208static char *
2209# if defined (__STDC__) || defined (__cplusplus)
2210yystpcpy (char *yydest, const char *yysrc)
2211# else
2212yystpcpy (yydest, yysrc)
2213 char *yydest;
2214 const char *yysrc;
2215# endif
2216{
2217 register char *yyd = yydest;
2218 register const char *yys = yysrc;
2219
2220 while ((*yyd++ = *yys++) != '\0')
2221 continue;
2222
2223 return yyd - 1;
2224}
2225# endif
2226# endif
2227
2228#endif /* !YYERROR_VERBOSE */
2229
2230
2231
2232#if YYDEBUG
2233/*--------------------------------.
2234| Print this symbol on YYOUTPUT. |
2235`--------------------------------*/
2236
2237#if defined (__STDC__) || defined (__cplusplus)
2238static void
2239yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
2240#else
2241static void
2242yysymprint (yyoutput, yytype, yyvaluep)
2243 FILE *yyoutput;
2244 int yytype;
2245 YYSTYPE *yyvaluep;
2246#endif
2247{
2248 /* Pacify ``unused variable'' warnings. */
2249 (void) yyvaluep;
2250
2251 if (yytype < YYNTOKENS)
2252 {
2253 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2254# ifdef YYPRINT
2255 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2256# endif
2257 }
2258 else
2259 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2260
2261 switch (yytype)
2262 {
2263 default:
2264 break;
2265 }
2266 YYFPRINTF (yyoutput, ")");
2267}
2268
2269#endif /* ! YYDEBUG */
2270/*-----------------------------------------------.
2271| Release the memory associated to this symbol. |
2272`-----------------------------------------------*/
2273
2274#if defined (__STDC__) || defined (__cplusplus)
2275static void
2276yydestruct (int yytype, YYSTYPE *yyvaluep)
2277#else
2278static void
2279yydestruct (yytype, yyvaluep)
2280 int yytype;
2281 YYSTYPE *yyvaluep;
2282#endif
2283{
2284 /* Pacify ``unused variable'' warnings. */
2285 (void) yyvaluep;
2286
2287 switch (yytype)
2288 {
2289
2290 default:
2291 break;
2292 }
2293}
2294
2295
2296/* Prevent warnings from -Wmissing-prototypes. */
2297
2298#ifdef YYPARSE_PARAM
2299# if defined (__STDC__) || defined (__cplusplus)
2300int yyparse (void *YYPARSE_PARAM);
2301# else
2302int yyparse ();
2303# endif
2304#else /* ! YYPARSE_PARAM */
2305#if defined (__STDC__) || defined (__cplusplus)
2306int yyparse (void);
2307#else
2308int yyparse ();
2309#endif
2310#endif /* ! YYPARSE_PARAM */
2311
2312
2313
2314/* The lookahead symbol. */
2315int yychar;
2316
2317/* The semantic value of the lookahead symbol. */
2318YYSTYPE yylval;
2319
2320/* Number of syntax errors so far. */
2321int yynerrs;
2322
2323
2324
2325/*----------.
2326| yyparse. |
2327`----------*/
2328
2329#ifdef YYPARSE_PARAM
2330# if defined (__STDC__) || defined (__cplusplus)
2331int yyparse (void *YYPARSE_PARAM)
2332# else
2333int yyparse (YYPARSE_PARAM)
2334 void *YYPARSE_PARAM;
2335# endif
2336#else /* ! YYPARSE_PARAM */
2337#if defined (__STDC__) || defined (__cplusplus)
2338int
2339yyparse (void)
2340#else
2341int
2342yyparse ()
2343
2344#endif
2345#endif
2346{
2347
2348 register int yystate;
2349 register int yyn;
2350 int yyresult;
2351 /* Number of tokens to shift before error messages enabled. */
2352 int yyerrstatus;
2353 /* Lookahead token as an internal (translated) token number. */
2354 int yytoken = 0;
2355
2356 /* Three stacks and their tools:
2357 `yyss': related to states,
2358 `yyvs': related to semantic values,
2359 `yyls': related to locations.
2360
2361 Refer to the stacks thru separate pointers, to allow yyoverflow
2362 to reallocate them elsewhere. */
2363
2364 /* The state stack. */
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002365 short int yyssa[YYINITDEPTH];
2366 short int *yyss = yyssa;
2367 register short int *yyssp;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002368
2369 /* The semantic value stack. */
2370 YYSTYPE yyvsa[YYINITDEPTH];
2371 YYSTYPE *yyvs = yyvsa;
2372 register YYSTYPE *yyvsp;
2373
2374
2375
2376#define YYPOPSTACK (yyvsp--, yyssp--)
2377
2378 YYSIZE_T yystacksize = YYINITDEPTH;
2379
2380 /* The variables used to return semantic value and location from the
2381 action routines. */
2382 YYSTYPE yyval;
2383
2384
2385 /* When reducing, the number of symbols on the RHS of the reduced
2386 rule. */
2387 int yylen;
2388
2389 YYDPRINTF ((stderr, "Starting parse\n"));
2390
2391 yystate = 0;
2392 yyerrstatus = 0;
2393 yynerrs = 0;
2394 yychar = YYEMPTY; /* Cause a token to be read. */
2395
2396 /* Initialize stack pointers.
2397 Waste one element of value and location stack
2398 so that they stay on the same level as the state stack.
2399 The wasted elements are never initialized. */
2400
2401 yyssp = yyss;
2402 yyvsp = yyvs;
2403
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002404
Reid Spencer68a24bd2005-08-27 18:50:39 +00002405 goto yysetstate;
2406
2407/*------------------------------------------------------------.
2408| yynewstate -- Push a new state, which is found in yystate. |
2409`------------------------------------------------------------*/
2410 yynewstate:
2411 /* In all cases, when you get here, the value and location stacks
2412 have just been pushed. so pushing a state here evens the stacks.
2413 */
2414 yyssp++;
2415
2416 yysetstate:
2417 *yyssp = yystate;
2418
2419 if (yyss + yystacksize - 1 <= yyssp)
2420 {
2421 /* Get the current used size of the three stacks, in elements. */
2422 YYSIZE_T yysize = yyssp - yyss + 1;
2423
2424#ifdef yyoverflow
2425 {
2426 /* Give user a chance to reallocate the stack. Use copies of
2427 these so that the &'s don't force the real ones into
2428 memory. */
2429 YYSTYPE *yyvs1 = yyvs;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002430 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002431
2432
2433 /* Each stack pointer address is followed by the size of the
2434 data in use in that stack, in bytes. This used to be a
2435 conditional around just the two extra args, but that might
2436 be undefined if yyoverflow is a macro. */
2437 yyoverflow ("parser stack overflow",
2438 &yyss1, yysize * sizeof (*yyssp),
2439 &yyvs1, yysize * sizeof (*yyvsp),
2440
2441 &yystacksize);
2442
2443 yyss = yyss1;
2444 yyvs = yyvs1;
2445 }
2446#else /* no yyoverflow */
2447# ifndef YYSTACK_RELOCATE
2448 goto yyoverflowlab;
2449# else
2450 /* Extend the stack our own way. */
2451 if (YYMAXDEPTH <= yystacksize)
2452 goto yyoverflowlab;
2453 yystacksize *= 2;
2454 if (YYMAXDEPTH < yystacksize)
2455 yystacksize = YYMAXDEPTH;
2456
2457 {
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002458 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002459 union yyalloc *yyptr =
2460 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2461 if (! yyptr)
2462 goto yyoverflowlab;
2463 YYSTACK_RELOCATE (yyss);
2464 YYSTACK_RELOCATE (yyvs);
2465
2466# undef YYSTACK_RELOCATE
2467 if (yyss1 != yyssa)
2468 YYSTACK_FREE (yyss1);
2469 }
2470# endif
2471#endif /* no yyoverflow */
2472
2473 yyssp = yyss + yysize - 1;
2474 yyvsp = yyvs + yysize - 1;
2475
2476
2477 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2478 (unsigned long int) yystacksize));
2479
2480 if (yyss + yystacksize - 1 <= yyssp)
2481 YYABORT;
2482 }
2483
2484 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
2485
2486 goto yybackup;
2487
2488/*-----------.
2489| yybackup. |
2490`-----------*/
2491yybackup:
2492
2493/* Do appropriate processing given the current state. */
2494/* Read a lookahead token if we need one and don't already have one. */
2495/* yyresume: */
2496
2497 /* First try to decide what to do without reference to lookahead token. */
2498
2499 yyn = yypact[yystate];
2500 if (yyn == YYPACT_NINF)
2501 goto yydefault;
2502
2503 /* Not known => get a lookahead token if don't already have one. */
2504
2505 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
2506 if (yychar == YYEMPTY)
2507 {
2508 YYDPRINTF ((stderr, "Reading a token: "));
2509 yychar = YYLEX;
2510 }
2511
2512 if (yychar <= YYEOF)
2513 {
2514 yychar = yytoken = YYEOF;
2515 YYDPRINTF ((stderr, "Now at end of input.\n"));
2516 }
2517 else
2518 {
2519 yytoken = YYTRANSLATE (yychar);
2520 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
2521 }
2522
2523 /* If the proper action on seeing token YYTOKEN is to reduce or to
2524 detect an error, take that action. */
2525 yyn += yytoken;
2526 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
2527 goto yydefault;
2528 yyn = yytable[yyn];
2529 if (yyn <= 0)
2530 {
2531 if (yyn == 0 || yyn == YYTABLE_NINF)
2532 goto yyerrlab;
2533 yyn = -yyn;
2534 goto yyreduce;
2535 }
2536
2537 if (yyn == YYFINAL)
2538 YYACCEPT;
2539
2540 /* Shift the lookahead token. */
2541 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
2542
2543 /* Discard the token being shifted unless it is eof. */
2544 if (yychar != YYEOF)
2545 yychar = YYEMPTY;
2546
2547 *++yyvsp = yylval;
2548
2549
2550 /* Count tokens shifted since error; after three, turn off error
2551 status. */
2552 if (yyerrstatus)
2553 yyerrstatus--;
2554
2555 yystate = yyn;
2556 goto yynewstate;
2557
2558
2559/*-----------------------------------------------------------.
2560| yydefault -- do the default action for the current state. |
2561`-----------------------------------------------------------*/
2562yydefault:
2563 yyn = yydefact[yystate];
2564 if (yyn == 0)
2565 goto yyerrlab;
2566 goto yyreduce;
2567
2568
2569/*-----------------------------.
2570| yyreduce -- Do a reduction. |
2571`-----------------------------*/
2572yyreduce:
2573 /* yyn is the number of a rule to reduce with. */
2574 yylen = yyr2[yyn];
2575
2576 /* If YYLEN is nonzero, implement the default value of the action:
2577 `$$ = $1'.
2578
2579 Otherwise, the following line sets YYVAL to garbage.
2580 This behavior is undocumented and Bison
2581 users should not rely upon it. Assigning to YYVAL
2582 unconditionally makes the parser a bit smaller, and it avoids a
2583 GCC warning that YYVAL may be used uninitialized. */
2584 yyval = yyvsp[1-yylen];
2585
2586
2587 YY_REDUCE_PRINT (yyn);
2588 switch (yyn)
2589 {
2590 case 3:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002591#line 984 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002592 {
2593 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
2594 ThrowException("Value too large for type!");
2595 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
2596;}
2597 break;
2598
2599 case 5:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002600#line 992 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002601 {
2602 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
2603 ThrowException("Value too large for type!");
2604 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
2605;}
2606 break;
2607
2608 case 34:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002609#line 1015 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002610 {
2611 yyval.StrVal = yyvsp[-1].StrVal;
2612 ;}
2613 break;
2614
2615 case 35:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002616#line 1018 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002617 {
2618 yyval.StrVal = 0;
2619 ;}
2620 break;
2621
2622 case 36:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002623#line 1022 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002624 { yyval.Linkage = GlobalValue::InternalLinkage; ;}
2625 break;
2626
2627 case 37:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002628#line 1023 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002629 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;}
2630 break;
2631
2632 case 38:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002633#line 1024 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002634 { yyval.Linkage = GlobalValue::WeakLinkage; ;}
2635 break;
2636
2637 case 39:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002638#line 1025 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002639 { yyval.Linkage = GlobalValue::AppendingLinkage; ;}
2640 break;
2641
2642 case 40:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002643#line 1026 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002644 { yyval.Linkage = GlobalValue::ExternalLinkage; ;}
2645 break;
2646
2647 case 41:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002648#line 1028 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002649 { yyval.UIntVal = CallingConv::C; ;}
2650 break;
2651
2652 case 42:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002653#line 1029 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002654 { yyval.UIntVal = CallingConv::C; ;}
2655 break;
2656
2657 case 43:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002658#line 1030 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002659 { yyval.UIntVal = CallingConv::Fast; ;}
2660 break;
2661
2662 case 44:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002663#line 1031 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002664 { yyval.UIntVal = CallingConv::Cold; ;}
2665 break;
2666
2667 case 45:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002668#line 1032 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002669 {
2670 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2671 ThrowException("Calling conv too large!");
2672 yyval.UIntVal = yyvsp[0].UInt64Val;
2673 ;}
2674 break;
2675
2676 case 47:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002677#line 1045 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002678 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;}
2679 break;
2680
2681 case 49:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002682#line 1046 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002683 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;}
2684 break;
2685
2686 case 50:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002687#line 1048 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002688 {
2689 if (!UpRefs.empty())
2690 ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2691 yyval.TypeVal = yyvsp[0].TypeVal;
2692 ;}
2693 break;
2694
2695 case 64:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002696#line 1059 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002697 {
2698 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2699 ;}
2700 break;
2701
2702 case 65:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002703#line 1062 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002704 {
2705 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2706 ;}
2707 break;
2708
2709 case 66:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002710#line 1065 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002711 { // Named types are also simple types...
2712 yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
2713;}
2714 break;
2715
2716 case 67:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002717#line 1071 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002718 { // Type UpReference
2719 if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2720 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2721 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2722 yyval.TypeVal = new PATypeHolder(OT);
2723 UR_OUT("New Upreference!\n");
2724 ;}
2725 break;
2726
2727 case 68:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002728#line 1078 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002729 { // Function derived type?
2730 std::vector<const Type*> Params;
2731 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2732 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2733 Params.push_back(*I);
2734 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2735 if (isVarArg) Params.pop_back();
2736
2737 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2738 delete yyvsp[-1].TypeList; // Delete the argument list
2739 delete yyvsp[-3].TypeVal; // Delete the return type handle
2740 ;}
2741 break;
2742
2743 case 69:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002744#line 1090 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002745 { // Sized array type?
2746 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2747 delete yyvsp[-1].TypeVal;
2748 ;}
2749 break;
2750
2751 case 70:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002752#line 1094 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002753 { // Packed array type?
2754 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2755 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) {
2756 ThrowException("Unsigned result not equal to signed result");
2757 }
2758 if(!ElemTy->isPrimitiveType()) {
2759 ThrowException("Elemental type of a PackedType must be primitive");
2760 }
2761 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2762 delete yyvsp[-1].TypeVal;
2763 ;}
2764 break;
2765
2766 case 71:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002767#line 1105 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002768 { // Structure type?
2769 std::vector<const Type*> Elements;
2770 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2771 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2772 Elements.push_back(*I);
2773
2774 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2775 delete yyvsp[-1].TypeList;
2776 ;}
2777 break;
2778
2779 case 72:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002780#line 1114 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002781 { // Empty structure type?
2782 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2783 ;}
2784 break;
2785
2786 case 73:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002787#line 1117 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002788 { // Pointer type?
2789 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2790 delete yyvsp[-1].TypeVal;
2791 ;}
2792 break;
2793
2794 case 74:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002795#line 1125 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002796 {
2797 yyval.TypeList = new std::list<PATypeHolder>();
2798 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2799 ;}
2800 break;
2801
2802 case 75:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002803#line 1129 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002804 {
2805 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2806 ;}
2807 break;
2808
2809 case 77:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002810#line 1135 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002811 {
2812 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
2813 ;}
2814 break;
2815
2816 case 78:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002817#line 1138 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002818 {
2819 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
2820 ;}
2821 break;
2822
2823 case 79:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002824#line 1141 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002825 {
2826 yyval.TypeList = new std::list<PATypeHolder>();
2827 ;}
2828 break;
2829
2830 case 80:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002831#line 1151 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002832 { // Nonempty unsized arr
2833 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2834 if (ATy == 0)
2835 ThrowException("Cannot make array constant with type: '" +
2836 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2837 const Type *ETy = ATy->getElementType();
2838 int NumElements = ATy->getNumElements();
2839
2840 // Verify that we have the correct size...
2841 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2842 ThrowException("Type mismatch: constant sized array initialized with " +
2843 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2844 itostr(NumElements) + "!");
2845
2846 // Verify all elements are correct type!
2847 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2848 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2849 ThrowException("Element #" + utostr(i) + " is not of type '" +
2850 ETy->getDescription() +"' as required!\nIt is of type '"+
2851 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2852 }
2853
2854 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2855 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2856 ;}
2857 break;
2858
2859 case 81:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002860#line 1176 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002861 {
2862 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2863 if (ATy == 0)
2864 ThrowException("Cannot make array constant with type: '" +
2865 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2866
2867 int NumElements = ATy->getNumElements();
2868 if (NumElements != -1 && NumElements != 0)
2869 ThrowException("Type mismatch: constant sized array initialized with 0"
2870 " arguments, but has size of " + itostr(NumElements) +"!");
2871 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2872 delete yyvsp[-2].TypeVal;
2873 ;}
2874 break;
2875
2876 case 82:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002877#line 1189 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002878 {
2879 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2880 if (ATy == 0)
2881 ThrowException("Cannot make array constant with type: '" +
2882 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2883
2884 int NumElements = ATy->getNumElements();
2885 const Type *ETy = ATy->getElementType();
2886 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2887 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2888 ThrowException("Can't build string constant of size " +
2889 itostr((int)(EndStr-yyvsp[0].StrVal)) +
2890 " when array has size " + itostr(NumElements) + "!");
2891 std::vector<Constant*> Vals;
2892 if (ETy == Type::SByteTy) {
2893 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2894 Vals.push_back(ConstantSInt::get(ETy, *C));
2895 } else if (ETy == Type::UByteTy) {
2896 for (char *C = yyvsp[0].StrVal; C != EndStr; ++C)
2897 Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C));
2898 } else {
2899 free(yyvsp[0].StrVal);
2900 ThrowException("Cannot build string arrays of non byte sized elements!");
2901 }
2902 free(yyvsp[0].StrVal);
2903 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2904 delete yyvsp[-2].TypeVal;
2905 ;}
2906 break;
2907
2908 case 83:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002909#line 1217 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002910 { // Nonempty unsized arr
2911 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2912 if (PTy == 0)
2913 ThrowException("Cannot make packed constant with type: '" +
2914 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2915 const Type *ETy = PTy->getElementType();
2916 int NumElements = PTy->getNumElements();
2917
2918 // Verify that we have the correct size...
2919 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2920 ThrowException("Type mismatch: constant sized packed initialized with " +
2921 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
2922 itostr(NumElements) + "!");
2923
2924 // Verify all elements are correct type!
2925 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2926 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2927 ThrowException("Element #" + utostr(i) + " is not of type '" +
2928 ETy->getDescription() +"' as required!\nIt is of type '"+
2929 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2930 }
2931
2932 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2933 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2934 ;}
2935 break;
2936
2937 case 84:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002938#line 1242 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002939 {
2940 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2941 if (STy == 0)
2942 ThrowException("Cannot make struct constant with type: '" +
2943 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2944
2945 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2946 ThrowException("Illegal number of initializers for structure type!");
2947
2948 // Check to ensure that constants are compatible with the type initializer!
2949 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2950 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2951 ThrowException("Expected type '" +
2952 STy->getElementType(i)->getDescription() +
2953 "' for element #" + utostr(i) +
2954 " of structure initializer!");
2955
2956 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2957 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2958 ;}
2959 break;
2960
2961 case 85:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002962#line 1262 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002963 {
2964 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2965 if (STy == 0)
2966 ThrowException("Cannot make struct constant with type: '" +
2967 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2968
2969 if (STy->getNumContainedTypes() != 0)
2970 ThrowException("Illegal number of initializers for structure type!");
2971
2972 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2973 delete yyvsp[-2].TypeVal;
2974 ;}
2975 break;
2976
2977 case 86:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002978#line 1274 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002979 {
2980 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2981 if (PTy == 0)
2982 ThrowException("Cannot make null pointer constant with type: '" +
2983 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2984
2985 yyval.ConstVal = ConstantPointerNull::get(PTy);
2986 delete yyvsp[-1].TypeVal;
2987 ;}
2988 break;
2989
2990 case 87:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002991#line 1283 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002992 {
2993 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2994 delete yyvsp[-1].TypeVal;
2995 ;}
2996 break;
2997
2998 case 88:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002999#line 1287 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003000 {
3001 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3002 if (Ty == 0)
3003 ThrowException("Global const reference must be a pointer type!");
3004
3005 // ConstExprs can exist in the body of a function, thus creating
3006 // GlobalValues whenever they refer to a variable. Because we are in
3007 // the context of a function, getValNonImprovising will search the functions
3008 // symbol table instead of the module symbol table for the global symbol,
3009 // which throws things all off. To get around this, we just tell
3010 // getValNonImprovising that we are at global scope here.
3011 //
3012 Function *SavedCurFn = CurFun.CurrentFunction;
3013 CurFun.CurrentFunction = 0;
3014
3015 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
3016
3017 CurFun.CurrentFunction = SavedCurFn;
3018
3019 // If this is an initializer for a constant pointer, which is referencing a
3020 // (currently) undefined variable, create a stub now that shall be replaced
3021 // in the future with the right type of variable.
3022 //
3023 if (V == 0) {
3024 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3025 const PointerType *PT = cast<PointerType>(Ty);
3026
3027 // First check to see if the forward references value is already created!
3028 PerModuleInfo::GlobalRefsType::iterator I =
3029 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
3030
3031 if (I != CurModule.GlobalRefs.end()) {
3032 V = I->second; // Placeholder already exists, use it...
3033 yyvsp[0].ValIDVal.destroy();
3034 } else {
3035 std::string Name;
3036 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
3037
3038 // Create the forward referenced global.
3039 GlobalValue *GV;
3040 if (const FunctionType *FTy =
3041 dyn_cast<FunctionType>(PT->getElementType())) {
3042 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3043 CurModule.CurrentModule);
3044 } else {
3045 GV = new GlobalVariable(PT->getElementType(), false,
3046 GlobalValue::ExternalLinkage, 0,
3047 Name, CurModule.CurrentModule);
3048 }
3049
3050 // Keep track of the fact that we have a forward ref to recycle it
3051 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
3052 V = GV;
3053 }
3054 }
3055
3056 yyval.ConstVal = cast<GlobalValue>(V);
3057 delete yyvsp[-1].TypeVal; // Free the type handle
3058 ;}
3059 break;
3060
3061 case 89:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003062#line 1346 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003063 {
3064 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
3065 ThrowException("Mismatched types for constant expression!");
3066 yyval.ConstVal = yyvsp[0].ConstVal;
3067 delete yyvsp[-1].TypeVal;
3068 ;}
3069 break;
3070
3071 case 90:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003072#line 1352 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003073 {
3074 const Type *Ty = yyvsp[-1].TypeVal->get();
3075 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3076 ThrowException("Cannot create a null initialized value of this type!");
3077 yyval.ConstVal = Constant::getNullValue(Ty);
3078 delete yyvsp[-1].TypeVal;
3079 ;}
3080 break;
3081
3082 case 91:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003083#line 1360 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003084 { // integral constants
3085 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
3086 ThrowException("Constant value doesn't fit in type!");
3087 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
3088 ;}
3089 break;
3090
3091 case 92:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003092#line 1365 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003093 { // integral constants
3094 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
3095 ThrowException("Constant value doesn't fit in type!");
3096 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
3097 ;}
3098 break;
3099
3100 case 93:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003101#line 1370 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003102 { // Boolean constants
3103 yyval.ConstVal = ConstantBool::True;
3104 ;}
3105 break;
3106
3107 case 94:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003108#line 1373 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003109 { // Boolean constants
3110 yyval.ConstVal = ConstantBool::False;
3111 ;}
3112 break;
3113
3114 case 95:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003115#line 1376 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003116 { // Float & Double constants
3117 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
3118 ThrowException("Floating point constant invalid for type!!");
3119 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
3120 ;}
3121 break;
3122
3123 case 96:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003124#line 1383 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003125 {
3126 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
3127 ThrowException("cast constant expression from a non-primitive type: '" +
3128 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
3129 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
3130 ThrowException("cast constant expression to a non-primitive type: '" +
3131 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
3132 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
3133 delete yyvsp[-1].TypeVal;
3134 ;}
3135 break;
3136
3137 case 97:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003138#line 1393 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003139 {
3140 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
3141 ThrowException("GetElementPtr requires a pointer operand!");
3142
3143 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3144 // indices to uint struct indices for compatibility.
3145 generic_gep_type_iterator<std::vector<Value*>::iterator>
3146 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
3147 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
3148 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
3149 if (isa<StructType>(*GTI)) // Only change struct indices
3150 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
3151 if (CUI->getType() == Type::UByteTy)
3152 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
3153
3154 const Type *IdxTy =
3155 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
3156 if (!IdxTy)
3157 ThrowException("Index list invalid for constant getelementptr!");
3158
3159 std::vector<Constant*> IdxVec;
3160 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3161 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
3162 IdxVec.push_back(C);
3163 else
3164 ThrowException("Indices to constant getelementptr must be constants!");
3165
3166 delete yyvsp[-1].ValueList;
3167
3168 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
3169 ;}
3170 break;
3171
3172 case 98:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003173#line 1424 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003174 {
3175 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
3176 ThrowException("Select condition must be of boolean type!");
3177 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3178 ThrowException("Select operand types must match!");
3179 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3180 ;}
3181 break;
3182
3183 case 99:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003184#line 1431 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003185 {
3186 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3187 ThrowException("Binary operator types must match!");
3188 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3189 // To retain backward compatibility with these early compilers, we emit a
3190 // cast to the appropriate integer type automatically if we are in the
3191 // broken case. See PR424 for more information.
3192 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
3193 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3194 } else {
3195 const Type *IntPtrTy = 0;
3196 switch (CurModule.CurrentModule->getPointerSize()) {
3197 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3198 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
3199 default: ThrowException("invalid pointer binary constant expr!");
3200 }
3201 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
3202 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
3203 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
3204 }
3205 ;}
3206 break;
3207
3208 case 100:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003209#line 1452 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003210 {
3211 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3212 ThrowException("Logical operator types must match!");
3213 if (!yyvsp[-3].ConstVal->getType()->isIntegral())
3214 ThrowException("Logical operands must have integral types!");
3215 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3216 ;}
3217 break;
3218
3219 case 101:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003220#line 1459 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003221 {
3222 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3223 ThrowException("setcc operand types must match!");
3224 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3225 ;}
3226 break;
3227
3228 case 102:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003229#line 1464 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003230 {
3231 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
3232 ThrowException("Shift count for shift constant must be unsigned byte!");
3233 if (!yyvsp[-3].ConstVal->getType()->isInteger())
3234 ThrowException("Shift constant expression requires integer operand!");
3235 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3236 ;}
3237 break;
3238
3239 case 103:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003240#line 1474 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003241 {
3242 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
3243 ;}
3244 break;
3245
3246 case 104:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003247#line 1477 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003248 {
3249 yyval.ConstVector = new std::vector<Constant*>();
3250 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
3251 ;}
3252 break;
3253
3254 case 105:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003255#line 1484 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003256 { yyval.BoolVal = false; ;}
3257 break;
3258
3259 case 106:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003260#line 1484 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003261 { yyval.BoolVal = true; ;}
3262 break;
3263
3264 case 107:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003265#line 1494 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003266 {
3267 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
3268 CurModule.ModuleDone();
3269;}
3270 break;
3271
3272 case 108:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003273#line 1501 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003274 {
3275 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3276 CurFun.FunctionDone();
3277 ;}
3278 break;
3279
3280 case 109:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003281#line 1505 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003282 {
3283 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3284 ;}
3285 break;
3286
3287 case 110:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003288#line 1508 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003289 {
3290 yyval.ModuleVal = yyvsp[-1].ModuleVal;
3291 ;}
3292 break;
3293
3294 case 111:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003295#line 1511 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003296 {
3297 yyval.ModuleVal = CurModule.CurrentModule;
3298 // Emit an error if there are any unresolved types left.
3299 if (!CurModule.LateResolveTypes.empty()) {
3300 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
3301 if (DID.Type == ValID::NameVal)
3302 ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
3303 else
3304 ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
3305 }
3306 ;}
3307 break;
3308
3309 case 112:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003310#line 1524 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003311 {
3312 // Eagerly resolve types. This is not an optimization, this is a
3313 // requirement that is due to the fact that we could have this:
3314 //
3315 // %list = type { %list * }
3316 // %list = type { %list * } ; repeated type decl
3317 //
3318 // If types are not resolved eagerly, then the two types will not be
3319 // determined to be the same type!
3320 //
3321 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
3322
3323 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3324 // If this is a named type that is not a redefinition, add it to the slot
3325 // table.
3326 CurModule.Types.push_back(*yyvsp[0].TypeVal);
3327 }
3328
3329 delete yyvsp[0].TypeVal;
3330 ;}
3331 break;
3332
3333 case 113:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003334#line 1544 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003335 { // Function prototypes can be in const pool
3336 ;}
3337 break;
3338
3339 case 114:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003340#line 1546 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003341 {
3342 if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
3343 ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
3344 ;}
3345 break;
3346
3347 case 115:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003348#line 1550 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003349 {
3350 ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3351 delete yyvsp[0].TypeVal;
3352 ;}
3353 break;
3354
3355 case 116:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003356#line 1554 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003357 {
3358 ;}
3359 break;
3360
3361 case 117:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003362#line 1556 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003363 {
3364 ;}
3365 break;
3366
3367 case 118:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003368#line 1558 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003369 {
3370 ;}
3371 break;
3372
3373 case 119:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003374#line 1563 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003375 { yyval.Endianness = Module::BigEndian; ;}
3376 break;
3377
3378 case 120:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003379#line 1564 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003380 { yyval.Endianness = Module::LittleEndian; ;}
3381 break;
3382
3383 case 121:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003384#line 1566 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003385 {
3386 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
3387 ;}
3388 break;
3389
3390 case 122:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003391#line 1569 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003392 {
3393 if (yyvsp[0].UInt64Val == 32)
3394 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3395 else if (yyvsp[0].UInt64Val == 64)
3396 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3397 else
3398 ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
3399 ;}
3400 break;
3401
3402 case 123:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003403#line 1577 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003404 {
3405 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3406 free(yyvsp[0].StrVal);
3407 ;}
3408 break;
3409
3410 case 125:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003411#line 1584 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003412 {
3413 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3414 free(yyvsp[0].StrVal);
3415 ;}
3416 break;
3417
3418 case 126:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003419#line 1588 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003420 {
3421 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3422 free(yyvsp[0].StrVal);
3423 ;}
3424 break;
3425
3426 case 127:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003427#line 1592 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003428 {
3429 ;}
3430 break;
3431
3432 case 131:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003433#line 1601 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003434 { yyval.StrVal = 0; ;}
3435 break;
3436
3437 case 132:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003438#line 1603 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003439 {
3440 if (*yyvsp[-1].TypeVal == Type::VoidTy)
3441 ThrowException("void typed arguments are invalid!");
3442 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
3443;}
3444 break;
3445
3446 case 133:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003447#line 1609 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003448 {
3449 yyval.ArgList = yyvsp[-2].ArgList;
3450 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3451 delete yyvsp[0].ArgVal;
3452 ;}
3453 break;
3454
3455 case 134:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003456#line 1614 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003457 {
3458 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3459 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3460 delete yyvsp[0].ArgVal;
3461 ;}
3462 break;
3463
3464 case 135:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003465#line 1620 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003466 {
3467 yyval.ArgList = yyvsp[0].ArgList;
3468 ;}
3469 break;
3470
3471 case 136:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003472#line 1623 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003473 {
3474 yyval.ArgList = yyvsp[-2].ArgList;
3475 yyval.ArgList->push_back(std::pair<PATypeHolder*,
3476 char*>(new PATypeHolder(Type::VoidTy), 0));
3477 ;}
3478 break;
3479
3480 case 137:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003481#line 1628 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003482 {
3483 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3484 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
3485 ;}
3486 break;
3487
3488 case 138:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003489#line 1632 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003490 {
3491 yyval.ArgList = 0;
3492 ;}
3493 break;
3494
3495 case 139:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003496#line 1636 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003497 {
3498 UnEscapeLexed(yyvsp[-3].StrVal);
3499 std::string FunctionName(yyvsp[-3].StrVal);
3500 free(yyvsp[-3].StrVal); // Free strdup'd memory!
3501
3502 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3503 ThrowException("LLVM functions cannot return aggregate types!");
3504
3505 std::vector<const Type*> ParamTypeList;
3506 if (yyvsp[-1].ArgList) { // If there are arguments...
3507 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-1].ArgList->begin();
3508 I != yyvsp[-1].ArgList->end(); ++I)
3509 ParamTypeList.push_back(I->first->get());
3510 }
3511
3512 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3513 if (isVarArg) ParamTypeList.pop_back();
3514
3515 const FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, ParamTypeList, isVarArg);
3516 const PointerType *PFT = PointerType::get(FT);
3517 delete yyvsp[-4].TypeVal;
3518
3519 ValID ID;
3520 if (!FunctionName.empty()) {
3521 ID = ValID::create((char*)FunctionName.c_str());
3522 } else {
3523 ID = ValID::create((int)CurModule.Values[PFT].size());
3524 }
3525
3526 Function *Fn = 0;
3527 // See if this function was forward referenced. If so, recycle the object.
3528 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3529 // Move the function to the end of the list, from whereever it was
3530 // previously inserted.
3531 Fn = cast<Function>(FWRef);
3532 CurModule.CurrentModule->getFunctionList().remove(Fn);
3533 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3534 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3535 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3536 // If this is the case, either we need to be a forward decl, or it needs
3537 // to be.
3538 if (!CurFun.isDeclare && !Fn->isExternal())
3539 ThrowException("Redefinition of function '" + FunctionName + "'!");
3540
3541 // Make sure to strip off any argument names so we can't get conflicts.
3542 if (Fn->isExternal())
3543 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3544 AI != AE; ++AI)
3545 AI->setName("");
3546
3547 } else { // Not already defined?
3548 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3549 CurModule.CurrentModule);
3550 InsertValue(Fn, CurModule.Values);
3551 }
3552
3553 CurFun.FunctionStart(Fn);
3554 Fn->setCallingConv(yyvsp[-5].UIntVal);
3555
3556 // Add all of the arguments we parsed to the function...
3557 if (yyvsp[-1].ArgList) { // Is null if empty...
3558 if (isVarArg) { // Nuke the last entry
3559 assert(yyvsp[-1].ArgList->back().first->get() == Type::VoidTy && yyvsp[-1].ArgList->back().second == 0&&
3560 "Not a varargs marker!");
3561 delete yyvsp[-1].ArgList->back().first;
3562 yyvsp[-1].ArgList->pop_back(); // Delete the last entry
3563 }
3564 Function::arg_iterator ArgIt = Fn->arg_begin();
3565 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-1].ArgList->begin();
3566 I != yyvsp[-1].ArgList->end(); ++I, ++ArgIt) {
3567 delete I->first; // Delete the typeholder...
3568
3569 setValueName(ArgIt, I->second); // Insert arg into symtab...
3570 InsertValue(ArgIt);
3571 }
3572
3573 delete yyvsp[-1].ArgList; // We're now done with the argument list
3574 }
3575;}
3576 break;
3577
3578 case 142:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003579#line 1718 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003580 {
3581 yyval.FunctionVal = CurFun.CurrentFunction;
3582
3583 // Make sure that we keep track of the linkage type even if there was a
3584 // previous "declare".
3585 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3586;}
3587 break;
3588
3589 case 145:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003590#line 1728 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003591 {
3592 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3593;}
3594 break;
3595
3596 case 146:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003597#line 1732 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003598 { CurFun.isDeclare = true; ;}
3599 break;
3600
3601 case 147:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003602#line 1732 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003603 {
3604 yyval.FunctionVal = CurFun.CurrentFunction;
3605 CurFun.FunctionDone();
3606;}
3607 break;
3608
3609 case 148:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003610#line 1741 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003611 { // A reference to a direct constant
3612 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
3613 ;}
3614 break;
3615
3616 case 149:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003617#line 1744 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003618 {
3619 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
3620 ;}
3621 break;
3622
3623 case 150:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003624#line 1747 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003625 { // Perhaps it's an FP constant?
3626 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
3627 ;}
3628 break;
3629
3630 case 151:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003631#line 1750 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003632 {
3633 yyval.ValIDVal = ValID::create(ConstantBool::True);
3634 ;}
3635 break;
3636
3637 case 152:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003638#line 1753 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003639 {
3640 yyval.ValIDVal = ValID::create(ConstantBool::False);
3641 ;}
3642 break;
3643
3644 case 153:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003645#line 1756 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003646 {
3647 yyval.ValIDVal = ValID::createNull();
3648 ;}
3649 break;
3650
3651 case 154:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003652#line 1759 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003653 {
3654 yyval.ValIDVal = ValID::createUndef();
3655 ;}
3656 break;
3657
3658 case 155:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003659#line 1762 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003660 { // Nonempty unsized packed vector
3661 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3662 int NumElements = yyvsp[-1].ConstVector->size();
3663
3664 PackedType* pt = PackedType::get(ETy, NumElements);
3665 PATypeHolder* PTy = new PATypeHolder(
3666 HandleUpRefs(
3667 PackedType::get(
3668 ETy,
3669 NumElements)
3670 )
3671 );
3672
3673 // Verify all elements are correct type!
3674 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3675 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3676 ThrowException("Element #" + utostr(i) + " is not of type '" +
3677 ETy->getDescription() +"' as required!\nIt is of type '" +
3678 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3679 }
3680
3681 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3682 delete PTy; delete yyvsp[-1].ConstVector;
3683 ;}
3684 break;
3685
3686 case 156:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003687#line 1786 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003688 {
3689 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
3690 ;}
3691 break;
3692
3693 case 157:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003694#line 1793 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003695 { // Is it an integer reference...?
3696 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
3697 ;}
3698 break;
3699
3700 case 158:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003701#line 1796 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003702 { // Is it a named reference...?
3703 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
3704 ;}
3705 break;
3706
3707 case 161:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003708#line 1807 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003709 {
3710 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
3711 ;}
3712 break;
3713
3714 case 162:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003715#line 1811 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003716 {
3717 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3718 ;}
3719 break;
3720
3721 case 163:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003722#line 1814 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003723 { // Do not allow functions with 0 basic blocks
3724 yyval.FunctionVal = yyvsp[-1].FunctionVal;
3725 ;}
3726 break;
3727
3728 case 164:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003729#line 1822 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003730 {
3731 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3732 InsertValue(yyvsp[0].TermInstVal);
3733
3734 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3735 InsertValue(yyvsp[-2].BasicBlockVal);
3736 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
3737 ;}
3738 break;
3739
3740 case 165:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003741#line 1831 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003742 {
3743 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3744 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
3745 ;}
3746 break;
3747
3748 case 166:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003749#line 1835 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003750 {
3751 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3752
3753 // Make sure to move the basic block to the correct location in the
3754 // function, instead of leaving it inserted wherever it was first
3755 // referenced.
3756 Function::BasicBlockListType &BBL =
3757 CurFun.CurrentFunction->getBasicBlockList();
3758 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3759 ;}
3760 break;
3761
3762 case 167:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003763#line 1845 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003764 {
3765 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3766
3767 // Make sure to move the basic block to the correct location in the
3768 // function, instead of leaving it inserted wherever it was first
3769 // referenced.
3770 Function::BasicBlockListType &BBL =
3771 CurFun.CurrentFunction->getBasicBlockList();
3772 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3773 ;}
3774 break;
3775
3776 case 168:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003777#line 1856 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003778 { // Return with a result...
3779 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
3780 ;}
3781 break;
3782
3783 case 169:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003784#line 1859 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003785 { // Return with no result...
3786 yyval.TermInstVal = new ReturnInst();
3787 ;}
3788 break;
3789
3790 case 170:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003791#line 1862 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003792 { // Unconditional Branch...
3793 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
3794 ;}
3795 break;
3796
3797 case 171:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003798#line 1865 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003799 {
3800 yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
3801 ;}
3802 break;
3803
3804 case 172:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003805#line 1868 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003806 {
3807 SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3808 yyval.TermInstVal = S;
3809
3810 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3811 E = yyvsp[-1].JumpTable->end();
3812 for (; I != E; ++I) {
3813 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3814 S->addCase(CI, I->second);
3815 else
3816 ThrowException("Switch case is constant, but not a simple integer!");
3817 }
3818 delete yyvsp[-1].JumpTable;
3819 ;}
3820 break;
3821
3822 case 173:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003823#line 1882 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003824 {
3825 SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3826 yyval.TermInstVal = S;
3827 ;}
3828 break;
3829
3830 case 174:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003831#line 1887 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003832 {
3833 const PointerType *PFTy;
3834 const FunctionType *Ty;
3835
3836 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3837 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3838 // Pull out the types of all of the arguments...
3839 std::vector<const Type*> ParamTypes;
3840 if (yyvsp[-7].ValueList) {
3841 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3842 I != E; ++I)
3843 ParamTypes.push_back((*I)->getType());
3844 }
3845
3846 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3847 if (isVarArg) ParamTypes.pop_back();
3848
3849 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3850 PFTy = PointerType::get(Ty);
3851 }
3852
3853 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
3854
3855 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3856 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3857
3858 // Create the call node...
3859 if (!yyvsp[-7].ValueList) { // Has no arguments?
3860 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3861 } else { // Has arguments?
3862 // Loop through FunctionType's arguments and ensure they are specified
3863 // correctly!
3864 //
3865 FunctionType::param_iterator I = Ty->param_begin();
3866 FunctionType::param_iterator E = Ty->param_end();
3867 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3868
3869 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3870 if ((*ArgI)->getType() != *I)
3871 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3872 (*I)->getDescription() + "'!");
3873
3874 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3875 ThrowException("Invalid number of parameters detected!");
3876
3877 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3878 }
3879 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3880
3881 delete yyvsp[-10].TypeVal;
3882 delete yyvsp[-7].ValueList;
3883 ;}
3884 break;
3885
3886 case 175:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003887#line 1939 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003888 {
3889 yyval.TermInstVal = new UnwindInst();
3890 ;}
3891 break;
3892
3893 case 176:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003894#line 1942 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003895 {
3896 yyval.TermInstVal = new UnreachableInst();
3897 ;}
3898 break;
3899
3900 case 177:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003901#line 1948 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003902 {
3903 yyval.JumpTable = yyvsp[-5].JumpTable;
3904 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3905 if (V == 0)
3906 ThrowException("May only switch on a constant pool value!");
3907
3908 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3909 ;}
3910 break;
3911
3912 case 178:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003913#line 1956 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003914 {
3915 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3916 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3917
3918 if (V == 0)
3919 ThrowException("May only switch on a constant pool value!");
3920
3921 yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3922 ;}
3923 break;
3924
3925 case 179:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003926#line 1966 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003927 {
3928 // Is this definition named?? if so, assign the name...
3929 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3930 InsertValue(yyvsp[0].InstVal);
3931 yyval.InstVal = yyvsp[0].InstVal;
3932;}
3933 break;
3934
3935 case 180:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003936#line 1973 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003937 { // Used for PHI nodes
3938 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3939 yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3940 delete yyvsp[-5].TypeVal;
3941 ;}
3942 break;
3943
3944 case 181:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003945#line 1978 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003946 {
3947 yyval.PHIList = yyvsp[-6].PHIList;
3948 yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3949 getBBVal(yyvsp[-1].ValIDVal)));
3950 ;}
3951 break;
3952
3953 case 182:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003954#line 1985 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003955 { // Used for call statements, and memory insts...
3956 yyval.ValueList = new std::vector<Value*>();
3957 yyval.ValueList->push_back(yyvsp[0].ValueVal);
3958 ;}
3959 break;
3960
3961 case 183:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003962#line 1989 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003963 {
3964 yyval.ValueList = yyvsp[-2].ValueList;
3965 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
3966 ;}
3967 break;
3968
3969 case 185:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003970#line 1995 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003971 { yyval.ValueList = 0; ;}
3972 break;
3973
3974 case 186:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003975#line 1997 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003976 {
3977 yyval.BoolVal = true;
3978 ;}
3979 break;
3980
3981 case 187:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003982#line 2000 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003983 {
3984 yyval.BoolVal = false;
3985 ;}
3986 break;
3987
3988 case 188:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00003989#line 2006 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003990 {
3991 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
3992 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3993 ThrowException(
3994 "Arithmetic operator requires integer, FP, or packed operands!");
3995 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3996 ThrowException("Rem not supported on packed types!");
3997 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3998 if (yyval.InstVal == 0)
3999 ThrowException("binary operator returned null!");
4000 delete yyvsp[-3].TypeVal;
4001 ;}
4002 break;
4003
4004 case 189:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004005#line 2018 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004006 {
4007 if (!(*yyvsp[-3].TypeVal)->isIntegral())
4008 ThrowException("Logical operator requires integral operands!");
4009 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
4010 if (yyval.InstVal == 0)
4011 ThrowException("binary operator returned null!");
4012 delete yyvsp[-3].TypeVal;
4013 ;}
4014 break;
4015
4016 case 190:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004017#line 2026 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004018 {
4019 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
4020 ThrowException(
4021 "PackedTypes currently not supported in setcc instructions!");
4022 }
4023 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
4024 if (yyval.InstVal == 0)
4025 ThrowException("binary operator returned null!");
4026 delete yyvsp[-3].TypeVal;
4027 ;}
4028 break;
4029
4030 case 191:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004031#line 2036 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004032 {
4033 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
4034 << " Replacing with 'xor'.\n";
4035
4036 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
4037 if (Ones == 0)
4038 ThrowException("Expected integral type for not instruction!");
4039
4040 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
4041 if (yyval.InstVal == 0)
4042 ThrowException("Could not create a xor instruction!");
4043 ;}
4044 break;
4045
4046 case 192:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004047#line 2048 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004048 {
4049 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
4050 ThrowException("Shift amount must be ubyte!");
4051 if (!yyvsp[-2].ValueVal->getType()->isInteger())
4052 ThrowException("Shift constant expression requires integer operand!");
4053 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4054 ;}
4055 break;
4056
4057 case 193:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004058#line 2055 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004059 {
4060 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
4061 ThrowException("cast instruction to a non-primitive type: '" +
4062 yyvsp[0].TypeVal->get()->getDescription() + "'!");
4063 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4064 delete yyvsp[0].TypeVal;
4065 ;}
4066 break;
4067
4068 case 194:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004069#line 2062 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004070 {
4071 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
4072 ThrowException("select condition must be boolean!");
4073 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
4074 ThrowException("select value types should match!");
4075 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4076 ;}
4077 break;
4078
4079 case 195:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004080#line 2069 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004081 {
4082 NewVarArgs = true;
4083 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4084 delete yyvsp[0].TypeVal;
4085 ;}
4086 break;
4087
4088 case 196:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004089#line 2074 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004090 {
4091 ObsoleteVarArgs = true;
4092 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
4093 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004094 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004095
4096 //b = vaarg a, t ->
4097 //foo = alloca 1 of t
4098 //bar = vacopy a
4099 //store bar -> foo
4100 //b = vaarg foo, t
4101 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
4102 CurBB->getInstList().push_back(foo);
4103 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
4104 CurBB->getInstList().push_back(bar);
4105 CurBB->getInstList().push_back(new StoreInst(bar, foo));
4106 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
4107 delete yyvsp[0].TypeVal;
4108 ;}
4109 break;
4110
4111 case 197:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004112#line 2093 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004113 {
4114 ObsoleteVarArgs = true;
4115 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
4116 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004117 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004118
4119 //b = vanext a, t ->
4120 //foo = alloca 1 of t
4121 //bar = vacopy a
4122 //store bar -> foo
4123 //tmp = vaarg foo, t
4124 //b = load foo
4125 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
4126 CurBB->getInstList().push_back(foo);
4127 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
4128 CurBB->getInstList().push_back(bar);
4129 CurBB->getInstList().push_back(new StoreInst(bar, foo));
4130 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
4131 CurBB->getInstList().push_back(tmp);
4132 yyval.InstVal = new LoadInst(foo);
4133 delete yyvsp[0].TypeVal;
4134 ;}
4135 break;
4136
4137 case 198:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004138#line 2115 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004139 {
4140 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
4141 if (!Ty->isFirstClassType())
4142 ThrowException("PHI node operands must be of first class type!");
4143 yyval.InstVal = new PHINode(Ty);
4144 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4145 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4146 if (yyvsp[0].PHIList->front().first->getType() != Ty)
4147 ThrowException("All elements of a PHI node must be of the same type!");
4148 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4149 yyvsp[0].PHIList->pop_front();
4150 }
4151 delete yyvsp[0].PHIList; // Free the list...
4152 ;}
4153 break;
4154
4155 case 199:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004156#line 2129 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004157 {
4158 const PointerType *PFTy;
4159 const FunctionType *Ty;
4160
4161 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
4162 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4163 // Pull out the types of all of the arguments...
4164 std::vector<const Type*> ParamTypes;
4165 if (yyvsp[-1].ValueList) {
4166 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
4167 I != E; ++I)
4168 ParamTypes.push_back((*I)->getType());
4169 }
4170
4171 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4172 if (isVarArg) ParamTypes.pop_back();
4173
4174 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
4175 ThrowException("LLVM functions cannot return aggregate types!");
4176
4177 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
4178 PFTy = PointerType::get(Ty);
4179 }
4180
4181 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
4182
4183 // Create the call node...
4184 if (!yyvsp[-1].ValueList) { // Has no arguments?
4185 // Make sure no arguments is a good thing!
4186 if (Ty->getNumParams() != 0)
4187 ThrowException("No arguments passed to a function that "
4188 "expects arguments!");
4189
4190 yyval.InstVal = new CallInst(V, std::vector<Value*>());
4191 } else { // Has arguments?
4192 // Loop through FunctionType's arguments and ensure they are specified
4193 // correctly!
4194 //
4195 FunctionType::param_iterator I = Ty->param_begin();
4196 FunctionType::param_iterator E = Ty->param_end();
4197 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
4198
4199 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4200 if ((*ArgI)->getType() != *I)
4201 ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
4202 (*I)->getDescription() + "'!");
4203
4204 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
4205 ThrowException("Invalid number of parameters detected!");
4206
4207 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
4208 }
4209 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
4210 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
4211 delete yyvsp[-4].TypeVal;
4212 delete yyvsp[-1].ValueList;
4213 ;}
4214 break;
4215
4216 case 200:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004217#line 2186 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004218 {
4219 yyval.InstVal = yyvsp[0].InstVal;
4220 ;}
4221 break;
4222
4223 case 201:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004224#line 2192 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004225 {
4226 yyval.ValueList = yyvsp[0].ValueList;
4227 ;}
4228 break;
4229
4230 case 202:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004231#line 2194 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004232 {
4233 yyval.ValueList = new std::vector<Value*>();
4234 ;}
4235 break;
4236
4237 case 203:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004238#line 2198 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004239 {
4240 yyval.BoolVal = true;
4241 ;}
4242 break;
4243
4244 case 204:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004245#line 2201 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004246 {
4247 yyval.BoolVal = false;
4248 ;}
4249 break;
4250
4251 case 205:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004252#line 2207 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004253 {
4254 yyval.InstVal = new MallocInst(*yyvsp[0].TypeVal);
4255 delete yyvsp[0].TypeVal;
4256 ;}
4257 break;
4258
4259 case 206:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004260#line 2211 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004261 {
4262 yyval.InstVal = new MallocInst(*yyvsp[-3].TypeVal, getVal(yyvsp[-1].PrimType, yyvsp[0].ValIDVal));
4263 delete yyvsp[-3].TypeVal;
4264 ;}
4265 break;
4266
4267 case 207:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004268#line 2215 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004269 {
4270 yyval.InstVal = new AllocaInst(*yyvsp[0].TypeVal);
4271 delete yyvsp[0].TypeVal;
4272 ;}
4273 break;
4274
4275 case 208:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004276#line 2219 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004277 {
4278 yyval.InstVal = new AllocaInst(*yyvsp[-3].TypeVal, getVal(yyvsp[-1].PrimType, yyvsp[0].ValIDVal));
4279 delete yyvsp[-3].TypeVal;
4280 ;}
4281 break;
4282
4283 case 209:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004284#line 2223 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004285 {
4286 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
4287 ThrowException("Trying to free nonpointer type " +
4288 yyvsp[0].ValueVal->getType()->getDescription() + "!");
4289 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
4290 ;}
4291 break;
4292
4293 case 210:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004294#line 2230 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004295 {
4296 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
4297 ThrowException("Can't load from nonpointer type: " +
4298 (*yyvsp[-1].TypeVal)->getDescription());
4299 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
4300 ThrowException("Can't load from pointer of non-first-class type: " +
4301 (*yyvsp[-1].TypeVal)->getDescription());
4302 yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
4303 delete yyvsp[-1].TypeVal;
4304 ;}
4305 break;
4306
4307 case 211:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004308#line 2240 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004309 {
4310 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
4311 if (!PT)
4312 ThrowException("Can't store to a nonpointer type: " +
4313 (*yyvsp[-1].TypeVal)->getDescription());
4314 const Type *ElTy = PT->getElementType();
4315 if (ElTy != yyvsp[-3].ValueVal->getType())
4316 ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
4317 "' into space of type '" + ElTy->getDescription() + "'!");
4318
4319 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
4320 delete yyvsp[-1].TypeVal;
4321 ;}
4322 break;
4323
4324 case 212:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004325#line 2253 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004326 {
4327 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4328 ThrowException("getelementptr insn requires pointer operand!");
4329
4330 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4331 // indices to uint struct indices for compatibility.
4332 generic_gep_type_iterator<std::vector<Value*>::iterator>
4333 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4334 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4335 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
4336 if (isa<StructType>(*GTI)) // Only change struct indices
4337 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
4338 if (CUI->getType() == Type::UByteTy)
4339 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
4340
4341 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4342 ThrowException("Invalid getelementptr indices for type '" +
4343 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4344 yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
4345 delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
4346 ;}
4347 break;
4348
4349
4350 }
4351
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004352/* Line 1010 of yacc.c. */
4353#line 4354 "llvmAsmParser.tab.c"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004354
4355 yyvsp -= yylen;
4356 yyssp -= yylen;
4357
4358
4359 YY_STACK_PRINT (yyss, yyssp);
4360
4361 *++yyvsp = yyval;
4362
4363
4364 /* Now `shift' the result of the reduction. Determine what state
4365 that goes to, based on the state we popped back to and the rule
4366 number reduced by. */
4367
4368 yyn = yyr1[yyn];
4369
4370 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
4371 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4372 yystate = yytable[yystate];
4373 else
4374 yystate = yydefgoto[yyn - YYNTOKENS];
4375
4376 goto yynewstate;
4377
4378
4379/*------------------------------------.
4380| yyerrlab -- here on detecting error |
4381`------------------------------------*/
4382yyerrlab:
4383 /* If not already recovering from an error, report this error. */
4384 if (!yyerrstatus)
4385 {
4386 ++yynerrs;
4387#if YYERROR_VERBOSE
4388 yyn = yypact[yystate];
4389
4390 if (YYPACT_NINF < yyn && yyn < YYLAST)
4391 {
4392 YYSIZE_T yysize = 0;
4393 int yytype = YYTRANSLATE (yychar);
4394 const char* yyprefix;
4395 char *yymsg;
4396 int yyx;
4397
4398 /* Start YYX at -YYN if negative to avoid negative indexes in
4399 YYCHECK. */
4400 int yyxbegin = yyn < 0 ? -yyn : 0;
4401
4402 /* Stay within bounds of both yycheck and yytname. */
4403 int yychecklim = YYLAST - yyn;
4404 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
4405 int yycount = 0;
4406
4407 yyprefix = ", expecting ";
4408 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
4409 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
4410 {
4411 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
4412 yycount += 1;
4413 if (yycount == 5)
4414 {
4415 yysize = 0;
4416 break;
4417 }
4418 }
4419 yysize += (sizeof ("syntax error, unexpected ")
4420 + yystrlen (yytname[yytype]));
4421 yymsg = (char *) YYSTACK_ALLOC (yysize);
4422 if (yymsg != 0)
4423 {
4424 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
4425 yyp = yystpcpy (yyp, yytname[yytype]);
4426
4427 if (yycount < 5)
4428 {
4429 yyprefix = ", expecting ";
4430 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
4431 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
4432 {
4433 yyp = yystpcpy (yyp, yyprefix);
4434 yyp = yystpcpy (yyp, yytname[yyx]);
4435 yyprefix = " or ";
4436 }
4437 }
4438 yyerror (yymsg);
4439 YYSTACK_FREE (yymsg);
4440 }
4441 else
4442 yyerror ("syntax error; also virtual memory exhausted");
4443 }
4444 else
4445#endif /* YYERROR_VERBOSE */
4446 yyerror ("syntax error");
4447 }
4448
4449
4450
4451 if (yyerrstatus == 3)
4452 {
4453 /* If just tried and failed to reuse lookahead token after an
4454 error, discard it. */
4455
4456 if (yychar <= YYEOF)
4457 {
4458 /* If at end of input, pop the error token,
4459 then the rest of the stack, then return failure. */
4460 if (yychar == YYEOF)
4461 for (;;)
4462 {
4463 YYPOPSTACK;
4464 if (yyssp == yyss)
4465 YYABORT;
4466 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
4467 yydestruct (yystos[*yyssp], yyvsp);
4468 }
4469 }
4470 else
4471 {
4472 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
4473 yydestruct (yytoken, &yylval);
4474 yychar = YYEMPTY;
4475
4476 }
4477 }
4478
4479 /* Else will try to reuse lookahead token after shifting the error
4480 token. */
4481 goto yyerrlab1;
4482
4483
4484/*---------------------------------------------------.
4485| yyerrorlab -- error raised explicitly by YYERROR. |
4486`---------------------------------------------------*/
4487yyerrorlab:
4488
4489#ifdef __GNUC__
4490 /* Pacify GCC when the user code never invokes YYERROR and the label
4491 yyerrorlab therefore never appears in user code. */
4492 if (0)
4493 goto yyerrorlab;
4494#endif
4495
4496 yyvsp -= yylen;
4497 yyssp -= yylen;
4498 yystate = *yyssp;
4499 goto yyerrlab1;
4500
4501
4502/*-------------------------------------------------------------.
4503| yyerrlab1 -- common code for both syntax error and YYERROR. |
4504`-------------------------------------------------------------*/
4505yyerrlab1:
4506 yyerrstatus = 3; /* Each real token shifted decrements this. */
4507
4508 for (;;)
4509 {
4510 yyn = yypact[yystate];
4511 if (yyn != YYPACT_NINF)
4512 {
4513 yyn += YYTERROR;
4514 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
4515 {
4516 yyn = yytable[yyn];
4517 if (0 < yyn)
4518 break;
4519 }
4520 }
4521
4522 /* Pop the current state because it cannot handle the error token. */
4523 if (yyssp == yyss)
4524 YYABORT;
4525
4526 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
4527 yydestruct (yystos[yystate], yyvsp);
4528 YYPOPSTACK;
4529 yystate = *yyssp;
4530 YY_STACK_PRINT (yyss, yyssp);
4531 }
4532
4533 if (yyn == YYFINAL)
4534 YYACCEPT;
4535
4536 YYDPRINTF ((stderr, "Shifting error token, "));
4537
4538 *++yyvsp = yylval;
4539
4540
4541 yystate = yyn;
4542 goto yynewstate;
4543
4544
4545/*-------------------------------------.
4546| yyacceptlab -- YYACCEPT comes here. |
4547`-------------------------------------*/
4548yyacceptlab:
4549 yyresult = 0;
4550 goto yyreturn;
4551
4552/*-----------------------------------.
4553| yyabortlab -- YYABORT comes here. |
4554`-----------------------------------*/
4555yyabortlab:
4556 yyresult = 1;
4557 goto yyreturn;
4558
4559#ifndef yyoverflow
4560/*----------------------------------------------.
4561| yyoverflowlab -- parser overflow comes here. |
4562`----------------------------------------------*/
4563yyoverflowlab:
4564 yyerror ("parser stack overflow");
4565 yyresult = 2;
4566 /* Fall through. */
4567#endif
4568
4569yyreturn:
4570#ifndef yyoverflow
4571 if (yyss != yyssa)
4572 YYSTACK_FREE (yyss);
4573#endif
4574 return yyresult;
4575}
4576
4577
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004578#line 2276 "/usr/home/llvm/obj/../lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004579
4580int yyerror(const char *ErrorMsg) {
4581 std::string where
4582 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4583 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4584 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4585 if (yychar == YYEMPTY || yychar == 0)
4586 errMsg += "end-of-file.";
4587 else
4588 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4589 ThrowException(errMsg);
4590 return 0;
4591}
4592