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