Add some missing node names
[oota-llvm.git] / lib / AsmParser / llvmAsmParser.cpp.cvs
1
2 /*  A Bison parser, made from /Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y
3     by GNU Bison version 1.28  */
4
5 #define YYBISON 1  /* Identify Bison output.  */
6
7 #define yyparse llvmAsmparse
8 #define yylex llvmAsmlex
9 #define yyerror llvmAsmerror
10 #define yylval llvmAsmlval
11 #define yychar llvmAsmchar
12 #define yydebug llvmAsmdebug
13 #define yynerrs llvmAsmnerrs
14 #define ESINT64VAL      257
15 #define EUINT64VAL      258
16 #define SINTVAL 259
17 #define UINTVAL 260
18 #define FPVAL   261
19 #define VOID    262
20 #define BOOL    263
21 #define SBYTE   264
22 #define UBYTE   265
23 #define SHORT   266
24 #define USHORT  267
25 #define INT     268
26 #define UINT    269
27 #define LONG    270
28 #define ULONG   271
29 #define FLOAT   272
30 #define DOUBLE  273
31 #define TYPE    274
32 #define LABEL   275
33 #define VAR_ID  276
34 #define LABELSTR        277
35 #define STRINGCONSTANT  278
36 #define IMPLEMENTATION  279
37 #define ZEROINITIALIZER 280
38 #define TRUETOK 281
39 #define FALSETOK        282
40 #define BEGINTOK        283
41 #define ENDTOK  284
42 #define DECLARE 285
43 #define GLOBAL  286
44 #define CONSTANT        287
45 #define SECTION 288
46 #define VOLATILE        289
47 #define TO      290
48 #define DOTDOTDOT       291
49 #define NULL_TOK        292
50 #define UNDEF   293
51 #define CONST   294
52 #define INTERNAL        295
53 #define LINKONCE        296
54 #define WEAK    297
55 #define APPENDING       298
56 #define OPAQUE  299
57 #define NOT     300
58 #define EXTERNAL        301
59 #define TARGET  302
60 #define TRIPLE  303
61 #define ENDIAN  304
62 #define POINTERSIZE     305
63 #define LITTLE  306
64 #define BIG     307
65 #define ALIGN   308
66 #define DEPLIBS 309
67 #define CALL    310
68 #define TAIL    311
69 #define ASM_TOK 312
70 #define MODULE  313
71 #define SIDEEFFECT      314
72 #define CC_TOK  315
73 #define CCC_TOK 316
74 #define FASTCC_TOK      317
75 #define COLDCC_TOK      318
76 #define RET     319
77 #define BR      320
78 #define SWITCH  321
79 #define INVOKE  322
80 #define UNWIND  323
81 #define UNREACHABLE     324
82 #define ADD     325
83 #define SUB     326
84 #define MUL     327
85 #define DIV     328
86 #define REM     329
87 #define AND     330
88 #define OR      331
89 #define XOR     332
90 #define SETLE   333
91 #define SETGE   334
92 #define SETLT   335
93 #define SETGT   336
94 #define SETEQ   337
95 #define SETNE   338
96 #define MALLOC  339
97 #define ALLOCA  340
98 #define FREE    341
99 #define LOAD    342
100 #define STORE   343
101 #define GETELEMENTPTR   344
102 #define PHI_TOK 345
103 #define CAST    346
104 #define SELECT  347
105 #define SHL     348
106 #define SHR     349
107 #define VAARG   350
108 #define EXTRACTELEMENT  351
109 #define INSERTELEMENT   352
110 #define VAARG_old       353
111 #define VANEXT_old      354
112
113 #line 14 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
114
115 #include "ParserInternals.h"
116 #include "llvm/CallingConv.h"
117 #include "llvm/InlineAsm.h"
118 #include "llvm/Instructions.h"
119 #include "llvm/Module.h"
120 #include "llvm/SymbolTable.h"
121 #include "llvm/Assembly/AutoUpgrade.h"
122 #include "llvm/Support/GetElementPtrTypeIterator.h"
123 #include "llvm/ADT/STLExtras.h"
124 #include "llvm/Support/MathExtras.h"
125 #include <algorithm>
126 #include <iostream>
127 #include <list>
128 #include <utility>
129
130 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
131 int yylex();                       // declaration" of xxx warnings.
132 int yyparse();
133
134 namespace llvm {
135   std::string CurFilename;
136 }
137 using namespace llvm;
138
139 static Module *ParserResult;
140
141 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
142 // relating to upreferences in the input stream.
143 //
144 //#define DEBUG_UPREFS 1
145 #ifdef DEBUG_UPREFS
146 #define UR_OUT(X) std::cerr << X
147 #else
148 #define UR_OUT(X)
149 #endif
150
151 #define YYERROR_VERBOSE 1
152
153 static bool ObsoleteVarArgs;
154 static bool NewVarArgs;
155 static BasicBlock *CurBB;
156 static GlobalVariable *CurGV;
157
158
159 // This contains info used when building the body of a function.  It is
160 // destroyed when the function is completed.
161 //
162 typedef std::vector<Value *> ValueList;           // Numbered defs
163 static void 
164 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
165                    std::map<const Type *,ValueList> *FutureLateResolvers = 0);
166
167 static struct PerModuleInfo {
168   Module *CurrentModule;
169   std::map<const Type *, ValueList> Values; // Module level numbered definitions
170   std::map<const Type *,ValueList> LateResolveValues;
171   std::vector<PATypeHolder>    Types;
172   std::map<ValID, PATypeHolder> LateResolveTypes;
173
174   /// PlaceHolderInfo - When temporary placeholder objects are created, remember
175   /// how they were referenced and one which line of the input they came from so
176   /// that we can resolve them later and print error messages as appropriate.
177   std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
178
179   // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
180   // references to global values.  Global values may be referenced before they
181   // are defined, and if so, the temporary object that they represent is held
182   // here.  This is used for forward references of GlobalValues.
183   //
184   typedef std::map<std::pair<const PointerType *,
185                              ValID>, GlobalValue*> GlobalRefsType;
186   GlobalRefsType GlobalRefs;
187
188   void ModuleDone() {
189     // If we could not resolve some functions at function compilation time
190     // (calls to functions before they are defined), resolve them now...  Types
191     // are resolved when the constant pool has been completely parsed.
192     //
193     ResolveDefinitions(LateResolveValues);
194
195     // Check to make sure that all global value forward references have been
196     // resolved!
197     //
198     if (!GlobalRefs.empty()) {
199       std::string UndefinedReferences = "Unresolved global references exist:\n";
200
201       for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
202            I != E; ++I) {
203         UndefinedReferences += "  " + I->first.first->getDescription() + " " +
204                                I->first.second.getName() + "\n";
205       }
206       ThrowException(UndefinedReferences);
207     }
208
209     // Look for intrinsic functions and CallInst that need to be upgraded
210     for (Module::iterator FI = CurrentModule->begin(),FE = CurrentModule->end();
211          FI != FE; )
212       UpgradeCallsToIntrinsic(FI++);
213
214     Values.clear();         // Clear out function local definitions
215     Types.clear();
216     CurrentModule = 0;
217   }
218
219   // GetForwardRefForGlobal - Check to see if there is a forward reference
220   // for this global.  If so, remove it from the GlobalRefs map and return it.
221   // If not, just return null.
222   GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
223     // Check to see if there is a forward reference to this global variable...
224     // if there is, eliminate it and patch the reference to use the new def'n.
225     GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
226     GlobalValue *Ret = 0;
227     if (I != GlobalRefs.end()) {
228       Ret = I->second;
229       GlobalRefs.erase(I);
230     }
231     return Ret;
232   }
233 } CurModule;
234
235 static struct PerFunctionInfo {
236   Function *CurrentFunction;     // Pointer to current function being created
237
238   std::map<const Type*, ValueList> Values;   // Keep track of #'d definitions
239   std::map<const Type*, ValueList> LateResolveValues;
240   bool isDeclare;                // Is this function a forward declararation?
241
242   /// BBForwardRefs - When we see forward references to basic blocks, keep
243   /// track of them here.
244   std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
245   std::vector<BasicBlock*> NumberedBlocks;
246   unsigned NextBBNum;
247
248   inline PerFunctionInfo() {
249     CurrentFunction = 0;
250     isDeclare = false;
251   }
252
253   inline void FunctionStart(Function *M) {
254     CurrentFunction = M;
255     NextBBNum = 0;
256   }
257
258   void FunctionDone() {
259     NumberedBlocks.clear();
260
261     // Any forward referenced blocks left?
262     if (!BBForwardRefs.empty())
263       ThrowException("Undefined reference to label " +
264                      BBForwardRefs.begin()->first->getName());
265
266     // Resolve all forward references now.
267     ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
268
269     Values.clear();         // Clear out function local definitions
270     CurrentFunction = 0;
271     isDeclare = false;
272   }
273 } CurFun;  // Info for the current function...
274
275 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
276
277
278 //===----------------------------------------------------------------------===//
279 //               Code to handle definitions of all the types
280 //===----------------------------------------------------------------------===//
281
282 static int InsertValue(Value *V,
283                   std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
284   if (V->hasName()) return -1;           // Is this a numbered definition?
285
286   // Yes, insert the value into the value table...
287   ValueList &List = ValueTab[V->getType()];
288   List.push_back(V);
289   return List.size()-1;
290 }
291
292 static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
293   switch (D.Type) {
294   case ValID::NumberVal:               // Is it a numbered definition?
295     // Module constants occupy the lowest numbered slots...
296     if ((unsigned)D.Num < CurModule.Types.size())
297       return CurModule.Types[(unsigned)D.Num];
298     break;
299   case ValID::NameVal:                 // Is it a named definition?
300     if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
301       D.destroy();  // Free old strdup'd memory...
302       return N;
303     }
304     break;
305   default:
306     ThrowException("Internal parser error: Invalid symbol type reference!");
307   }
308
309   // If we reached here, we referenced either a symbol that we don't know about
310   // or an id number that hasn't been read yet.  We may be referencing something
311   // forward, so just create an entry to be resolved later and get to it...
312   //
313   if (DoNotImprovise) return 0;  // Do we just want a null to be returned?
314
315
316   if (inFunctionScope()) {
317     if (D.Type == ValID::NameVal)
318       ThrowException("Reference to an undefined type: '" + D.getName() + "'");
319     else
320       ThrowException("Reference to an undefined type: #" + itostr(D.Num));
321   }
322
323   std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
324   if (I != CurModule.LateResolveTypes.end())
325     return I->second;
326
327   Type *Typ = OpaqueType::get();
328   CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
329   return Typ;
330  }
331
332 static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
333   SymbolTable &SymTab =
334     inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
335                         CurModule.CurrentModule->getSymbolTable();
336   return SymTab.lookup(Ty, Name);
337 }
338
339 // getValNonImprovising - Look up the value specified by the provided type and
340 // the provided ValID.  If the value exists and has already been defined, return
341 // it.  Otherwise return null.
342 //
343 static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
344   if (isa<FunctionType>(Ty))
345     ThrowException("Functions are not values and "
346                    "must be referenced as pointers");
347
348   switch (D.Type) {
349   case ValID::NumberVal: {                 // Is it a numbered definition?
350     unsigned Num = (unsigned)D.Num;
351
352     // Module constants occupy the lowest numbered slots...
353     std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
354     if (VI != CurModule.Values.end()) {
355       if (Num < VI->second.size())
356         return VI->second[Num];
357       Num -= VI->second.size();
358     }
359
360     // Make sure that our type is within bounds
361     VI = CurFun.Values.find(Ty);
362     if (VI == CurFun.Values.end()) return 0;
363
364     // Check that the number is within bounds...
365     if (VI->second.size() <= Num) return 0;
366
367     return VI->second[Num];
368   }
369
370   case ValID::NameVal: {                // Is it a named definition?
371     Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
372     if (N == 0) return 0;
373
374     D.destroy();  // Free old strdup'd memory...
375     return N;
376   }
377
378   // Check to make sure that "Ty" is an integral type, and that our
379   // value will fit into the specified type...
380   case ValID::ConstSIntVal:    // Is it a constant pool reference??
381     if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
382       ThrowException("Signed integral constant '" +
383                      itostr(D.ConstPool64) + "' is invalid for type '" +
384                      Ty->getDescription() + "'!");
385     return ConstantSInt::get(Ty, D.ConstPool64);
386
387   case ValID::ConstUIntVal:     // Is it an unsigned const pool reference?
388     if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
389       if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
390         ThrowException("Integral constant '" + utostr(D.UConstPool64) +
391                        "' is invalid or out of range!");
392       } else {     // This is really a signed reference.  Transmogrify.
393         return ConstantSInt::get(Ty, D.ConstPool64);
394       }
395     } else {
396       return ConstantUInt::get(Ty, D.UConstPool64);
397     }
398
399   case ValID::ConstFPVal:        // Is it a floating point const pool reference?
400     if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
401       ThrowException("FP constant invalid for type!!");
402     return ConstantFP::get(Ty, D.ConstPoolFP);
403
404   case ValID::ConstNullVal:      // Is it a null value?
405     if (!isa<PointerType>(Ty))
406       ThrowException("Cannot create a a non pointer null!");
407     return ConstantPointerNull::get(cast<PointerType>(Ty));
408
409   case ValID::ConstUndefVal:      // Is it an undef value?
410     return UndefValue::get(Ty);
411
412   case ValID::ConstZeroVal:      // Is it a zero value?
413     return Constant::getNullValue(Ty);
414     
415   case ValID::ConstantVal:       // Fully resolved constant?
416     if (D.ConstantValue->getType() != Ty)
417       ThrowException("Constant expression type different from required type!");
418     return D.ConstantValue;
419
420   case ValID::InlineAsmVal: {    // Inline asm expression
421     const PointerType *PTy = dyn_cast<PointerType>(Ty);
422     const FunctionType *FTy =
423       PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
424     if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
425       ThrowException("Invalid type for asm constraint string!");
426     InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
427                                    D.IAD->HasSideEffects);
428     D.destroy();   // Free InlineAsmDescriptor.
429     return IA;
430   }
431   default:
432     assert(0 && "Unhandled case!");
433     return 0;
434   }   // End of switch
435
436   assert(0 && "Unhandled case!");
437   return 0;
438 }
439
440 // getVal - This function is identical to getValNonImprovising, except that if a
441 // value is not already defined, it "improvises" by creating a placeholder var
442 // that looks and acts just like the requested variable.  When the value is
443 // defined later, all uses of the placeholder variable are replaced with the
444 // real thing.
445 //
446 static Value *getVal(const Type *Ty, const ValID &ID) {
447   if (Ty == Type::LabelTy)
448     ThrowException("Cannot use a basic block here");
449
450   // See if the value has already been defined.
451   Value *V = getValNonImprovising(Ty, ID);
452   if (V) return V;
453
454   if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
455     ThrowException("Invalid use of a composite type!");
456
457   // If we reached here, we referenced either a symbol that we don't know about
458   // or an id number that hasn't been read yet.  We may be referencing something
459   // forward, so just create an entry to be resolved later and get to it...
460   //
461   V = new Argument(Ty);
462
463   // Remember where this forward reference came from.  FIXME, shouldn't we try
464   // to recycle these things??
465   CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
466                                                                llvmAsmlineno)));
467
468   if (inFunctionScope())
469     InsertValue(V, CurFun.LateResolveValues);
470   else
471     InsertValue(V, CurModule.LateResolveValues);
472   return V;
473 }
474
475 /// getBBVal - This is used for two purposes:
476 ///  * If isDefinition is true, a new basic block with the specified ID is being
477 ///    defined.
478 ///  * If isDefinition is true, this is a reference to a basic block, which may
479 ///    or may not be a forward reference.
480 ///
481 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
482   assert(inFunctionScope() && "Can't get basic block at global scope!");
483
484   std::string Name;
485   BasicBlock *BB = 0;
486   switch (ID.Type) {
487   default: ThrowException("Illegal label reference " + ID.getName());
488   case ValID::NumberVal:                // Is it a numbered definition?
489     if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
490       CurFun.NumberedBlocks.resize(ID.Num+1);
491     BB = CurFun.NumberedBlocks[ID.Num];
492     break;
493   case ValID::NameVal:                  // Is it a named definition?
494     Name = ID.Name;
495     if (Value *N = CurFun.CurrentFunction->
496                    getSymbolTable().lookup(Type::LabelTy, Name))
497       BB = cast<BasicBlock>(N);
498     break;
499   }
500
501   // See if the block has already been defined.
502   if (BB) {
503     // If this is the definition of the block, make sure the existing value was
504     // just a forward reference.  If it was a forward reference, there will be
505     // an entry for it in the PlaceHolderInfo map.
506     if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
507       // The existing value was a definition, not a forward reference.
508       ThrowException("Redefinition of label " + ID.getName());
509
510     ID.destroy();                       // Free strdup'd memory.
511     return BB;
512   }
513
514   // Otherwise this block has not been seen before.
515   BB = new BasicBlock("", CurFun.CurrentFunction);
516   if (ID.Type == ValID::NameVal) {
517     BB->setName(ID.Name);
518   } else {
519     CurFun.NumberedBlocks[ID.Num] = BB;
520   }
521
522   // If this is not a definition, keep track of it so we can use it as a forward
523   // reference.
524   if (!isDefinition) {
525     // Remember where this forward reference came from.
526     CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
527   } else {
528     // The forward declaration could have been inserted anywhere in the
529     // function: insert it into the correct place now.
530     CurFun.CurrentFunction->getBasicBlockList().remove(BB);
531     CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
532   }
533   ID.destroy();
534   return BB;
535 }
536
537
538 //===----------------------------------------------------------------------===//
539 //              Code to handle forward references in instructions
540 //===----------------------------------------------------------------------===//
541 //
542 // This code handles the late binding needed with statements that reference
543 // values not defined yet... for example, a forward branch, or the PHI node for
544 // a loop body.
545 //
546 // This keeps a table (CurFun.LateResolveValues) of all such forward references
547 // and back patchs after we are done.
548 //
549
550 // ResolveDefinitions - If we could not resolve some defs at parsing
551 // time (forward branches, phi functions for loops, etc...) resolve the
552 // defs now...
553 //
554 static void 
555 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
556                    std::map<const Type*,ValueList> *FutureLateResolvers) {
557   // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
558   for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
559          E = LateResolvers.end(); LRI != E; ++LRI) {
560     ValueList &List = LRI->second;
561     while (!List.empty()) {
562       Value *V = List.back();
563       List.pop_back();
564
565       std::map<Value*, std::pair<ValID, int> >::iterator PHI =
566         CurModule.PlaceHolderInfo.find(V);
567       assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
568
569       ValID &DID = PHI->second.first;
570
571       Value *TheRealValue = getValNonImprovising(LRI->first, DID);
572       if (TheRealValue) {
573         V->replaceAllUsesWith(TheRealValue);
574         delete V;
575         CurModule.PlaceHolderInfo.erase(PHI);
576       } else if (FutureLateResolvers) {
577         // Functions have their unresolved items forwarded to the module late
578         // resolver table
579         InsertValue(V, *FutureLateResolvers);
580       } else {
581         if (DID.Type == ValID::NameVal)
582           ThrowException("Reference to an invalid definition: '" +DID.getName()+
583                          "' of type '" + V->getType()->getDescription() + "'",
584                          PHI->second.second);
585         else
586           ThrowException("Reference to an invalid definition: #" +
587                          itostr(DID.Num) + " of type '" +
588                          V->getType()->getDescription() + "'",
589                          PHI->second.second);
590       }
591     }
592   }
593
594   LateResolvers.clear();
595 }
596
597 // ResolveTypeTo - A brand new type was just declared.  This means that (if
598 // name is not null) things referencing Name can be resolved.  Otherwise, things
599 // refering to the number can be resolved.  Do this now.
600 //
601 static void ResolveTypeTo(char *Name, const Type *ToTy) {
602   ValID D;
603   if (Name) D = ValID::create(Name);
604   else      D = ValID::create((int)CurModule.Types.size());
605
606   std::map<ValID, PATypeHolder>::iterator I =
607     CurModule.LateResolveTypes.find(D);
608   if (I != CurModule.LateResolveTypes.end()) {
609     ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
610     CurModule.LateResolveTypes.erase(I);
611   }
612 }
613
614 // setValueName - Set the specified value to the name given.  The name may be
615 // null potentially, in which case this is a noop.  The string passed in is
616 // assumed to be a malloc'd string buffer, and is free'd by this function.
617 //
618 static void setValueName(Value *V, char *NameStr) {
619   if (NameStr) {
620     std::string Name(NameStr);      // Copy string
621     free(NameStr);                  // Free old string
622
623     if (V->getType() == Type::VoidTy)
624       ThrowException("Can't assign name '" + Name+"' to value with void type!");
625
626     assert(inFunctionScope() && "Must be in function scope!");
627     SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
628     if (ST.lookup(V->getType(), Name))
629       ThrowException("Redefinition of value named '" + Name + "' in the '" +
630                      V->getType()->getDescription() + "' type plane!");
631
632     // Set the name.
633     V->setName(Name);
634   }
635 }
636
637 /// ParseGlobalVariable - Handle parsing of a global.  If Initializer is null,
638 /// this is a declaration, otherwise it is a definition.
639 static GlobalVariable *
640 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
641                     bool isConstantGlobal, const Type *Ty,
642                     Constant *Initializer) {
643   if (isa<FunctionType>(Ty))
644     ThrowException("Cannot declare global vars of function type!");
645
646   const PointerType *PTy = PointerType::get(Ty);
647
648   std::string Name;
649   if (NameStr) {
650     Name = NameStr;      // Copy string
651     free(NameStr);       // Free old string
652   }
653
654   // See if this global value was forward referenced.  If so, recycle the
655   // object.
656   ValID ID;
657   if (!Name.empty()) {
658     ID = ValID::create((char*)Name.c_str());
659   } else {
660     ID = ValID::create((int)CurModule.Values[PTy].size());
661   }
662
663   if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
664     // Move the global to the end of the list, from whereever it was
665     // previously inserted.
666     GlobalVariable *GV = cast<GlobalVariable>(FWGV);
667     CurModule.CurrentModule->getGlobalList().remove(GV);
668     CurModule.CurrentModule->getGlobalList().push_back(GV);
669     GV->setInitializer(Initializer);
670     GV->setLinkage(Linkage);
671     GV->setConstant(isConstantGlobal);
672     InsertValue(GV, CurModule.Values);
673     return GV;
674   }
675
676   // If this global has a name, check to see if there is already a definition
677   // of this global in the module.  If so, merge as appropriate.  Note that
678   // this is really just a hack around problems in the CFE.  :(
679   if (!Name.empty()) {
680     // We are a simple redefinition of a value, check to see if it is defined
681     // the same as the old one.
682     if (GlobalVariable *EGV =
683                 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
684       // We are allowed to redefine a global variable in two circumstances:
685       // 1. If at least one of the globals is uninitialized or
686       // 2. If both initializers have the same value.
687       //
688       if (!EGV->hasInitializer() || !Initializer ||
689           EGV->getInitializer() == Initializer) {
690
691         // Make sure the existing global version gets the initializer!  Make
692         // sure that it also gets marked const if the new version is.
693         if (Initializer && !EGV->hasInitializer())
694           EGV->setInitializer(Initializer);
695         if (isConstantGlobal)
696           EGV->setConstant(true);
697         EGV->setLinkage(Linkage);
698         return EGV;
699       }
700
701       ThrowException("Redefinition of global variable named '" + Name +
702                      "' in the '" + Ty->getDescription() + "' type plane!");
703     }
704   }
705
706   // Otherwise there is no existing GV to use, create one now.
707   GlobalVariable *GV =
708     new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
709                        CurModule.CurrentModule);
710   InsertValue(GV, CurModule.Values);
711   return GV;
712 }
713
714 // setTypeName - Set the specified type to the name given.  The name may be
715 // null potentially, in which case this is a noop.  The string passed in is
716 // assumed to be a malloc'd string buffer, and is freed by this function.
717 //
718 // This function returns true if the type has already been defined, but is
719 // allowed to be redefined in the specified context.  If the name is a new name
720 // for the type plane, it is inserted and false is returned.
721 static bool setTypeName(const Type *T, char *NameStr) {
722   assert(!inFunctionScope() && "Can't give types function-local names!");
723   if (NameStr == 0) return false;
724  
725   std::string Name(NameStr);      // Copy string
726   free(NameStr);                  // Free old string
727
728   // We don't allow assigning names to void type
729   if (T == Type::VoidTy)
730     ThrowException("Can't assign name '" + Name + "' to the void type!");
731
732   // Set the type name, checking for conflicts as we do so.
733   bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
734
735   if (AlreadyExists) {   // Inserting a name that is already defined???
736     const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
737     assert(Existing && "Conflict but no matching type?");
738
739     // There is only one case where this is allowed: when we are refining an
740     // opaque type.  In this case, Existing will be an opaque type.
741     if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
742       // We ARE replacing an opaque type!
743       const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
744       return true;
745     }
746
747     // Otherwise, this is an attempt to redefine a type. That's okay if
748     // the redefinition is identical to the original. This will be so if
749     // Existing and T point to the same Type object. In this one case we
750     // allow the equivalent redefinition.
751     if (Existing == T) return true;  // Yes, it's equal.
752
753     // Any other kind of (non-equivalent) redefinition is an error.
754     ThrowException("Redefinition of type named '" + Name + "' in the '" +
755                    T->getDescription() + "' type plane!");
756   }
757
758   return false;
759 }
760
761 //===----------------------------------------------------------------------===//
762 // Code for handling upreferences in type names...
763 //
764
765 // TypeContains - Returns true if Ty directly contains E in it.
766 //
767 static bool TypeContains(const Type *Ty, const Type *E) {
768   return std::find(Ty->subtype_begin(), Ty->subtype_end(),
769                    E) != Ty->subtype_end();
770 }
771
772 namespace {
773   struct UpRefRecord {
774     // NestingLevel - The number of nesting levels that need to be popped before
775     // this type is resolved.
776     unsigned NestingLevel;
777
778     // LastContainedTy - This is the type at the current binding level for the
779     // type.  Every time we reduce the nesting level, this gets updated.
780     const Type *LastContainedTy;
781
782     // UpRefTy - This is the actual opaque type that the upreference is
783     // represented with.
784     OpaqueType *UpRefTy;
785
786     UpRefRecord(unsigned NL, OpaqueType *URTy)
787       : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
788   };
789 }
790
791 // UpRefs - A list of the outstanding upreferences that need to be resolved.
792 static std::vector<UpRefRecord> UpRefs;
793
794 /// HandleUpRefs - Every time we finish a new layer of types, this function is
795 /// called.  It loops through the UpRefs vector, which is a list of the
796 /// currently active types.  For each type, if the up reference is contained in
797 /// the newly completed type, we decrement the level count.  When the level
798 /// count reaches zero, the upreferenced type is the type that is passed in:
799 /// thus we can complete the cycle.
800 ///
801 static PATypeHolder HandleUpRefs(const Type *ty) {
802   if (!ty->isAbstract()) return ty;
803   PATypeHolder Ty(ty);
804   UR_OUT("Type '" << Ty->getDescription() <<
805          "' newly formed.  Resolving upreferences.\n" <<
806          UpRefs.size() << " upreferences active!\n");
807
808   // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
809   // to zero), we resolve them all together before we resolve them to Ty.  At
810   // the end of the loop, if there is anything to resolve to Ty, it will be in
811   // this variable.
812   OpaqueType *TypeToResolve = 0;
813
814   for (unsigned i = 0; i != UpRefs.size(); ++i) {
815     UR_OUT("  UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
816            << UpRefs[i].second->getDescription() << ") = "
817            << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
818     if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
819       // Decrement level of upreference
820       unsigned Level = --UpRefs[i].NestingLevel;
821       UpRefs[i].LastContainedTy = Ty;
822       UR_OUT("  Uplevel Ref Level = " << Level << "\n");
823       if (Level == 0) {                     // Upreference should be resolved!
824         if (!TypeToResolve) {
825           TypeToResolve = UpRefs[i].UpRefTy;
826         } else {
827           UR_OUT("  * Resolving upreference for "
828                  << UpRefs[i].second->getDescription() << "\n";
829                  std::string OldName = UpRefs[i].UpRefTy->getDescription());
830           UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
831           UR_OUT("  * Type '" << OldName << "' refined upreference to: "
832                  << (const void*)Ty << ", " << Ty->getDescription() << "\n");
833         }
834         UpRefs.erase(UpRefs.begin()+i);     // Remove from upreference list...
835         --i;                                // Do not skip the next element...
836       }
837     }
838   }
839
840   if (TypeToResolve) {
841     UR_OUT("  * Resolving upreference for "
842            << UpRefs[i].second->getDescription() << "\n";
843            std::string OldName = TypeToResolve->getDescription());
844     TypeToResolve->refineAbstractTypeTo(Ty);
845   }
846
847   return Ty;
848 }
849
850
851 // common code from the two 'RunVMAsmParser' functions
852  static Module * RunParser(Module * M) {
853
854   llvmAsmlineno = 1;      // Reset the current line number...
855   ObsoleteVarArgs = false;
856   NewVarArgs = false;
857
858   CurModule.CurrentModule = M;
859   yyparse();       // Parse the file, potentially throwing exception
860
861   Module *Result = ParserResult;
862   ParserResult = 0;
863
864   //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
865   {
866     Function* F;
867     if ((F = Result->getNamedFunction("llvm.va_start"))
868         && F->getFunctionType()->getNumParams() == 0)
869       ObsoleteVarArgs = true;
870     if((F = Result->getNamedFunction("llvm.va_copy"))
871        && F->getFunctionType()->getNumParams() == 1)
872       ObsoleteVarArgs = true;
873   }
874
875   if (ObsoleteVarArgs && NewVarArgs)
876     ThrowException("This file is corrupt: it uses both new and old style varargs");
877
878   if(ObsoleteVarArgs) {
879     if(Function* F = Result->getNamedFunction("llvm.va_start")) {
880       if (F->arg_size() != 0)
881         ThrowException("Obsolete va_start takes 0 argument!");
882       
883       //foo = va_start()
884       // ->
885       //bar = alloca typeof(foo)
886       //va_start(bar)
887       //foo = load bar
888
889       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
890       const Type* ArgTy = F->getFunctionType()->getReturnType();
891       const Type* ArgTyPtr = PointerType::get(ArgTy);
892       Function* NF = Result->getOrInsertFunction("llvm.va_start", 
893                                                  RetTy, ArgTyPtr, (Type *)0);
894
895       while (!F->use_empty()) {
896         CallInst* CI = cast<CallInst>(F->use_back());
897         AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
898         new CallInst(NF, bar, "", CI);
899         Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
900         CI->replaceAllUsesWith(foo);
901         CI->getParent()->getInstList().erase(CI);
902       }
903       Result->getFunctionList().erase(F);
904     }
905     
906     if(Function* F = Result->getNamedFunction("llvm.va_end")) {
907       if(F->arg_size() != 1)
908         ThrowException("Obsolete va_end takes 1 argument!");
909
910       //vaend foo
911       // ->
912       //bar = alloca 1 of typeof(foo)
913       //vaend bar
914       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
915       const Type* ArgTy = F->getFunctionType()->getParamType(0);
916       const Type* ArgTyPtr = PointerType::get(ArgTy);
917       Function* NF = Result->getOrInsertFunction("llvm.va_end", 
918                                                  RetTy, ArgTyPtr, (Type *)0);
919
920       while (!F->use_empty()) {
921         CallInst* CI = cast<CallInst>(F->use_back());
922         AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
923         new StoreInst(CI->getOperand(1), bar, CI);
924         new CallInst(NF, bar, "", CI);
925         CI->getParent()->getInstList().erase(CI);
926       }
927       Result->getFunctionList().erase(F);
928     }
929
930     if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
931       if(F->arg_size() != 1)
932         ThrowException("Obsolete va_copy takes 1 argument!");
933       //foo = vacopy(bar)
934       // ->
935       //a = alloca 1 of typeof(foo)
936       //b = alloca 1 of typeof(foo)
937       //store bar -> b
938       //vacopy(a, b)
939       //foo = load a
940       
941       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
942       const Type* ArgTy = F->getFunctionType()->getReturnType();
943       const Type* ArgTyPtr = PointerType::get(ArgTy);
944       Function* NF = Result->getOrInsertFunction("llvm.va_copy", 
945                                                  RetTy, ArgTyPtr, ArgTyPtr,
946                                                  (Type *)0);
947
948       while (!F->use_empty()) {
949         CallInst* CI = cast<CallInst>(F->use_back());
950         AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
951         AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
952         new StoreInst(CI->getOperand(1), b, CI);
953         new CallInst(NF, a, b, "", CI);
954         Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
955         CI->replaceAllUsesWith(foo);
956         CI->getParent()->getInstList().erase(CI);
957       }
958       Result->getFunctionList().erase(F);
959     }
960   }
961
962   return Result;
963
964  }
965
966 //===----------------------------------------------------------------------===//
967 //            RunVMAsmParser - Define an interface to this parser
968 //===----------------------------------------------------------------------===//
969 //
970 Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
971   set_scan_file(F);
972
973   CurFilename = Filename;
974   return RunParser(new Module(CurFilename));
975 }
976
977 Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
978   set_scan_string(AsmString);
979
980   CurFilename = "from_memory";
981   if (M == NULL) {
982     return RunParser(new Module (CurFilename));
983   } else {
984     return RunParser(M);
985   }
986 }
987
988
989 #line 890 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
990 typedef union {
991   llvm::Module                           *ModuleVal;
992   llvm::Function                         *FunctionVal;
993   std::pair<llvm::PATypeHolder*, char*>  *ArgVal;
994   llvm::BasicBlock                       *BasicBlockVal;
995   llvm::TerminatorInst                   *TermInstVal;
996   llvm::Instruction                      *InstVal;
997   llvm::Constant                         *ConstVal;
998
999   const llvm::Type                       *PrimType;
1000   llvm::PATypeHolder                     *TypeVal;
1001   llvm::Value                            *ValueVal;
1002
1003   std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1004   std::vector<llvm::Value*>              *ValueList;
1005   std::list<llvm::PATypeHolder>          *TypeList;
1006   // Represent the RHS of PHI node
1007   std::list<std::pair<llvm::Value*,
1008                       llvm::BasicBlock*> > *PHIList;
1009   std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1010   std::vector<llvm::Constant*>           *ConstVector;
1011
1012   llvm::GlobalValue::LinkageTypes         Linkage;
1013   int64_t                           SInt64Val;
1014   uint64_t                          UInt64Val;
1015   int                               SIntVal;
1016   unsigned                          UIntVal;
1017   double                            FPVal;
1018   bool                              BoolVal;
1019
1020   char                             *StrVal;   // This memory is strdup'd!
1021   llvm::ValID                             ValIDVal; // strdup'd memory maybe!
1022
1023   llvm::Instruction::BinaryOps            BinaryOpVal;
1024   llvm::Instruction::TermOps              TermOpVal;
1025   llvm::Instruction::MemoryOps            MemOpVal;
1026   llvm::Instruction::OtherOps             OtherOpVal;
1027   llvm::Module::Endianness                Endianness;
1028 } YYSTYPE;
1029 #include <stdio.h>
1030
1031 #ifndef __cplusplus
1032 #ifndef __STDC__
1033 #define const
1034 #endif
1035 #endif
1036
1037
1038
1039 #define YYFINAL         473
1040 #define YYFLAG          -32768
1041 #define YYNTBASE        115
1042
1043 #define YYTRANSLATE(x) ((unsigned)(x) <= 354 ? yytranslate[x] : 186)
1044
1045 static const char yytranslate[] = {     0,
1046      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1047      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1048      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1049      2,     2,     2,     2,     2,     2,     2,     2,     2,   104,
1050    105,   113,     2,   102,     2,     2,     2,     2,     2,     2,
1051      2,     2,     2,     2,     2,     2,     2,     2,     2,   109,
1052    101,   110,     2,     2,     2,     2,     2,     2,     2,     2,
1053      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1054      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1055    106,   103,   108,     2,     2,     2,     2,     2,   114,     2,
1056      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1057      2,     2,     2,     2,     2,     2,     2,     2,     2,   107,
1058      2,     2,   111,     2,   112,     2,     2,     2,     2,     2,
1059      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1060      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1061      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1062      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1063      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1064      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1065      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1066      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1067      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1068      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1069      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1070      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1071      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
1072      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
1073     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
1074     27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
1075     37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
1076     47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
1077     57,    58,    59,    60,    61,    62,    63,    64,    65,    66,
1078     67,    68,    69,    70,    71,    72,    73,    74,    75,    76,
1079     77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
1080     87,    88,    89,    90,    91,    92,    93,    94,    95,    96,
1081     97,    98,    99,   100
1082 };
1083
1084 #if YYDEBUG != 0
1085 static const short yyprhs[] = {     0,
1086      0,     2,     4,     6,     8,    10,    12,    14,    16,    18,
1087     20,    22,    24,    26,    28,    30,    32,    34,    36,    38,
1088     40,    42,    44,    46,    48,    50,    52,    54,    56,    58,
1089     60,    62,    64,    67,    68,    70,    72,    74,    76,    77,
1090     78,    80,    82,    84,    87,    88,    91,    92,    96,    99,
1091    100,   102,   103,   107,   109,   112,   114,   116,   118,   120,
1092    122,   124,   126,   128,   130,   132,   134,   136,   138,   140,
1093    142,   144,   146,   148,   150,   152,   154,   157,   162,   168,
1094    174,   178,   181,   184,   186,   190,   192,   196,   198,   199,
1095    204,   208,   212,   217,   222,   226,   229,   232,   235,   238,
1096    241,   244,   247,   250,   253,   256,   263,   269,   278,   285,
1097    292,   299,   306,   313,   317,   319,   321,   323,   325,   328,
1098    331,   336,   339,   341,   346,   349,   354,   355,   363,   364,
1099    372,   376,   381,   382,   384,   386,   388,   392,   396,   400,
1100    404,   408,   410,   411,   413,   415,   417,   418,   421,   425,
1101    427,   429,   433,   435,   436,   445,   447,   449,   453,   455,
1102    457,   460,   461,   465,   466,   468,   470,   472,   474,   476,
1103    478,   480,   482,   484,   488,   490,   496,   498,   500,   502,
1104    504,   507,   510,   513,   517,   520,   521,   523,   526,   529,
1105    533,   543,   553,   562,   576,   578,   580,   587,   593,   596,
1106    603,   611,   613,   617,   619,   620,   623,   625,   631,   637,
1107    643,   646,   651,   656,   663,   668,   673,   678,   683,   690,
1108    693,   701,   703,   706,   707,   709,   710,   714,   721,   725,
1109    732,   735,   740,   747
1110 };
1111
1112 static const short yyrhs[] = {     5,
1113      0,     6,     0,     3,     0,     4,     0,    71,     0,    72,
1114      0,    73,     0,    74,     0,    75,     0,    76,     0,    77,
1115      0,    78,     0,    79,     0,    80,     0,    81,     0,    82,
1116      0,    83,     0,    84,     0,    94,     0,    95,     0,    16,
1117      0,    14,     0,    12,     0,    10,     0,    17,     0,    15,
1118      0,    13,     0,    11,     0,   121,     0,   122,     0,    18,
1119      0,    19,     0,   155,   101,     0,     0,    41,     0,    42,
1120      0,    43,     0,    44,     0,     0,     0,    62,     0,    63,
1121      0,    64,     0,    61,     4,     0,     0,    54,     4,     0,
1122      0,   102,    54,     4,     0,    34,    24,     0,     0,   130,
1123      0,     0,   102,   133,   132,     0,   130,     0,    54,     4,
1124      0,   136,     0,     8,     0,   138,     0,     8,     0,   138,
1125      0,     9,     0,    10,     0,    11,     0,    12,     0,    13,
1126      0,    14,     0,    15,     0,    16,     0,    17,     0,    18,
1127      0,    19,     0,    20,     0,    21,     0,    45,     0,   137,
1128      0,   169,     0,   103,     4,     0,   135,   104,   140,   105,
1129      0,   106,     4,   107,   138,   108,     0,   109,     4,   107,
1130    138,   110,     0,   111,   139,   112,     0,   111,   112,     0,
1131    138,   113,     0,   138,     0,   139,   102,   138,     0,   139,
1132      0,   139,   102,    37,     0,    37,     0,     0,   136,   106,
1133    143,   108,     0,   136,   106,   108,     0,   136,   114,    24,
1134      0,   136,   109,   143,   110,     0,   136,   111,   143,   112,
1135      0,   136,   111,   112,     0,   136,    38,     0,   136,    39,
1136      0,   136,   169,     0,   136,   142,     0,   136,    26,     0,
1137    121,   116,     0,   122,     4,     0,     9,    27,     0,     9,
1138     28,     0,   124,     7,     0,    92,   104,   141,    36,   136,
1139    105,     0,    90,   104,   141,   183,   105,     0,    93,   104,
1140    141,   102,   141,   102,   141,   105,     0,   117,   104,   141,
1141    102,   141,   105,     0,   118,   104,   141,   102,   141,   105,
1142      0,   119,   104,   141,   102,   141,   105,     0,   120,   104,
1143    141,   102,   141,   105,     0,    97,   104,   141,   102,   141,
1144    105,     0,   143,   102,   141,     0,   141,     0,    32,     0,
1145     33,     0,   146,     0,   146,   164,     0,   146,   165,     0,
1146    146,    59,    58,   150,     0,   146,    25,     0,   147,     0,
1147    147,   125,    20,   134,     0,   147,   165,     0,   147,    59,
1148     58,   150,     0,     0,   147,   125,   126,   144,   141,   148,
1149    132,     0,     0,   147,   125,    47,   144,   136,   149,   132,
1150      0,   147,    48,   152,     0,   147,    55,   101,   153,     0,
1151      0,    24,     0,    53,     0,    52,     0,    50,   101,   151,
1152      0,    51,   101,     4,     0,    49,   101,    24,     0,   106,
1153    154,   108,     0,   154,   102,    24,     0,    24,     0,     0,
1154     22,     0,    24,     0,   155,     0,     0,   136,   156,     0,
1155    158,   102,   157,     0,   157,     0,   158,     0,   158,   102,
1156     37,     0,    37,     0,     0,   127,   134,   155,   104,   159,
1157    105,   131,   128,     0,    29,     0,   111,     0,   126,   160,
1158    161,     0,    30,     0,   112,     0,   172,   163,     0,     0,
1159     31,   166,   160,     0,     0,    60,     0,     3,     0,     4,
1160      0,     7,     0,    27,     0,    28,     0,    38,     0,    39,
1161      0,    26,     0,   109,   143,   110,     0,   142,     0,    58,
1162    167,    24,   102,    24,     0,   115,     0,   155,     0,   169,
1163      0,   168,     0,   136,   170,     0,   172,   173,     0,   162,
1164    173,     0,   174,   125,   175,     0,   174,   177,     0,     0,
1165     23,     0,    65,   171,     0,    65,     8,     0,    66,    21,
1166    170,     0,    66,     9,   170,   102,    21,   170,   102,    21,
1167    170,     0,    67,   123,   170,   102,    21,   170,   106,   176,
1168    108,     0,    67,   123,   170,   102,    21,   170,   106,   108,
1169      0,    68,   127,   134,   170,   104,   180,   105,    36,    21,
1170    170,    69,    21,   170,     0,    69,     0,    70,     0,   176,
1171    123,   168,   102,    21,   170,     0,   123,   168,   102,    21,
1172    170,     0,   125,   182,     0,   136,   106,   170,   102,   170,
1173    108,     0,   178,   102,   106,   170,   102,   170,   108,     0,
1174    171,     0,   179,   102,   171,     0,   179,     0,     0,    57,
1175     56,     0,    56,     0,   117,   136,   170,   102,   170,     0,
1176    118,   136,   170,   102,   170,     0,   119,   136,   170,   102,
1177    170,     0,    46,   171,     0,   120,   171,   102,   171,     0,
1178     92,   171,    36,   136,     0,    93,   171,   102,   171,   102,
1179    171,     0,    96,   171,   102,   136,     0,    99,   171,   102,
1180    136,     0,   100,   171,   102,   136,     0,    97,   171,   102,
1181    171,     0,    98,   171,   102,   171,   102,   171,     0,    91,
1182    178,     0,   181,   127,   134,   170,   104,   180,   105,     0,
1183    185,     0,   102,   179,     0,     0,    35,     0,     0,    85,
1184    136,   129,     0,    85,   136,   102,    15,   170,   129,     0,
1185     86,   136,   129,     0,    86,   136,   102,    15,   170,   129,
1186      0,    87,   171,     0,   184,    88,   136,   170,     0,   184,
1187     89,   171,   102,   136,   170,     0,    90,   136,   170,   183,
1188      0
1189 };
1190
1191 #endif
1192
1193 #if YYDEBUG != 0
1194 static const short yyrline[] = { 0,
1195   1010,  1011,  1018,  1019,  1028,  1028,  1028,  1028,  1028,  1029,
1196   1029,  1029,  1030,  1030,  1030,  1030,  1030,  1030,  1032,  1032,
1197   1036,  1036,  1036,  1036,  1037,  1037,  1037,  1037,  1038,  1038,
1198   1039,  1039,  1042,  1045,  1049,  1049,  1050,  1051,  1052,  1055,
1199   1055,  1056,  1057,  1058,  1067,  1067,  1073,  1073,  1081,  1088,
1200   1088,  1094,  1094,  1096,  1100,  1113,  1113,  1114,  1114,  1116,
1201   1125,  1125,  1125,  1125,  1125,  1125,  1125,  1126,  1126,  1126,
1202   1126,  1126,  1126,  1127,  1130,  1133,  1139,  1146,  1158,  1162,
1203   1173,  1182,  1185,  1193,  1197,  1202,  1203,  1206,  1209,  1219,
1204   1244,  1257,  1286,  1311,  1331,  1343,  1352,  1356,  1415,  1421,
1205   1429,  1434,  1439,  1442,  1445,  1452,  1462,  1493,  1500,  1521,
1206   1531,  1536,  1543,  1553,  1556,  1563,  1563,  1573,  1580,  1584,
1207   1587,  1590,  1593,  1606,  1626,  1628,  1630,  1633,  1636,  1640,
1208   1643,  1645,  1647,  1651,  1663,  1664,  1666,  1669,  1677,  1682,
1209   1684,  1688,  1692,  1700,  1700,  1701,  1701,  1703,  1709,  1714,
1210   1720,  1723,  1728,  1732,  1736,  1822,  1822,  1824,  1832,  1832,
1211   1834,  1838,  1838,  1847,  1850,  1854,  1857,  1860,  1863,  1866,
1212   1869,  1872,  1875,  1878,  1902,  1905,  1918,  1921,  1926,  1926,
1213   1932,  1936,  1939,  1947,  1956,  1960,  1970,  1981,  1984,  1987,
1214   1990,  1993,  2007,  2011,  2064,  2067,  2073,  2081,  2091,  2098,
1215   2103,  2110,  2114,  2120,  2120,  2122,  2125,  2131,  2143,  2154,
1216   2164,  2176,  2183,  2190,  2197,  2202,  2221,  2243,  2251,  2263,
1217   2277,  2334,  2340,  2342,  2346,  2349,  2355,  2359,  2363,  2367,
1218   2371,  2378,  2388,  2401
1219 };
1220 #endif
1221
1222
1223 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1224
1225 static const char * const yytname[] = {   "$","error","$undefined.","ESINT64VAL",
1226 "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1227 "USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1228 "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1229 "BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1230 "DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1231 "OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE",
1232 "BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK",
1233 "CCC_TOK","FASTCC_TOK","COLDCC_TOK","RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE",
1234 "ADD","SUB","MUL","DIV","REM","AND","OR","XOR","SETLE","SETGE","SETLT","SETGT",
1235 "SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK",
1236 "CAST","SELECT","SHL","SHR","VAARG","EXTRACTELEMENT","INSERTELEMENT","VAARG_old",
1237 "VANEXT_old","'='","','","'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'",
1238 "'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps","LogicalOps","SetCondOps",
1239 "ShiftOps","SIntType","UIntType","IntType","FPType","OptAssign","OptLinkage",
1240 "OptCallingConv","OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes",
1241 "GlobalVarAttribute","TypesV","UpRTypesV","Types","PrimType","UpRTypes","TypeListI",
1242 "ArgTypeListI","ConstVal","ConstExpr","ConstVector","GlobalType","Module","FunctionList",
1243 "ConstPool","@1","@2","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition",
1244 "LibList","Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1245 "FunctionHeader","END","Function","FunctionProto","@3","OptSideEffect","ConstValueRef",
1246 "SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList",
1247 "BBTerminatorInst","JumpTable","Inst","PHIList","ValueRefList","ValueRefListE",
1248 "OptTailCall","InstVal","IndexList","OptVolatile","MemoryInst", NULL
1249 };
1250 #endif
1251
1252 static const short yyr1[] = {     0,
1253    115,   115,   116,   116,   117,   117,   117,   117,   117,   118,
1254    118,   118,   119,   119,   119,   119,   119,   119,   120,   120,
1255    121,   121,   121,   121,   122,   122,   122,   122,   123,   123,
1256    124,   124,   125,   125,   126,   126,   126,   126,   126,   127,
1257    127,   127,   127,   127,   128,   128,   129,   129,   130,   131,
1258    131,   132,   132,   133,   133,   134,   134,   135,   135,   136,
1259    137,   137,   137,   137,   137,   137,   137,   137,   137,   137,
1260    137,   137,   137,   138,   138,   138,   138,   138,   138,   138,
1261    138,   138,   138,   139,   139,   140,   140,   140,   140,   141,
1262    141,   141,   141,   141,   141,   141,   141,   141,   141,   141,
1263    141,   141,   141,   141,   141,   142,   142,   142,   142,   142,
1264    142,   142,   142,   143,   143,   144,   144,   145,   146,   146,
1265    146,   146,   146,   147,   147,   147,   148,   147,   149,   147,
1266    147,   147,   147,   150,   151,   151,   152,   152,   152,   153,
1267    154,   154,   154,   155,   155,   156,   156,   157,   158,   158,
1268    159,   159,   159,   159,   160,   161,   161,   162,   163,   163,
1269    164,   166,   165,   167,   167,   168,   168,   168,   168,   168,
1270    168,   168,   168,   168,   168,   168,   169,   169,   170,   170,
1271    171,   172,   172,   173,   174,   174,   174,   175,   175,   175,
1272    175,   175,   175,   175,   175,   175,   176,   176,   177,   178,
1273    178,   179,   179,   180,   180,   181,   181,   182,   182,   182,
1274    182,   182,   182,   182,   182,   182,   182,   182,   182,   182,
1275    182,   182,   183,   183,   184,   184,   185,   185,   185,   185,
1276    185,   185,   185,   185
1277 };
1278
1279 static const short yyr2[] = {     0,
1280      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
1281      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
1282      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
1283      1,     1,     2,     0,     1,     1,     1,     1,     0,     0,
1284      1,     1,     1,     2,     0,     2,     0,     3,     2,     0,
1285      1,     0,     3,     1,     2,     1,     1,     1,     1,     1,
1286      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
1287      1,     1,     1,     1,     1,     1,     2,     4,     5,     5,
1288      3,     2,     2,     1,     3,     1,     3,     1,     0,     4,
1289      3,     3,     4,     4,     3,     2,     2,     2,     2,     2,
1290      2,     2,     2,     2,     2,     6,     5,     8,     6,     6,
1291      6,     6,     6,     3,     1,     1,     1,     1,     2,     2,
1292      4,     2,     1,     4,     2,     4,     0,     7,     0,     7,
1293      3,     4,     0,     1,     1,     1,     3,     3,     3,     3,
1294      3,     1,     0,     1,     1,     1,     0,     2,     3,     1,
1295      1,     3,     1,     0,     8,     1,     1,     3,     1,     1,
1296      2,     0,     3,     0,     1,     1,     1,     1,     1,     1,
1297      1,     1,     1,     3,     1,     5,     1,     1,     1,     1,
1298      2,     2,     2,     3,     2,     0,     1,     2,     2,     3,
1299      9,     9,     8,    13,     1,     1,     6,     5,     2,     6,
1300      7,     1,     3,     1,     0,     2,     1,     5,     5,     5,
1301      2,     4,     4,     6,     4,     4,     4,     4,     6,     2,
1302      7,     1,     2,     0,     1,     0,     3,     6,     3,     6,
1303      2,     4,     6,     4
1304 };
1305
1306 static const short yydefact[] = {   133,
1307     39,   123,   122,   162,    35,    36,    37,    38,     0,    40,
1308    186,   119,   120,   186,   144,   145,     0,     0,     0,    39,
1309      0,   125,    40,     0,     0,    41,    42,    43,     0,     0,
1310    187,   183,    34,   159,   160,   161,   182,     0,     0,     0,
1311    131,     0,     0,     0,     0,     0,    33,   163,   134,   121,
1312     44,     1,     2,    57,    61,    62,    63,    64,    65,    66,
1313     67,    68,    69,    70,    71,    72,    73,    74,     0,     0,
1314      0,     0,   177,     0,     0,    56,    75,    60,   178,    76,
1315    156,   157,   158,   226,   185,     0,     0,     0,   143,   132,
1316    126,   124,   116,   117,     0,     0,    77,     0,     0,    59,
1317     82,    84,     0,     0,    89,    83,   225,     0,   207,     0,
1318      0,     0,     0,    40,   195,   196,     5,     6,     7,     8,
1319      9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
1320      0,     0,     0,     0,     0,     0,     0,    19,    20,     0,
1321      0,     0,     0,     0,     0,     0,     0,     0,   184,    40,
1322    199,     0,   222,   139,   136,   135,   137,   138,   142,     0,
1323    129,    61,    62,    63,    64,    65,    66,    67,    68,    69,
1324     70,    71,     0,     0,     0,     0,   127,     0,     0,     0,
1325     81,   154,    88,    86,     0,     0,   211,   206,   189,   188,
1326      0,     0,    24,    28,    23,    27,    22,    26,    21,    25,
1327     29,    30,     0,     0,    47,    47,   231,     0,     0,   220,
1328      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1329      0,     0,     0,     0,     0,   140,    52,   103,   104,     3,
1330      4,   101,   102,   105,   100,    96,    97,     0,     0,     0,
1331      0,     0,     0,     0,     0,     0,     0,     0,     0,    99,
1332     98,    52,    58,    58,    85,   153,   147,   150,   151,     0,
1333      0,    78,   166,   167,   168,   173,   169,   170,   171,   172,
1334    164,     0,   175,   180,   179,   181,     0,   190,     0,     0,
1335      0,   227,     0,   229,   224,     0,     0,     0,     0,     0,
1336      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1337      0,   141,     0,   130,     0,     0,     0,     0,    91,   115,
1338      0,     0,    95,     0,    92,     0,     0,     0,     0,   128,
1339     79,    80,   146,   148,     0,    50,    87,   165,     0,     0,
1340      0,     0,     0,     0,     0,     0,     0,   234,     0,     0,
1341    213,     0,   215,   218,     0,   216,   217,     0,     0,     0,
1342    212,     0,   232,     0,     0,     0,    54,    52,   224,     0,
1343      0,     0,     0,    90,    93,    94,     0,     0,     0,     0,
1344    152,   149,    51,    45,     0,   174,     0,     0,   205,    47,
1345     48,    47,   202,   223,     0,     0,     0,     0,   208,   209,
1346    210,   205,     0,    49,    55,    53,     0,     0,     0,     0,
1347    114,     0,     0,     0,     0,     0,   155,     0,     0,     0,
1348    204,     0,     0,   228,   230,     0,     0,     0,   214,   219,
1349      0,   233,   107,     0,     0,     0,     0,     0,     0,     0,
1350     46,   176,     0,     0,     0,   203,   200,     0,   221,   106,
1351      0,   113,   109,   110,   111,   112,     0,   193,     0,     0,
1352      0,   201,     0,   191,     0,   192,     0,     0,   108,     0,
1353      0,     0,     0,     0,     0,   198,     0,     0,   197,   194,
1354      0,     0,     0
1355 };
1356
1357 static const short yydefgoto[] = {    73,
1358    232,   246,   247,   248,   249,   173,   174,   203,   175,    20,
1359     10,    29,   407,   282,   357,   374,   304,   358,    74,    75,
1360    186,    77,    78,   103,   185,   310,   273,   311,    95,   471,
1361      1,     2,   252,   227,    50,   157,    41,    90,   160,    79,
1362    324,   258,   259,   260,    30,    83,    11,    36,    12,    13,
1363     23,   329,   274,    80,   276,   383,    14,    32,    33,   149,
1364    450,    85,   210,   411,   412,   150,   151,   338,   152,   153
1365 };
1366
1367 static const short yypact[] = {-32768,
1368     30,    99,-32768,-32768,-32768,-32768,-32768,-32768,   -47,    46,
1369     33,-32768,-32768,   -13,-32768,-32768,    75,   -32,    26,    21,
1370     -3,-32768,    46,    63,   100,-32768,-32768,-32768,   974,   -21,
1371 -32768,-32768,   105,-32768,-32768,-32768,-32768,    10,    27,    32,
1372 -32768,    38,    63,   974,   103,   103,-32768,-32768,-32768,-32768,
1373 -32768,-32768,-32768,    18,-32768,-32768,-32768,-32768,-32768,-32768,
1374 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   135,   148,
1375    155,   490,-32768,   105,    67,-32768,-32768,   -64,-32768,-32768,
1376 -32768,-32768,-32768,  1136,-32768,   149,    85,   172,   154,-32768,
1377 -32768,-32768,-32768,-32768,  1012,  1050,-32768,    73,    76,-32768,
1378 -32768,   -64,   -17,    80,   784,-32768,-32768,  1012,-32768,   129,
1379   1088,    23,   221,    46,-32768,-32768,-32768,-32768,-32768,-32768,
1380 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1381   1012,  1012,  1012,  1012,  1012,  1012,  1012,-32768,-32768,  1012,
1382   1012,  1012,  1012,  1012,  1012,  1012,  1012,  1012,-32768,    46,
1383 -32768,    60,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   -14,
1384 -32768,   123,   153,   182,   159,   186,   162,   187,   164,   188,
1385    189,   190,   166,   194,   193,   372,-32768,  1012,  1012,  1012,
1386 -32768,   822,-32768,   101,   102,   622,-32768,-32768,    18,-32768,
1387    622,   622,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1388 -32768,-32768,   622,   974,   104,   107,-32768,   622,    98,   108,
1389    169,   109,   110,   118,   119,   120,   121,   622,   622,   622,
1390    122,   974,  1012,  1012,   201,-32768,   124,-32768,-32768,-32768,
1391 -32768,-32768,-32768,-32768,-32768,-32768,-32768,   136,   137,   138,
1392    141,   860,  1050,   531,   215,   142,   143,   144,   146,-32768,
1393 -32768,   124,   -75,   -53,   -64,-32768,   105,-32768,   150,   139,
1394    898,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1395    191,  1050,-32768,-32768,-32768,-32768,   151,-32768,   152,   622,
1396      5,-32768,    16,-32768,   158,   622,   156,  1012,  1012,  1012,
1397   1012,  1012,  1012,  1012,   161,   165,   168,  1012,   622,   622,
1398    170,-32768,   -18,-32768,  1050,  1050,  1050,  1050,-32768,-32768,
1399    -11,   -65,-32768,   -16,-32768,  1050,  1050,  1050,  1050,-32768,
1400 -32768,-32768,-32768,-32768,   936,   222,-32768,-32768,   233,   -10,
1401    245,   250,   171,   622,   269,   622,  1012,-32768,   178,   622,
1402 -32768,   179,-32768,-32768,   180,-32768,-32768,   622,   622,   622,
1403 -32768,   181,-32768,  1012,   259,   280,-32768,   124,   158,   255,
1404    184,   192,  1050,-32768,-32768,-32768,   197,   198,   199,   200,
1405 -32768,-32768,-32768,   238,   202,-32768,   622,   622,  1012,   204,
1406 -32768,   204,-32768,   205,   622,   206,  1012,  1012,-32768,-32768,
1407 -32768,  1012,   622,-32768,-32768,-32768,   207,  1012,  1050,  1050,
1408 -32768,  1050,  1050,  1050,  1050,   289,-32768,   271,   218,   223,
1409    205,   216,   270,-32768,-32768,  1012,   219,   622,-32768,-32768,
1410    225,-32768,-32768,   228,   226,   230,   231,   232,   235,   236,
1411 -32768,-32768,   321,    12,   308,-32768,-32768,   237,-32768,-32768,
1412   1050,-32768,-32768,-32768,-32768,-32768,   622,-32768,   682,    66,
1413    328,-32768,   246,-32768,   248,-32768,   682,   622,-32768,   332,
1414    253,   287,   622,   336,   340,-32768,   622,   622,-32768,-32768,
1415    363,   364,-32768
1416 };
1417
1418 static const short yypgoto[] = {-32768,
1419 -32768,   281,   282,   283,   284,  -112,  -111,  -415,-32768,   339,
1420    359,  -102,-32768,  -201,    54,-32768,  -243,-32768,   -40,-32768,
1421    -29,-32768,   -66,   276,-32768,   -89,   208,  -230,   337,-32768,
1422 -32768,-32768,-32768,-32768,   342,-32768,-32768,-32768,-32768,     1,
1423 -32768,    57,-32768,-32768,   365,-32768,-32768,-32768,-32768,   384,
1424 -32768,-32768,  -356,   -31,   140,   -90,-32768,   375,-32768,-32768,
1425 -32768,-32768,-32768,    53,    -1,-32768,-32768,    34,-32768,-32768
1426 };
1427
1428
1429 #define YYLAST          1236
1430
1431
1432 static const short yytable[] = {    76,
1433    201,   202,    21,    92,   284,   102,   177,    81,   320,    31,
1434     24,   204,   312,   314,    76,   355,    34,   187,   449,   334,
1435    190,   193,   194,   195,   196,   197,   198,   199,   200,  -118,
1436    336,   191,   321,    21,   457,   356,   363,   106,   102,   -58,
1437     44,   330,   207,   192,   365,   211,   212,   222,   106,   213,
1438    214,   215,   216,   217,     3,    31,   322,   221,   335,   106,
1439      4,     5,     6,     7,     8,   161,   176,    45,    42,   335,
1440      5,     6,     7,     8,   104,   193,   194,   195,   196,   197,
1441    198,   199,   200,    43,   180,   363,    49,   225,     9,    82,
1442    363,   363,   455,   226,   181,   366,   364,    47,    35,   376,
1443    461,   205,   206,    51,   208,   209,    25,    26,    27,    28,
1444     86,   253,   254,   255,   396,   218,   219,   220,   -34,   448,
1445     15,   -59,    16,    38,    39,    40,    15,    87,    16,     4,
1446    -34,   -34,    88,   301,    93,    94,   155,   156,    97,   -34,
1447    -34,   -34,   -34,    89,   251,   -34,    17,   223,   224,   228,
1448    229,    98,   257,    18,   275,   -24,   -24,    19,    99,   275,
1449    275,   -23,   -23,   280,   -22,   -22,   -21,   -21,   230,   231,
1450    105,   275,   154,   456,    76,   158,   275,   159,   414,   178,
1451    415,   299,   179,   182,   188,   -28,   275,   275,   275,   -27,
1452    -26,   -25,    76,   300,   255,   -31,   -32,   233,   342,   234,
1453    344,   345,   261,   286,   288,   281,   262,   351,   283,   287,
1454    289,   290,   176,   176,   176,   359,   360,   361,   362,   291,
1455    292,   293,   294,   298,   302,   303,   367,   368,   369,   370,
1456    193,   194,   195,   196,   197,   198,   199,   200,   315,   305,
1457    306,   307,   176,   326,   308,   316,   317,   318,   275,   319,
1458    328,   325,   331,   332,   275,   355,   375,   323,   341,   337,
1459    343,   340,   348,   346,   347,   377,   349,   275,   275,   350,
1460    378,   354,   381,   401,   379,   176,   176,   176,   176,   385,
1461    387,   388,   394,   395,   392,   399,   176,   176,   176,   176,
1462    398,   406,   431,   400,   432,   257,   419,   420,   402,   403,
1463    404,   405,   275,   408,   275,   413,   416,   418,   275,   425,
1464    426,   423,   427,   428,   429,   430,   275,   275,   275,   433,
1465    435,   201,   202,   335,   393,   436,   437,   441,   434,   439,
1466    277,   278,   440,   176,   442,   443,   444,   201,   202,   445,
1467    446,   447,   279,   451,   452,   275,   275,   285,   458,   460,
1468    459,   453,   463,   275,   464,   465,   467,   295,   296,   297,
1469    468,   275,   472,   473,   145,   146,   147,   148,   424,   176,
1470    176,    84,   176,   176,   176,   176,    52,    53,    46,   373,
1471    184,   372,    96,   250,    91,    22,   275,    48,    37,   384,
1472    421,     0,   397,    15,     0,    16,     0,   235,     0,     0,
1473      0,     0,     0,     0,     0,     0,     0,     0,     0,   236,
1474    237,   176,     0,     0,     0,   275,     0,     0,     0,   333,
1475      0,     0,     0,     0,     0,   339,   275,     0,     0,     0,
1476      0,   275,     0,     0,     0,   275,   275,     0,   352,   353,
1477      0,     0,   117,   118,   119,   120,   121,   122,   123,   124,
1478    125,   126,   127,   128,   129,   130,     0,     0,     0,     0,
1479      0,   238,     0,   239,   240,   138,   139,     0,   241,     0,
1480      0,     0,     0,   380,     0,   382,     0,   242,     0,   386,
1481    243,     0,   244,     0,     0,   245,     0,   389,   390,   391,
1482      0,     0,     0,     0,    52,    53,     0,   100,    55,    56,
1483     57,    58,    59,    60,    61,    62,    63,    64,    65,    66,
1484     67,    15,     0,    16,     0,     0,   409,   410,     0,     0,
1485      0,     0,     0,     0,   417,     0,     0,     0,     0,     0,
1486      0,     0,   422,     0,    68,    52,    53,     0,   100,   162,
1487    163,   164,   165,   166,   167,   168,   169,   170,   171,   172,
1488     66,    67,    15,     0,    16,     0,     0,   438,     0,     0,
1489      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1490      0,     0,     0,     0,     0,    68,     0,     0,     0,     0,
1491      0,     0,     0,     0,     0,     0,   454,     0,     0,     0,
1492      0,     0,    69,     0,     0,    70,     0,   462,    71,     0,
1493     72,   101,   466,     0,     0,     0,   469,   470,     0,     0,
1494      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1495      0,     0,     0,     0,   263,   264,    52,    53,   265,     0,
1496      0,     0,     0,    69,     0,     0,    70,     0,     0,    71,
1497      0,    72,   313,    15,     0,    16,     0,   266,   267,   268,
1498      0,     0,     0,     0,     0,     0,     0,     0,     0,   269,
1499    270,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1500      0,     0,     0,     0,     0,     0,     0,     0,     0,   271,
1501      0,     0,     0,     0,   263,   264,     0,     0,   265,     0,
1502      0,     0,   117,   118,   119,   120,   121,   122,   123,   124,
1503    125,   126,   127,   128,   129,   130,     0,   266,   267,   268,
1504      0,   238,     0,   239,   240,   138,   139,     0,   241,   269,
1505    270,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1506    272,     0,     0,     0,     0,     0,     0,     0,     0,   271,
1507      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1508      0,     0,   117,   118,   119,   120,   121,   122,   123,   124,
1509    125,   126,   127,   128,   129,   130,     0,     0,     0,     0,
1510      0,   238,     0,   239,   240,   138,   139,     0,   241,     0,
1511      0,     0,     0,     0,     0,     0,     0,     0,    52,    53,
1512    272,   100,    55,    56,    57,    58,    59,    60,    61,    62,
1513     63,    64,    65,    66,    67,    15,     0,    16,     0,     0,
1514      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1515    183,     0,     0,     0,     0,     0,    52,    53,    68,   100,
1516     55,    56,    57,    58,    59,    60,    61,    62,    63,    64,
1517     65,    66,    67,    15,     0,    16,     0,     0,     0,     0,
1518      0,     0,     0,     0,     0,     0,     0,     0,   256,     0,
1519      0,     0,     0,     0,    52,    53,    68,   100,   162,   163,
1520    164,   165,   166,   167,   168,   169,   170,   171,   172,    66,
1521     67,    15,     0,    16,     0,     0,    69,     0,     0,    70,
1522      0,     0,    71,     0,    72,     0,     0,     0,     0,     0,
1523      0,     0,    52,    53,    68,   100,    55,    56,    57,    58,
1524     59,    60,    61,    62,    63,    64,    65,    66,    67,    15,
1525      0,    16,     0,     0,    69,     0,     0,    70,     0,     0,
1526     71,     0,    72,     0,   327,     0,     0,     0,     0,     0,
1527     52,    53,    68,   100,    55,    56,    57,    58,    59,    60,
1528     61,    62,    63,    64,    65,    66,    67,    15,     0,    16,
1529      0,     0,    69,     0,     0,    70,     0,   309,    71,     0,
1530     72,     0,   371,     0,     0,     0,     0,     0,    52,    53,
1531     68,    54,    55,    56,    57,    58,    59,    60,    61,    62,
1532     63,    64,    65,    66,    67,    15,     0,    16,     0,     0,
1533     69,     0,     0,    70,     0,     0,    71,     0,    72,     0,
1534      0,     0,     0,     0,     0,     0,    52,    53,    68,   100,
1535     55,    56,    57,    58,    59,    60,    61,    62,    63,    64,
1536     65,    66,    67,    15,     0,    16,     0,     0,    69,     0,
1537      0,    70,     0,     0,    71,     0,    72,     0,     0,     0,
1538      0,     0,     0,     0,    52,    53,    68,   100,   162,   163,
1539    164,   165,   166,   167,   168,   169,   170,   171,   172,    66,
1540     67,    15,     0,    16,     0,     0,    69,     0,     0,    70,
1541      0,     0,    71,     0,    72,     0,     0,     0,     0,     0,
1542      0,     0,    52,    53,    68,   189,    55,    56,    57,    58,
1543     59,    60,    61,    62,    63,    64,    65,    66,    67,    15,
1544      0,    16,     0,     0,    69,     0,     0,    70,     0,     0,
1545     71,     0,    72,     0,     0,     0,     0,     0,     0,     0,
1546      0,     0,    68,     0,     0,     0,     0,     0,     0,     0,
1547      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1548      0,     0,    69,     0,     0,    70,     0,     0,    71,     0,
1549     72,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1550    107,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1551      0,   108,     0,     0,     0,     0,     0,     0,     0,     0,
1552     69,   109,   110,    70,     0,     0,    71,     0,    72,     0,
1553    111,   112,   113,   114,   115,   116,   117,   118,   119,   120,
1554    121,   122,   123,   124,   125,   126,   127,   128,   129,   130,
1555    131,   132,   133,     0,     0,   134,   135,   136,   137,   138,
1556    139,   140,   141,   142,   143,   144
1557 };
1558
1559 static const short yycheck[] = {    29,
1560    113,   113,     2,    44,   206,    72,    96,    29,   252,    23,
1561     58,   114,   243,   244,    44,    34,    30,   108,   434,    15,
1562    111,    10,    11,    12,    13,    14,    15,    16,    17,     0,
1563     15,     9,   108,    33,   450,    54,   102,   113,   105,   104,
1564     20,   272,   133,    21,   110,   136,   137,   150,   113,   140,
1565    141,   142,   143,   144,    25,    23,   110,   148,    54,   113,
1566     31,    41,    42,    43,    44,    95,    96,    47,   101,    54,
1567     41,    42,    43,    44,    74,    10,    11,    12,    13,    14,
1568     15,    16,    17,    58,   102,   102,    24,   102,    59,   111,
1569    102,   102,   449,   108,   112,   112,   108,   101,   112,   110,
1570    457,   131,   132,     4,   134,   135,    61,    62,    63,    64,
1571    101,   178,   179,   180,   358,   145,   146,   147,    20,   108,
1572     22,   104,    24,    49,    50,    51,    22,   101,    24,    31,
1573     32,    33,   101,   224,    32,    33,    52,    53,     4,    41,
1574     42,    43,    44,   106,   176,    47,    48,    88,    89,    27,
1575     28,     4,   182,    55,   186,     3,     4,    59,     4,   191,
1576    192,     3,     4,   204,     3,     4,     3,     4,     3,     4,
1577    104,   203,    24,   108,   204,     4,   208,    24,   380,   107,
1578    382,   222,   107,   104,    56,     4,   218,   219,   220,     4,
1579      4,     4,   222,   223,   261,     7,     7,     4,   289,     7,
1580    291,   292,   102,   106,    36,   102,   105,   298,   102,   102,
1581    102,   102,   242,   243,   244,   305,   306,   307,   308,   102,
1582    102,   102,   102,   102,    24,   102,   316,   317,   318,   319,
1583     10,    11,    12,    13,    14,    15,    16,    17,    24,   104,
1584    104,   104,   272,   105,   104,   104,   104,   104,   280,   104,
1585     60,   102,   102,   102,   286,    34,    24,   257,   288,   102,
1586    290,   106,   102,   293,   294,    21,   102,   299,   300,   102,
1587     21,   102,     4,   363,   104,   305,   306,   307,   308,   102,
1588    102,   102,    24,     4,   104,   102,   316,   317,   318,   319,
1589     36,    54,     4,   102,    24,   325,   387,   388,   102,   102,
1590    102,   102,   334,   102,   336,   102,   102,   102,   340,   399,
1591    400,   105,   402,   403,   404,   405,   348,   349,   350,   102,
1592    105,   434,   434,    54,   354,   416,   108,   102,   106,   105,
1593    191,   192,   105,   363,   105,   105,   105,   450,   450,   105,
1594    105,    21,   203,    36,   108,   377,   378,   208,    21,   102,
1595    105,   441,    21,   385,   102,    69,    21,   218,   219,   220,
1596     21,   393,     0,     0,    84,    84,    84,    84,   398,   399,
1597    400,    33,   402,   403,   404,   405,     5,     6,    20,   326,
1598    105,   325,    46,   176,    43,     2,   418,    23,    14,   337,
1599    392,    -1,   359,    22,    -1,    24,    -1,    26,    -1,    -1,
1600     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    38,
1601     39,   441,    -1,    -1,    -1,   447,    -1,    -1,    -1,   280,
1602     -1,    -1,    -1,    -1,    -1,   286,   458,    -1,    -1,    -1,
1603     -1,   463,    -1,    -1,    -1,   467,   468,    -1,   299,   300,
1604     -1,    -1,    71,    72,    73,    74,    75,    76,    77,    78,
1605     79,    80,    81,    82,    83,    84,    -1,    -1,    -1,    -1,
1606     -1,    90,    -1,    92,    93,    94,    95,    -1,    97,    -1,
1607     -1,    -1,    -1,   334,    -1,   336,    -1,   106,    -1,   340,
1608    109,    -1,   111,    -1,    -1,   114,    -1,   348,   349,   350,
1609     -1,    -1,    -1,    -1,     5,     6,    -1,     8,     9,    10,
1610     11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
1611     21,    22,    -1,    24,    -1,    -1,   377,   378,    -1,    -1,
1612     -1,    -1,    -1,    -1,   385,    -1,    -1,    -1,    -1,    -1,
1613     -1,    -1,   393,    -1,    45,     5,     6,    -1,     8,     9,
1614     10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
1615     20,    21,    22,    -1,    24,    -1,    -1,   418,    -1,    -1,
1616     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1617     -1,    -1,    -1,    -1,    -1,    45,    -1,    -1,    -1,    -1,
1618     -1,    -1,    -1,    -1,    -1,    -1,   447,    -1,    -1,    -1,
1619     -1,    -1,   103,    -1,    -1,   106,    -1,   458,   109,    -1,
1620    111,   112,   463,    -1,    -1,    -1,   467,   468,    -1,    -1,
1621     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1622     -1,    -1,    -1,    -1,     3,     4,     5,     6,     7,    -1,
1623     -1,    -1,    -1,   103,    -1,    -1,   106,    -1,    -1,   109,
1624     -1,   111,   112,    22,    -1,    24,    -1,    26,    27,    28,
1625     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    38,
1626     39,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1627     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    58,
1628     -1,    -1,    -1,    -1,     3,     4,    -1,    -1,     7,    -1,
1629     -1,    -1,    71,    72,    73,    74,    75,    76,    77,    78,
1630     79,    80,    81,    82,    83,    84,    -1,    26,    27,    28,
1631     -1,    90,    -1,    92,    93,    94,    95,    -1,    97,    38,
1632     39,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1633    109,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    58,
1634     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1635     -1,    -1,    71,    72,    73,    74,    75,    76,    77,    78,
1636     79,    80,    81,    82,    83,    84,    -1,    -1,    -1,    -1,
1637     -1,    90,    -1,    92,    93,    94,    95,    -1,    97,    -1,
1638     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,     5,     6,
1639    109,     8,     9,    10,    11,    12,    13,    14,    15,    16,
1640     17,    18,    19,    20,    21,    22,    -1,    24,    -1,    -1,
1641     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1642     37,    -1,    -1,    -1,    -1,    -1,     5,     6,    45,     8,
1643      9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
1644     19,    20,    21,    22,    -1,    24,    -1,    -1,    -1,    -1,
1645     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    37,    -1,
1646     -1,    -1,    -1,    -1,     5,     6,    45,     8,     9,    10,
1647     11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
1648     21,    22,    -1,    24,    -1,    -1,   103,    -1,    -1,   106,
1649     -1,    -1,   109,    -1,   111,    -1,    -1,    -1,    -1,    -1,
1650     -1,    -1,     5,     6,    45,     8,     9,    10,    11,    12,
1651     13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
1652     -1,    24,    -1,    -1,   103,    -1,    -1,   106,    -1,    -1,
1653    109,    -1,   111,    -1,    37,    -1,    -1,    -1,    -1,    -1,
1654      5,     6,    45,     8,     9,    10,    11,    12,    13,    14,
1655     15,    16,    17,    18,    19,    20,    21,    22,    -1,    24,
1656     -1,    -1,   103,    -1,    -1,   106,    -1,   108,   109,    -1,
1657    111,    -1,    37,    -1,    -1,    -1,    -1,    -1,     5,     6,
1658     45,     8,     9,    10,    11,    12,    13,    14,    15,    16,
1659     17,    18,    19,    20,    21,    22,    -1,    24,    -1,    -1,
1660    103,    -1,    -1,   106,    -1,    -1,   109,    -1,   111,    -1,
1661     -1,    -1,    -1,    -1,    -1,    -1,     5,     6,    45,     8,
1662      9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
1663     19,    20,    21,    22,    -1,    24,    -1,    -1,   103,    -1,
1664     -1,   106,    -1,    -1,   109,    -1,   111,    -1,    -1,    -1,
1665     -1,    -1,    -1,    -1,     5,     6,    45,     8,     9,    10,
1666     11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
1667     21,    22,    -1,    24,    -1,    -1,   103,    -1,    -1,   106,
1668     -1,    -1,   109,    -1,   111,    -1,    -1,    -1,    -1,    -1,
1669     -1,    -1,     5,     6,    45,     8,     9,    10,    11,    12,
1670     13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
1671     -1,    24,    -1,    -1,   103,    -1,    -1,   106,    -1,    -1,
1672    109,    -1,   111,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1673     -1,    -1,    45,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1674     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1675     -1,    -1,   103,    -1,    -1,   106,    -1,    -1,   109,    -1,
1676    111,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1677     35,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1678     -1,    46,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1679    103,    56,    57,   106,    -1,    -1,   109,    -1,   111,    -1,
1680     65,    66,    67,    68,    69,    70,    71,    72,    73,    74,
1681     75,    76,    77,    78,    79,    80,    81,    82,    83,    84,
1682     85,    86,    87,    -1,    -1,    90,    91,    92,    93,    94,
1683     95,    96,    97,    98,    99,   100
1684 };
1685 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
1686 #line 3 "/usr/share/bison.simple"
1687 /* This file comes from bison-1.28.  */
1688
1689 /* Skeleton output parser for bison,
1690    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1691
1692    This program is free software; you can redistribute it and/or modify
1693    it under the terms of the GNU General Public License as published by
1694    the Free Software Foundation; either version 2, or (at your option)
1695    any later version.
1696
1697    This program is distributed in the hope that it will be useful,
1698    but WITHOUT ANY WARRANTY; without even the implied warranty of
1699    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1700    GNU General Public License for more details.
1701
1702    You should have received a copy of the GNU General Public License
1703    along with this program; if not, write to the Free Software
1704    Foundation, Inc., 59 Temple Place - Suite 330,
1705    Boston, MA 02111-1307, USA.  */
1706
1707 /* As a special exception, when this file is copied by Bison into a
1708    Bison output file, you may use that output file without restriction.
1709    This special exception was added by the Free Software Foundation
1710    in version 1.24 of Bison.  */
1711
1712 /* This is the parser code that is written into each bison parser
1713   when the %semantic_parser declaration is not specified in the grammar.
1714   It was written by Richard Stallman by simplifying the hairy parser
1715   used when %semantic_parser is specified.  */
1716
1717 #ifndef YYSTACK_USE_ALLOCA
1718 #ifdef alloca
1719 #define YYSTACK_USE_ALLOCA
1720 #else /* alloca not defined */
1721 #ifdef __GNUC__
1722 #define YYSTACK_USE_ALLOCA
1723 #define alloca __builtin_alloca
1724 #else /* not GNU C.  */
1725 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1726 #define YYSTACK_USE_ALLOCA
1727 #include <alloca.h>
1728 #else /* not sparc */
1729 /* We think this test detects Watcom and Microsoft C.  */
1730 /* This used to test MSDOS, but that is a bad idea
1731    since that symbol is in the user namespace.  */
1732 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1733 #if 0 /* No need for malloc.h, which pollutes the namespace;
1734          instead, just don't use alloca.  */
1735 #include <malloc.h>
1736 #endif
1737 #else /* not MSDOS, or __TURBOC__ */
1738 #if defined(_AIX)
1739 /* I don't know what this was needed for, but it pollutes the namespace.
1740    So I turned it off.   rms, 2 May 1997.  */
1741 /* #include <malloc.h>  */
1742  #pragma alloca
1743 #define YYSTACK_USE_ALLOCA
1744 #else /* not MSDOS, or __TURBOC__, or _AIX */
1745 #if 0
1746 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1747                  and on HPUX 10.  Eventually we can turn this on.  */
1748 #define YYSTACK_USE_ALLOCA
1749 #define alloca __builtin_alloca
1750 #endif /* __hpux */
1751 #endif
1752 #endif /* not _AIX */
1753 #endif /* not MSDOS, or __TURBOC__ */
1754 #endif /* not sparc */
1755 #endif /* not GNU C */
1756 #endif /* alloca not defined */
1757 #endif /* YYSTACK_USE_ALLOCA not defined */
1758
1759 #ifdef YYSTACK_USE_ALLOCA
1760 #define YYSTACK_ALLOC alloca
1761 #else
1762 #define YYSTACK_ALLOC malloc
1763 #endif
1764
1765 /* Note: there must be only one dollar sign in this file.
1766    It is replaced by the list of actions, each action
1767    as one case of the switch.  */
1768
1769 #define yyerrok         (yyerrstatus = 0)
1770 #define yyclearin       (yychar = YYEMPTY)
1771 #define YYEMPTY         -2
1772 #define YYEOF           0
1773 #define YYACCEPT        goto yyacceptlab
1774 #define YYABORT         goto yyabortlab
1775 #define YYERROR         goto yyerrlab1
1776 /* Like YYERROR except do call yyerror.
1777    This remains here temporarily to ease the
1778    transition to the new meaning of YYERROR, for GCC.
1779    Once GCC version 2 has supplanted version 1, this can go.  */
1780 #define YYFAIL          goto yyerrlab
1781 #define YYRECOVERING()  (!!yyerrstatus)
1782 #define YYBACKUP(token, value) \
1783 do                                                              \
1784   if (yychar == YYEMPTY && yylen == 1)                          \
1785     { yychar = (token), yylval = (value);                       \
1786       yychar1 = YYTRANSLATE (yychar);                           \
1787       YYPOPSTACK;                                               \
1788       goto yybackup;                                            \
1789     }                                                           \
1790   else                                                          \
1791     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
1792 while (0)
1793
1794 #define YYTERROR        1
1795 #define YYERRCODE       256
1796
1797 #ifndef YYPURE
1798 #define YYLEX           yylex()
1799 #endif
1800
1801 #ifdef YYPURE
1802 #ifdef YYLSP_NEEDED
1803 #ifdef YYLEX_PARAM
1804 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
1805 #else
1806 #define YYLEX           yylex(&yylval, &yylloc)
1807 #endif
1808 #else /* not YYLSP_NEEDED */
1809 #ifdef YYLEX_PARAM
1810 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
1811 #else
1812 #define YYLEX           yylex(&yylval)
1813 #endif
1814 #endif /* not YYLSP_NEEDED */
1815 #endif
1816
1817 /* If nonreentrant, generate the variables here */
1818
1819 #ifndef YYPURE
1820
1821 int     yychar;                 /*  the lookahead symbol                */
1822 YYSTYPE yylval;                 /*  the semantic value of the           */
1823                                 /*  lookahead symbol                    */
1824
1825 #ifdef YYLSP_NEEDED
1826 YYLTYPE yylloc;                 /*  location data for the lookahead     */
1827                                 /*  symbol                              */
1828 #endif
1829
1830 int yynerrs;                    /*  number of parse errors so far       */
1831 #endif  /* not YYPURE */
1832
1833 #if YYDEBUG != 0
1834 int yydebug;                    /*  nonzero means print parse trace     */
1835 /* Since this is uninitialized, it does not stop multiple parsers
1836    from coexisting.  */
1837 #endif
1838
1839 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
1840
1841 #ifndef YYINITDEPTH
1842 #define YYINITDEPTH 200
1843 #endif
1844
1845 /*  YYMAXDEPTH is the maximum size the stacks can grow to
1846     (effective only if the built-in stack extension method is used).  */
1847
1848 #if YYMAXDEPTH == 0
1849 #undef YYMAXDEPTH
1850 #endif
1851
1852 #ifndef YYMAXDEPTH
1853 #define YYMAXDEPTH 10000
1854 #endif
1855 \f
1856 /* Define __yy_memcpy.  Note that the size argument
1857    should be passed with type unsigned int, because that is what the non-GCC
1858    definitions require.  With GCC, __builtin_memcpy takes an arg
1859    of type size_t, but it can handle unsigned int.  */
1860
1861 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
1862 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
1863 #else                           /* not GNU C or C++ */
1864 #ifndef __cplusplus
1865
1866 /* This is the most reliable way to avoid incompatibilities
1867    in available built-in functions on various systems.  */
1868 static void
1869 __yy_memcpy (to, from, count)
1870      char *to;
1871      char *from;
1872      unsigned int count;
1873 {
1874   register char *f = from;
1875   register char *t = to;
1876   register int i = count;
1877
1878   while (i-- > 0)
1879     *t++ = *f++;
1880 }
1881
1882 #else /* __cplusplus */
1883
1884 /* This is the most reliable way to avoid incompatibilities
1885    in available built-in functions on various systems.  */
1886 static void
1887 __yy_memcpy (char *to, char *from, unsigned int count)
1888 {
1889   register char *t = to;
1890   register char *f = from;
1891   register int i = count;
1892
1893   while (i-- > 0)
1894     *t++ = *f++;
1895 }
1896
1897 #endif
1898 #endif
1899 \f
1900 #line 217 "/usr/share/bison.simple"
1901
1902 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
1903    into yyparse.  The argument should have type void *.
1904    It should actually point to an object.
1905    Grammar actions can access the variable by casting it
1906    to the proper pointer type.  */
1907
1908 #ifdef YYPARSE_PARAM
1909 #ifdef __cplusplus
1910 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1911 #define YYPARSE_PARAM_DECL
1912 #else /* not __cplusplus */
1913 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1914 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1915 #endif /* not __cplusplus */
1916 #else /* not YYPARSE_PARAM */
1917 #define YYPARSE_PARAM_ARG
1918 #define YYPARSE_PARAM_DECL
1919 #endif /* not YYPARSE_PARAM */
1920
1921 /* Prevent warning if -Wstrict-prototypes.  */
1922 #ifdef __GNUC__
1923 #ifdef YYPARSE_PARAM
1924 int yyparse (void *);
1925 #else
1926 int yyparse (void);
1927 #endif
1928 #endif
1929
1930 int
1931 yyparse(YYPARSE_PARAM_ARG)
1932      YYPARSE_PARAM_DECL
1933 {
1934   register int yystate;
1935   register int yyn;
1936   register short *yyssp;
1937   register YYSTYPE *yyvsp;
1938   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
1939   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
1940
1941   short yyssa[YYINITDEPTH];     /*  the state stack                     */
1942   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
1943
1944   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
1945   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
1946
1947 #ifdef YYLSP_NEEDED
1948   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
1949   YYLTYPE *yyls = yylsa;
1950   YYLTYPE *yylsp;
1951
1952 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
1953 #else
1954 #define YYPOPSTACK   (yyvsp--, yyssp--)
1955 #endif
1956
1957   int yystacksize = YYINITDEPTH;
1958   int yyfree_stacks = 0;
1959
1960 #ifdef YYPURE
1961   int yychar;
1962   YYSTYPE yylval;
1963   int yynerrs;
1964 #ifdef YYLSP_NEEDED
1965   YYLTYPE yylloc;
1966 #endif
1967 #endif
1968
1969   YYSTYPE yyval;                /*  the variable used to return         */
1970                                 /*  semantic values from the action     */
1971                                 /*  routines                            */
1972
1973   int yylen;
1974
1975 #if YYDEBUG != 0
1976   if (yydebug)
1977     fprintf(stderr, "Starting parse\n");
1978 #endif
1979
1980   yystate = 0;
1981   yyerrstatus = 0;
1982   yynerrs = 0;
1983   yychar = YYEMPTY;             /* Cause a token to be read.  */
1984
1985   /* Initialize stack pointers.
1986      Waste one element of value and location stack
1987      so that they stay on the same level as the state stack.
1988      The wasted elements are never initialized.  */
1989
1990   yyssp = yyss - 1;
1991   yyvsp = yyvs;
1992 #ifdef YYLSP_NEEDED
1993   yylsp = yyls;
1994 #endif
1995
1996 /* Push a new state, which is found in  yystate  .  */
1997 /* In all cases, when you get here, the value and location stacks
1998    have just been pushed. so pushing a state here evens the stacks.  */
1999 yynewstate:
2000
2001   *++yyssp = yystate;
2002
2003   if (yyssp >= yyss + yystacksize - 1)
2004     {
2005       /* Give user a chance to reallocate the stack */
2006       /* Use copies of these so that the &'s don't force the real ones into memory. */
2007       YYSTYPE *yyvs1 = yyvs;
2008       short *yyss1 = yyss;
2009 #ifdef YYLSP_NEEDED
2010       YYLTYPE *yyls1 = yyls;
2011 #endif
2012
2013       /* Get the current used size of the three stacks, in elements.  */
2014       int size = yyssp - yyss + 1;
2015
2016 #ifdef yyoverflow
2017       /* Each stack pointer address is followed by the size of
2018          the data in use in that stack, in bytes.  */
2019 #ifdef YYLSP_NEEDED
2020       /* This used to be a conditional around just the two extra args,
2021          but that might be undefined if yyoverflow is a macro.  */
2022       yyoverflow("parser stack overflow",
2023                  &yyss1, size * sizeof (*yyssp),
2024                  &yyvs1, size * sizeof (*yyvsp),
2025                  &yyls1, size * sizeof (*yylsp),
2026                  &yystacksize);
2027 #else
2028       yyoverflow("parser stack overflow",
2029                  &yyss1, size * sizeof (*yyssp),
2030                  &yyvs1, size * sizeof (*yyvsp),
2031                  &yystacksize);
2032 #endif
2033
2034       yyss = yyss1; yyvs = yyvs1;
2035 #ifdef YYLSP_NEEDED
2036       yyls = yyls1;
2037 #endif
2038 #else /* no yyoverflow */
2039       /* Extend the stack our own way.  */
2040       if (yystacksize >= YYMAXDEPTH)
2041         {
2042           yyerror("parser stack overflow");
2043           if (yyfree_stacks)
2044             {
2045               free (yyss);
2046               free (yyvs);
2047 #ifdef YYLSP_NEEDED
2048               free (yyls);
2049 #endif
2050             }
2051           return 2;
2052         }
2053       yystacksize *= 2;
2054       if (yystacksize > YYMAXDEPTH)
2055         yystacksize = YYMAXDEPTH;
2056 #ifndef YYSTACK_USE_ALLOCA
2057       yyfree_stacks = 1;
2058 #endif
2059       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2060       __yy_memcpy ((char *)yyss, (char *)yyss1,
2061                    size * (unsigned int) sizeof (*yyssp));
2062       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2063       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2064                    size * (unsigned int) sizeof (*yyvsp));
2065 #ifdef YYLSP_NEEDED
2066       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2067       __yy_memcpy ((char *)yyls, (char *)yyls1,
2068                    size * (unsigned int) sizeof (*yylsp));
2069 #endif
2070 #endif /* no yyoverflow */
2071
2072       yyssp = yyss + size - 1;
2073       yyvsp = yyvs + size - 1;
2074 #ifdef YYLSP_NEEDED
2075       yylsp = yyls + size - 1;
2076 #endif
2077
2078 #if YYDEBUG != 0
2079       if (yydebug)
2080         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2081 #endif
2082
2083       if (yyssp >= yyss + yystacksize - 1)
2084         YYABORT;
2085     }
2086
2087 #if YYDEBUG != 0
2088   if (yydebug)
2089     fprintf(stderr, "Entering state %d\n", yystate);
2090 #endif
2091
2092   goto yybackup;
2093  yybackup:
2094
2095 /* Do appropriate processing given the current state.  */
2096 /* Read a lookahead token if we need one and don't already have one.  */
2097 /* yyresume: */
2098
2099   /* First try to decide what to do without reference to lookahead token.  */
2100
2101   yyn = yypact[yystate];
2102   if (yyn == YYFLAG)
2103     goto yydefault;
2104
2105   /* Not known => get a lookahead token if don't already have one.  */
2106
2107   /* yychar is either YYEMPTY or YYEOF
2108      or a valid token in external form.  */
2109
2110   if (yychar == YYEMPTY)
2111     {
2112 #if YYDEBUG != 0
2113       if (yydebug)
2114         fprintf(stderr, "Reading a token: ");
2115 #endif
2116       yychar = YYLEX;
2117     }
2118
2119   /* Convert token to internal form (in yychar1) for indexing tables with */
2120
2121   if (yychar <= 0)              /* This means end of input. */
2122     {
2123       yychar1 = 0;
2124       yychar = YYEOF;           /* Don't call YYLEX any more */
2125
2126 #if YYDEBUG != 0
2127       if (yydebug)
2128         fprintf(stderr, "Now at end of input.\n");
2129 #endif
2130     }
2131   else
2132     {
2133       yychar1 = YYTRANSLATE(yychar);
2134
2135 #if YYDEBUG != 0
2136       if (yydebug)
2137         {
2138           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2139           /* Give the individual parser a way to print the precise meaning
2140              of a token, for further debugging info.  */
2141 #ifdef YYPRINT
2142           YYPRINT (stderr, yychar, yylval);
2143 #endif
2144           fprintf (stderr, ")\n");
2145         }
2146 #endif
2147     }
2148
2149   yyn += yychar1;
2150   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2151     goto yydefault;
2152
2153   yyn = yytable[yyn];
2154
2155   /* yyn is what to do for this token type in this state.
2156      Negative => reduce, -yyn is rule number.
2157      Positive => shift, yyn is new state.
2158        New state is final state => don't bother to shift,
2159        just return success.
2160      0, or most negative number => error.  */
2161
2162   if (yyn < 0)
2163     {
2164       if (yyn == YYFLAG)
2165         goto yyerrlab;
2166       yyn = -yyn;
2167       goto yyreduce;
2168     }
2169   else if (yyn == 0)
2170     goto yyerrlab;
2171
2172   if (yyn == YYFINAL)
2173     YYACCEPT;
2174
2175   /* Shift the lookahead token.  */
2176
2177 #if YYDEBUG != 0
2178   if (yydebug)
2179     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2180 #endif
2181
2182   /* Discard the token being shifted unless it is eof.  */
2183   if (yychar != YYEOF)
2184     yychar = YYEMPTY;
2185
2186   *++yyvsp = yylval;
2187 #ifdef YYLSP_NEEDED
2188   *++yylsp = yylloc;
2189 #endif
2190
2191   /* count tokens shifted since error; after three, turn off error status.  */
2192   if (yyerrstatus) yyerrstatus--;
2193
2194   yystate = yyn;
2195   goto yynewstate;
2196
2197 /* Do the default action for the current state.  */
2198 yydefault:
2199
2200   yyn = yydefact[yystate];
2201   if (yyn == 0)
2202     goto yyerrlab;
2203
2204 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
2205 yyreduce:
2206   yylen = yyr2[yyn];
2207   if (yylen > 0)
2208     yyval = yyvsp[1-yylen]; /* implement default value of the action */
2209
2210 #if YYDEBUG != 0
2211   if (yydebug)
2212     {
2213       int i;
2214
2215       fprintf (stderr, "Reducing via rule %d (line %d), ",
2216                yyn, yyrline[yyn]);
2217
2218       /* Print the symbols being reduced, and their result.  */
2219       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2220         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2221       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2222     }
2223 #endif
2224
2225
2226   switch (yyn) {
2227
2228 case 2:
2229 #line 1011 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2230 {
2231   if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX)     // Outside of my range!
2232     ThrowException("Value too large for type!");
2233   yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
2234 ;
2235     break;}
2236 case 4:
2237 #line 1019 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2238 {
2239   if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX)     // Outside of my range!
2240     ThrowException("Value too large for type!");
2241   yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
2242 ;
2243     break;}
2244 case 33:
2245 #line 1042 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2246 {
2247     yyval.StrVal = yyvsp[-1].StrVal;
2248   ;
2249     break;}
2250 case 34:
2251 #line 1045 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2252 {
2253     yyval.StrVal = 0;
2254   ;
2255     break;}
2256 case 35:
2257 #line 1049 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2258 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2259     break;}
2260 case 36:
2261 #line 1050 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2262 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2263     break;}
2264 case 37:
2265 #line 1051 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2266 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2267     break;}
2268 case 38:
2269 #line 1052 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2270 { yyval.Linkage = GlobalValue::AppendingLinkage; ;
2271     break;}
2272 case 39:
2273 #line 1053 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2274 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2275     break;}
2276 case 40:
2277 #line 1055 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2278 { yyval.UIntVal = CallingConv::C; ;
2279     break;}
2280 case 41:
2281 #line 1056 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2282 { yyval.UIntVal = CallingConv::C; ;
2283     break;}
2284 case 42:
2285 #line 1057 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2286 { yyval.UIntVal = CallingConv::Fast; ;
2287     break;}
2288 case 43:
2289 #line 1058 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2290 { yyval.UIntVal = CallingConv::Cold; ;
2291     break;}
2292 case 44:
2293 #line 1059 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2294 {
2295                    if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2296                      ThrowException("Calling conv too large!");
2297                    yyval.UIntVal = yyvsp[0].UInt64Val;
2298                  ;
2299     break;}
2300 case 45:
2301 #line 1067 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2302 { yyval.UIntVal = 0; ;
2303     break;}
2304 case 46:
2305 #line 1068 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2306 {
2307   yyval.UIntVal = yyvsp[0].UInt64Val;
2308   if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2309     ThrowException("Alignment must be a power of two!");
2310 ;
2311     break;}
2312 case 47:
2313 #line 1073 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2314 { yyval.UIntVal = 0; ;
2315     break;}
2316 case 48:
2317 #line 1074 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2318 {
2319   yyval.UIntVal = yyvsp[0].UInt64Val;
2320   if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2321     ThrowException("Alignment must be a power of two!");
2322 ;
2323     break;}
2324 case 49:
2325 #line 1081 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2326 {
2327   for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2328     if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2329       ThrowException("Invalid character in section name!");
2330   yyval.StrVal = yyvsp[0].StrVal;
2331 ;
2332     break;}
2333 case 50:
2334 #line 1088 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2335 { yyval.StrVal = 0; ;
2336     break;}
2337 case 51:
2338 #line 1089 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2339 { yyval.StrVal = yyvsp[0].StrVal; ;
2340     break;}
2341 case 52:
2342 #line 1094 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2343 {;
2344     break;}
2345 case 53:
2346 #line 1095 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2347 {;
2348     break;}
2349 case 54:
2350 #line 1096 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2351 {
2352     CurGV->setSection(yyvsp[0].StrVal);
2353     free(yyvsp[0].StrVal);
2354   ;
2355     break;}
2356 case 55:
2357 #line 1100 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2358 {
2359     if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2360       ThrowException("Alignment must be a power of two!");
2361     CurGV->setAlignment(yyvsp[0].UInt64Val);
2362   ;
2363     break;}
2364 case 57:
2365 #line 1113 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2366 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2367     break;}
2368 case 59:
2369 #line 1114 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2370 { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2371     break;}
2372 case 60:
2373 #line 1116 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2374 {
2375     if (!UpRefs.empty())
2376       ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2377     yyval.TypeVal = yyvsp[0].TypeVal;
2378   ;
2379     break;}
2380 case 74:
2381 #line 1127 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2382 {
2383     yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2384   ;
2385     break;}
2386 case 75:
2387 #line 1130 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2388 {
2389     yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2390   ;
2391     break;}
2392 case 76:
2393 #line 1133 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2394 {            // Named types are also simple types...
2395   yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal));
2396 ;
2397     break;}
2398 case 77:
2399 #line 1139 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2400 {                   // Type UpReference
2401     if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!");
2402     OpaqueType *OT = OpaqueType::get();        // Use temporary placeholder
2403     UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT));  // Add to vector...
2404     yyval.TypeVal = new PATypeHolder(OT);
2405     UR_OUT("New Upreference!\n");
2406   ;
2407     break;}
2408 case 78:
2409 #line 1146 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2410 {           // Function derived type?
2411     std::vector<const Type*> Params;
2412     for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2413            E = yyvsp[-1].TypeList->end(); I != E; ++I)
2414       Params.push_back(*I);
2415     bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2416     if (isVarArg) Params.pop_back();
2417
2418     yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2419     delete yyvsp[-1].TypeList;      // Delete the argument list
2420     delete yyvsp[-3].TypeVal;      // Delete the return type handle
2421   ;
2422     break;}
2423 case 79:
2424 #line 1158 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2425 {          // Sized array type?
2426     yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2427     delete yyvsp[-1].TypeVal;
2428   ;
2429     break;}
2430 case 80:
2431 #line 1162 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2432 {          // Packed array type?
2433      const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2434      if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
2435         ThrowException("Unsigned result not equal to signed result");
2436      if (!ElemTy->isPrimitiveType())
2437         ThrowException("Elemental type of a PackedType must be primitive");
2438      if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2439        ThrowException("Vector length should be a power of 2!");
2440      yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2441      delete yyvsp[-1].TypeVal;
2442   ;
2443     break;}
2444 case 81:
2445 #line 1173 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2446 {                        // Structure type?
2447     std::vector<const Type*> Elements;
2448     for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2449            E = yyvsp[-1].TypeList->end(); I != E; ++I)
2450       Elements.push_back(*I);
2451
2452     yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2453     delete yyvsp[-1].TypeList;
2454   ;
2455     break;}
2456 case 82:
2457 #line 1182 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2458 {                                  // Empty structure type?
2459     yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2460   ;
2461     break;}
2462 case 83:
2463 #line 1185 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2464 {                             // Pointer type?
2465     yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2466     delete yyvsp[-1].TypeVal;
2467   ;
2468     break;}
2469 case 84:
2470 #line 1193 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2471 {
2472     yyval.TypeList = new std::list<PATypeHolder>();
2473     yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2474   ;
2475     break;}
2476 case 85:
2477 #line 1197 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2478 {
2479     (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
2480   ;
2481     break;}
2482 case 87:
2483 #line 1203 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2484 {
2485     (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
2486   ;
2487     break;}
2488 case 88:
2489 #line 1206 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2490 {
2491     (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
2492   ;
2493     break;}
2494 case 89:
2495 #line 1209 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2496 {
2497     yyval.TypeList = new std::list<PATypeHolder>();
2498   ;
2499     break;}
2500 case 90:
2501 #line 1219 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2502 { // Nonempty unsized arr
2503     const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
2504     if (ATy == 0)
2505       ThrowException("Cannot make array constant with type: '" + 
2506                      (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2507     const Type *ETy = ATy->getElementType();
2508     int NumElements = ATy->getNumElements();
2509
2510     // Verify that we have the correct size...
2511     if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2512       ThrowException("Type mismatch: constant sized array initialized with " +
2513                      utostr(yyvsp[-1].ConstVector->size()) +  " arguments, but has size of " + 
2514                      itostr(NumElements) + "!");
2515
2516     // Verify all elements are correct type!
2517     for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2518       if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2519         ThrowException("Element #" + utostr(i) + " is not of type '" + 
2520                        ETy->getDescription() +"' as required!\nIt is of type '"+
2521                        (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2522     }
2523
2524     yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2525     delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2526   ;
2527     break;}
2528 case 91:
2529 #line 1244 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2530 {
2531     const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2532     if (ATy == 0)
2533       ThrowException("Cannot make array constant with type: '" + 
2534                      (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2535
2536     int NumElements = ATy->getNumElements();
2537     if (NumElements != -1 && NumElements != 0) 
2538       ThrowException("Type mismatch: constant sized array initialized with 0"
2539                      " arguments, but has size of " + itostr(NumElements) +"!");
2540     yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2541     delete yyvsp[-2].TypeVal;
2542   ;
2543     break;}
2544 case 92:
2545 #line 1257 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2546 {
2547     const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
2548     if (ATy == 0)
2549       ThrowException("Cannot make array constant with type: '" + 
2550                      (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2551
2552     int NumElements = ATy->getNumElements();
2553     const Type *ETy = ATy->getElementType();
2554     char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2555     if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
2556       ThrowException("Can't build string constant of size " + 
2557                      itostr((int)(EndStr-yyvsp[0].StrVal)) +
2558                      " when array has size " + itostr(NumElements) + "!");
2559     std::vector<Constant*> Vals;
2560     if (ETy == Type::SByteTy) {
2561       for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C)
2562         Vals.push_back(ConstantSInt::get(ETy, *C));
2563     } else if (ETy == Type::UByteTy) {
2564       for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal; 
2565            C != (unsigned char*)EndStr; ++C)
2566         Vals.push_back(ConstantUInt::get(ETy, *C));
2567     } else {
2568       free(yyvsp[0].StrVal);
2569       ThrowException("Cannot build string arrays of non byte sized elements!");
2570     }
2571     free(yyvsp[0].StrVal);
2572     yyval.ConstVal = ConstantArray::get(ATy, Vals);
2573     delete yyvsp[-2].TypeVal;
2574   ;
2575     break;}
2576 case 93:
2577 #line 1286 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2578 { // Nonempty unsized arr
2579     const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
2580     if (PTy == 0)
2581       ThrowException("Cannot make packed constant with type: '" + 
2582                      (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2583     const Type *ETy = PTy->getElementType();
2584     int NumElements = PTy->getNumElements();
2585
2586     // Verify that we have the correct size...
2587     if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
2588       ThrowException("Type mismatch: constant sized packed initialized with " +
2589                      utostr(yyvsp[-1].ConstVector->size()) +  " arguments, but has size of " + 
2590                      itostr(NumElements) + "!");
2591
2592     // Verify all elements are correct type!
2593     for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2594       if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
2595         ThrowException("Element #" + utostr(i) + " is not of type '" + 
2596            ETy->getDescription() +"' as required!\nIt is of type '"+
2597            (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
2598     }
2599
2600     yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2601     delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2602   ;
2603     break;}
2604 case 94:
2605 #line 1311 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2606 {
2607     const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
2608     if (STy == 0)
2609       ThrowException("Cannot make struct constant with type: '" + 
2610                      (*yyvsp[-3].TypeVal)->getDescription() + "'!");
2611
2612     if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
2613       ThrowException("Illegal number of initializers for structure type!");
2614
2615     // Check to ensure that constants are compatible with the type initializer!
2616     for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2617       if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
2618         ThrowException("Expected type '" +
2619                        STy->getElementType(i)->getDescription() +
2620                        "' for element #" + utostr(i) +
2621                        " of structure initializer!");
2622
2623     yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2624     delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
2625   ;
2626     break;}
2627 case 95:
2628 #line 1331 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2629 {
2630     const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
2631     if (STy == 0)
2632       ThrowException("Cannot make struct constant with type: '" + 
2633                      (*yyvsp[-2].TypeVal)->getDescription() + "'!");
2634
2635     if (STy->getNumContainedTypes() != 0)
2636       ThrowException("Illegal number of initializers for structure type!");
2637
2638     yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2639     delete yyvsp[-2].TypeVal;
2640   ;
2641     break;}
2642 case 96:
2643 #line 1343 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2644 {
2645     const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2646     if (PTy == 0)
2647       ThrowException("Cannot make null pointer constant with type: '" + 
2648                      (*yyvsp[-1].TypeVal)->getDescription() + "'!");
2649
2650     yyval.ConstVal = ConstantPointerNull::get(PTy);
2651     delete yyvsp[-1].TypeVal;
2652   ;
2653     break;}
2654 case 97:
2655 #line 1352 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2656 {
2657     yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2658     delete yyvsp[-1].TypeVal;
2659   ;
2660     break;}
2661 case 98:
2662 #line 1356 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2663 {
2664     const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
2665     if (Ty == 0)
2666       ThrowException("Global const reference must be a pointer type!");
2667
2668     // ConstExprs can exist in the body of a function, thus creating
2669     // GlobalValues whenever they refer to a variable.  Because we are in
2670     // the context of a function, getValNonImprovising will search the functions
2671     // symbol table instead of the module symbol table for the global symbol,
2672     // which throws things all off.  To get around this, we just tell
2673     // getValNonImprovising that we are at global scope here.
2674     //
2675     Function *SavedCurFn = CurFun.CurrentFunction;
2676     CurFun.CurrentFunction = 0;
2677
2678     Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
2679
2680     CurFun.CurrentFunction = SavedCurFn;
2681
2682     // If this is an initializer for a constant pointer, which is referencing a
2683     // (currently) undefined variable, create a stub now that shall be replaced
2684     // in the future with the right type of variable.
2685     //
2686     if (V == 0) {
2687       assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2688       const PointerType *PT = cast<PointerType>(Ty);
2689
2690       // First check to see if the forward references value is already created!
2691       PerModuleInfo::GlobalRefsType::iterator I =
2692         CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
2693     
2694       if (I != CurModule.GlobalRefs.end()) {
2695         V = I->second;             // Placeholder already exists, use it...
2696         yyvsp[0].ValIDVal.destroy();
2697       } else {
2698         std::string Name;
2699         if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
2700
2701         // Create the forward referenced global.
2702         GlobalValue *GV;
2703         if (const FunctionType *FTy = 
2704                  dyn_cast<FunctionType>(PT->getElementType())) {
2705           GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2706                             CurModule.CurrentModule);
2707         } else {
2708           GV = new GlobalVariable(PT->getElementType(), false,
2709                                   GlobalValue::ExternalLinkage, 0,
2710                                   Name, CurModule.CurrentModule);
2711         }
2712
2713         // Keep track of the fact that we have a forward ref to recycle it
2714         CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
2715         V = GV;
2716       }
2717     }
2718
2719     yyval.ConstVal = cast<GlobalValue>(V);
2720     delete yyvsp[-1].TypeVal;            // Free the type handle
2721   ;
2722     break;}
2723 case 99:
2724 #line 1415 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2725 {
2726     if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
2727       ThrowException("Mismatched types for constant expression!");
2728     yyval.ConstVal = yyvsp[0].ConstVal;
2729     delete yyvsp[-1].TypeVal;
2730   ;
2731     break;}
2732 case 100:
2733 #line 1421 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2734 {
2735     const Type *Ty = yyvsp[-1].TypeVal->get();
2736     if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
2737       ThrowException("Cannot create a null initialized value of this type!");
2738     yyval.ConstVal = Constant::getNullValue(Ty);
2739     delete yyvsp[-1].TypeVal;
2740   ;
2741     break;}
2742 case 101:
2743 #line 1429 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2744 {      // integral constants
2745     if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
2746       ThrowException("Constant value doesn't fit in type!");
2747     yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
2748   ;
2749     break;}
2750 case 102:
2751 #line 1434 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2752 {            // integral constants
2753     if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
2754       ThrowException("Constant value doesn't fit in type!");
2755     yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
2756   ;
2757     break;}
2758 case 103:
2759 #line 1439 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2760 {                      // Boolean constants
2761     yyval.ConstVal = ConstantBool::True;
2762   ;
2763     break;}
2764 case 104:
2765 #line 1442 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2766 {                     // Boolean constants
2767     yyval.ConstVal = ConstantBool::False;
2768   ;
2769     break;}
2770 case 105:
2771 #line 1445 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2772 {                   // Float & Double constants
2773     if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
2774       ThrowException("Floating point constant invalid for type!!");
2775     yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
2776   ;
2777     break;}
2778 case 106:
2779 #line 1452 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2780 {
2781     if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
2782       ThrowException("cast constant expression from a non-primitive type: '" +
2783                      yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2784     if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
2785       ThrowException("cast constant expression to a non-primitive type: '" +
2786                      yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2787     yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2788     delete yyvsp[-1].TypeVal;
2789   ;
2790     break;}
2791 case 107:
2792 #line 1462 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2793 {
2794     if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
2795       ThrowException("GetElementPtr requires a pointer operand!");
2796
2797     // LLVM 1.2 and earlier used ubyte struct indices.  Convert any ubyte struct
2798     // indices to uint struct indices for compatibility.
2799     generic_gep_type_iterator<std::vector<Value*>::iterator>
2800       GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2801       GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2802     for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
2803       if (isa<StructType>(*GTI))        // Only change struct indices
2804         if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
2805           if (CUI->getType() == Type::UByteTy)
2806             (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
2807
2808     const Type *IdxTy =
2809       GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
2810     if (!IdxTy)
2811       ThrowException("Index list invalid for constant getelementptr!");
2812
2813     std::vector<Constant*> IdxVec;
2814     for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
2815       if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
2816         IdxVec.push_back(C);
2817       else
2818         ThrowException("Indices to constant getelementptr must be constants!");
2819
2820     delete yyvsp[-1].ValueList;
2821
2822     yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
2823   ;
2824     break;}
2825 case 108:
2826 #line 1493 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2827 {
2828     if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
2829       ThrowException("Select condition must be of boolean type!");
2830     if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2831       ThrowException("Select operand types must match!");
2832     yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2833   ;
2834     break;}
2835 case 109:
2836 #line 1500 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2837 {
2838     if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2839       ThrowException("Binary operator types must match!");
2840     // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
2841     // To retain backward compatibility with these early compilers, we emit a
2842     // cast to the appropriate integer type automatically if we are in the
2843     // broken case.  See PR424 for more information.
2844     if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
2845       yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2846     } else {
2847       const Type *IntPtrTy = 0;
2848       switch (CurModule.CurrentModule->getPointerSize()) {
2849       case Module::Pointer32: IntPtrTy = Type::IntTy; break;
2850       case Module::Pointer64: IntPtrTy = Type::LongTy; break;
2851       default: ThrowException("invalid pointer binary constant expr!");
2852       }
2853       yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
2854                              ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
2855       yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
2856     }
2857   ;
2858     break;}
2859 case 110:
2860 #line 1521 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2861 {
2862     if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2863       ThrowException("Logical operator types must match!");
2864     if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
2865       if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) || 
2866           !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
2867         ThrowException("Logical operator requires integral operands!");
2868     }
2869     yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2870   ;
2871     break;}
2872 case 111:
2873 #line 1531 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2874 {
2875     if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
2876       ThrowException("setcc operand types must match!");
2877     yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2878   ;
2879     break;}
2880 case 112:
2881 #line 1536 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2882 {
2883     if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
2884       ThrowException("Shift count for shift constant must be unsigned byte!");
2885     if (!yyvsp[-3].ConstVal->getType()->isInteger())
2886       ThrowException("Shift constant expression requires integer operand!");
2887     yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2888   ;
2889     break;}
2890 case 113:
2891 #line 1543 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2892 {
2893         if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()))
2894       ThrowException("First operand of extractelement must be "
2895                      "packed type!");
2896     if (yyvsp[-1].ConstVal->getType() != Type::UIntTy)
2897       ThrowException("Second operand of extractelement must be uint!");
2898     yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
2899   ;
2900     break;}
2901 case 114:
2902 #line 1553 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2903 {
2904     (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
2905   ;
2906     break;}
2907 case 115:
2908 #line 1556 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2909 {
2910     yyval.ConstVector = new std::vector<Constant*>();
2911     yyval.ConstVector->push_back(yyvsp[0].ConstVal);
2912   ;
2913     break;}
2914 case 116:
2915 #line 1563 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2916 { yyval.BoolVal = false; ;
2917     break;}
2918 case 117:
2919 #line 1563 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2920 { yyval.BoolVal = true; ;
2921     break;}
2922 case 118:
2923 #line 1573 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2924 {
2925   yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
2926   CurModule.ModuleDone();
2927 ;
2928     break;}
2929 case 119:
2930 #line 1580 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2931 {
2932     yyval.ModuleVal = yyvsp[-1].ModuleVal;
2933     CurFun.FunctionDone();
2934   ;
2935     break;}
2936 case 120:
2937 #line 1584 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2938 {
2939     yyval.ModuleVal = yyvsp[-1].ModuleVal;
2940   ;
2941     break;}
2942 case 121:
2943 #line 1587 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2944 {
2945     yyval.ModuleVal = yyvsp[-3].ModuleVal;
2946   ;
2947     break;}
2948 case 122:
2949 #line 1590 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2950 {
2951     yyval.ModuleVal = yyvsp[-1].ModuleVal;
2952   ;
2953     break;}
2954 case 123:
2955 #line 1593 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2956 {
2957     yyval.ModuleVal = CurModule.CurrentModule;
2958     // Emit an error if there are any unresolved types left.
2959     if (!CurModule.LateResolveTypes.empty()) {
2960       const ValID &DID = CurModule.LateResolveTypes.begin()->first;
2961       if (DID.Type == ValID::NameVal)
2962         ThrowException("Reference to an undefined type: '"+DID.getName() + "'");
2963       else
2964         ThrowException("Reference to an undefined type: #" + itostr(DID.Num));
2965     }
2966   ;
2967     break;}
2968 case 124:
2969 #line 1606 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2970 {
2971     // Eagerly resolve types.  This is not an optimization, this is a
2972     // requirement that is due to the fact that we could have this:
2973     //
2974     // %list = type { %list * }
2975     // %list = type { %list * }    ; repeated type decl
2976     //
2977     // If types are not resolved eagerly, then the two types will not be
2978     // determined to be the same type!
2979     //
2980     ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
2981
2982     if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
2983       // If this is a named type that is not a redefinition, add it to the slot
2984       // table.
2985       CurModule.Types.push_back(*yyvsp[0].TypeVal);
2986     }
2987
2988     delete yyvsp[0].TypeVal;
2989   ;
2990     break;}
2991 case 125:
2992 #line 1626 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2993 {       // Function prototypes can be in const pool
2994   ;
2995     break;}
2996 case 126:
2997 #line 1628 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
2998 {  // Asm blocks can be in the const pool
2999   ;
3000     break;}
3001 case 127:
3002 #line 1630 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3003 {
3004     if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!");
3005     CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
3006                                                        ;
3007     break;}
3008 case 128:
3009 #line 1633 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3010 {
3011     CurGV = 0;
3012   ;
3013     break;}
3014 case 129:
3015 #line 1636 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3016 {
3017     CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
3018                                              yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
3019     delete yyvsp[0].TypeVal;
3020                                                    ;
3021     break;}
3022 case 130:
3023 #line 1640 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3024 {
3025     CurGV = 0;
3026   ;
3027     break;}
3028 case 131:
3029 #line 1643 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3030
3031   ;
3032     break;}
3033 case 132:
3034 #line 1645 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3035 {
3036   ;
3037     break;}
3038 case 133:
3039 #line 1647 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3040
3041   ;
3042     break;}
3043 case 134:
3044 #line 1651 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3045 {
3046   const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3047   char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3048   std::string NewAsm(yyvsp[0].StrVal, EndStr);
3049   free(yyvsp[0].StrVal);
3050
3051   if (AsmSoFar.empty())
3052     CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3053   else
3054     CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
3055 ;
3056     break;}
3057 case 135:
3058 #line 1663 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3059 { yyval.Endianness = Module::BigEndian; ;
3060     break;}
3061 case 136:
3062 #line 1664 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3063 { yyval.Endianness = Module::LittleEndian; ;
3064     break;}
3065 case 137:
3066 #line 1666 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3067 {
3068     CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
3069   ;
3070     break;}
3071 case 138:
3072 #line 1669 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3073 {
3074     if (yyvsp[0].UInt64Val == 32)
3075       CurModule.CurrentModule->setPointerSize(Module::Pointer32);
3076     else if (yyvsp[0].UInt64Val == 64)
3077       CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3078     else
3079       ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
3080   ;
3081     break;}
3082 case 139:
3083 #line 1677 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3084 {
3085     CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3086     free(yyvsp[0].StrVal);
3087   ;
3088     break;}
3089 case 141:
3090 #line 1684 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3091 {
3092           CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3093           free(yyvsp[0].StrVal);
3094         ;
3095     break;}
3096 case 142:
3097 #line 1688 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3098 {
3099           CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3100           free(yyvsp[0].StrVal);
3101         ;
3102     break;}
3103 case 143:
3104 #line 1692 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3105 {
3106         ;
3107     break;}
3108 case 147:
3109 #line 1701 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3110 { yyval.StrVal = 0; ;
3111     break;}
3112 case 148:
3113 #line 1703 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3114 {
3115   if (*yyvsp[-1].TypeVal == Type::VoidTy)
3116     ThrowException("void typed arguments are invalid!");
3117   yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
3118 ;
3119     break;}
3120 case 149:
3121 #line 1709 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3122 {
3123     yyval.ArgList = yyvsp[-2].ArgList;
3124     yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3125     delete yyvsp[0].ArgVal;
3126   ;
3127     break;}
3128 case 150:
3129 #line 1714 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3130 {
3131     yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3132     yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3133     delete yyvsp[0].ArgVal;
3134   ;
3135     break;}
3136 case 151:
3137 #line 1720 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3138 {
3139     yyval.ArgList = yyvsp[0].ArgList;
3140   ;
3141     break;}
3142 case 152:
3143 #line 1723 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3144 {
3145     yyval.ArgList = yyvsp[-2].ArgList;
3146     yyval.ArgList->push_back(std::pair<PATypeHolder*,
3147                             char*>(new PATypeHolder(Type::VoidTy), 0));
3148   ;
3149     break;}
3150 case 153:
3151 #line 1728 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3152 {
3153     yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3154     yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
3155   ;
3156     break;}
3157 case 154:
3158 #line 1732 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3159 {
3160     yyval.ArgList = 0;
3161   ;
3162     break;}
3163 case 155:
3164 #line 1737 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3165 {
3166   UnEscapeLexed(yyvsp[-5].StrVal);
3167   std::string FunctionName(yyvsp[-5].StrVal);
3168   free(yyvsp[-5].StrVal);  // Free strdup'd memory!
3169   
3170   if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
3171     ThrowException("LLVM functions cannot return aggregate types!");
3172
3173   std::vector<const Type*> ParamTypeList;
3174   if (yyvsp[-3].ArgList) {   // If there are arguments...
3175     for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3176          I != yyvsp[-3].ArgList->end(); ++I)
3177       ParamTypeList.push_back(I->first->get());
3178   }
3179
3180   bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3181   if (isVarArg) ParamTypeList.pop_back();
3182
3183   const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
3184   const PointerType *PFT = PointerType::get(FT);
3185   delete yyvsp[-6].TypeVal;
3186
3187   ValID ID;
3188   if (!FunctionName.empty()) {
3189     ID = ValID::create((char*)FunctionName.c_str());
3190   } else {
3191     ID = ValID::create((int)CurModule.Values[PFT].size());
3192   }
3193
3194   Function *Fn = 0;
3195   // See if this function was forward referenced.  If so, recycle the object.
3196   if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3197     // Move the function to the end of the list, from whereever it was 
3198     // previously inserted.
3199     Fn = cast<Function>(FWRef);
3200     CurModule.CurrentModule->getFunctionList().remove(Fn);
3201     CurModule.CurrentModule->getFunctionList().push_back(Fn);
3202   } else if (!FunctionName.empty() &&     // Merge with an earlier prototype?
3203              (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3204     // If this is the case, either we need to be a forward decl, or it needs 
3205     // to be.
3206     if (!CurFun.isDeclare && !Fn->isExternal())
3207       ThrowException("Redefinition of function '" + FunctionName + "'!");
3208     
3209     // Make sure to strip off any argument names so we can't get conflicts.
3210     if (Fn->isExternal())
3211       for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3212            AI != AE; ++AI)
3213         AI->setName("");
3214
3215   } else  {  // Not already defined?
3216     Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3217                       CurModule.CurrentModule);
3218     InsertValue(Fn, CurModule.Values);
3219   }
3220
3221   CurFun.FunctionStart(Fn);
3222   Fn->setCallingConv(yyvsp[-7].UIntVal);
3223   Fn->setAlignment(yyvsp[0].UIntVal);
3224   if (yyvsp[-1].StrVal) {
3225     Fn->setSection(yyvsp[-1].StrVal);
3226     free(yyvsp[-1].StrVal);
3227   }
3228
3229   // Add all of the arguments we parsed to the function...
3230   if (yyvsp[-3].ArgList) {                     // Is null if empty...
3231     if (isVarArg) {  // Nuke the last entry
3232       assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
3233              "Not a varargs marker!");
3234       delete yyvsp[-3].ArgList->back().first;
3235       yyvsp[-3].ArgList->pop_back();  // Delete the last entry
3236     }
3237     Function::arg_iterator ArgIt = Fn->arg_begin();
3238     for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3239          I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
3240       delete I->first;                          // Delete the typeholder...
3241
3242       setValueName(ArgIt, I->second);           // Insert arg into symtab...
3243       InsertValue(ArgIt);
3244     }
3245
3246     delete yyvsp[-3].ArgList;                     // We're now done with the argument list
3247   }
3248 ;
3249     break;}
3250 case 158:
3251 #line 1824 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3252 {
3253   yyval.FunctionVal = CurFun.CurrentFunction;
3254
3255   // Make sure that we keep track of the linkage type even if there was a
3256   // previous "declare".
3257   yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3258 ;
3259     break;}
3260 case 161:
3261 #line 1834 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3262 {
3263   yyval.FunctionVal = yyvsp[-1].FunctionVal;
3264 ;
3265     break;}
3266 case 162:
3267 #line 1838 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3268 { CurFun.isDeclare = true; ;
3269     break;}
3270 case 163:
3271 #line 1838 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3272 {
3273   yyval.FunctionVal = CurFun.CurrentFunction;
3274   CurFun.FunctionDone();
3275 ;
3276     break;}
3277 case 164:
3278 #line 1847 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3279 {
3280     yyval.BoolVal = false;
3281   ;
3282     break;}
3283 case 165:
3284 #line 1850 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3285 {
3286     yyval.BoolVal = true;
3287   ;
3288     break;}
3289 case 166:
3290 #line 1854 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3291 {    // A reference to a direct constant
3292     yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
3293   ;
3294     break;}
3295 case 167:
3296 #line 1857 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3297 {
3298     yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
3299   ;
3300     break;}
3301 case 168:
3302 #line 1860 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3303 {                     // Perhaps it's an FP constant?
3304     yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
3305   ;
3306     break;}
3307 case 169:
3308 #line 1863 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3309 {
3310     yyval.ValIDVal = ValID::create(ConstantBool::True);
3311   ;
3312     break;}
3313 case 170:
3314 #line 1866 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3315 {
3316     yyval.ValIDVal = ValID::create(ConstantBool::False);
3317   ;
3318     break;}
3319 case 171:
3320 #line 1869 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3321 {
3322     yyval.ValIDVal = ValID::createNull();
3323   ;
3324     break;}
3325 case 172:
3326 #line 1872 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3327 {
3328     yyval.ValIDVal = ValID::createUndef();
3329   ;
3330     break;}
3331 case 173:
3332 #line 1875 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3333 {     // A vector zero constant.
3334     yyval.ValIDVal = ValID::createZeroInit();
3335   ;
3336     break;}
3337 case 174:
3338 #line 1878 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3339 { // Nonempty unsized packed vector
3340     const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3341     int NumElements = yyvsp[-1].ConstVector->size(); 
3342     
3343     PackedType* pt = PackedType::get(ETy, NumElements);
3344     PATypeHolder* PTy = new PATypeHolder(
3345                                          HandleUpRefs(
3346                                             PackedType::get(
3347                                                 ETy, 
3348                                                 NumElements)
3349                                             )
3350                                          );
3351     
3352     // Verify all elements are correct type!
3353     for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3354       if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3355         ThrowException("Element #" + utostr(i) + " is not of type '" + 
3356                      ETy->getDescription() +"' as required!\nIt is of type '" +
3357                      (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3358     }
3359
3360     yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3361     delete PTy; delete yyvsp[-1].ConstVector;
3362   ;
3363     break;}
3364 case 175:
3365 #line 1902 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3366 {
3367     yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
3368   ;
3369     break;}
3370 case 176:
3371 #line 1905 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3372 {
3373     char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3374     std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3375     End = UnEscapeLexed(yyvsp[0].StrVal, true);
3376     std::string Constraints = std::string(yyvsp[0].StrVal, End);
3377     yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3378     free(yyvsp[-2].StrVal);
3379     free(yyvsp[0].StrVal);
3380   ;
3381     break;}
3382 case 177:
3383 #line 1918 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3384 {  // Is it an integer reference...?
3385     yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
3386   ;
3387     break;}
3388 case 178:
3389 #line 1921 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3390 {                   // Is it a named reference...?
3391     yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
3392   ;
3393     break;}
3394 case 181:
3395 #line 1932 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3396 {
3397     yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
3398   ;
3399     break;}
3400 case 182:
3401 #line 1936 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3402 {
3403     yyval.FunctionVal = yyvsp[-1].FunctionVal;
3404   ;
3405     break;}
3406 case 183:
3407 #line 1939 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3408 { // Do not allow functions with 0 basic blocks   
3409     yyval.FunctionVal = yyvsp[-1].FunctionVal;
3410   ;
3411     break;}
3412 case 184:
3413 #line 1947 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3414 {
3415     setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
3416     InsertValue(yyvsp[0].TermInstVal);
3417
3418     yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3419     InsertValue(yyvsp[-2].BasicBlockVal);
3420     yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
3421   ;
3422     break;}
3423 case 185:
3424 #line 1956 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3425 {
3426     yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3427     yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
3428   ;
3429     break;}
3430 case 186:
3431 #line 1960 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3432 {
3433     yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
3434
3435     // Make sure to move the basic block to the correct location in the
3436     // function, instead of leaving it inserted wherever it was first
3437     // referenced.
3438     Function::BasicBlockListType &BBL = 
3439       CurFun.CurrentFunction->getBasicBlockList();
3440     BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3441   ;
3442     break;}
3443 case 187:
3444 #line 1970 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3445 {
3446     yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
3447
3448     // Make sure to move the basic block to the correct location in the
3449     // function, instead of leaving it inserted wherever it was first
3450     // referenced.
3451     Function::BasicBlockListType &BBL = 
3452       CurFun.CurrentFunction->getBasicBlockList();
3453     BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
3454   ;
3455     break;}
3456 case 188:
3457 #line 1981 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3458 {              // Return with a result...
3459     yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
3460   ;
3461     break;}
3462 case 189:
3463 #line 1984 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3464 {                                       // Return with no result...
3465     yyval.TermInstVal = new ReturnInst();
3466   ;
3467     break;}
3468 case 190:
3469 #line 1987 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3470 {                         // Unconditional Branch...
3471     yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal));
3472   ;
3473     break;}
3474 case 191:
3475 #line 1990 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3476 {  
3477     yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
3478   ;
3479     break;}
3480 case 192:
3481 #line 1993 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3482 {
3483     SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size());
3484     yyval.TermInstVal = S;
3485
3486     std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3487       E = yyvsp[-1].JumpTable->end();
3488     for (; I != E; ++I) {
3489       if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3490           S->addCase(CI, I->second);
3491       else
3492         ThrowException("Switch case is constant, but not a simple integer!");
3493     }
3494     delete yyvsp[-1].JumpTable;
3495   ;
3496     break;}
3497 case 193:
3498 #line 2007 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3499 {
3500     SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0);
3501     yyval.TermInstVal = S;
3502   ;
3503     break;}
3504 case 194:
3505 #line 2012 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3506 {
3507     const PointerType *PFTy;
3508     const FunctionType *Ty;
3509
3510     if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
3511         !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3512       // Pull out the types of all of the arguments...
3513       std::vector<const Type*> ParamTypes;
3514       if (yyvsp[-7].ValueList) {
3515         for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
3516              I != E; ++I)
3517           ParamTypes.push_back((*I)->getType());
3518       }
3519
3520       bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3521       if (isVarArg) ParamTypes.pop_back();
3522
3523       Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
3524       PFTy = PointerType::get(Ty);
3525     }
3526
3527     Value *V = getVal(PFTy, yyvsp[-9].ValIDVal);   // Get the function we're calling...
3528
3529     BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
3530     BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
3531
3532     // Create the call node...
3533     if (!yyvsp[-7].ValueList) {                                   // Has no arguments?
3534       yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
3535     } else {                                     // Has arguments?
3536       // Loop through FunctionType's arguments and ensure they are specified
3537       // correctly!
3538       //
3539       FunctionType::param_iterator I = Ty->param_begin();
3540       FunctionType::param_iterator E = Ty->param_end();
3541       std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
3542
3543       for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3544         if ((*ArgI)->getType() != *I)
3545           ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3546                          (*I)->getDescription() + "'!");
3547
3548       if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3549         ThrowException("Invalid number of parameters detected!");
3550
3551       yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
3552     }
3553     cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
3554   
3555     delete yyvsp[-10].TypeVal;
3556     delete yyvsp[-7].ValueList;
3557   ;
3558     break;}
3559 case 195:
3560 #line 2064 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3561 {
3562     yyval.TermInstVal = new UnwindInst();
3563   ;
3564     break;}
3565 case 196:
3566 #line 2067 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3567 {
3568     yyval.TermInstVal = new UnreachableInst();
3569   ;
3570     break;}
3571 case 197:
3572 #line 2073 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3573 {
3574     yyval.JumpTable = yyvsp[-5].JumpTable;
3575     Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3576     if (V == 0)
3577       ThrowException("May only switch on a constant pool value!");
3578
3579     yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3580   ;
3581     break;}
3582 case 198:
3583 #line 2081 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3584 {
3585     yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3586     Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
3587
3588     if (V == 0)
3589       ThrowException("May only switch on a constant pool value!");
3590
3591     yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal)));
3592   ;
3593     break;}
3594 case 199:
3595 #line 2091 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3596 {
3597   // Is this definition named?? if so, assign the name...
3598   setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
3599   InsertValue(yyvsp[0].InstVal);
3600   yyval.InstVal = yyvsp[0].InstVal;
3601 ;
3602     break;}
3603 case 200:
3604 #line 2098 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3605 {    // Used for PHI nodes
3606     yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3607     yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal)));
3608     delete yyvsp[-5].TypeVal;
3609   ;
3610     break;}
3611 case 201:
3612 #line 2103 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3613 {
3614     yyval.PHIList = yyvsp[-6].PHIList;
3615     yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
3616                                  getBBVal(yyvsp[-1].ValIDVal)));
3617   ;
3618     break;}
3619 case 202:
3620 #line 2110 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3621 {    // Used for call statements, and memory insts...
3622     yyval.ValueList = new std::vector<Value*>();
3623     yyval.ValueList->push_back(yyvsp[0].ValueVal);
3624   ;
3625     break;}
3626 case 203:
3627 #line 2114 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3628 {
3629     yyval.ValueList = yyvsp[-2].ValueList;
3630     yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
3631   ;
3632     break;}
3633 case 205:
3634 #line 2120 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3635 { yyval.ValueList = 0; ;
3636     break;}
3637 case 206:
3638 #line 2122 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3639 {
3640     yyval.BoolVal = true;
3641   ;
3642     break;}
3643 case 207:
3644 #line 2125 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3645 {
3646     yyval.BoolVal = false;
3647   ;
3648     break;}
3649 case 208:
3650 #line 2131 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3651 {
3652     if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() && 
3653         !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
3654       ThrowException(
3655         "Arithmetic operator requires integer, FP, or packed operands!");
3656     if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
3657       ThrowException("Rem not supported on packed types!");
3658     yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3659     if (yyval.InstVal == 0)
3660       ThrowException("binary operator returned null!");
3661     delete yyvsp[-3].TypeVal;
3662   ;
3663     break;}
3664 case 209:
3665 #line 2143 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3666 {
3667     if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
3668       if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
3669           !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
3670         ThrowException("Logical operator requires integral operands!");
3671     }
3672     yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3673     if (yyval.InstVal == 0)
3674       ThrowException("binary operator returned null!");
3675     delete yyvsp[-3].TypeVal;
3676   ;
3677     break;}
3678 case 210:
3679 #line 2154 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3680 {
3681     if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
3682       ThrowException(
3683         "PackedTypes currently not supported in setcc instructions!");
3684     }
3685     yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
3686     if (yyval.InstVal == 0)
3687       ThrowException("binary operator returned null!");
3688     delete yyvsp[-3].TypeVal;
3689   ;
3690     break;}
3691 case 211:
3692 #line 2164 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3693 {
3694     std::cerr << "WARNING: Use of eliminated 'not' instruction:"
3695               << " Replacing with 'xor'.\n";
3696
3697     Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
3698     if (Ones == 0)
3699       ThrowException("Expected integral type for not instruction!");
3700
3701     yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
3702     if (yyval.InstVal == 0)
3703       ThrowException("Could not create a xor instruction!");
3704   ;
3705     break;}
3706 case 212:
3707 #line 2176 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3708 {
3709     if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
3710       ThrowException("Shift amount must be ubyte!");
3711     if (!yyvsp[-2].ValueVal->getType()->isInteger())
3712       ThrowException("Shift constant expression requires integer operand!");
3713     yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3714   ;
3715     break;}
3716 case 213:
3717 #line 2183 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3718 {
3719     if (!yyvsp[0].TypeVal->get()->isFirstClassType())
3720       ThrowException("cast instruction to a non-primitive type: '" +
3721                      yyvsp[0].TypeVal->get()->getDescription() + "'!");
3722     yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3723     delete yyvsp[0].TypeVal;
3724   ;
3725     break;}
3726 case 214:
3727 #line 2190 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3728 {
3729     if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
3730       ThrowException("select condition must be boolean!");
3731     if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
3732       ThrowException("select value types should match!");
3733     yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3734   ;
3735     break;}
3736 case 215:
3737 #line 2197 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3738 {
3739     NewVarArgs = true;
3740     yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
3741     delete yyvsp[0].TypeVal;
3742   ;
3743     break;}
3744 case 216:
3745 #line 2202 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3746 {
3747     ObsoleteVarArgs = true;
3748     const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3749     Function* NF = CurModule.CurrentModule->
3750       getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
3751
3752     //b = vaarg a, t -> 
3753     //foo = alloca 1 of t
3754     //bar = vacopy a 
3755     //store bar -> foo
3756     //b = vaarg foo, t
3757     AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
3758     CurBB->getInstList().push_back(foo);
3759     CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3760     CurBB->getInstList().push_back(bar);
3761     CurBB->getInstList().push_back(new StoreInst(bar, foo));
3762     yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
3763     delete yyvsp[0].TypeVal;
3764   ;
3765     break;}
3766 case 217:
3767 #line 2221 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3768 {
3769     ObsoleteVarArgs = true;
3770     const Type* ArgTy = yyvsp[-2].ValueVal->getType();
3771     Function* NF = CurModule.CurrentModule->
3772       getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
3773
3774     //b = vanext a, t ->
3775     //foo = alloca 1 of t
3776     //bar = vacopy a
3777     //store bar -> foo
3778     //tmp = vaarg foo, t
3779     //b = load foo
3780     AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
3781     CurBB->getInstList().push_back(foo);
3782     CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
3783     CurBB->getInstList().push_back(bar);
3784     CurBB->getInstList().push_back(new StoreInst(bar, foo));
3785     Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
3786     CurBB->getInstList().push_back(tmp);
3787     yyval.InstVal = new LoadInst(foo);
3788     delete yyvsp[0].TypeVal;
3789   ;
3790     break;}
3791 case 218:
3792 #line 2243 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3793 {
3794     if (!isa<PackedType>(yyvsp[-2].ValueVal->getType()))
3795       ThrowException("First operand of extractelement must be "
3796                      "packed type!");
3797     if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
3798       ThrowException("Second operand of extractelement must be uint!");
3799     yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3800   ;
3801     break;}
3802 case 219:
3803 #line 2251 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3804 {
3805     if (!isa<PackedType>(yyvsp[-4].ValueVal->getType()))
3806       ThrowException("First operand of insertelement must be "
3807                      "packed type!");
3808     if (yyvsp[-2].ValueVal->getType() != 
3809         cast<PackedType>(yyvsp[-4].ValueVal->getType())->getElementType())
3810       ThrowException("Second operand of insertelement must be "
3811                      "packed element type!");
3812     if (yyvsp[0].ValueVal->getType() != Type::UIntTy)
3813       ThrowException("Third operand of insertelement must be uint!");
3814     yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
3815   ;
3816     break;}
3817 case 220:
3818 #line 2263 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3819 {
3820     const Type *Ty = yyvsp[0].PHIList->front().first->getType();
3821     if (!Ty->isFirstClassType())
3822       ThrowException("PHI node operands must be of first class type!");
3823     yyval.InstVal = new PHINode(Ty);
3824     ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
3825     while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
3826       if (yyvsp[0].PHIList->front().first->getType() != Ty) 
3827         ThrowException("All elements of a PHI node must be of the same type!");
3828       cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
3829       yyvsp[0].PHIList->pop_front();
3830     }
3831     delete yyvsp[0].PHIList;  // Free the list...
3832   ;
3833     break;}
3834 case 221:
3835 #line 2277 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3836 {
3837     const PointerType *PFTy;
3838     const FunctionType *Ty;
3839
3840     if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
3841         !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3842       // Pull out the types of all of the arguments...
3843       std::vector<const Type*> ParamTypes;
3844       if (yyvsp[-1].ValueList) {
3845         for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
3846              I != E; ++I)
3847           ParamTypes.push_back((*I)->getType());
3848       }
3849
3850       bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3851       if (isVarArg) ParamTypes.pop_back();
3852
3853       if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
3854         ThrowException("LLVM functions cannot return aggregate types!");
3855
3856       Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
3857       PFTy = PointerType::get(Ty);
3858     }
3859
3860     Value *V = getVal(PFTy, yyvsp[-3].ValIDVal);   // Get the function we're calling...
3861
3862     // Create the call node...
3863     if (!yyvsp[-1].ValueList) {                                   // Has no arguments?
3864       // Make sure no arguments is a good thing!
3865       if (Ty->getNumParams() != 0)
3866         ThrowException("No arguments passed to a function that "
3867                        "expects arguments!");
3868
3869       yyval.InstVal = new CallInst(V, std::vector<Value*>());
3870     } else {                                     // Has arguments?
3871       // Loop through FunctionType's arguments and ensure they are specified
3872       // correctly!
3873       //
3874       FunctionType::param_iterator I = Ty->param_begin();
3875       FunctionType::param_iterator E = Ty->param_end();
3876       std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
3877
3878       for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3879         if ((*ArgI)->getType() != *I)
3880           ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
3881                          (*I)->getDescription() + "'!");
3882
3883       if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
3884         ThrowException("Invalid number of parameters detected!");
3885
3886       yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
3887     }
3888     cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
3889     cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
3890     delete yyvsp[-4].TypeVal;
3891     delete yyvsp[-1].ValueList;
3892   ;
3893     break;}
3894 case 222:
3895 #line 2334 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3896 {
3897     yyval.InstVal = yyvsp[0].InstVal;
3898   ;
3899     break;}
3900 case 223:
3901 #line 2340 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3902
3903     yyval.ValueList = yyvsp[0].ValueList; 
3904   ;
3905     break;}
3906 case 224:
3907 #line 2342 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3908
3909     yyval.ValueList = new std::vector<Value*>(); 
3910   ;
3911     break;}
3912 case 225:
3913 #line 2346 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3914 {
3915     yyval.BoolVal = true;
3916   ;
3917     break;}
3918 case 226:
3919 #line 2349 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3920 {
3921     yyval.BoolVal = false;
3922   ;
3923     break;}
3924 case 227:
3925 #line 2355 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3926 {
3927     yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3928     delete yyvsp[-1].TypeVal;
3929   ;
3930     break;}
3931 case 228:
3932 #line 2359 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3933 {
3934     yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3935     delete yyvsp[-4].TypeVal;
3936   ;
3937     break;}
3938 case 229:
3939 #line 2363 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3940 {
3941     yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
3942     delete yyvsp[-1].TypeVal;
3943   ;
3944     break;}
3945 case 230:
3946 #line 2367 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3947 {
3948     yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
3949     delete yyvsp[-4].TypeVal;
3950   ;
3951     break;}
3952 case 231:
3953 #line 2371 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3954 {
3955     if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
3956       ThrowException("Trying to free nonpointer type " + 
3957                      yyvsp[0].ValueVal->getType()->getDescription() + "!");
3958     yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
3959   ;
3960     break;}
3961 case 232:
3962 #line 2378 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3963 {
3964     if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
3965       ThrowException("Can't load from nonpointer type: " +
3966                      (*yyvsp[-1].TypeVal)->getDescription());
3967     if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
3968       ThrowException("Can't load from pointer of non-first-class type: " +
3969                      (*yyvsp[-1].TypeVal)->getDescription());
3970     yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal);
3971     delete yyvsp[-1].TypeVal;
3972   ;
3973     break;}
3974 case 233:
3975 #line 2388 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3976 {
3977     const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3978     if (!PT)
3979       ThrowException("Can't store to a nonpointer type: " +
3980                      (*yyvsp[-1].TypeVal)->getDescription());
3981     const Type *ElTy = PT->getElementType();
3982     if (ElTy != yyvsp[-3].ValueVal->getType())
3983       ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
3984                      "' into space of type '" + ElTy->getDescription() + "'!");
3985
3986     yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal);
3987     delete yyvsp[-1].TypeVal;
3988   ;
3989     break;}
3990 case 234:
3991 #line 2401 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
3992 {
3993     if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
3994       ThrowException("getelementptr insn requires pointer operand!");
3995
3996     // LLVM 1.2 and earlier used ubyte struct indices.  Convert any ubyte struct
3997     // indices to uint struct indices for compatibility.
3998     generic_gep_type_iterator<std::vector<Value*>::iterator>
3999       GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4000       GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4001     for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
4002       if (isa<StructType>(*GTI))        // Only change struct indices
4003         if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
4004           if (CUI->getType() == Type::UByteTy)
4005             (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
4006
4007     if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
4008       ThrowException("Invalid getelementptr indices for type '" +
4009                      (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4010     yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList);
4011     delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList;
4012   ;
4013     break;}
4014 }
4015    /* the action file gets copied in in place of this dollarsign */
4016 #line 543 "/usr/share/bison.simple"
4017 \f
4018   yyvsp -= yylen;
4019   yyssp -= yylen;
4020 #ifdef YYLSP_NEEDED
4021   yylsp -= yylen;
4022 #endif
4023
4024 #if YYDEBUG != 0
4025   if (yydebug)
4026     {
4027       short *ssp1 = yyss - 1;
4028       fprintf (stderr, "state stack now");
4029       while (ssp1 != yyssp)
4030         fprintf (stderr, " %d", *++ssp1);
4031       fprintf (stderr, "\n");
4032     }
4033 #endif
4034
4035   *++yyvsp = yyval;
4036
4037 #ifdef YYLSP_NEEDED
4038   yylsp++;
4039   if (yylen == 0)
4040     {
4041       yylsp->first_line = yylloc.first_line;
4042       yylsp->first_column = yylloc.first_column;
4043       yylsp->last_line = (yylsp-1)->last_line;
4044       yylsp->last_column = (yylsp-1)->last_column;
4045       yylsp->text = 0;
4046     }
4047   else
4048     {
4049       yylsp->last_line = (yylsp+yylen-1)->last_line;
4050       yylsp->last_column = (yylsp+yylen-1)->last_column;
4051     }
4052 #endif
4053
4054   /* Now "shift" the result of the reduction.
4055      Determine what state that goes to,
4056      based on the state we popped back to
4057      and the rule number reduced by.  */
4058
4059   yyn = yyr1[yyn];
4060
4061   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4062   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4063     yystate = yytable[yystate];
4064   else
4065     yystate = yydefgoto[yyn - YYNTBASE];
4066
4067   goto yynewstate;
4068
4069 yyerrlab:   /* here on detecting error */
4070
4071   if (! yyerrstatus)
4072     /* If not already recovering from an error, report this error.  */
4073     {
4074       ++yynerrs;
4075
4076 #ifdef YYERROR_VERBOSE
4077       yyn = yypact[yystate];
4078
4079       if (yyn > YYFLAG && yyn < YYLAST)
4080         {
4081           int size = 0;
4082           char *msg;
4083           int x, count;
4084
4085           count = 0;
4086           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
4087           for (x = (yyn < 0 ? -yyn : 0);
4088                x < (sizeof(yytname) / sizeof(char *)); x++)
4089             if (yycheck[x + yyn] == x)
4090               size += strlen(yytname[x]) + 15, count++;
4091           msg = (char *) malloc(size + 15);
4092           if (msg != 0)
4093             {
4094               strcpy(msg, "parse error");
4095
4096               if (count < 5)
4097                 {
4098                   count = 0;
4099                   for (x = (yyn < 0 ? -yyn : 0);
4100                        x < (sizeof(yytname) / sizeof(char *)); x++)
4101                     if (yycheck[x + yyn] == x)
4102                       {
4103                         strcat(msg, count == 0 ? ", expecting `" : " or `");
4104                         strcat(msg, yytname[x]);
4105                         strcat(msg, "'");
4106                         count++;
4107                       }
4108                 }
4109               yyerror(msg);
4110               free(msg);
4111             }
4112           else
4113             yyerror ("parse error; also virtual memory exceeded");
4114         }
4115       else
4116 #endif /* YYERROR_VERBOSE */
4117         yyerror("parse error");
4118     }
4119
4120   goto yyerrlab1;
4121 yyerrlab1:   /* here on error raised explicitly by an action */
4122
4123   if (yyerrstatus == 3)
4124     {
4125       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
4126
4127       /* return failure if at end of input */
4128       if (yychar == YYEOF)
4129         YYABORT;
4130
4131 #if YYDEBUG != 0
4132       if (yydebug)
4133         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4134 #endif
4135
4136       yychar = YYEMPTY;
4137     }
4138
4139   /* Else will try to reuse lookahead token
4140      after shifting the error token.  */
4141
4142   yyerrstatus = 3;              /* Each real token shifted decrements this */
4143
4144   goto yyerrhandle;
4145
4146 yyerrdefault:  /* current state does not do anything special for the error token. */
4147
4148 #if 0
4149   /* This is wrong; only states that explicitly want error tokens
4150      should shift them.  */
4151   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
4152   if (yyn) goto yydefault;
4153 #endif
4154
4155 yyerrpop:   /* pop the current state because it cannot handle the error token */
4156
4157   if (yyssp == yyss) YYABORT;
4158   yyvsp--;
4159   yystate = *--yyssp;
4160 #ifdef YYLSP_NEEDED
4161   yylsp--;
4162 #endif
4163
4164 #if YYDEBUG != 0
4165   if (yydebug)
4166     {
4167       short *ssp1 = yyss - 1;
4168       fprintf (stderr, "Error: state stack now");
4169       while (ssp1 != yyssp)
4170         fprintf (stderr, " %d", *++ssp1);
4171       fprintf (stderr, "\n");
4172     }
4173 #endif
4174
4175 yyerrhandle:
4176
4177   yyn = yypact[yystate];
4178   if (yyn == YYFLAG)
4179     goto yyerrdefault;
4180
4181   yyn += YYTERROR;
4182   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4183     goto yyerrdefault;
4184
4185   yyn = yytable[yyn];
4186   if (yyn < 0)
4187     {
4188       if (yyn == YYFLAG)
4189         goto yyerrpop;
4190       yyn = -yyn;
4191       goto yyreduce;
4192     }
4193   else if (yyn == 0)
4194     goto yyerrpop;
4195
4196   if (yyn == YYFINAL)
4197     YYACCEPT;
4198
4199 #if YYDEBUG != 0
4200   if (yydebug)
4201     fprintf(stderr, "Shifting error token, ");
4202 #endif
4203
4204   *++yyvsp = yylval;
4205 #ifdef YYLSP_NEEDED
4206   *++yylsp = yylloc;
4207 #endif
4208
4209   yystate = yyn;
4210   goto yynewstate;
4211
4212  yyacceptlab:
4213   /* YYACCEPT comes here.  */
4214   if (yyfree_stacks)
4215     {
4216       free (yyss);
4217       free (yyvs);
4218 #ifdef YYLSP_NEEDED
4219       free (yyls);
4220 #endif
4221     }
4222   return 0;
4223
4224  yyabortlab:
4225   /* YYABORT comes here.  */
4226   if (yyfree_stacks)
4227     {
4228       free (yyss);
4229       free (yyvs);
4230 #ifdef YYLSP_NEEDED
4231       free (yyls);
4232 #endif
4233     }
4234   return 1;
4235 }
4236 #line 2424 "/Users/sabre/llvm/lib/AsmParser/llvmAsmParser.y"
4237
4238 int yyerror(const char *ErrorMsg) {
4239   std::string where 
4240     = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4241                   + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4242   std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4243   if (yychar == YYEMPTY || yychar == 0)
4244     errMsg += "end-of-file.";
4245   else
4246     errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
4247   ThrowException(errMsg);
4248   return 0;
4249 }