Couple of fixes to mention bunzip2 and make instructions more clear.
[llvm-complete.git] / tools / llvm-upgrade / UpgradeParser.cpp.cvs
blob2f6c02a216fb82ec27ed7c8ec44c8f0aef9470d7
2 /*  A Bison parser, made from /Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y
3     by GNU Bison version 1.28  */
5 #define YYBISON 1  /* Identify Bison output.  */
7 #define yyparse Upgradeparse
8 #define yylex Upgradelex
9 #define yyerror Upgradeerror
10 #define yylval Upgradelval
11 #define yychar Upgradechar
12 #define yydebug Upgradedebug
13 #define yynerrs Upgradenerrs
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 DLLIMPORT       299
57 #define DLLEXPORT       300
58 #define EXTERN_WEAK     301
59 #define OPAQUE  302
60 #define NOT     303
61 #define EXTERNAL        304
62 #define TARGET  305
63 #define TRIPLE  306
64 #define ENDIAN  307
65 #define POINTERSIZE     308
66 #define LITTLE  309
67 #define BIG     310
68 #define ALIGN   311
69 #define DEPLIBS 312
70 #define CALL    313
71 #define TAIL    314
72 #define ASM_TOK 315
73 #define MODULE  316
74 #define SIDEEFFECT      317
75 #define CC_TOK  318
76 #define CCC_TOK 319
77 #define CSRETCC_TOK     320
78 #define FASTCC_TOK      321
79 #define COLDCC_TOK      322
80 #define X86_STDCALLCC_TOK       323
81 #define X86_FASTCALLCC_TOK      324
82 #define DATALAYOUT      325
83 #define RET     326
84 #define BR      327
85 #define SWITCH  328
86 #define INVOKE  329
87 #define UNREACHABLE     330
88 #define UNWIND  331
89 #define EXCEPT  332
90 #define ADD     333
91 #define SUB     334
92 #define MUL     335
93 #define DIV     336
94 #define UDIV    337
95 #define SDIV    338
96 #define FDIV    339
97 #define REM     340
98 #define UREM    341
99 #define SREM    342
100 #define FREM    343
101 #define AND     344
102 #define OR      345
103 #define XOR     346
104 #define SHL     347
105 #define SHR     348
106 #define ASHR    349
107 #define LSHR    350
108 #define SETLE   351
109 #define SETGE   352
110 #define SETLT   353
111 #define SETGT   354
112 #define SETEQ   355
113 #define SETNE   356
114 #define ICMP    357
115 #define FCMP    358
116 #define MALLOC  359
117 #define ALLOCA  360
118 #define FREE    361
119 #define LOAD    362
120 #define STORE   363
121 #define GETELEMENTPTR   364
122 #define PHI_TOK 365
123 #define SELECT  366
124 #define VAARG   367
125 #define EXTRACTELEMENT  368
126 #define INSERTELEMENT   369
127 #define SHUFFLEVECTOR   370
128 #define VAARG_old       371
129 #define VANEXT_old      372
130 #define EQ      373
131 #define NE      374
132 #define SLT     375
133 #define SGT     376
134 #define SLE     377
135 #define SGE     378
136 #define ULT     379
137 #define UGT     380
138 #define ULE     381
139 #define UGE     382
140 #define OEQ     383
141 #define ONE     384
142 #define OLT     385
143 #define OGT     386
144 #define OLE     387
145 #define OGE     388
146 #define ORD     389
147 #define UNO     390
148 #define UEQ     391
149 #define UNE     392
150 #define CAST    393
151 #define TRUNC   394
152 #define ZEXT    395
153 #define SEXT    396
154 #define FPTRUNC 397
155 #define FPEXT   398
156 #define FPTOUI  399
157 #define FPTOSI  400
158 #define UITOFP  401
159 #define SITOFP  402
160 #define PTRTOINT        403
161 #define INTTOPTR        404
162 #define BITCAST 405
164 #line 14 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
166 #include "UpgradeInternals.h"
167 #include "llvm/CallingConv.h"
168 #include "llvm/InlineAsm.h"
169 #include "llvm/Instructions.h"
170 #include "llvm/Module.h"
171 #include "llvm/ParameterAttributes.h"
172 #include "llvm/ValueSymbolTable.h"
173 #include "llvm/Support/GetElementPtrTypeIterator.h"
174 #include "llvm/ADT/STLExtras.h"
175 #include "llvm/Support/MathExtras.h"
176 #include <algorithm>
177 #include <iostream>
178 #include <map>
179 #include <list>
180 #include <utility>
182 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
183 // relating to upreferences in the input stream.
185 //#define DEBUG_UPREFS 1
186 #ifdef DEBUG_UPREFS
187 #define UR_OUT(X) std::cerr << X
188 #else
189 #define UR_OUT(X)
190 #endif
192 #define YYERROR_VERBOSE 1
193 #define YYINCLUDED_STDLIB_H
194 #define YYDEBUG 1
196 int yylex();
197 int yyparse();
199 int yyerror(const char*);
200 static void warning(const std::string& WarningMsg);
202 namespace llvm {
204 std::istream* LexInput;
205 static std::string CurFilename;
207 // This bool controls whether attributes are ever added to function declarations
208 // definitions and calls.
209 static bool AddAttributes = false;
211 static Module *ParserResult;
212 static bool ObsoleteVarArgs;
213 static bool NewVarArgs;
214 static BasicBlock *CurBB;
215 static GlobalVariable *CurGV;
216 static unsigned lastCallingConv;
218 // This contains info used when building the body of a function.  It is
219 // destroyed when the function is completed.
221 typedef std::vector<Value *> ValueList;           // Numbered defs
223 typedef std::pair<std::string,TypeInfo> RenameMapKey;
224 typedef std::map<RenameMapKey,std::string> RenameMapType;
226 static void 
227 ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
228                    std::map<const Type *,ValueList> *FutureLateResolvers = 0);
230 static struct PerModuleInfo {
231   Module *CurrentModule;
232   std::map<const Type *, ValueList> Values; // Module level numbered definitions
233   std::map<const Type *,ValueList> LateResolveValues;
234   std::vector<PATypeHolder> Types;
235   std::vector<Signedness> TypeSigns;
236   std::map<std::string,Signedness> NamedTypeSigns;
237   std::map<std::string,Signedness> NamedValueSigns;
238   std::map<ValID, PATypeHolder> LateResolveTypes;
239   static Module::Endianness Endian;
240   static Module::PointerSize PointerSize;
241   RenameMapType RenameMap;
243   /// PlaceHolderInfo - When temporary placeholder objects are created, remember
244   /// how they were referenced and on which line of the input they came from so
245   /// that we can resolve them later and print error messages as appropriate.
246   std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
248   // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
249   // references to global values.  Global values may be referenced before they
250   // are defined, and if so, the temporary object that they represent is held
251   // here.  This is used for forward references of GlobalValues.
252   //
253   typedef std::map<std::pair<const PointerType *, ValID>, GlobalValue*> 
254     GlobalRefsType;
255   GlobalRefsType GlobalRefs;
257   void ModuleDone() {
258     // If we could not resolve some functions at function compilation time
259     // (calls to functions before they are defined), resolve them now...  Types
260     // are resolved when the constant pool has been completely parsed.
261     //
262     ResolveDefinitions(LateResolveValues);
264     // Check to make sure that all global value forward references have been
265     // resolved!
266     //
267     if (!GlobalRefs.empty()) {
268       std::string UndefinedReferences = "Unresolved global references exist:\n";
270       for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
271            I != E; ++I) {
272         UndefinedReferences += "  " + I->first.first->getDescription() + " " +
273                                I->first.second.getName() + "\n";
274       }
275       error(UndefinedReferences);
276       return;
277     }
279     if (CurrentModule->getDataLayout().empty()) {
280       std::string dataLayout;
281       if (Endian != Module::AnyEndianness)
282         dataLayout.append(Endian == Module::BigEndian ? "E" : "e");
283       if (PointerSize != Module::AnyPointerSize) {
284         if (!dataLayout.empty())
285           dataLayout += "-";
286         dataLayout.append(PointerSize == Module::Pointer64 ? 
287                           "p:64:64" : "p:32:32");
288       }
289       CurrentModule->setDataLayout(dataLayout);
290     }
292     Values.clear();         // Clear out function local definitions
293     Types.clear();
294     TypeSigns.clear();
295     NamedTypeSigns.clear();
296     NamedValueSigns.clear();
297     CurrentModule = 0;
298   }
300   // GetForwardRefForGlobal - Check to see if there is a forward reference
301   // for this global.  If so, remove it from the GlobalRefs map and return it.
302   // If not, just return null.
303   GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
304     // Check to see if there is a forward reference to this global variable...
305     // if there is, eliminate it and patch the reference to use the new def'n.
306     GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
307     GlobalValue *Ret = 0;
308     if (I != GlobalRefs.end()) {
309       Ret = I->second;
310       GlobalRefs.erase(I);
311     }
312     return Ret;
313   }
314   void setEndianness(Module::Endianness E) { Endian = E; }
315   void setPointerSize(Module::PointerSize sz) { PointerSize = sz; }
316 } CurModule;
318 Module::Endianness  PerModuleInfo::Endian = Module::AnyEndianness;
319 Module::PointerSize PerModuleInfo::PointerSize = Module::AnyPointerSize;
321 static struct PerFunctionInfo {
322   Function *CurrentFunction;     // Pointer to current function being created
324   std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
325   std::map<const Type*, ValueList> LateResolveValues;
326   bool isDeclare;                   // Is this function a forward declararation?
327   GlobalValue::LinkageTypes Linkage;// Linkage for forward declaration.
329   /// BBForwardRefs - When we see forward references to basic blocks, keep
330   /// track of them here.
331   std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
332   std::vector<BasicBlock*> NumberedBlocks;
333   RenameMapType RenameMap;
334   unsigned NextBBNum;
336   inline PerFunctionInfo() {
337     CurrentFunction = 0;
338     isDeclare = false;
339     Linkage = GlobalValue::ExternalLinkage;    
340   }
342   inline void FunctionStart(Function *M) {
343     CurrentFunction = M;
344     NextBBNum = 0;
345   }
347   void FunctionDone() {
348     NumberedBlocks.clear();
350     // Any forward referenced blocks left?
351     if (!BBForwardRefs.empty()) {
352       error("Undefined reference to label " + 
353             BBForwardRefs.begin()->first->getName());
354       return;
355     }
357     // Resolve all forward references now.
358     ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
360     Values.clear();         // Clear out function local definitions
361     RenameMap.clear();
362     CurrentFunction = 0;
363     isDeclare = false;
364     Linkage = GlobalValue::ExternalLinkage;
365   }
366 } CurFun;  // Info for the current function...
368 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
370 /// This function is just a utility to make a Key value for the rename map.
371 /// The Key is a combination of the name, type, Signedness of the original 
372 /// value (global/function). This just constructs the key and ensures that
373 /// named Signedness values are resolved to the actual Signedness.
374 /// @brief Make a key for the RenameMaps
375 static RenameMapKey makeRenameMapKey(const std::string &Name, const Type* Ty, 
376                                      const Signedness &Sign) {
377   TypeInfo TI; 
378   TI.T = Ty; 
379   if (Sign.isNamed())
380     // Don't allow Named Signedness nodes because they won't match. The actual
381     // Signedness must be looked up in the NamedTypeSigns map.
382     TI.S.copy(CurModule.NamedTypeSigns[Sign.getName()]);
383   else
384     TI.S.copy(Sign);
385   return std::make_pair(Name, TI);
389 //===----------------------------------------------------------------------===//
390 //               Code to handle definitions of all the types
391 //===----------------------------------------------------------------------===//
393 static int InsertValue(Value *V,
394                   std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
395   if (V->hasName()) return -1;           // Is this a numbered definition?
397   // Yes, insert the value into the value table...
398   ValueList &List = ValueTab[V->getType()];
399   List.push_back(V);
400   return List.size()-1;
403 static const Type *getType(const ValID &D, bool DoNotImprovise = false) {
404   switch (D.Type) {
405   case ValID::NumberVal:               // Is it a numbered definition?
406     // Module constants occupy the lowest numbered slots...
407     if ((unsigned)D.Num < CurModule.Types.size()) {
408       return CurModule.Types[(unsigned)D.Num];
409     }
410     break;
411   case ValID::NameVal:                 // Is it a named definition?
412     if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
413       return N;
414     }
415     break;
416   default:
417     error("Internal parser error: Invalid symbol type reference");
418     return 0;
419   }
421   // If we reached here, we referenced either a symbol that we don't know about
422   // or an id number that hasn't been read yet.  We may be referencing something
423   // forward, so just create an entry to be resolved later and get to it...
424   //
425   if (DoNotImprovise) return 0;  // Do we just want a null to be returned?
427   if (inFunctionScope()) {
428     if (D.Type == ValID::NameVal) {
429       error("Reference to an undefined type: '" + D.getName() + "'");
430       return 0;
431     } else {
432       error("Reference to an undefined type: #" + itostr(D.Num));
433       return 0;
434     }
435   }
437   std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
438   if (I != CurModule.LateResolveTypes.end())
439     return I->second;
441   Type *Typ = OpaqueType::get();
442   CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
443   return Typ;
446 /// This is like the getType method except that instead of looking up the type
447 /// for a given ID, it looks up that type's sign.
448 /// @brief Get the signedness of a referenced type
449 static Signedness getTypeSign(const ValID &D) {
450   switch (D.Type) {
451   case ValID::NumberVal:               // Is it a numbered definition?
452     // Module constants occupy the lowest numbered slots...
453     if ((unsigned)D.Num < CurModule.TypeSigns.size()) {
454       return CurModule.TypeSigns[(unsigned)D.Num];
455     }
456     break;
457   case ValID::NameVal: {               // Is it a named definition?
458     std::map<std::string,Signedness>::const_iterator I = 
459       CurModule.NamedTypeSigns.find(D.Name);
460     if (I != CurModule.NamedTypeSigns.end())
461       return I->second;
462     // Perhaps its a named forward .. just cache the name
463     Signedness S;
464     S.makeNamed(D.Name);
465     return S;
466   }
467   default: 
468     break;
469   }
470   // If we don't find it, its signless
471   Signedness S;
472   S.makeSignless();
473   return S;
476 /// This function is analagous to getElementType in LLVM. It provides the same
477 /// function except that it looks up the Signedness instead of the type. This is
478 /// used when processing GEP instructions that need to extract the type of an
479 /// indexed struct/array/ptr member. 
480 /// @brief Look up an element's sign.
481 static Signedness getElementSign(const ValueInfo& VI, 
482                                  const std::vector<Value*> &Indices) {
483   const Type *Ptr = VI.V->getType();
484   assert(isa<PointerType>(Ptr) && "Need pointer type");
486   unsigned CurIdx = 0;
487   Signedness S(VI.S);
488   while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) {
489     if (CurIdx == Indices.size())
490       break;
492     Value *Index = Indices[CurIdx++];
493     assert(!isa<PointerType>(CT) || CurIdx == 1 && "Invalid type");
494     Ptr = CT->getTypeAtIndex(Index);
495     if (const Type* Ty = Ptr->getForwardedType())
496       Ptr = Ty;
497     assert(S.isComposite() && "Bad Signedness type");
498     if (isa<StructType>(CT)) {
499       S = S.get(cast<ConstantInt>(Index)->getZExtValue());
500     } else {
501       S = S.get(0UL);
502     }
503     if (S.isNamed())
504       S = CurModule.NamedTypeSigns[S.getName()];
505   }
506   Signedness Result;
507   Result.makeComposite(S);
508   return Result;
511 /// This function just translates a ConstantInfo into a ValueInfo and calls
512 /// getElementSign(ValueInfo,...). Its just a convenience.
513 /// @brief ConstantInfo version of getElementSign.
514 static Signedness getElementSign(const ConstInfo& CI, 
515                                  const std::vector<Constant*> &Indices) {
516   ValueInfo VI;
517   VI.V = CI.C;
518   VI.S.copy(CI.S);
519   std::vector<Value*> Idx;
520   for (unsigned i = 0; i < Indices.size(); ++i)
521     Idx.push_back(Indices[i]);
522   Signedness result = getElementSign(VI, Idx);
523   VI.destroy();
524   return result;
527 /// This function determines if two function types differ only in their use of
528 /// the sret parameter attribute in the first argument. If they are identical 
529 /// in all other respects, it returns true. Otherwise, it returns false.
530 static bool FuncTysDifferOnlyBySRet(const FunctionType *F1, 
531                                     const FunctionType *F2) {
532   if (F1->getReturnType() != F2->getReturnType() ||
533       F1->getNumParams() != F2->getNumParams())
534     return false;
535   const ParamAttrsList *PAL1 = F1->getParamAttrs();
536   const ParamAttrsList *PAL2 = F2->getParamAttrs();
537   if (PAL1 && !PAL2 || PAL2 && !PAL1)
538     return false;
539   if (PAL1 && PAL2 && ((PAL1->size() != PAL2->size()) ||
540       (PAL1->getParamAttrs(0) != PAL2->getParamAttrs(0)))) 
541     return false;
542   unsigned SRetMask = ~unsigned(ParamAttr::StructRet);
543   for (unsigned i = 0; i < F1->getNumParams(); ++i) {
544     if (F1->getParamType(i) != F2->getParamType(i) || (PAL1 && PAL2 &&
545         (unsigned(PAL1->getParamAttrs(i+1)) & SRetMask !=
546          unsigned(PAL2->getParamAttrs(i+1)) & SRetMask)))
547       return false;
548   }
549   return true;
552 /// This function determines if the type of V and Ty differ only by the SRet
553 /// parameter attribute. This is a more generalized case of
554 /// FuncTysDIfferOnlyBySRet since it doesn't require FunctionType arguments.
555 static bool TypesDifferOnlyBySRet(Value *V, const Type* Ty) {
556   if (V->getType() == Ty)
557     return true;
558   const PointerType *PF1 = dyn_cast<PointerType>(Ty);
559   const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
560   if (PF1 && PF2) {
561     const FunctionType* FT1 = dyn_cast<FunctionType>(PF1->getElementType());
562     const FunctionType* FT2 = dyn_cast<FunctionType>(PF2->getElementType());
563     if (FT1 && FT2)
564       return FuncTysDifferOnlyBySRet(FT1, FT2);
565   }
566   return false;
569 // The upgrade of csretcc to sret param attribute may have caused a function 
570 // to not be found because the param attribute changed the type of the called 
571 // function. This helper function, used in getExistingValue, detects that
572 // situation and bitcasts the function to the correct type.
573 static Value* handleSRetFuncTypeMerge(Value *V, const Type* Ty) {
574   // Handle degenerate cases
575   if (!V)
576     return 0;
577   if (V->getType() == Ty)
578     return V;
580   const PointerType *PF1 = dyn_cast<PointerType>(Ty);
581   const PointerType *PF2 = dyn_cast<PointerType>(V->getType());
582   if (PF1 && PF2) {
583     const FunctionType *FT1 = dyn_cast<FunctionType>(PF1->getElementType());
584     const FunctionType *FT2 = dyn_cast<FunctionType>(PF2->getElementType());
585     if (FT1 && FT2 && FuncTysDifferOnlyBySRet(FT1, FT2)) {
586       const ParamAttrsList *PAL2 = FT2->getParamAttrs();
587       if (PAL2 && PAL2->paramHasAttr(1, ParamAttr::StructRet))
588         return V;
589       else if (Constant *C = dyn_cast<Constant>(V))
590         return ConstantExpr::getBitCast(C, PF1);
591       else
592         return new BitCastInst(V, PF1, "upgrd.cast", CurBB);
593     }
594       
595   }
596   return 0;
599 // getExistingValue - Look up the value specified by the provided type and
600 // the provided ValID.  If the value exists and has already been defined, return
601 // it.  Otherwise return null.
603 static Value *getExistingValue(const Type *Ty, const ValID &D) {
604   if (isa<FunctionType>(Ty)) {
605     error("Functions are not values and must be referenced as pointers");
606   }
608   switch (D.Type) {
609   case ValID::NumberVal: {                 // Is it a numbered definition?
610     unsigned Num = (unsigned)D.Num;
612     // Module constants occupy the lowest numbered slots...
613     std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
614     if (VI != CurModule.Values.end()) {
615       if (Num < VI->second.size())
616         return VI->second[Num];
617       Num -= VI->second.size();
618     }
620     // Make sure that our type is within bounds
621     VI = CurFun.Values.find(Ty);
622     if (VI == CurFun.Values.end()) return 0;
624     // Check that the number is within bounds...
625     if (VI->second.size() <= Num) return 0;
627     return VI->second[Num];
628   }
630   case ValID::NameVal: {                // Is it a named definition?
631     // Get the name out of the ID
632     RenameMapKey Key = makeRenameMapKey(D.Name, Ty, D.S);
633     Value *V = 0;
634     if (inFunctionScope()) {
635       // See if the name was renamed
636       RenameMapType::const_iterator I = CurFun.RenameMap.find(Key);
637       std::string LookupName;
638       if (I != CurFun.RenameMap.end())
639         LookupName = I->second;
640       else
641         LookupName = D.Name;
642       ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
643       V = SymTab.lookup(LookupName);
644       if (V && V->getType() != Ty)
645         V = handleSRetFuncTypeMerge(V, Ty);
646       assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type");
647     }
648     if (!V) {
649       RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
650       std::string LookupName;
651       if (I != CurModule.RenameMap.end())
652         LookupName = I->second;
653       else
654         LookupName = D.Name;
655       V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
656       if (V && V->getType() != Ty)
657         V = handleSRetFuncTypeMerge(V, Ty);
658       assert((!V || TypesDifferOnlyBySRet(V, Ty)) && "Found wrong type");
659     }
660     if (!V) 
661       return 0;
663     D.destroy();  // Free old strdup'd memory...
664     return V;
665   }
667   // Check to make sure that "Ty" is an integral type, and that our
668   // value will fit into the specified type...
669   case ValID::ConstSIntVal:    // Is it a constant pool reference??
670     if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
671       error("Signed integral constant '" + itostr(D.ConstPool64) + 
672             "' is invalid for type '" + Ty->getDescription() + "'");
673     }
674     return ConstantInt::get(Ty, D.ConstPool64);
676   case ValID::ConstUIntVal:     // Is it an unsigned const pool reference?
677     if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
678       if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64))
679         error("Integral constant '" + utostr(D.UConstPool64) + 
680               "' is invalid or out of range");
681       else     // This is really a signed reference.  Transmogrify.
682         return ConstantInt::get(Ty, D.ConstPool64);
683     } else
684       return ConstantInt::get(Ty, D.UConstPool64);
686   case ValID::ConstFPVal:        // Is it a floating point const pool reference?
687     if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP))
688       error("FP constant invalid for type");
689     // Lexer has no type info, so builds all FP constants as double.
690     // Fix this here.
691     if (Ty==Type::FloatTy)
692       D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
693     return ConstantFP::get(Ty, *D.ConstPoolFP);
695   case ValID::ConstNullVal:      // Is it a null value?
696     if (!isa<PointerType>(Ty))
697       error("Cannot create a a non pointer null");
698     return ConstantPointerNull::get(cast<PointerType>(Ty));
700   case ValID::ConstUndefVal:      // Is it an undef value?
701     return UndefValue::get(Ty);
703   case ValID::ConstZeroVal:      // Is it a zero value?
704     return Constant::getNullValue(Ty);
705     
706   case ValID::ConstantVal:       // Fully resolved constant?
707     if (D.ConstantValue->getType() != Ty) 
708       error("Constant expression type different from required type");
709     return D.ConstantValue;
711   case ValID::InlineAsmVal: {    // Inline asm expression
712     const PointerType *PTy = dyn_cast<PointerType>(Ty);
713     const FunctionType *FTy =
714       PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
715     if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
716       error("Invalid type for asm constraint string");
717     InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
718                                    D.IAD->HasSideEffects);
719     D.destroy();   // Free InlineAsmDescriptor.
720     return IA;
721   }
722   default:
723     assert(0 && "Unhandled case");
724     return 0;
725   }   // End of switch
727   assert(0 && "Unhandled case");
728   return 0;
731 // getVal - This function is identical to getExistingValue, except that if a
732 // value is not already defined, it "improvises" by creating a placeholder var
733 // that looks and acts just like the requested variable.  When the value is
734 // defined later, all uses of the placeholder variable are replaced with the
735 // real thing.
737 static Value *getVal(const Type *Ty, const ValID &ID) {
738   if (Ty == Type::LabelTy)
739     error("Cannot use a basic block here");
741   // See if the value has already been defined.
742   Value *V = getExistingValue(Ty, ID);
743   if (V) return V;
745   if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
746     error("Invalid use of a composite type");
748   // If we reached here, we referenced either a symbol that we don't know about
749   // or an id number that hasn't been read yet.  We may be referencing something
750   // forward, so just create an entry to be resolved later and get to it...
751   V = new Argument(Ty);
753   // Remember where this forward reference came from.  FIXME, shouldn't we try
754   // to recycle these things??
755   CurModule.PlaceHolderInfo.insert(
756     std::make_pair(V, std::make_pair(ID, Upgradelineno)));
758   if (inFunctionScope())
759     InsertValue(V, CurFun.LateResolveValues);
760   else
761     InsertValue(V, CurModule.LateResolveValues);
762   return V;
765 /// @brief This just makes any name given to it unique, up to MAX_UINT times.
766 static std::string makeNameUnique(const std::string& Name) {
767   static unsigned UniqueNameCounter = 1;
768   std::string Result(Name);
769   Result += ".upgrd." + llvm::utostr(UniqueNameCounter++);
770   return Result;
773 /// getBBVal - This is used for two purposes:
774 ///  * If isDefinition is true, a new basic block with the specified ID is being
775 ///    defined.
776 ///  * If isDefinition is true, this is a reference to a basic block, which may
777 ///    or may not be a forward reference.
779 static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
780   assert(inFunctionScope() && "Can't get basic block at global scope");
782   std::string Name;
783   BasicBlock *BB = 0;
784   switch (ID.Type) {
785   default: 
786     error("Illegal label reference " + ID.getName());
787     break;
788   case ValID::NumberVal:                // Is it a numbered definition?
789     if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
790       CurFun.NumberedBlocks.resize(ID.Num+1);
791     BB = CurFun.NumberedBlocks[ID.Num];
792     break;
793   case ValID::NameVal:                  // Is it a named definition?
794     Name = ID.Name;
795     if (Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name)) {
796       if (N->getType() != Type::LabelTy) {
797         // Register names didn't use to conflict with basic block names
798         // because of type planes. Now they all have to be unique. So, we just
799         // rename the register and treat this name as if no basic block
800         // had been found.
801         RenameMapKey Key = makeRenameMapKey(ID.Name, N->getType(), ID.S);
802         N->setName(makeNameUnique(N->getName()));
803         CurModule.RenameMap[Key] = N->getName();
804         BB = 0;
805       } else {
806         BB = cast<BasicBlock>(N);
807       }
808     }
809     break;
810   }
812   // See if the block has already been defined.
813   if (BB) {
814     // If this is the definition of the block, make sure the existing value was
815     // just a forward reference.  If it was a forward reference, there will be
816     // an entry for it in the PlaceHolderInfo map.
817     if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
818       // The existing value was a definition, not a forward reference.
819       error("Redefinition of label " + ID.getName());
821     ID.destroy();                       // Free strdup'd memory.
822     return BB;
823   }
825   // Otherwise this block has not been seen before.
826   BB = new BasicBlock("", CurFun.CurrentFunction);
827   if (ID.Type == ValID::NameVal) {
828     BB->setName(ID.Name);
829   } else {
830     CurFun.NumberedBlocks[ID.Num] = BB;
831   }
833   // If this is not a definition, keep track of it so we can use it as a forward
834   // reference.
835   if (!isDefinition) {
836     // Remember where this forward reference came from.
837     CurFun.BBForwardRefs[BB] = std::make_pair(ID, Upgradelineno);
838   } else {
839     // The forward declaration could have been inserted anywhere in the
840     // function: insert it into the correct place now.
841     CurFun.CurrentFunction->getBasicBlockList().remove(BB);
842     CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
843   }
844   ID.destroy();
845   return BB;
849 //===----------------------------------------------------------------------===//
850 //              Code to handle forward references in instructions
851 //===----------------------------------------------------------------------===//
853 // This code handles the late binding needed with statements that reference
854 // values not defined yet... for example, a forward branch, or the PHI node for
855 // a loop body.
857 // This keeps a table (CurFun.LateResolveValues) of all such forward references
858 // and back patchs after we are done.
861 // ResolveDefinitions - If we could not resolve some defs at parsing
862 // time (forward branches, phi functions for loops, etc...) resolve the
863 // defs now...
865 static void 
866 ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
867                    std::map<const Type*,ValueList> *FutureLateResolvers) {
869   // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
870   for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
871          E = LateResolvers.end(); LRI != E; ++LRI) {
872     const Type* Ty = LRI->first;
873     ValueList &List = LRI->second;
874     while (!List.empty()) {
875       Value *V = List.back();
876       List.pop_back();
878       std::map<Value*, std::pair<ValID, int> >::iterator PHI =
879         CurModule.PlaceHolderInfo.find(V);
880       assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error");
882       ValID &DID = PHI->second.first;
884       Value *TheRealValue = getExistingValue(Ty, DID);
885       if (TheRealValue) {
886         V->replaceAllUsesWith(TheRealValue);
887         delete V;
888         CurModule.PlaceHolderInfo.erase(PHI);
889       } else if (FutureLateResolvers) {
890         // Functions have their unresolved items forwarded to the module late
891         // resolver table
892         InsertValue(V, *FutureLateResolvers);
893       } else {
894         if (DID.Type == ValID::NameVal) {
895           error("Reference to an invalid definition: '" + DID.getName() +
896                 "' of type '" + V->getType()->getDescription() + "'",
897                 PHI->second.second);
898             return;
899         } else {
900           error("Reference to an invalid definition: #" +
901                 itostr(DID.Num) + " of type '" + 
902                 V->getType()->getDescription() + "'", PHI->second.second);
903           return;
904         }
905       }
906     }
907   }
909   LateResolvers.clear();
912 /// This function is used for type resolution and upref handling. When a type
913 /// becomes concrete, this function is called to adjust the signedness for the
914 /// concrete type.
915 static void ResolveTypeSign(const Type* oldTy, const Signedness &Sign) {
916   std::string TyName = CurModule.CurrentModule->getTypeName(oldTy);
917   if (!TyName.empty())
918     CurModule.NamedTypeSigns[TyName] = Sign;
921 /// ResolveTypeTo - A brand new type was just declared.  This means that (if
922 /// name is not null) things referencing Name can be resolved.  Otherwise, 
923 /// things refering to the number can be resolved.  Do this now.
924 static void ResolveTypeTo(char *Name, const Type *ToTy, const Signedness& Sign){
925   ValID D;
926   if (Name)
927     D = ValID::create(Name);
928   else      
929     D = ValID::create((int)CurModule.Types.size());
930   D.S.copy(Sign);
932   if (Name)
933     CurModule.NamedTypeSigns[Name] = Sign;
935   std::map<ValID, PATypeHolder>::iterator I =
936     CurModule.LateResolveTypes.find(D);
937   if (I != CurModule.LateResolveTypes.end()) {
938     const Type *OldTy = I->second.get();
939     ((DerivedType*)OldTy)->refineAbstractTypeTo(ToTy);
940     CurModule.LateResolveTypes.erase(I);
941   }
944 /// This is the implementation portion of TypeHasInteger. It traverses the
945 /// type given, avoiding recursive types, and returns true as soon as it finds
946 /// an integer type. If no integer type is found, it returns false.
947 static bool TypeHasIntegerI(const Type *Ty, std::vector<const Type*> Stack) {
948   // Handle some easy cases
949   if (Ty->isPrimitiveType() || (Ty->getTypeID() == Type::OpaqueTyID))
950     return false;
951   if (Ty->isInteger())
952     return true;
953   if (const SequentialType *STy = dyn_cast<SequentialType>(Ty))
954     return STy->getElementType()->isInteger();
956   // Avoid type structure recursion
957   for (std::vector<const Type*>::iterator I = Stack.begin(), E = Stack.end();
958        I != E; ++I)
959     if (Ty == *I)
960       return false;
962   // Push us on the type stack
963   Stack.push_back(Ty);
965   if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
966     if (TypeHasIntegerI(FTy->getReturnType(), Stack)) 
967       return true;
968     FunctionType::param_iterator I = FTy->param_begin();
969     FunctionType::param_iterator E = FTy->param_end();
970     for (; I != E; ++I)
971       if (TypeHasIntegerI(*I, Stack))
972         return true;
973     return false;
974   } else if (const StructType *STy = dyn_cast<StructType>(Ty)) {
975     StructType::element_iterator I = STy->element_begin();
976     StructType::element_iterator E = STy->element_end();
977     for (; I != E; ++I) {
978       if (TypeHasIntegerI(*I, Stack))
979         return true;
980     }
981     return false;
982   }
983   // There shouldn't be anything else, but its definitely not integer
984   assert(0 && "What type is this?");
985   return false;
988 /// This is the interface to TypeHasIntegerI. It just provides the type stack,
989 /// to avoid recursion, and then calls TypeHasIntegerI.
990 static inline bool TypeHasInteger(const Type *Ty) {
991   std::vector<const Type*> TyStack;
992   return TypeHasIntegerI(Ty, TyStack);
995 // setValueName - Set the specified value to the name given.  The name may be
996 // null potentially, in which case this is a noop.  The string passed in is
997 // assumed to be a malloc'd string buffer, and is free'd by this function.
999 static void setValueName(const ValueInfo &V, char *NameStr) {
1000   if (NameStr) {
1001     std::string Name(NameStr);      // Copy string
1002     free(NameStr);                  // Free old string
1004     if (V.V->getType() == Type::VoidTy) {
1005       error("Can't assign name '" + Name + "' to value with void type");
1006       return;
1007     }
1009     assert(inFunctionScope() && "Must be in function scope");
1011     // Search the function's symbol table for an existing value of this name
1012     ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
1013     Value* Existing = ST.lookup(Name);
1014     if (Existing) {
1015       // An existing value of the same name was found. This might have happened
1016       // because of the integer type planes collapsing in LLVM 2.0. 
1017       if (Existing->getType() == V.V->getType() &&
1018           !TypeHasInteger(Existing->getType())) {
1019         // If the type does not contain any integers in them then this can't be
1020         // a type plane collapsing issue. It truly is a redefinition and we 
1021         // should error out as the assembly is invalid.
1022         error("Redefinition of value named '" + Name + "' of type '" +
1023               V.V->getType()->getDescription() + "'");
1024         return;
1025       } 
1026       // In LLVM 2.0 we don't allow names to be re-used for any values in a 
1027       // function, regardless of Type. Previously re-use of names was okay as 
1028       // long as they were distinct types. With type planes collapsing because
1029       // of the signedness change and because of PR411, this can no longer be
1030       // supported. We must search the entire symbol table for a conflicting
1031       // name and make the name unique. No warning is needed as this can't 
1032       // cause a problem.
1033       std::string NewName = makeNameUnique(Name);
1034       // We're changing the name but it will probably be used by other 
1035       // instructions as operands later on. Consequently we have to retain
1036       // a mapping of the renaming that we're doing.
1037       RenameMapKey Key = makeRenameMapKey(Name, V.V->getType(), V.S);
1038       CurFun.RenameMap[Key] = NewName;
1039       Name = NewName;
1040     }
1042     // Set the name.
1043     V.V->setName(Name);
1044   }
1047 /// ParseGlobalVariable - Handle parsing of a global.  If Initializer is null,
1048 /// this is a declaration, otherwise it is a definition.
1049 static GlobalVariable *
1050 ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
1051                     bool isConstantGlobal, const Type *Ty,
1052                     Constant *Initializer,
1053                     const Signedness &Sign) {
1054   if (isa<FunctionType>(Ty))
1055     error("Cannot declare global vars of function type");
1057   const PointerType *PTy = PointerType::get(Ty);
1059   std::string Name;
1060   if (NameStr) {
1061     Name = NameStr;      // Copy string
1062     free(NameStr);       // Free old string
1063   }
1065   // See if this global value was forward referenced.  If so, recycle the
1066   // object.
1067   ValID ID;
1068   if (!Name.empty()) {
1069     ID = ValID::create((char*)Name.c_str());
1070   } else {
1071     ID = ValID::create((int)CurModule.Values[PTy].size());
1072   }
1073   ID.S.makeComposite(Sign);
1075   if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
1076     // Move the global to the end of the list, from whereever it was
1077     // previously inserted.
1078     GlobalVariable *GV = cast<GlobalVariable>(FWGV);
1079     CurModule.CurrentModule->getGlobalList().remove(GV);
1080     CurModule.CurrentModule->getGlobalList().push_back(GV);
1081     GV->setInitializer(Initializer);
1082     GV->setLinkage(Linkage);
1083     GV->setConstant(isConstantGlobal);
1084     InsertValue(GV, CurModule.Values);
1085     return GV;
1086   }
1088   // If this global has a name, check to see if there is already a definition
1089   // of this global in the module and emit warnings if there are conflicts.
1090   if (!Name.empty()) {
1091     // The global has a name. See if there's an existing one of the same name.
1092     if (CurModule.CurrentModule->getNamedGlobal(Name) ||
1093         CurModule.CurrentModule->getFunction(Name)) {
1094       // We found an existing global of the same name. This isn't allowed 
1095       // in LLVM 2.0. Consequently, we must alter the name of the global so it
1096       // can at least compile. This can happen because of type planes 
1097       // There is alread a global of the same name which means there is a
1098       // conflict. Let's see what we can do about it.
1099       std::string NewName(makeNameUnique(Name));
1100       if (Linkage != GlobalValue::InternalLinkage) {
1101         // The linkage of this gval is external so we can't reliably rename 
1102         // it because it could potentially create a linking problem.  
1103         // However, we can't leave the name conflict in the output either or 
1104         // it won't assemble with LLVM 2.0.  So, all we can do is rename 
1105         // this one to something unique and emit a warning about the problem.
1106         warning("Renaming global variable '" + Name + "' to '" + NewName + 
1107                   "' may cause linkage errors");
1108       }
1110       // Put the renaming in the global rename map
1111       RenameMapKey Key = makeRenameMapKey(Name, PointerType::get(Ty), ID.S);
1112       CurModule.RenameMap[Key] = NewName;
1114       // Rename it
1115       Name = NewName;
1116     }
1117   }
1119   // Otherwise there is no existing GV to use, create one now.
1120   GlobalVariable *GV =
1121     new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
1122                        CurModule.CurrentModule);
1123   InsertValue(GV, CurModule.Values);
1124   // Remember the sign of this global.
1125   CurModule.NamedValueSigns[Name] = ID.S;
1126   return GV;
1129 // setTypeName - Set the specified type to the name given.  The name may be
1130 // null potentially, in which case this is a noop.  The string passed in is
1131 // assumed to be a malloc'd string buffer, and is freed by this function.
1133 // This function returns true if the type has already been defined, but is
1134 // allowed to be redefined in the specified context.  If the name is a new name
1135 // for the type plane, it is inserted and false is returned.
1136 static bool setTypeName(const PATypeInfo& TI, char *NameStr) {
1137   assert(!inFunctionScope() && "Can't give types function-local names");
1138   if (NameStr == 0) return false;
1140   std::string Name(NameStr);      // Copy string
1141   free(NameStr);                  // Free old string
1143   const Type* Ty = TI.PAT->get();
1145   // We don't allow assigning names to void type
1146   if (Ty == Type::VoidTy) {
1147     error("Can't assign name '" + Name + "' to the void type");
1148     return false;
1149   }
1151   // Set the type name, checking for conflicts as we do so.
1152   bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, Ty);
1154   // Save the sign information for later use 
1155   CurModule.NamedTypeSigns[Name] = TI.S;
1157   if (AlreadyExists) {   // Inserting a name that is already defined???
1158     const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1159     assert(Existing && "Conflict but no matching type?");
1161     // There is only one case where this is allowed: when we are refining an
1162     // opaque type.  In this case, Existing will be an opaque type.
1163     if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1164       // We ARE replacing an opaque type!
1165       const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(Ty);
1166       return true;
1167     }
1169     // Otherwise, this is an attempt to redefine a type. That's okay if
1170     // the redefinition is identical to the original. This will be so if
1171     // Existing and T point to the same Type object. In this one case we
1172     // allow the equivalent redefinition.
1173     if (Existing == Ty) return true;  // Yes, it's equal.
1175     // Any other kind of (non-equivalent) redefinition is an error.
1176     error("Redefinition of type named '" + Name + "' in the '" +
1177           Ty->getDescription() + "' type plane");
1178   }
1180   return false;
1183 //===----------------------------------------------------------------------===//
1184 // Code for handling upreferences in type names...
1187 // TypeContains - Returns true if Ty directly contains E in it.
1189 static bool TypeContains(const Type *Ty, const Type *E) {
1190   return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1191                    E) != Ty->subtype_end();
1194 namespace {
1195   struct UpRefRecord {
1196     // NestingLevel - The number of nesting levels that need to be popped before
1197     // this type is resolved.
1198     unsigned NestingLevel;
1200     // LastContainedTy - This is the type at the current binding level for the
1201     // type.  Every time we reduce the nesting level, this gets updated.
1202     const Type *LastContainedTy;
1204     // UpRefTy - This is the actual opaque type that the upreference is
1205     // represented with.
1206     OpaqueType *UpRefTy;
1208     UpRefRecord(unsigned NL, OpaqueType *URTy)
1209       : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) { }
1210   };
1213 // UpRefs - A list of the outstanding upreferences that need to be resolved.
1214 static std::vector<UpRefRecord> UpRefs;
1216 /// HandleUpRefs - Every time we finish a new layer of types, this function is
1217 /// called.  It loops through the UpRefs vector, which is a list of the
1218 /// currently active types.  For each type, if the up reference is contained in
1219 /// the newly completed type, we decrement the level count.  When the level
1220 /// count reaches zero, the upreferenced type is the type that is passed in:
1221 /// thus we can complete the cycle.
1223 static PATypeHolder HandleUpRefs(const Type *ty, const Signedness& Sign) {
1224   // If Ty isn't abstract, or if there are no up-references in it, then there is
1225   // nothing to resolve here.
1226   if (!ty->isAbstract() || UpRefs.empty()) return ty;
1227   
1228   PATypeHolder Ty(ty);
1229   UR_OUT("Type '" << Ty->getDescription() <<
1230          "' newly formed.  Resolving upreferences.\n" <<
1231          UpRefs.size() << " upreferences active!\n");
1233   // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1234   // to zero), we resolve them all together before we resolve them to Ty.  At
1235   // the end of the loop, if there is anything to resolve to Ty, it will be in
1236   // this variable.
1237   OpaqueType *TypeToResolve = 0;
1239   unsigned i = 0;
1240   for (; i != UpRefs.size(); ++i) {
1241     UR_OUT("  UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1242            << UpRefs[i].UpRefTy->getDescription() << ") = "
1243            << (TypeContains(Ty, UpRefs[i].UpRefTy) ? "true" : "false") << "\n");
1244     if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1245       // Decrement level of upreference
1246       unsigned Level = --UpRefs[i].NestingLevel;
1247       UpRefs[i].LastContainedTy = Ty;
1248       UR_OUT("  Uplevel Ref Level = " << Level << "\n");
1249       if (Level == 0) {                     // Upreference should be resolved!
1250         if (!TypeToResolve) {
1251           TypeToResolve = UpRefs[i].UpRefTy;
1252         } else {
1253           UR_OUT("  * Resolving upreference for "
1254                  << UpRefs[i].UpRefTy->getDescription() << "\n";
1255           std::string OldName = UpRefs[i].UpRefTy->getDescription());
1256           ResolveTypeSign(UpRefs[i].UpRefTy, Sign);
1257           UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1258           UR_OUT("  * Type '" << OldName << "' refined upreference to: "
1259                  << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1260         }
1261         UpRefs.erase(UpRefs.begin()+i);     // Remove from upreference list...
1262         --i;                                // Do not skip the next element...
1263       }
1264     }
1265   }
1267   if (TypeToResolve) {
1268     UR_OUT("  * Resolving upreference for "
1269            << UpRefs[i].UpRefTy->getDescription() << "\n";
1270            std::string OldName = TypeToResolve->getDescription());
1271     ResolveTypeSign(TypeToResolve, Sign);
1272     TypeToResolve->refineAbstractTypeTo(Ty);
1273   }
1275   return Ty;
1278 bool Signedness::operator<(const Signedness &that) const {
1279   if (isNamed()) {
1280     if (that.isNamed()) 
1281       return *(this->name) < *(that.name);
1282     else
1283       return CurModule.NamedTypeSigns[*name] < that;
1284   } else if (that.isNamed()) {
1285     return *this < CurModule.NamedTypeSigns[*that.name];
1286   }
1288   if (isComposite() && that.isComposite()) {
1289     if (sv->size() == that.sv->size()) {
1290       SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
1291       SignVector::const_iterator thatI = that.sv->begin(), 
1292                                  thatE = that.sv->end();
1293       for (; thisI != thisE; ++thisI, ++thatI) {
1294         if (*thisI < *thatI)
1295           return true;
1296         else if (!(*thisI == *thatI))
1297           return false;
1298       }
1299       return false;
1300     }
1301     return sv->size() < that.sv->size();
1302   }  
1303   return kind < that.kind;
1306 bool Signedness::operator==(const Signedness &that) const {
1307   if (isNamed())
1308     if (that.isNamed())
1309       return *(this->name) == *(that.name);
1310     else 
1311       return CurModule.NamedTypeSigns[*(this->name)] == that;
1312   else if (that.isNamed())
1313     return *this == CurModule.NamedTypeSigns[*(that.name)];
1314   if (isComposite() && that.isComposite()) {
1315     if (sv->size() == that.sv->size()) {
1316       SignVector::const_iterator thisI = sv->begin(), thisE = sv->end();
1317       SignVector::const_iterator thatI = that.sv->begin(), 
1318                                  thatE = that.sv->end();
1319       for (; thisI != thisE; ++thisI, ++thatI) {
1320         if (!(*thisI == *thatI))
1321           return false;
1322       }
1323       return true;
1324     }
1325     return false;
1326   }
1327   return kind == that.kind;
1330 void Signedness::copy(const Signedness &that) {
1331   if (that.isNamed()) {
1332     kind = Named;
1333     name = new std::string(*that.name);
1334   } else if (that.isComposite()) {
1335     kind = Composite;
1336     sv = new SignVector();
1337     *sv = *that.sv;
1338   } else {
1339     kind = that.kind;
1340     sv = 0;
1341   }
1344 void Signedness::destroy() {
1345   if (isNamed()) {
1346     delete name;
1347   } else if (isComposite()) {
1348     delete sv;
1349   } 
1352 #ifndef NDEBUG
1353 void Signedness::dump() const {
1354   if (isComposite()) {
1355     if (sv->size() == 1) {
1356       (*sv)[0].dump();
1357       std::cerr << "*";
1358     } else {
1359       std::cerr << "{ " ;
1360       for (unsigned i = 0; i < sv->size(); ++i) {
1361         if (i != 0)
1362           std::cerr << ", ";
1363         (*sv)[i].dump();
1364       }
1365       std::cerr << "} " ;
1366     }
1367   } else if (isNamed()) {
1368     std::cerr << *name;
1369   } else if (isSigned()) {
1370     std::cerr << "S";
1371   } else if (isUnsigned()) {
1372     std::cerr << "U";
1373   } else
1374     std::cerr << ".";
1376 #endif
1378 static inline Instruction::TermOps 
1379 getTermOp(TermOps op) {
1380   switch (op) {
1381     default           : assert(0 && "Invalid OldTermOp");
1382     case RetOp        : return Instruction::Ret;
1383     case BrOp         : return Instruction::Br;
1384     case SwitchOp     : return Instruction::Switch;
1385     case InvokeOp     : return Instruction::Invoke;
1386     case UnwindOp     : return Instruction::Unwind;
1387     case UnreachableOp: return Instruction::Unreachable;
1388   }
1391 static inline Instruction::BinaryOps 
1392 getBinaryOp(BinaryOps op, const Type *Ty, const Signedness& Sign) {
1393   switch (op) {
1394     default     : assert(0 && "Invalid OldBinaryOps");
1395     case SetEQ  : 
1396     case SetNE  : 
1397     case SetLE  :
1398     case SetGE  :
1399     case SetLT  :
1400     case SetGT  : assert(0 && "Should use getCompareOp");
1401     case AddOp  : return Instruction::Add;
1402     case SubOp  : return Instruction::Sub;
1403     case MulOp  : return Instruction::Mul;
1404     case DivOp  : {
1405       // This is an obsolete instruction so we must upgrade it based on the
1406       // types of its operands.
1407       bool isFP = Ty->isFloatingPoint();
1408       if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
1409         // If its a vector type we want to use the element type
1410         isFP = PTy->getElementType()->isFloatingPoint();
1411       if (isFP)
1412         return Instruction::FDiv;
1413       else if (Sign.isSigned())
1414         return Instruction::SDiv;
1415       return Instruction::UDiv;
1416     }
1417     case UDivOp : return Instruction::UDiv;
1418     case SDivOp : return Instruction::SDiv;
1419     case FDivOp : return Instruction::FDiv;
1420     case RemOp  : {
1421       // This is an obsolete instruction so we must upgrade it based on the
1422       // types of its operands.
1423       bool isFP = Ty->isFloatingPoint();
1424       if (const VectorType* PTy = dyn_cast<VectorType>(Ty))
1425         // If its a vector type we want to use the element type
1426         isFP = PTy->getElementType()->isFloatingPoint();
1427       // Select correct opcode
1428       if (isFP)
1429         return Instruction::FRem;
1430       else if (Sign.isSigned())
1431         return Instruction::SRem;
1432       return Instruction::URem;
1433     }
1434     case URemOp : return Instruction::URem;
1435     case SRemOp : return Instruction::SRem;
1436     case FRemOp : return Instruction::FRem;
1437     case LShrOp : return Instruction::LShr;
1438     case AShrOp : return Instruction::AShr;
1439     case ShlOp  : return Instruction::Shl;
1440     case ShrOp  : 
1441       if (Sign.isSigned())
1442         return Instruction::AShr;
1443       return Instruction::LShr;
1444     case AndOp  : return Instruction::And;
1445     case OrOp   : return Instruction::Or;
1446     case XorOp  : return Instruction::Xor;
1447   }
1450 static inline Instruction::OtherOps 
1451 getCompareOp(BinaryOps op, unsigned short &predicate, const Type* &Ty,
1452              const Signedness &Sign) {
1453   bool isSigned = Sign.isSigned();
1454   bool isFP = Ty->isFloatingPoint();
1455   switch (op) {
1456     default     : assert(0 && "Invalid OldSetCC");
1457     case SetEQ  : 
1458       if (isFP) {
1459         predicate = FCmpInst::FCMP_OEQ;
1460         return Instruction::FCmp;
1461       } else {
1462         predicate = ICmpInst::ICMP_EQ;
1463         return Instruction::ICmp;
1464       }
1465     case SetNE  : 
1466       if (isFP) {
1467         predicate = FCmpInst::FCMP_UNE;
1468         return Instruction::FCmp;
1469       } else {
1470         predicate = ICmpInst::ICMP_NE;
1471         return Instruction::ICmp;
1472       }
1473     case SetLE  : 
1474       if (isFP) {
1475         predicate = FCmpInst::FCMP_OLE;
1476         return Instruction::FCmp;
1477       } else {
1478         if (isSigned)
1479           predicate = ICmpInst::ICMP_SLE;
1480         else
1481           predicate = ICmpInst::ICMP_ULE;
1482         return Instruction::ICmp;
1483       }
1484     case SetGE  : 
1485       if (isFP) {
1486         predicate = FCmpInst::FCMP_OGE;
1487         return Instruction::FCmp;
1488       } else {
1489         if (isSigned)
1490           predicate = ICmpInst::ICMP_SGE;
1491         else
1492           predicate = ICmpInst::ICMP_UGE;
1493         return Instruction::ICmp;
1494       }
1495     case SetLT  : 
1496       if (isFP) {
1497         predicate = FCmpInst::FCMP_OLT;
1498         return Instruction::FCmp;
1499       } else {
1500         if (isSigned)
1501           predicate = ICmpInst::ICMP_SLT;
1502         else
1503           predicate = ICmpInst::ICMP_ULT;
1504         return Instruction::ICmp;
1505       }
1506     case SetGT  : 
1507       if (isFP) {
1508         predicate = FCmpInst::FCMP_OGT;
1509         return Instruction::FCmp;
1510       } else {
1511         if (isSigned)
1512           predicate = ICmpInst::ICMP_SGT;
1513         else
1514           predicate = ICmpInst::ICMP_UGT;
1515         return Instruction::ICmp;
1516       }
1517   }
1520 static inline Instruction::MemoryOps getMemoryOp(MemoryOps op) {
1521   switch (op) {
1522     default              : assert(0 && "Invalid OldMemoryOps");
1523     case MallocOp        : return Instruction::Malloc;
1524     case FreeOp          : return Instruction::Free;
1525     case AllocaOp        : return Instruction::Alloca;
1526     case LoadOp          : return Instruction::Load;
1527     case StoreOp         : return Instruction::Store;
1528     case GetElementPtrOp : return Instruction::GetElementPtr;
1529   }
1532 static inline Instruction::OtherOps 
1533 getOtherOp(OtherOps op, const Signedness &Sign) {
1534   switch (op) {
1535     default               : assert(0 && "Invalid OldOtherOps");
1536     case PHIOp            : return Instruction::PHI;
1537     case CallOp           : return Instruction::Call;
1538     case SelectOp         : return Instruction::Select;
1539     case UserOp1          : return Instruction::UserOp1;
1540     case UserOp2          : return Instruction::UserOp2;
1541     case VAArg            : return Instruction::VAArg;
1542     case ExtractElementOp : return Instruction::ExtractElement;
1543     case InsertElementOp  : return Instruction::InsertElement;
1544     case ShuffleVectorOp  : return Instruction::ShuffleVector;
1545     case ICmpOp           : return Instruction::ICmp;
1546     case FCmpOp           : return Instruction::FCmp;
1547   };
1550 static inline Value*
1551 getCast(CastOps op, Value *Src, const Signedness &SrcSign, const Type *DstTy, 
1552         const Signedness &DstSign, bool ForceInstruction = false) {
1553   Instruction::CastOps Opcode;
1554   const Type* SrcTy = Src->getType();
1555   if (op == CastOp) {
1556     if (SrcTy->isFloatingPoint() && isa<PointerType>(DstTy)) {
1557       // fp -> ptr cast is no longer supported but we must upgrade this
1558       // by doing a double cast: fp -> int -> ptr
1559       SrcTy = Type::Int64Ty;
1560       Opcode = Instruction::IntToPtr;
1561       if (isa<Constant>(Src)) {
1562         Src = ConstantExpr::getCast(Instruction::FPToUI, 
1563                                      cast<Constant>(Src), SrcTy);
1564       } else {
1565         std::string NewName(makeNameUnique(Src->getName()));
1566         Src = new FPToUIInst(Src, SrcTy, NewName, CurBB);
1567       }
1568     } else if (isa<IntegerType>(DstTy) &&
1569                cast<IntegerType>(DstTy)->getBitWidth() == 1) {
1570       // cast type %x to bool was previously defined as setne type %x, null
1571       // The cast semantic is now to truncate, not compare so we must retain
1572       // the original intent by replacing the cast with a setne
1573       Constant* Null = Constant::getNullValue(SrcTy);
1574       Instruction::OtherOps Opcode = Instruction::ICmp;
1575       unsigned short predicate = ICmpInst::ICMP_NE;
1576       if (SrcTy->isFloatingPoint()) {
1577         Opcode = Instruction::FCmp;
1578         predicate = FCmpInst::FCMP_ONE;
1579       } else if (!SrcTy->isInteger() && !isa<PointerType>(SrcTy)) {
1580         error("Invalid cast to bool");
1581       }
1582       if (isa<Constant>(Src) && !ForceInstruction)
1583         return ConstantExpr::getCompare(predicate, cast<Constant>(Src), Null);
1584       else
1585         return CmpInst::create(Opcode, predicate, Src, Null);
1586     }
1587     // Determine the opcode to use by calling CastInst::getCastOpcode
1588     Opcode = 
1589       CastInst::getCastOpcode(Src, SrcSign.isSigned(), DstTy, 
1590                               DstSign.isSigned());
1592   } else switch (op) {
1593     default: assert(0 && "Invalid cast token");
1594     case TruncOp:    Opcode = Instruction::Trunc; break;
1595     case ZExtOp:     Opcode = Instruction::ZExt; break;
1596     case SExtOp:     Opcode = Instruction::SExt; break;
1597     case FPTruncOp:  Opcode = Instruction::FPTrunc; break;
1598     case FPExtOp:    Opcode = Instruction::FPExt; break;
1599     case FPToUIOp:   Opcode = Instruction::FPToUI; break;
1600     case FPToSIOp:   Opcode = Instruction::FPToSI; break;
1601     case UIToFPOp:   Opcode = Instruction::UIToFP; break;
1602     case SIToFPOp:   Opcode = Instruction::SIToFP; break;
1603     case PtrToIntOp: Opcode = Instruction::PtrToInt; break;
1604     case IntToPtrOp: Opcode = Instruction::IntToPtr; break;
1605     case BitCastOp:  Opcode = Instruction::BitCast; break;
1606   }
1608   if (isa<Constant>(Src) && !ForceInstruction)
1609     return ConstantExpr::getCast(Opcode, cast<Constant>(Src), DstTy);
1610   return CastInst::create(Opcode, Src, DstTy);
1613 static Instruction *
1614 upgradeIntrinsicCall(const Type* RetTy, const ValID &ID, 
1615                      std::vector<Value*>& Args) {
1617   std::string Name = ID.Type == ValID::NameVal ? ID.Name : "";
1618   if (Name.length() <= 5 || Name[0] != 'l' || Name[1] != 'l' || 
1619       Name[2] != 'v' || Name[3] != 'm' || Name[4] != '.')
1620     return 0;
1622   switch (Name[5]) {
1623     case 'i':
1624       if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64") {
1625         if (Args.size() != 2)
1626           error("Invalid prototype for " + Name);
1627         return new FCmpInst(FCmpInst::FCMP_UNO, Args[0], Args[1]);
1628       }
1629       break;
1631     case 'v' : {
1632       const Type* PtrTy = PointerType::get(Type::Int8Ty);
1633       std::vector<const Type*> Params;
1634       if (Name == "llvm.va_start" || Name == "llvm.va_end") {
1635         if (Args.size() != 1)
1636           error("Invalid prototype for " + Name + " prototype");
1637         Params.push_back(PtrTy);
1638         const FunctionType *FTy = 
1639           FunctionType::get(Type::VoidTy, Params, false);
1640         const PointerType *PFTy = PointerType::get(FTy);
1641         Value* Func = getVal(PFTy, ID);
1642         Args[0] = new BitCastInst(Args[0], PtrTy, makeNameUnique("va"), CurBB);
1643         return new CallInst(Func, Args.begin(), Args.end());
1644       } else if (Name == "llvm.va_copy") {
1645         if (Args.size() != 2)
1646           error("Invalid prototype for " + Name + " prototype");
1647         Params.push_back(PtrTy);
1648         Params.push_back(PtrTy);
1649         const FunctionType *FTy = 
1650           FunctionType::get(Type::VoidTy, Params, false);
1651         const PointerType *PFTy = PointerType::get(FTy);
1652         Value* Func = getVal(PFTy, ID);
1653         std::string InstName0(makeNameUnique("va0"));
1654         std::string InstName1(makeNameUnique("va1"));
1655         Args[0] = new BitCastInst(Args[0], PtrTy, InstName0, CurBB);
1656         Args[1] = new BitCastInst(Args[1], PtrTy, InstName1, CurBB);
1657         return new CallInst(Func, Args.begin(), Args.end());
1658       }
1659     }
1660   }
1661   return 0;
1664 const Type* upgradeGEPCEIndices(const Type* PTy, 
1665                                 std::vector<ValueInfo> *Indices, 
1666                                 std::vector<Constant*> &Result) {
1667   const Type *Ty = PTy;
1668   Result.clear();
1669   for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
1670     Constant *Index = cast<Constant>((*Indices)[i].V);
1672     if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
1673       // LLVM 1.2 and earlier used ubyte struct indices.  Convert any ubyte 
1674       // struct indices to i32 struct indices with ZExt for compatibility.
1675       if (CI->getBitWidth() < 32)
1676         Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
1677     }
1678     
1679     if (isa<SequentialType>(Ty)) {
1680       // Make sure that unsigned SequentialType indices are zext'd to 
1681       // 64-bits if they were smaller than that because LLVM 2.0 will sext 
1682       // all indices for SequentialType elements. We must retain the same 
1683       // semantic (zext) for unsigned types.
1684       if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
1685         if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
1686           Index = ConstantExpr::getCast(Instruction::ZExt, Index,Type::Int64Ty);
1687         }
1688       }
1689     }
1690     Result.push_back(Index);
1691     Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(), 
1692                                            Result.end(),true);
1693     if (!Ty)
1694       error("Index list invalid for constant getelementptr");
1695   }
1696   return Ty;
1699 const Type* upgradeGEPInstIndices(const Type* PTy, 
1700                                   std::vector<ValueInfo> *Indices, 
1701                                   std::vector<Value*>    &Result) {
1702   const Type *Ty = PTy;
1703   Result.clear();
1704   for (unsigned i = 0, e = Indices->size(); i != e ; ++i) {
1705     Value *Index = (*Indices)[i].V;
1707     if (ConstantInt *CI = dyn_cast<ConstantInt>(Index)) {
1708       // LLVM 1.2 and earlier used ubyte struct indices.  Convert any ubyte 
1709       // struct indices to i32 struct indices with ZExt for compatibility.
1710       if (CI->getBitWidth() < 32)
1711         Index = ConstantExpr::getCast(Instruction::ZExt, CI, Type::Int32Ty);
1712     }
1713     
1715     if (isa<StructType>(Ty)) {        // Only change struct indices
1716       if (!isa<Constant>(Index)) {
1717         error("Invalid non-constant structure index");
1718         return 0;
1719       }
1720     } else {
1721       // Make sure that unsigned SequentialType indices are zext'd to 
1722       // 64-bits if they were smaller than that because LLVM 2.0 will sext 
1723       // all indices for SequentialType elements. We must retain the same 
1724       // semantic (zext) for unsigned types.
1725       if (const IntegerType *Ity = dyn_cast<IntegerType>(Index->getType())) {
1726         if (Ity->getBitWidth() < 64 && (*Indices)[i].S.isUnsigned()) {
1727           if (isa<Constant>(Index))
1728             Index = ConstantExpr::getCast(Instruction::ZExt, 
1729               cast<Constant>(Index), Type::Int64Ty);
1730           else
1731             Index = CastInst::create(Instruction::ZExt, Index, Type::Int64Ty,
1732               makeNameUnique("gep"), CurBB);
1733         }
1734       }
1735     }
1736     Result.push_back(Index);
1737     Ty = GetElementPtrInst::getIndexedType(PTy, Result.begin(),
1738                                            Result.end(),true);
1739     if (!Ty)
1740       error("Index list invalid for constant getelementptr");
1741   }
1742   return Ty;
1745 unsigned upgradeCallingConv(unsigned CC) {
1746   switch (CC) {
1747     case OldCallingConv::C           : return CallingConv::C;
1748     case OldCallingConv::CSRet       : return CallingConv::C;
1749     case OldCallingConv::Fast        : return CallingConv::Fast;
1750     case OldCallingConv::Cold        : return CallingConv::Cold;
1751     case OldCallingConv::X86_StdCall : return CallingConv::X86_StdCall;
1752     case OldCallingConv::X86_FastCall: return CallingConv::X86_FastCall;
1753     default:
1754       return CC;
1755   }
1758 Module* UpgradeAssembly(const std::string &infile, std::istream& in, 
1759                               bool debug, bool addAttrs)
1761   Upgradelineno = 1; 
1762   CurFilename = infile;
1763   LexInput = &in;
1764   yydebug = debug;
1765   AddAttributes = addAttrs;
1766   ObsoleteVarArgs = false;
1767   NewVarArgs = false;
1769   CurModule.CurrentModule = new Module(CurFilename);
1771   // Check to make sure the parser succeeded
1772   if (yyparse()) {
1773     if (ParserResult)
1774       delete ParserResult;
1775     std::cerr << "llvm-upgrade: parse failed.\n";
1776     return 0;
1777   }
1779   // Check to make sure that parsing produced a result
1780   if (!ParserResult) {
1781     std::cerr << "llvm-upgrade: no parse result.\n";
1782     return 0;
1783   }
1785   // Reset ParserResult variable while saving its value for the result.
1786   Module *Result = ParserResult;
1787   ParserResult = 0;
1789   //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1790   {
1791     Function* F;
1792     if ((F = Result->getFunction("llvm.va_start"))
1793         && F->getFunctionType()->getNumParams() == 0)
1794       ObsoleteVarArgs = true;
1795     if((F = Result->getFunction("llvm.va_copy"))
1796        && F->getFunctionType()->getNumParams() == 1)
1797       ObsoleteVarArgs = true;
1798   }
1800   if (ObsoleteVarArgs && NewVarArgs) {
1801     error("This file is corrupt: it uses both new and old style varargs");
1802     return 0;
1803   }
1805   if(ObsoleteVarArgs) {
1806     if(Function* F = Result->getFunction("llvm.va_start")) {
1807       if (F->arg_size() != 0) {
1808         error("Obsolete va_start takes 0 argument");
1809         return 0;
1810       }
1811       
1812       //foo = va_start()
1813       // ->
1814       //bar = alloca typeof(foo)
1815       //va_start(bar)
1816       //foo = load bar
1818       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1819       const Type* ArgTy = F->getFunctionType()->getReturnType();
1820       const Type* ArgTyPtr = PointerType::get(ArgTy);
1821       Function* NF = cast<Function>(Result->getOrInsertFunction(
1822         "llvm.va_start", RetTy, ArgTyPtr, (Type *)0));
1824       while (!F->use_empty()) {
1825         CallInst* CI = cast<CallInst>(F->use_back());
1826         AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1827         new CallInst(NF, bar, "", CI);
1828         Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1829         CI->replaceAllUsesWith(foo);
1830         CI->getParent()->getInstList().erase(CI);
1831       }
1832       Result->getFunctionList().erase(F);
1833     }
1834     
1835     if(Function* F = Result->getFunction("llvm.va_end")) {
1836       if(F->arg_size() != 1) {
1837         error("Obsolete va_end takes 1 argument");
1838         return 0;
1839       }
1841       //vaend foo
1842       // ->
1843       //bar = alloca 1 of typeof(foo)
1844       //vaend bar
1845       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1846       const Type* ArgTy = F->getFunctionType()->getParamType(0);
1847       const Type* ArgTyPtr = PointerType::get(ArgTy);
1848       Function* NF = cast<Function>(Result->getOrInsertFunction(
1849         "llvm.va_end", RetTy, ArgTyPtr, (Type *)0));
1851       while (!F->use_empty()) {
1852         CallInst* CI = cast<CallInst>(F->use_back());
1853         AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1854         new StoreInst(CI->getOperand(1), bar, CI);
1855         new CallInst(NF, bar, "", CI);
1856         CI->getParent()->getInstList().erase(CI);
1857       }
1858       Result->getFunctionList().erase(F);
1859     }
1861     if(Function* F = Result->getFunction("llvm.va_copy")) {
1862       if(F->arg_size() != 1) {
1863         error("Obsolete va_copy takes 1 argument");
1864         return 0;
1865       }
1866       //foo = vacopy(bar)
1867       // ->
1868       //a = alloca 1 of typeof(foo)
1869       //b = alloca 1 of typeof(foo)
1870       //store bar -> b
1871       //vacopy(a, b)
1872       //foo = load a
1873       
1874       const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1875       const Type* ArgTy = F->getFunctionType()->getReturnType();
1876       const Type* ArgTyPtr = PointerType::get(ArgTy);
1877       Function* NF = cast<Function>(Result->getOrInsertFunction(
1878         "llvm.va_copy", RetTy, ArgTyPtr, ArgTyPtr, (Type *)0));
1880       while (!F->use_empty()) {
1881         CallInst* CI = cast<CallInst>(F->use_back());
1882         Value *Args[2] = {
1883           new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI),
1884           new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI)         
1885         };
1886         new StoreInst(CI->getOperand(1), Args[1], CI);
1887         new CallInst(NF, Args, Args + 2, "", CI);
1888         Value* foo = new LoadInst(Args[0], "vacopy.fix.3", CI);
1889         CI->replaceAllUsesWith(foo);
1890         CI->getParent()->getInstList().erase(CI);
1891       }
1892       Result->getFunctionList().erase(F);
1893     }
1894   }
1896   return Result;
1899 } // end llvm namespace
1901 using namespace llvm;
1904 #line 1754 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
1905 typedef union {
1906   llvm::Module                           *ModuleVal;
1907   llvm::Function                         *FunctionVal;
1908   std::pair<llvm::PATypeInfo, char*>     *ArgVal;
1909   llvm::BasicBlock                       *BasicBlockVal;
1910   llvm::TermInstInfo                     TermInstVal;
1911   llvm::InstrInfo                        InstVal;
1912   llvm::ConstInfo                        ConstVal;
1913   llvm::ValueInfo                        ValueVal;
1914   llvm::PATypeInfo                       TypeVal;
1915   llvm::TypeInfo                         PrimType;
1916   llvm::PHIListInfo                      PHIList;
1917   std::list<llvm::PATypeInfo>            *TypeList;
1918   std::vector<llvm::ValueInfo>           *ValueList;
1919   std::vector<llvm::ConstInfo>           *ConstVector;
1922   std::vector<std::pair<llvm::PATypeInfo,char*> > *ArgList;
1923   // Represent the RHS of PHI node
1924   std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1926   llvm::GlobalValue::LinkageTypes         Linkage;
1927   int64_t                           SInt64Val;
1928   uint64_t                          UInt64Val;
1929   int                               SIntVal;
1930   unsigned                          UIntVal;
1931   llvm::APFloat                    *FPVal;
1932   bool                              BoolVal;
1934   char                             *StrVal;   // This memory is strdup'd!
1935   llvm::ValID                       ValIDVal; // strdup'd memory maybe!
1937   llvm::BinaryOps                   BinaryOpVal;
1938   llvm::TermOps                     TermOpVal;
1939   llvm::MemoryOps                   MemOpVal;
1940   llvm::OtherOps                    OtherOpVal;
1941   llvm::CastOps                     CastOpVal;
1942   llvm::ICmpInst::Predicate         IPred;
1943   llvm::FCmpInst::Predicate         FPred;
1944   llvm::Module::Endianness          Endianness;
1945 } YYSTYPE;
1946 #include <stdio.h>
1948 #ifndef __cplusplus
1949 #ifndef __STDC__
1950 #define const
1951 #endif
1952 #endif
1956 #define YYFINAL         606
1957 #define YYFLAG          -32768
1958 #define YYNTBASE        166
1960 #define YYTRANSLATE(x) ((unsigned)(x) <= 405 ? yytranslate[x] : 246)
1962 static const short yytranslate[] = {     0,
1963      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1964      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1965      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1966      2,     2,     2,     2,     2,     2,     2,     2,     2,   155,
1967    156,   164,     2,   153,     2,     2,     2,     2,     2,     2,
1968      2,     2,     2,     2,     2,     2,     2,     2,     2,   160,
1969    152,   161,     2,     2,     2,     2,     2,     2,     2,     2,
1970      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1971      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1972    157,   154,   159,     2,     2,     2,     2,     2,   165,     2,
1973      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1974      2,     2,     2,     2,     2,     2,     2,     2,     2,   158,
1975      2,     2,   162,     2,   163,     2,     2,     2,     2,     2,
1976      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1977      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1978      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1979      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1980      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1981      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1982      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1983      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1984      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1985      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1986      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1987      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
1988      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
1989      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
1990     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
1991     27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
1992     37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
1993     47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
1994     57,    58,    59,    60,    61,    62,    63,    64,    65,    66,
1995     67,    68,    69,    70,    71,    72,    73,    74,    75,    76,
1996     77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
1997     87,    88,    89,    90,    91,    92,    93,    94,    95,    96,
1998     97,    98,    99,   100,   101,   102,   103,   104,   105,   106,
1999    107,   108,   109,   110,   111,   112,   113,   114,   115,   116,
2000    117,   118,   119,   120,   121,   122,   123,   124,   125,   126,
2001    127,   128,   129,   130,   131,   132,   133,   134,   135,   136,
2002    137,   138,   139,   140,   141,   142,   143,   144,   145,   146,
2003    147,   148,   149,   150,   151
2006 #if YYDEBUG != 0
2007 static const short yyprhs[] = {     0,
2008      0,     2,     4,     6,     8,    10,    12,    14,    16,    18,
2009     20,    22,    24,    26,    28,    30,    32,    34,    36,    38,
2010     40,    42,    44,    46,    48,    50,    52,    54,    56,    58,
2011     60,    62,    64,    66,    68,    70,    72,    74,    76,    78,
2012     80,    82,    84,    86,    88,    90,    92,    94,    96,    98,
2013    100,   102,   104,   106,   108,   110,   112,   114,   116,   118,
2014    120,   122,   124,   126,   128,   130,   132,   134,   136,   138,
2015    140,   142,   144,   146,   148,   150,   152,   154,   156,   158,
2016    161,   162,   164,   166,   168,   170,   172,   174,   176,   177,
2017    178,   180,   182,   184,   186,   188,   190,   193,   194,   197,
2018    198,   202,   205,   206,   208,   209,   213,   215,   218,   220,
2019    222,   224,   226,   228,   230,   232,   234,   236,   238,   240,
2020    242,   244,   246,   248,   250,   252,   254,   256,   258,   261,
2021    266,   272,   278,   282,   285,   291,   296,   299,   301,   305,
2022    307,   311,   313,   314,   319,   323,   327,   332,   337,   341,
2023    348,   354,   357,   360,   363,   366,   369,   372,   375,   378,
2024    381,   384,   391,   397,   406,   413,   420,   427,   435,   443,
2025    450,   457,   466,   475,   479,   481,   483,   485,   487,   490,
2026    493,   498,   501,   503,   508,   511,   516,   517,   525,   526,
2027    534,   535,   543,   544,   552,   556,   561,   562,   564,   566,
2028    568,   572,   576,   580,   584,   588,   592,   594,   595,   597,
2029    599,   601,   602,   605,   609,   611,   613,   617,   619,   620,
2030    629,   631,   633,   634,   639,   641,   643,   646,   647,   649,
2031    651,   652,   653,   659,   660,   662,   664,   666,   668,   670,
2032    672,   674,   676,   678,   682,   684,   690,   692,   694,   696,
2033    698,   701,   704,   707,   711,   714,   715,   717,   719,   721,
2034    724,   727,   731,   741,   751,   760,   774,   776,   778,   785,
2035    791,   794,   801,   809,   811,   815,   817,   818,   821,   823,
2036    829,   835,   841,   848,   855,   858,   863,   868,   875,   880,
2037    885,   890,   895,   902,   909,   912,   920,   922,   925,   926,
2038    928,   929,   933,   940,   944,   951,   954,   959,   966
2041 static const short yyrhs[] = {     5,
2042      0,     6,     0,     3,     0,     4,     0,    79,     0,    80,
2043      0,    81,     0,    82,     0,    83,     0,    84,     0,    85,
2044      0,    86,     0,    87,     0,    88,     0,    89,     0,    90,
2045      0,    91,     0,    92,     0,    97,     0,    98,     0,    99,
2046      0,   100,     0,   101,     0,   102,     0,   119,     0,   120,
2047      0,   121,     0,   122,     0,   123,     0,   124,     0,   125,
2048      0,   126,     0,   127,     0,   128,     0,   129,     0,   130,
2049      0,   131,     0,   132,     0,   133,     0,   134,     0,   135,
2050      0,   136,     0,   137,     0,   138,     0,   125,     0,   126,
2051      0,   127,     0,   128,     0,    27,     0,    28,     0,    93,
2052      0,    94,     0,    95,     0,    96,     0,   140,     0,   141,
2053      0,   142,     0,   143,     0,   144,     0,   145,     0,   146,
2054      0,   147,     0,   148,     0,   149,     0,   150,     0,   151,
2055      0,   139,     0,    16,     0,    14,     0,    12,     0,    10,
2056      0,    17,     0,    15,     0,    13,     0,    11,     0,   175,
2057      0,   176,     0,    18,     0,    19,     0,   211,   152,     0,
2058      0,    41,     0,    42,     0,    43,     0,    44,     0,    45,
2059      0,    46,     0,    47,     0,     0,     0,    65,     0,    66,
2060      0,    67,     0,    68,     0,    69,     0,    70,     0,    64,
2061      4,     0,     0,    57,     4,     0,     0,   153,    57,     4,
2062      0,    34,    24,     0,     0,   184,     0,     0,   153,   187,
2063    186,     0,   184,     0,    57,     4,     0,   190,     0,     8,
2064      0,   192,     0,     8,     0,   192,     0,     9,     0,    10,
2065      0,    11,     0,    12,     0,    13,     0,    14,     0,    15,
2066      0,    16,     0,    17,     0,    18,     0,    19,     0,    21,
2067      0,   191,     0,    48,     0,   228,     0,   154,     4,     0,
2068    189,   155,   194,   156,     0,   157,     4,   158,   192,   159,
2069      0,   160,     4,   158,   192,   161,     0,   162,   193,   163,
2070      0,   162,   163,     0,   160,   162,   193,   163,   161,     0,
2071    160,   162,   163,   161,     0,   192,   164,     0,   192,     0,
2072    193,   153,   192,     0,   193,     0,   193,   153,    37,     0,
2073     37,     0,     0,   190,   157,   197,   159,     0,   190,   157,
2074    159,     0,   190,   165,    24,     0,   190,   160,   197,   161,
2075      0,   190,   162,   197,   163,     0,   190,   162,   163,     0,
2076    190,   160,   162,   197,   163,   161,     0,   190,   160,   162,
2077    163,   161,     0,   190,    38,     0,   190,    39,     0,   190,
2078    228,     0,   190,   196,     0,   190,    26,     0,   175,   167,
2079      0,   176,     4,     0,     9,    27,     0,     9,    28,     0,
2080    178,     7,     0,   174,   155,   195,    36,   190,   156,     0,
2081    110,   155,   195,   243,   156,     0,   112,   155,   195,   153,
2082    195,   153,   195,   156,     0,   168,   155,   195,   153,   195,
2083    156,     0,   169,   155,   195,   153,   195,   156,     0,   170,
2084    155,   195,   153,   195,   156,     0,   103,   171,   155,   195,
2085    153,   195,   156,     0,   104,   172,   155,   195,   153,   195,
2086    156,     0,   173,   155,   195,   153,   195,   156,     0,   114,
2087    155,   195,   153,   195,   156,     0,   115,   155,   195,   153,
2088    195,   153,   195,   156,     0,   116,   155,   195,   153,   195,
2089    153,   195,   156,     0,   197,   153,   195,     0,   195,     0,
2090     32,     0,    33,     0,   200,     0,   200,   221,     0,   200,
2091    223,     0,   200,    62,    61,   206,     0,   200,    25,     0,
2092    201,     0,   201,   179,    20,   188,     0,   201,   223,     0,
2093    201,    62,    61,   206,     0,     0,   201,   179,   180,   198,
2094    195,   202,   186,     0,     0,   201,   179,    50,   198,   190,
2095    203,   186,     0,     0,   201,   179,    45,   198,   190,   204,
2096    186,     0,     0,   201,   179,    47,   198,   190,   205,   186,
2097      0,   201,    51,   208,     0,   201,    58,   152,   209,     0,
2098      0,    24,     0,    56,     0,    55,     0,    53,   152,   207,
2099      0,    54,   152,     4,     0,    52,   152,    24,     0,    71,
2100    152,    24,     0,   157,   210,   159,     0,   210,   153,    24,
2101      0,    24,     0,     0,    22,     0,    24,     0,   211,     0,
2102      0,   190,   212,     0,   214,   153,   213,     0,   213,     0,
2103    214,     0,   214,   153,    37,     0,    37,     0,     0,   181,
2104    188,   211,   155,   215,   156,   185,   182,     0,    29,     0,
2105    162,     0,     0,   180,   219,   216,   217,     0,    30,     0,
2106    163,     0,   231,   220,     0,     0,    45,     0,    47,     0,
2107      0,     0,    31,   224,   222,   225,   216,     0,     0,    63,
2108      0,     3,     0,     4,     0,     7,     0,    27,     0,    28,
2109      0,    38,     0,    39,     0,    26,     0,   160,   197,   161,
2110      0,   196,     0,    61,   226,    24,   153,    24,     0,   166,
2111      0,   211,     0,   228,     0,   227,     0,   190,   229,     0,
2112    231,   232,     0,   218,   232,     0,   233,   179,   235,     0,
2113    233,   237,     0,     0,    23,     0,    77,     0,    78,     0,
2114     72,   230,     0,    72,     8,     0,    73,    21,   229,     0,
2115     73,     9,   229,   153,    21,   229,   153,    21,   229,     0,
2116     74,   177,   229,   153,    21,   229,   157,   236,   159,     0,
2117     74,   177,   229,   153,    21,   229,   157,   159,     0,    75,
2118    181,   188,   229,   155,   240,   156,    36,    21,   229,   234,
2119     21,   229,     0,   234,     0,    76,     0,   236,   177,   227,
2120    153,    21,   229,     0,   177,   227,   153,    21,   229,     0,
2121    179,   242,     0,   190,   157,   229,   153,   229,   159,     0,
2122    238,   153,   157,   229,   153,   229,   159,     0,   230,     0,
2123    239,   153,   230,     0,   239,     0,     0,    60,    59,     0,
2124     59,     0,   168,   190,   229,   153,   229,     0,   169,   190,
2125    229,   153,   229,     0,   170,   190,   229,   153,   229,     0,
2126    103,   171,   190,   229,   153,   229,     0,   104,   172,   190,
2127    229,   153,   229,     0,    49,   230,     0,   173,   230,   153,
2128    230,     0,   174,   230,    36,   190,     0,   112,   230,   153,
2129    230,   153,   230,     0,   113,   230,   153,   190,     0,   117,
2130    230,   153,   190,     0,   118,   230,   153,   190,     0,   114,
2131    230,   153,   230,     0,   115,   230,   153,   230,   153,   230,
2132      0,   116,   230,   153,   230,   153,   230,     0,   111,   238,
2133      0,   241,   181,   188,   229,   155,   240,   156,     0,   245,
2134      0,   153,   239,     0,     0,    35,     0,     0,   105,   190,
2135    183,     0,   105,   190,   153,    15,   229,   183,     0,   106,
2136    190,   183,     0,   106,   190,   153,    15,   229,   183,     0,
2137    107,   230,     0,   244,   108,   190,   229,     0,   244,   109,
2138    230,   153,   190,   229,     0,   110,   190,   229,   243,     0
2141 #endif
2143 #if YYDEBUG != 0
2144 static const short yyrline[] = { 0,
2145   1894,  1895,  1903,  1904,  1914,  1914,  1914,  1914,  1914,  1914,
2146   1914,  1914,  1914,  1914,  1914,  1918,  1918,  1918,  1922,  1922,
2147   1922,  1922,  1922,  1922,  1926,  1926,  1927,  1927,  1928,  1928,
2148   1929,  1929,  1930,  1930,  1934,  1934,  1935,  1935,  1936,  1936,
2149   1937,  1937,  1938,  1938,  1939,  1939,  1940,  1940,  1941,  1942,
2150   1945,  1945,  1945,  1945,  1949,  1949,  1949,  1949,  1949,  1949,
2151   1949,  1950,  1950,  1950,  1950,  1950,  1950,  1956,  1956,  1956,
2152   1956,  1960,  1960,  1960,  1960,  1964,  1964,  1968,  1968,  1973,
2153   1976,  1981,  1982,  1983,  1984,  1985,  1986,  1987,  1988,  1992,
2154   1993,  1994,  1995,  1996,  1997,  1998,  1999,  2009,  2010,  2018,
2155   2019,  2027,  2036,  2037,  2044,  2045,  2049,  2053,  2069,  2070,
2156   2077,  2078,  2085,  2093,  2093,  2093,  2093,  2093,  2093,  2093,
2157   2094,  2094,  2094,  2094,  2094,  2099,  2103,  2107,  2112,  2121,
2158   2148,  2154,  2167,  2178,  2182,  2195,  2199,  2213,  2217,  2224,
2159   2225,  2231,  2238,  2250,  2280,  2293,  2316,  2344,  2366,  2377,
2160   2399,  2410,  2419,  2424,  2483,  2490,  2498,  2505,  2512,  2516,
2161   2520,  2534,  2549,  2561,  2570,  2598,  2611,  2620,  2626,  2632,
2162   2643,  2649,  2655,  2666,  2667,  2676,  2677,  2689,  2698,  2699,
2163   2700,  2701,  2702,  2718,  2738,  2740,  2742,  2746,  2749,  2754,
2164   2757,  2762,  2765,  2771,  2774,  2776,  2778,  2783,  2797,  2798,
2165   2802,  2805,  2813,  2817,  2824,  2828,  2832,  2836,  2844,  2844,
2166   2848,  2849,  2853,  2861,  2866,  2874,  2875,  2882,  2889,  2893,
2167   3083,  3083,  3087,  3087,  3097,  3097,  3101,  3106,  3107,  3108,
2168   3112,  3113,  3113,  3125,  3126,  3131,  3132,  3133,  3134,  3138,
2169   3142,  3143,  3144,  3145,  3166,  3170,  3184,  3185,  3190,  3190,
2170   3198,  3208,  3211,  3220,  3231,  3236,  3245,  3256,  3256,  3259,
2171   3263,  3267,  3272,  3282,  3300,  3309,  3383,  3387,  3394,  3406,
2172   3421,  3451,  3461,  3471,  3475,  3482,  3483,  3487,  3490,  3496,
2173   3515,  3533,  3549,  3563,  3577,  3588,  3606,  3615,  3624,  3631,
2174   3652,  3676,  3682,  3688,  3694,  3710,  3803,  3811,  3812,  3816,
2175   3817,  3821,  3827,  3834,  3840,  3847,  3854,  3867,  3893
2177 #endif
2180 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
2182 static const char * const yytname[] = {   "$","error","$undefined.","ESINT64VAL",
2183 "EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
2184 "USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
2185 "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
2186 "BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
2187 "DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
2188 "DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE",
2189 "ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK",
2190 "MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK","COLDCC_TOK",
2191 "X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE",
2192 "UNREACHABLE","UNWIND","EXCEPT","ADD","SUB","MUL","DIV","UDIV","SDIV","FDIV",
2193 "REM","UREM","SREM","FREM","AND","OR","XOR","SHL","SHR","ASHR","LSHR","SETLE",
2194 "SETGE","SETLT","SETGT","SETEQ","SETNE","ICMP","FCMP","MALLOC","ALLOCA","FREE",
2195 "LOAD","STORE","GETELEMENTPTR","PHI_TOK","SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT",
2196 "SHUFFLEVECTOR","VAARG_old","VANEXT_old","EQ","NE","SLT","SGT","SLE","SGE","ULT",
2197 "UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO","UEQ","UNE",
2198 "CAST","TRUNC","ZEXT","SEXT","FPTRUNC","FPEXT","FPTOUI","FPTOSI","UITOFP","SITOFP",
2199 "PTRTOINT","INTTOPTR","BITCAST","'='","','","'\\\\'","'('","')'","'['","'x'",
2200 "']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps",
2201 "LogicalOps","SetCondOps","IPredicates","FPredicates","ShiftOps","CastOps","SIntType",
2202 "UIntType","IntType","FPType","OptAssign","OptLinkage","OptCallingConv","OptAlign",
2203 "OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute",
2204 "TypesV","UpRTypesV","Types","PrimType","UpRTypes","TypeListI","ArgTypeListI",
2205 "ConstVal","ConstExpr","ConstVector","GlobalType","Module","FunctionList","ConstPool",
2206 "@1","@2","@3","@4","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition",
2207 "LibList","Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN",
2208 "FunctionHeader","@5","END","Function","FnDeclareLinkage","FunctionProto","@6",
2209 "@7","OptSideEffect","ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal",
2210 "BasicBlockList","BasicBlock","InstructionList","Unwind","BBTerminatorInst",
2211 "JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","OptTailCall","InstVal",
2212 "IndexList","OptVolatile","MemoryInst", NULL
2214 #endif
2216 static const short yyr1[] = {     0,
2217    166,   166,   167,   167,   168,   168,   168,   168,   168,   168,
2218    168,   168,   168,   168,   168,   169,   169,   169,   170,   170,
2219    170,   170,   170,   170,   171,   171,   171,   171,   171,   171,
2220    171,   171,   171,   171,   172,   172,   172,   172,   172,   172,
2221    172,   172,   172,   172,   172,   172,   172,   172,   172,   172,
2222    173,   173,   173,   173,   174,   174,   174,   174,   174,   174,
2223    174,   174,   174,   174,   174,   174,   174,   175,   175,   175,
2224    175,   176,   176,   176,   176,   177,   177,   178,   178,   179,
2225    179,   180,   180,   180,   180,   180,   180,   180,   180,   181,
2226    181,   181,   181,   181,   181,   181,   181,   182,   182,   183,
2227    183,   184,   185,   185,   186,   186,   187,   187,   188,   188,
2228    189,   189,   190,   191,   191,   191,   191,   191,   191,   191,
2229    191,   191,   191,   191,   191,   192,   192,   192,   192,   192,
2230    192,   192,   192,   192,   192,   192,   192,   193,   193,   194,
2231    194,   194,   194,   195,   195,   195,   195,   195,   195,   195,
2232    195,   195,   195,   195,   195,   195,   195,   195,   195,   195,
2233    195,   196,   196,   196,   196,   196,   196,   196,   196,   196,
2234    196,   196,   196,   197,   197,   198,   198,   199,   200,   200,
2235    200,   200,   200,   201,   201,   201,   202,   201,   203,   201,
2236    204,   201,   205,   201,   201,   201,   201,   206,   207,   207,
2237    208,   208,   208,   208,   209,   210,   210,   210,   211,   211,
2238    212,   212,   213,   214,   214,   215,   215,   215,   215,   216,
2239    217,   217,   219,   218,   220,   220,   221,   222,   222,   222,
2240    224,   225,   223,   226,   226,   227,   227,   227,   227,   227,
2241    227,   227,   227,   227,   227,   227,   228,   228,   229,   229,
2242    230,   231,   231,   232,   233,   233,   233,   234,   234,   235,
2243    235,   235,   235,   235,   235,   235,   235,   235,   236,   236,
2244    237,   238,   238,   239,   239,   240,   240,   241,   241,   242,
2245    242,   242,   242,   242,   242,   242,   242,   242,   242,   242,
2246    242,   242,   242,   242,   242,   242,   242,   243,   243,   244,
2247    244,   245,   245,   245,   245,   245,   245,   245,   245
2250 static const short yyr2[] = {     0,
2251      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2252      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2253      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2254      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2255      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2256      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2257      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2258      1,     1,     1,     1,     1,     1,     1,     1,     1,     2,
2259      0,     1,     1,     1,     1,     1,     1,     1,     0,     0,
2260      1,     1,     1,     1,     1,     1,     2,     0,     2,     0,
2261      3,     2,     0,     1,     0,     3,     1,     2,     1,     1,
2262      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2263      1,     1,     1,     1,     1,     1,     1,     1,     2,     4,
2264      5,     5,     3,     2,     5,     4,     2,     1,     3,     1,
2265      3,     1,     0,     4,     3,     3,     4,     4,     3,     6,
2266      5,     2,     2,     2,     2,     2,     2,     2,     2,     2,
2267      2,     6,     5,     8,     6,     6,     6,     7,     7,     6,
2268      6,     8,     8,     3,     1,     1,     1,     1,     2,     2,
2269      4,     2,     1,     4,     2,     4,     0,     7,     0,     7,
2270      0,     7,     0,     7,     3,     4,     0,     1,     1,     1,
2271      3,     3,     3,     3,     3,     3,     1,     0,     1,     1,
2272      1,     0,     2,     3,     1,     1,     3,     1,     0,     8,
2273      1,     1,     0,     4,     1,     1,     2,     0,     1,     1,
2274      0,     0,     5,     0,     1,     1,     1,     1,     1,     1,
2275      1,     1,     1,     3,     1,     5,     1,     1,     1,     1,
2276      2,     2,     2,     3,     2,     0,     1,     1,     1,     2,
2277      2,     3,     9,     9,     8,    13,     1,     1,     6,     5,
2278      2,     6,     7,     1,     3,     1,     0,     2,     1,     5,
2279      5,     5,     6,     6,     2,     4,     4,     6,     4,     4,
2280      4,     4,     6,     6,     2,     7,     1,     2,     0,     1,
2281      0,     3,     6,     3,     6,     2,     4,     6,     4
2284 static const short yydefact[] = {   197,
2285     89,   183,   182,   231,    82,    83,    84,    85,    86,    87,
2286     88,     0,   223,   256,   179,   180,   256,   209,   210,     0,
2287      0,     0,    89,     0,   185,   228,     0,    90,   257,   253,
2288     81,   225,   226,   227,   252,     0,     0,     0,     0,   195,
2289      0,     0,     0,     0,     0,     0,     0,    80,   229,   230,
2290    232,   198,   181,     0,    91,    92,    93,    94,    95,    96,
2291      0,     0,   301,   255,     0,     0,     0,     0,   208,   196,
2292    186,     1,     2,   110,   114,   115,   116,   117,   118,   119,
2293    120,   121,   122,   123,   124,   125,   127,     0,     0,     0,
2294      0,   247,   184,     0,   109,   126,   113,   248,   128,   176,
2295    177,     0,     0,     0,     0,    90,    97,     0,   221,   222,
2296    224,   300,     0,   279,     0,     0,     0,     0,    90,   268,
2297    258,   259,     5,     6,     7,     8,     9,    10,    11,    12,
2298     13,    14,    15,    16,    17,    18,    51,    52,    53,    54,
2299     19,    20,    21,    22,    23,    24,     0,     0,     0,     0,
2300      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2301     67,    55,    56,    57,    58,    59,    60,    61,    62,    63,
2302     64,    65,    66,     0,     0,     0,     0,     0,   267,   254,
2303     90,   271,     0,   297,   203,   200,   199,   201,   202,   204,
2304    207,     0,   129,     0,     0,     0,   112,   134,   138,     0,
2305    143,   137,   191,   193,   189,   114,   115,   116,   117,   118,
2306    119,   120,   121,   122,   123,   124,     0,     0,     0,     0,
2307    187,   233,     0,     0,   285,   278,   261,   260,     0,     0,
2308     71,    75,    70,    74,    69,    73,    68,    72,    76,    77,
2309      0,     0,    25,    26,    27,    28,    29,    30,    31,    32,
2310     33,    34,     0,    49,    50,    45,    46,    47,    48,    35,
2311     36,    37,    38,    39,    40,    41,    42,    43,    44,     0,
2312    100,   100,   306,     0,     0,   295,     0,     0,     0,     0,
2313      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2314      0,     0,   205,     0,     0,     0,     0,     0,   133,   142,
2315    140,     0,   105,   105,   105,   159,   160,     3,     4,   157,
2316    158,   161,   156,   152,   153,     0,     0,     0,     0,     0,
2317      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2318      0,   155,   154,   105,   219,   236,   237,   238,   243,   239,
2319    240,   241,   242,   234,     0,   245,   250,   249,   251,     0,
2320    262,     0,     0,     0,     0,     0,   302,     0,   304,   299,
2321      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2322      0,     0,     0,     0,     0,     0,     0,   206,   111,   111,
2323    136,     0,   139,     0,   130,     0,   192,   194,   190,     0,
2324      0,     0,     0,     0,     0,     0,   145,   175,     0,     0,
2325      0,   149,     0,   146,     0,     0,     0,     0,     0,   188,
2326    218,   212,   215,   216,     0,   235,     0,     0,     0,     0,
2327      0,     0,     0,     0,     0,     0,     0,   309,     0,     0,
2328      0,   289,   292,     0,     0,   290,   291,     0,     0,     0,
2329    286,   287,     0,   307,     0,   131,   132,   135,   141,     0,
2330      0,   107,   105,     0,     0,   299,     0,     0,     0,     0,
2331      0,   144,   134,   113,     0,   147,   148,     0,     0,     0,
2332      0,     0,   211,   213,     0,   103,     0,   244,     0,     0,
2333    277,     0,     0,   100,   101,   100,   274,   298,     0,     0,
2334      0,     0,     0,   280,   281,   282,   277,     0,   102,   108,
2335    106,     0,     0,     0,     0,     0,     0,     0,   174,   151,
2336      0,     0,     0,     0,     0,     0,   217,   214,   104,    98,
2337      0,     0,     0,   276,     0,   283,   284,     0,   303,   305,
2338      0,     0,     0,   288,   293,   294,     0,   308,     0,     0,
2339    163,     0,     0,     0,     0,   150,     0,     0,     0,     0,
2340      0,     0,   220,   246,     0,     0,     0,   275,   272,     0,
2341    296,     0,     0,     0,   171,     0,     0,   165,   166,   167,
2342    170,   162,    99,     0,   265,     0,     0,     0,   273,   168,
2343    169,     0,     0,     0,   263,     0,   264,     0,     0,   164,
2344    172,   173,     0,     0,     0,     0,     0,     0,   270,     0,
2345      0,   269,   266,     0,     0,     0
2348 static const short yydefgoto[] = {    92,
2349    310,   327,   328,   329,   253,   270,   330,   331,   217,   218,
2350    241,   219,    23,    13,    61,   553,   357,   452,   520,   387,
2351    453,    93,    94,   220,    96,    97,   200,   302,   398,   346,
2352    399,   102,   604,     1,     2,   334,   305,   303,   304,    53,
2353    188,    40,    70,   192,    98,   474,   413,   414,   415,    62,
2354    111,    14,    28,    34,    15,    51,    16,    26,   106,   417,
2355    347,    99,   349,   487,    17,    30,    31,   179,   180,   577,
2356     64,   276,   524,   525,   181,   182,   428,   183,   184
2359 static const short yypact[] = {-32768,
2360    239,   567,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
2361 -32768,   -46,-32768,    55,-32768,-32768,   -14,-32768,-32768,    48,
2362     -6,   104,   161,    19,-32768,   -34,   155,   249,-32768,-32768,
2363     98,-32768,-32768,-32768,-32768,    33,    43,    49,    57,-32768,
2364     59,   155,  1265,   150,   150,   150,   150,-32768,-32768,-32768,
2365 -32768,-32768,-32768,   214,-32768,-32768,-32768,-32768,-32768,-32768,
2366   1265,   -19,  1479,-32768,   196,   157,   224,   206,   212,-32768,
2367 -32768,-32768,-32768,    87,-32768,-32768,-32768,-32768,-32768,-32768,
2368 -32768,-32768,-32768,-32768,-32768,-32768,-32768,   241,   247,     4,
2369     15,-32768,-32768,   108,-32768,-32768,    12,-32768,-32768,-32768,
2370 -32768,  1306,  1306,  1306,  1326,   249,-32768,    98,-32768,-32768,
2371 -32768,-32768,  1306,-32768,   194,  1367,   116,   177,   249,-32768,
2372 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
2373 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
2374 -32768,-32768,-32768,-32768,-32768,-32768,   355,   429,  1306,  1306,
2375   1306,  1306,  1306,  1306,  1306,  1306,  1306,  1306,  1306,  1306,
2376 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
2377 -32768,-32768,-32768,  1306,  1306,  1306,  1306,  1306,-32768,-32768,
2378    249,-32768,   106,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
2379 -32768,   -32,-32768,   103,   110,    75,-32768,-32768,    12,   -81,
2380   1046,-32768,-32768,-32768,-32768,   197,   230,   265,   237,   267,
2381    240,   268,   246,   270,   269,   271,   254,   273,   272,   566,
2382 -32768,-32768,   120,   766,-32768,-32768,    87,-32768,   766,   766,
2383 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
2384    766,  1265,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
2385 -32768,-32768,  1306,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
2386 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,  1306,
2387    136,   137,-32768,   766,   134,   146,   147,   149,   152,   158,
2388    174,   176,   179,   766,   766,   766,   180,   262,  1265,  1306,
2389   1306,   279,-32768,  1306,  1306,   173,   -27,  1306,-32768,-32768,
2390    184,   183,   187,   187,   187,-32768,-32768,-32768,-32768,-32768,
2391 -32768,-32768,-32768,-32768,-32768,   355,   429,   186,   188,   189,
2392    190,   191,  1087,  1387,   529,   311,   192,   193,   198,   199,
2393    202,-32768,-32768,   187,  1107,-32768,-32768,-32768,-32768,-32768,
2394 -32768,-32768,-32768,   286,  1326,-32768,-32768,-32768,-32768,   205,
2395 -32768,   207,   766,   766,   766,     7,-32768,    20,-32768,   208,
2396    766,   209,  1306,  1306,  1306,  1306,  1306,  1306,  1306,   210,
2397    216,   217,  1306,  1306,   766,   766,   218,-32768,   -12,     9,
2398 -32768,   204,    12,  1148,-32768,     8,-32768,-32768,-32768,   220,
2399    221,  1326,  1326,  1326,  1326,  1326,-32768,-32768,    -8,   741,
2400    -82,-32768,    -9,-32768,  1326,  1326,  1326,  1326,  1326,-32768,
2401 -32768,    98,-32768,   219,   203,-32768,   343,   -13,   356,   357,
2402    228,   226,   233,   766,   383,   766,  1306,-32768,   235,   766,
2403    236,-32768,-32768,   243,   244,-32768,-32768,   766,   766,   766,
2404 -32768,-32768,   238,-32768,  1306,-32768,-32768,-32768,-32768,   366,
2405    394,-32768,   187,  1326,  1326,   208,   250,   251,   252,   258,
2406   1326,-32768,   256,   -25,    11,-32768,-32768,   259,   266,   274,
2407    278,   363,-32768,-32768,  1205,   387,   280,-32768,   766,   766,
2408   1306,   766,   766,   281,-32768,   281,-32768,   282,   766,   283,
2409   1306,  1306,  1306,-32768,-32768,-32768,  1306,   766,-32768,-32768,
2410 -32768,   284,   290,   288,  1326,  1326,  1326,  1326,-32768,-32768,
2411    263,  1326,  1326,  1326,  1326,  1306,-32768,-32768,-32768,   368,
2412    376,   293,   294,   282,   291,-32768,-32768,   369,-32768,-32768,
2413   1306,   264,   766,-32768,-32768,-32768,   296,-32768,  1326,  1326,
2414 -32768,   300,   299,   305,   306,-32768,   308,   310,   313,   314,
2415    315,   457,-32768,-32768,   441,    41,   436,-32768,-32768,   325,
2416 -32768,   329,   331,  1326,-32768,  1326,  1326,-32768,-32768,-32768,
2417 -32768,-32768,-32768,   766,-32768,   893,   145,   468,-32768,-32768,
2418 -32768,   334,   335,   336,-32768,   340,-32768,   893,   766,-32768,
2419 -32768,-32768,   473,   342,   182,   766,   475,   479,-32768,   766,
2420    766,-32768,-32768,   502,   503,-32768
2423 static const short yypgoto[] = {-32768,
2424 -32768,   443,   444,   446,   195,   200,   447,   451,  -117,  -114,
2425   -539,-32768,   484,   481,  -105,-32768,  -265,    40,-32768,  -236,
2426 -32768,   -58,-32768,   -43,-32768,   -72,   -33,-32768,   -99,   298,
2427   -250,    58,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   480,
2428 -32768,-32768,-32768,-32768,    10,-32768,    46,-32768,-32768,   417,
2429 -32768,-32768,-32768,-32768,-32768,-32768,   522,-32768,-32768,-32768,
2430   -526,   144,   -88,  -111,-32768,   508,-32768,   -69,-32768,-32768,
2431 -32768,-32768,   100,    31,-32768,-32768,    73,-32768,-32768
2435 #define YYLAST          1630
2438 static const short yytable[] = {    95,
2439    239,   225,   108,   240,   228,   221,   359,   195,    29,   109,
2440     49,    24,    50,   242,    27,    32,   576,    95,   199,    72,
2441     73,   424,   197,    75,    76,    77,    78,    79,    80,    81,
2442     82,    83,    84,    85,   426,    86,    18,   588,    19,   273,
2443     24,   450,   277,   278,   279,   280,   281,   282,   283,   586,
2444    231,   232,   233,   234,   235,   236,   237,   238,   203,   204,
2445    205,   594,    87,   425,   451,   287,   288,   388,   389,   224,
2446    461,   298,   224,   401,   403,   289,   425,    29,   466,    72,
2447     73,   299,   197,    75,    76,    77,    78,    79,    80,    81,
2448     82,    83,    84,    85,   418,    86,    18,   410,    19,    36,
2449     37,    38,   103,   104,   105,   271,   272,   224,   274,   275,
2450    224,   224,   224,   224,   224,   224,   224,   223,    39,    18,
2451    292,    19,    87,   199,   229,   298,   293,  -138,   199,  -111,
2452    284,   285,   286,   224,   224,   382,   230,  -138,   202,   461,
2453    350,   351,   110,   461,   461,    41,   446,   478,    33,   465,
2454    462,   202,   352,   467,   231,   232,   233,   234,   235,   236,
2455    237,   238,   297,   461,    42,   196,  -111,   301,    88,   447,
2456     48,    89,   202,   511,    90,   202,    91,   198,    52,   377,
2457     43,   100,   101,   353,    65,   360,   231,   232,   233,   234,
2458    235,   236,   237,   238,    66,   370,   371,   372,    95,   575,
2459     67,     5,     6,     7,     8,    44,    10,    45,    68,   354,
2460     46,   186,   187,   290,   291,    69,   501,   107,   529,   185,
2461    530,   379,   380,   306,   307,   383,   355,   189,    88,   190,
2462    375,    89,   -71,   -71,    90,   191,    91,   296,  -178,   -70,
2463    -70,  -112,   -69,   -69,   193,    95,   376,   224,   -68,   -68,
2464    194,   431,   226,   433,   434,   435,   308,   309,   121,   122,
2465    294,   441,   201,     3,   421,   422,   423,   295,   -75,     4,
2466    -74,   -73,   429,   -72,   335,   -78,   311,   -79,   312,     5,
2467      6,     7,     8,     9,    10,    11,   443,   444,   356,   358,
2468    361,   412,   456,   457,   458,   459,   460,   374,   362,   363,
2469     12,   364,   378,   587,   365,   468,   469,   470,   471,   472,
2470    366,   383,    54,    55,    56,    57,    58,    59,    60,   224,
2471    432,   224,   224,   224,   436,   437,   367,   464,   368,   224,
2472    442,   369,   373,   381,   404,   484,   384,   486,   385,   386,
2473    392,   490,   393,   394,   395,   396,   405,   406,   416,   494,
2474    495,   496,   407,   408,   502,   503,   409,   419,   476,   420,
2475    427,   509,   438,   333,   448,   430,   477,   348,   439,   440,
2476    445,   475,   348,   348,   454,   455,   479,   480,   482,   534,
2477    535,   536,   481,   224,   348,   483,   485,   489,   491,   499,
2478    522,   523,   497,   526,   527,   492,   493,   500,   516,   554,
2479    532,   498,   505,   506,   507,   542,   543,   544,   545,   538,
2480    508,   512,   547,   548,   549,   550,   510,   348,   513,   558,
2481    450,   473,   559,   546,   552,   425,   514,   348,   348,   348,
2482    515,   412,   521,   528,   531,   533,   539,   224,   239,   562,
2483    563,   240,   540,   541,   560,   555,   557,   224,   224,   224,
2484    556,   561,   564,   224,   565,   254,   255,   566,   567,   239,
2485    573,   574,   240,   568,   582,   569,   583,   584,   570,   571,
2486    572,   578,   551,   243,   244,   245,   246,   247,   248,   249,
2487    250,   251,   252,   579,   580,   585,   581,   224,   589,   590,
2488    591,   592,   593,   596,   597,   600,   348,   348,   348,   601,
2489    595,   605,   606,    47,   348,   174,   175,   599,   176,   177,
2490    390,   602,   603,   178,    63,   519,   391,   332,   348,   348,
2491    518,    71,   222,    25,    35,   598,   488,   537,   504,     0,
2492      0,     0,     0,    72,    73,     0,   197,   206,   207,   208,
2493    209,   210,   211,   212,   213,   214,   215,   216,     0,    86,
2494     18,     0,    19,   256,   257,   258,   259,   260,   261,   262,
2495    263,   264,   265,   266,   267,   268,   269,   348,     0,   348,
2496     72,    73,     0,   348,     0,     0,    87,     0,     0,     0,
2497      0,   348,   348,   348,     0,     0,   -81,    18,    18,    19,
2498     19,   313,     0,     0,     0,     0,     0,     4,   -81,   -81,
2499      0,     0,     0,   314,   315,     0,     0,   -81,   -81,   -81,
2500    -81,   -81,   -81,   -81,     0,     0,   -81,    20,     0,     0,
2501      0,     0,   348,   348,    21,   348,   348,     0,    22,     0,
2502      0,     0,   348,     0,     0,     0,     0,     0,     0,     0,
2503      0,   348,     0,     0,   123,   124,   125,   126,   127,   128,
2504    129,   130,   131,   132,   133,   134,   135,   136,   137,   138,
2505    139,   140,   141,   142,   143,   144,   145,   146,   316,   317,
2506      0,     0,     0,     0,     0,   318,   348,   319,     0,   320,
2507    321,   322,    88,     0,     0,    89,     0,     0,    90,     0,
2508     91,   402,     0,     0,     0,     0,     0,     0,     0,     0,
2509      0,     0,     0,     0,   161,   162,   163,   164,   165,   166,
2510    167,   168,   169,   170,   171,   172,   173,   348,     0,     0,
2511      0,     0,   323,     0,     0,   324,     0,   325,     0,     0,
2512    326,     0,   348,     0,     0,     0,     0,     0,     0,   348,
2513      0,     0,     0,   348,   348,    72,    73,     0,   197,   206,
2514    207,   208,   209,   210,   211,   212,   213,   214,   215,   216,
2515      0,    86,    18,     0,    19,     0,     0,     0,   336,   337,
2516     72,    73,   338,     0,     0,     0,     0,     0,     0,     0,
2517      0,     0,     0,     0,     0,     0,     0,    18,    87,    19,
2518      0,   339,   340,   341,     0,     0,     0,     0,     0,     0,
2519      0,     0,     0,   342,   343,     0,     0,     0,     0,     0,
2520      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2521      0,     0,     0,     0,     0,     0,   344,     0,     0,     0,
2522      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2523      0,     0,     0,     0,   123,   124,   125,   126,   127,   128,
2524    129,   130,   131,   132,   133,   134,   135,   136,   137,   138,
2525    139,   140,   141,   142,   143,   144,   145,   146,   316,   317,
2526      0,     0,     0,     0,     0,   318,     0,   319,     0,   320,
2527    321,   322,     0,     0,     0,     0,     0,     0,     0,     0,
2528      0,     0,     0,     0,    88,   336,   337,    89,     0,   338,
2529     90,     0,    91,   463,   161,   162,   163,   164,   165,   166,
2530    167,   168,   169,   170,   171,   172,   173,     0,   339,   340,
2531    341,     0,     0,     0,     0,   345,     0,     0,     0,     0,
2532    342,   343,     0,     0,     0,     0,     0,     0,     0,     0,
2533      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2534      0,     0,     0,   344,     0,     0,     0,     0,     0,     0,
2535      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2536      0,   123,   124,   125,   126,   127,   128,   129,   130,   131,
2537    132,   133,   134,   135,   136,   137,   138,   139,   140,   141,
2538    142,   143,   144,   145,   146,   316,   317,     0,     0,     0,
2539      0,     0,   318,     0,   319,     0,   320,   321,   322,     0,
2540      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2541      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2542      0,   161,   162,   163,   164,   165,   166,   167,   168,   169,
2543    170,   171,   172,   173,     0,     0,     0,     0,     0,     0,
2544     72,    73,   345,   197,    75,    76,    77,    78,    79,    80,
2545     81,    82,    83,    84,    85,     0,    86,    18,     0,    19,
2546      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2547      0,     0,   300,     0,     0,     0,     0,     0,     0,     0,
2548      0,    72,    73,    87,   197,   206,   207,   208,   209,   210,
2549    211,   212,   213,   214,   215,   216,     0,    86,    18,     0,
2550     19,    72,    73,     0,   197,    75,    76,    77,    78,    79,
2551     80,    81,    82,    83,    84,    85,     0,    86,    18,     0,
2552     19,     0,     0,     0,    87,     0,     0,     0,     0,     0,
2553      0,     0,     0,   411,     0,     0,     0,     0,     0,     0,
2554      0,     0,    72,    73,    87,   197,    75,    76,    77,    78,
2555     79,    80,    81,    82,    83,    84,    85,     0,    86,    18,
2556      0,    19,     0,     0,     0,     0,     0,     0,     0,     0,
2557      0,     0,     0,     0,   449,     0,     0,     0,     0,     0,
2558      0,     0,     0,     0,     0,    87,     0,     0,     0,    88,
2559      0,     0,    89,     0,     0,    90,     0,    91,     0,    72,
2560     73,     0,   197,    75,    76,    77,    78,    79,    80,    81,
2561     82,    83,    84,    85,     0,    86,    18,     0,    19,     0,
2562      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2563     88,   517,     0,    89,     0,   397,    90,     0,    91,     0,
2564      0,     0,    87,     0,     0,     0,     0,     0,     0,     0,
2565     88,     0,     0,    89,     0,     0,    90,     0,    91,    72,
2566     73,     0,    74,    75,    76,    77,    78,    79,    80,    81,
2567     82,    83,    84,    85,     0,    86,    18,     0,    19,     0,
2568      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2569      0,    88,     0,     0,    89,     0,     0,    90,     0,    91,
2570     72,    73,    87,   197,    75,    76,    77,    78,    79,    80,
2571     81,    82,    83,    84,    85,     0,    86,    18,     0,    19,
2572     72,    73,     0,   197,   206,   207,   208,   209,   210,   211,
2573    212,   213,   214,   215,   216,     0,    86,    18,     0,    19,
2574      0,     0,     0,    87,     0,     0,     0,     0,    88,     0,
2575      0,    89,     0,     0,    90,     0,    91,     0,     0,     0,
2576      0,    72,    73,    87,   227,    75,    76,    77,    78,    79,
2577     80,    81,    82,    83,    84,    85,     0,    86,    18,     0,
2578     19,    72,    73,     0,   197,   206,   207,   208,   209,   210,
2579    211,   212,   213,   214,   215,   216,     0,    86,    18,     0,
2580     19,     0,     0,     0,    87,     0,     0,     0,    88,     0,
2581      0,    89,     0,     0,    90,     0,    91,     0,     0,     0,
2582      0,     0,     0,     0,    87,     0,     0,     0,     0,     0,
2583      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2584      0,     0,     0,     0,     0,     0,     0,     0,     0,    88,
2585      0,     0,    89,     0,     0,    90,     0,    91,     0,     0,
2586      0,     0,     0,     0,     0,     0,     0,     0,     0,    88,
2587      0,     0,    89,     0,     0,    90,     0,    91,     0,     0,
2588      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2589      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2590      0,     0,     0,   112,     0,     0,     0,     0,     0,     0,
2591     88,     0,     0,    89,     0,     0,    90,   113,    91,     0,
2592      0,     0,     0,     0,     0,     0,     0,   114,   115,     0,
2593     88,     0,     0,    89,     0,     0,    90,     0,   400,     0,
2594    116,   117,   118,   119,   120,   121,   122,   123,   124,   125,
2595    126,   127,   128,   129,   130,   131,   132,   133,   134,   135,
2596    136,   137,   138,   139,   140,   141,   142,   143,   144,   145,
2597    146,   147,   148,   149,   150,   151,     0,     0,   152,   153,
2598    154,   155,   156,   157,   158,   159,   160,     0,     0,     0,
2599      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
2600      0,     0,     0,     0,     0,     0,     0,   161,   162,   163,
2601    164,   165,   166,   167,   168,   169,   170,   171,   172,   173
2604 static const short yycheck[] = {    43,
2605    118,   113,    61,   118,   116,   105,   272,     4,    23,    29,
2606     45,     2,    47,   119,    61,    30,   556,    61,    91,     5,
2607      6,    15,     8,     9,    10,    11,    12,    13,    14,    15,
2608     16,    17,    18,    19,    15,    21,    22,   577,    24,   151,
2609     31,    34,   154,   155,   156,   157,   158,   159,   160,   576,
2610     10,    11,    12,    13,    14,    15,    16,    17,   102,   103,
2611    104,   588,    48,    57,    57,   177,   178,   304,   305,   113,
2612    153,   153,   116,   324,   325,   181,    57,    23,   161,     5,
2613      6,   163,     8,     9,    10,    11,    12,    13,    14,    15,
2614     16,    17,    18,    19,   345,    21,    22,   334,    24,    52,
2615     53,    54,    45,    46,    47,   149,   150,   151,   152,   153,
2616    154,   155,   156,   157,   158,   159,   160,   108,    71,    22,
2617    153,    24,    48,   196,     9,   153,   159,   153,   201,   155,
2618    174,   175,   176,   177,   178,   163,    21,   163,   164,   153,
2619    229,   230,   162,   153,   153,   152,   159,   161,   163,   400,
2620    159,   164,   241,   163,    10,    11,    12,    13,    14,    15,
2621     16,    17,   196,   153,    61,   162,   155,   201,   154,   161,
2622    152,   157,   164,   163,   160,   164,   162,   163,    24,   291,
2623     20,    32,    33,   242,   152,   274,    10,    11,    12,    13,
2624     14,    15,    16,    17,   152,   284,   285,   286,   242,   159,
2625    152,    41,    42,    43,    44,    45,    46,    47,   152,   253,
2626     50,    55,    56,   108,   109,   157,   453,     4,   484,    24,
2627    486,   294,   295,    27,    28,   298,   270,     4,   154,    24,
2628    289,   157,     3,     4,   160,    24,   162,   163,     0,     3,
2629      4,   155,     3,     4,     4,   289,   290,   291,     3,     4,
2630      4,   363,    59,   365,   366,   367,     3,     4,    77,    78,
2631    158,   373,   155,    25,   353,   354,   355,   158,     4,    31,
2632      4,     4,   361,     4,   155,     7,     4,     7,     7,    41,
2633     42,    43,    44,    45,    46,    47,   375,   376,   153,   153,
2634    157,   335,   392,   393,   394,   395,   396,    36,   153,   153,
2635     62,   153,    24,   159,   153,   405,   406,   407,   408,   409,
2636    153,   384,    64,    65,    66,    67,    68,    69,    70,   363,
2637    364,   365,   366,   367,   368,   369,   153,   400,   153,   373,
2638    374,   153,   153,   161,    24,   424,   153,   426,   156,   153,
2639    155,   430,   155,   155,   155,   155,   155,   155,    63,   438,
2640    439,   440,   155,   155,   454,   455,   155,   153,   156,   153,
2641    153,   461,   153,   220,   161,   157,    24,   224,   153,   153,
2642    153,   153,   229,   230,   155,   155,    21,    21,   153,   491,
2643    492,   493,   155,   427,   241,   153,     4,   153,   153,    24,
2644    479,   480,   155,   482,   483,   153,   153,     4,    36,    24,
2645    489,   445,   153,   153,   153,   505,   506,   507,   508,   498,
2646    153,   153,   512,   513,   514,   515,   161,   274,   153,   531,
2647     34,   412,   159,   161,    57,    57,   153,   284,   285,   286,
2648    153,   475,   153,   153,   153,   153,   153,   481,   556,   539,
2649    540,   556,   153,   156,   533,   153,   156,   491,   492,   493,
2650    157,   156,   153,   497,   156,    27,    28,   153,   153,   577,
2651      4,    21,   577,   156,   564,   156,   566,   567,   156,   156,
2652    156,    36,   516,   119,   120,   121,   122,   123,   124,   125,
2653    126,   127,   128,   159,   156,   574,   156,   531,    21,   156,
2654    156,   156,   153,    21,   153,    21,   353,   354,   355,    21,
2655    589,     0,     0,    23,   361,    63,    63,   596,    63,    63,
2656    316,   600,   601,    63,    31,   476,   317,   220,   375,   376,
2657    475,    42,   106,     2,    17,   595,   427,   497,   456,    -1,
2658     -1,    -1,    -1,     5,     6,    -1,     8,     9,    10,    11,
2659     12,    13,    14,    15,    16,    17,    18,    19,    -1,    21,
2660     22,    -1,    24,   125,   126,   127,   128,   129,   130,   131,
2661    132,   133,   134,   135,   136,   137,   138,   424,    -1,   426,
2662      5,     6,    -1,   430,    -1,    -1,    48,    -1,    -1,    -1,
2663     -1,   438,   439,   440,    -1,    -1,    20,    22,    22,    24,
2664     24,    26,    -1,    -1,    -1,    -1,    -1,    31,    32,    33,
2665     -1,    -1,    -1,    38,    39,    -1,    -1,    41,    42,    43,
2666     44,    45,    46,    47,    -1,    -1,    50,    51,    -1,    -1,
2667     -1,    -1,   479,   480,    58,   482,   483,    -1,    62,    -1,
2668     -1,    -1,   489,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2669     -1,   498,    -1,    -1,    79,    80,    81,    82,    83,    84,
2670     85,    86,    87,    88,    89,    90,    91,    92,    93,    94,
2671     95,    96,    97,    98,    99,   100,   101,   102,   103,   104,
2672     -1,    -1,    -1,    -1,    -1,   110,   533,   112,    -1,   114,
2673    115,   116,   154,    -1,    -1,   157,    -1,    -1,   160,    -1,
2674    162,   163,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2675     -1,    -1,    -1,    -1,   139,   140,   141,   142,   143,   144,
2676    145,   146,   147,   148,   149,   150,   151,   574,    -1,    -1,
2677     -1,    -1,   157,    -1,    -1,   160,    -1,   162,    -1,    -1,
2678    165,    -1,   589,    -1,    -1,    -1,    -1,    -1,    -1,   596,
2679     -1,    -1,    -1,   600,   601,     5,     6,    -1,     8,     9,
2680     10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
2681     -1,    21,    22,    -1,    24,    -1,    -1,    -1,     3,     4,
2682      5,     6,     7,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2683     -1,    -1,    -1,    -1,    -1,    -1,    -1,    22,    48,    24,
2684     -1,    26,    27,    28,    -1,    -1,    -1,    -1,    -1,    -1,
2685     -1,    -1,    -1,    38,    39,    -1,    -1,    -1,    -1,    -1,
2686     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2687     -1,    -1,    -1,    -1,    -1,    -1,    61,    -1,    -1,    -1,
2688     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2689     -1,    -1,    -1,    -1,    79,    80,    81,    82,    83,    84,
2690     85,    86,    87,    88,    89,    90,    91,    92,    93,    94,
2691     95,    96,    97,    98,    99,   100,   101,   102,   103,   104,
2692     -1,    -1,    -1,    -1,    -1,   110,    -1,   112,    -1,   114,
2693    115,   116,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2694     -1,    -1,    -1,    -1,   154,     3,     4,   157,    -1,     7,
2695    160,    -1,   162,   163,   139,   140,   141,   142,   143,   144,
2696    145,   146,   147,   148,   149,   150,   151,    -1,    26,    27,
2697     28,    -1,    -1,    -1,    -1,   160,    -1,    -1,    -1,    -1,
2698     38,    39,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2699     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2700     -1,    -1,    -1,    61,    -1,    -1,    -1,    -1,    -1,    -1,
2701     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2702     -1,    79,    80,    81,    82,    83,    84,    85,    86,    87,
2703     88,    89,    90,    91,    92,    93,    94,    95,    96,    97,
2704     98,    99,   100,   101,   102,   103,   104,    -1,    -1,    -1,
2705     -1,    -1,   110,    -1,   112,    -1,   114,   115,   116,    -1,
2706     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2707     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2708     -1,   139,   140,   141,   142,   143,   144,   145,   146,   147,
2709    148,   149,   150,   151,    -1,    -1,    -1,    -1,    -1,    -1,
2710      5,     6,   160,     8,     9,    10,    11,    12,    13,    14,
2711     15,    16,    17,    18,    19,    -1,    21,    22,    -1,    24,
2712     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2713     -1,    -1,    37,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2714     -1,     5,     6,    48,     8,     9,    10,    11,    12,    13,
2715     14,    15,    16,    17,    18,    19,    -1,    21,    22,    -1,
2716     24,     5,     6,    -1,     8,     9,    10,    11,    12,    13,
2717     14,    15,    16,    17,    18,    19,    -1,    21,    22,    -1,
2718     24,    -1,    -1,    -1,    48,    -1,    -1,    -1,    -1,    -1,
2719     -1,    -1,    -1,    37,    -1,    -1,    -1,    -1,    -1,    -1,
2720     -1,    -1,     5,     6,    48,     8,     9,    10,    11,    12,
2721     13,    14,    15,    16,    17,    18,    19,    -1,    21,    22,
2722     -1,    24,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2723     -1,    -1,    -1,    -1,    37,    -1,    -1,    -1,    -1,    -1,
2724     -1,    -1,    -1,    -1,    -1,    48,    -1,    -1,    -1,   154,
2725     -1,    -1,   157,    -1,    -1,   160,    -1,   162,    -1,     5,
2726      6,    -1,     8,     9,    10,    11,    12,    13,    14,    15,
2727     16,    17,    18,    19,    -1,    21,    22,    -1,    24,    -1,
2728     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2729    154,    37,    -1,   157,    -1,   159,   160,    -1,   162,    -1,
2730     -1,    -1,    48,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2731    154,    -1,    -1,   157,    -1,    -1,   160,    -1,   162,     5,
2732      6,    -1,     8,     9,    10,    11,    12,    13,    14,    15,
2733     16,    17,    18,    19,    -1,    21,    22,    -1,    24,    -1,
2734     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2735     -1,   154,    -1,    -1,   157,    -1,    -1,   160,    -1,   162,
2736      5,     6,    48,     8,     9,    10,    11,    12,    13,    14,
2737     15,    16,    17,    18,    19,    -1,    21,    22,    -1,    24,
2738      5,     6,    -1,     8,     9,    10,    11,    12,    13,    14,
2739     15,    16,    17,    18,    19,    -1,    21,    22,    -1,    24,
2740     -1,    -1,    -1,    48,    -1,    -1,    -1,    -1,   154,    -1,
2741     -1,   157,    -1,    -1,   160,    -1,   162,    -1,    -1,    -1,
2742     -1,     5,     6,    48,     8,     9,    10,    11,    12,    13,
2743     14,    15,    16,    17,    18,    19,    -1,    21,    22,    -1,
2744     24,     5,     6,    -1,     8,     9,    10,    11,    12,    13,
2745     14,    15,    16,    17,    18,    19,    -1,    21,    22,    -1,
2746     24,    -1,    -1,    -1,    48,    -1,    -1,    -1,   154,    -1,
2747     -1,   157,    -1,    -1,   160,    -1,   162,    -1,    -1,    -1,
2748     -1,    -1,    -1,    -1,    48,    -1,    -1,    -1,    -1,    -1,
2749     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2750     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   154,
2751     -1,    -1,   157,    -1,    -1,   160,    -1,   162,    -1,    -1,
2752     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   154,
2753     -1,    -1,   157,    -1,    -1,   160,    -1,   162,    -1,    -1,
2754     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2755     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2756     -1,    -1,    -1,    35,    -1,    -1,    -1,    -1,    -1,    -1,
2757    154,    -1,    -1,   157,    -1,    -1,   160,    49,   162,    -1,
2758     -1,    -1,    -1,    -1,    -1,    -1,    -1,    59,    60,    -1,
2759    154,    -1,    -1,   157,    -1,    -1,   160,    -1,   162,    -1,
2760     72,    73,    74,    75,    76,    77,    78,    79,    80,    81,
2761     82,    83,    84,    85,    86,    87,    88,    89,    90,    91,
2762     92,    93,    94,    95,    96,    97,    98,    99,   100,   101,
2763    102,   103,   104,   105,   106,   107,    -1,    -1,   110,   111,
2764    112,   113,   114,   115,   116,   117,   118,    -1,    -1,    -1,
2765     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2766     -1,    -1,    -1,    -1,    -1,    -1,    -1,   139,   140,   141,
2767    142,   143,   144,   145,   146,   147,   148,   149,   150,   151
2769 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
2770 #line 3 "/usr/share/bison.simple"
2771 /* This file comes from bison-1.28.  */
2773 /* Skeleton output parser for bison,
2774    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2776    This program is free software; you can redistribute it and/or modify
2777    it under the terms of the GNU General Public License as published by
2778    the Free Software Foundation; either version 2, or (at your option)
2779    any later version.
2781    This program is distributed in the hope that it will be useful,
2782    but WITHOUT ANY WARRANTY; without even the implied warranty of
2783    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2784    GNU General Public License for more details.
2786    You should have received a copy of the GNU General Public License
2787    along with this program; if not, write to the Free Software
2788    Foundation, Inc., 59 Temple Place - Suite 330,
2789    Boston, MA 02111-1307, USA.  */
2791 /* As a special exception, when this file is copied by Bison into a
2792    Bison output file, you may use that output file without restriction.
2793    This special exception was added by the Free Software Foundation
2794    in version 1.24 of Bison.  */
2796 /* This is the parser code that is written into each bison parser
2797   when the %semantic_parser declaration is not specified in the grammar.
2798   It was written by Richard Stallman by simplifying the hairy parser
2799   used when %semantic_parser is specified.  */
2801 #ifndef YYSTACK_USE_ALLOCA
2802 #ifdef alloca
2803 #define YYSTACK_USE_ALLOCA
2804 #else /* alloca not defined */
2805 #ifdef __GNUC__
2806 #define YYSTACK_USE_ALLOCA
2807 #define alloca __builtin_alloca
2808 #else /* not GNU C.  */
2809 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2810 #define YYSTACK_USE_ALLOCA
2811 #include <alloca.h>
2812 #else /* not sparc */
2813 /* We think this test detects Watcom and Microsoft C.  */
2814 /* This used to test MSDOS, but that is a bad idea
2815    since that symbol is in the user namespace.  */
2816 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2817 #if 0 /* No need for malloc.h, which pollutes the namespace;
2818          instead, just don't use alloca.  */
2819 #include <malloc.h>
2820 #endif
2821 #else /* not MSDOS, or __TURBOC__ */
2822 #if defined(_AIX)
2823 /* I don't know what this was needed for, but it pollutes the namespace.
2824    So I turned it off.   rms, 2 May 1997.  */
2825 /* #include <malloc.h>  */
2826  #pragma alloca
2827 #define YYSTACK_USE_ALLOCA
2828 #else /* not MSDOS, or __TURBOC__, or _AIX */
2829 #if 0
2830 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2831                  and on HPUX 10.  Eventually we can turn this on.  */
2832 #define YYSTACK_USE_ALLOCA
2833 #define alloca __builtin_alloca
2834 #endif /* __hpux */
2835 #endif
2836 #endif /* not _AIX */
2837 #endif /* not MSDOS, or __TURBOC__ */
2838 #endif /* not sparc */
2839 #endif /* not GNU C */
2840 #endif /* alloca not defined */
2841 #endif /* YYSTACK_USE_ALLOCA not defined */
2843 #ifdef YYSTACK_USE_ALLOCA
2844 #define YYSTACK_ALLOC alloca
2845 #else
2846 #define YYSTACK_ALLOC malloc
2847 #endif
2849 /* Note: there must be only one dollar sign in this file.
2850    It is replaced by the list of actions, each action
2851    as one case of the switch.  */
2853 #define yyerrok         (yyerrstatus = 0)
2854 #define yyclearin       (yychar = YYEMPTY)
2855 #define YYEMPTY         -2
2856 #define YYEOF           0
2857 #define YYACCEPT        goto yyacceptlab
2858 #define YYABORT         goto yyabortlab
2859 #define YYERROR         goto yyerrlab1
2860 /* Like YYERROR except do call yyerror.
2861    This remains here temporarily to ease the
2862    transition to the new meaning of YYERROR, for GCC.
2863    Once GCC version 2 has supplanted version 1, this can go.  */
2864 #define YYFAIL          goto yyerrlab
2865 #define YYRECOVERING()  (!!yyerrstatus)
2866 #define YYBACKUP(token, value) \
2867 do                                                              \
2868   if (yychar == YYEMPTY && yylen == 1)                          \
2869     { yychar = (token), yylval = (value);                       \
2870       yychar1 = YYTRANSLATE (yychar);                           \
2871       YYPOPSTACK;                                               \
2872       goto yybackup;                                            \
2873     }                                                           \
2874   else                                                          \
2875     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
2876 while (0)
2878 #define YYTERROR        1
2879 #define YYERRCODE       256
2881 #ifndef YYPURE
2882 #define YYLEX           yylex()
2883 #endif
2885 #ifdef YYPURE
2886 #ifdef YYLSP_NEEDED
2887 #ifdef YYLEX_PARAM
2888 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
2889 #else
2890 #define YYLEX           yylex(&yylval, &yylloc)
2891 #endif
2892 #else /* not YYLSP_NEEDED */
2893 #ifdef YYLEX_PARAM
2894 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
2895 #else
2896 #define YYLEX           yylex(&yylval)
2897 #endif
2898 #endif /* not YYLSP_NEEDED */
2899 #endif
2901 /* If nonreentrant, generate the variables here */
2903 #ifndef YYPURE
2905 int     yychar;                 /*  the lookahead symbol                */
2906 YYSTYPE yylval;                 /*  the semantic value of the           */
2907                                 /*  lookahead symbol                    */
2909 #ifdef YYLSP_NEEDED
2910 YYLTYPE yylloc;                 /*  location data for the lookahead     */
2911                                 /*  symbol                              */
2912 #endif
2914 int yynerrs;                    /*  number of parse errors so far       */
2915 #endif  /* not YYPURE */
2917 #if YYDEBUG != 0
2918 int yydebug;                    /*  nonzero means print parse trace     */
2919 /* Since this is uninitialized, it does not stop multiple parsers
2920    from coexisting.  */
2921 #endif
2923 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
2925 #ifndef YYINITDEPTH
2926 #define YYINITDEPTH 200
2927 #endif
2929 /*  YYMAXDEPTH is the maximum size the stacks can grow to
2930     (effective only if the built-in stack extension method is used).  */
2932 #if YYMAXDEPTH == 0
2933 #undef YYMAXDEPTH
2934 #endif
2936 #ifndef YYMAXDEPTH
2937 #define YYMAXDEPTH 10000
2938 #endif
2940 /* Define __yy_memcpy.  Note that the size argument
2941    should be passed with type unsigned int, because that is what the non-GCC
2942    definitions require.  With GCC, __builtin_memcpy takes an arg
2943    of type size_t, but it can handle unsigned int.  */
2945 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
2946 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
2947 #else                           /* not GNU C or C++ */
2948 #ifndef __cplusplus
2950 /* This is the most reliable way to avoid incompatibilities
2951    in available built-in functions on various systems.  */
2952 static void
2953 __yy_memcpy (to, from, count)
2954      char *to;
2955      char *from;
2956      unsigned int count;
2958   register char *f = from;
2959   register char *t = to;
2960   register int i = count;
2962   while (i-- > 0)
2963     *t++ = *f++;
2966 #else /* __cplusplus */
2968 /* This is the most reliable way to avoid incompatibilities
2969    in available built-in functions on various systems.  */
2970 static void
2971 __yy_memcpy (char *to, char *from, unsigned int count)
2973   register char *t = to;
2974   register char *f = from;
2975   register int i = count;
2977   while (i-- > 0)
2978     *t++ = *f++;
2981 #endif
2982 #endif
2984 #line 217 "/usr/share/bison.simple"
2986 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2987    into yyparse.  The argument should have type void *.
2988    It should actually point to an object.
2989    Grammar actions can access the variable by casting it
2990    to the proper pointer type.  */
2992 #ifdef YYPARSE_PARAM
2993 #ifdef __cplusplus
2994 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2995 #define YYPARSE_PARAM_DECL
2996 #else /* not __cplusplus */
2997 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2998 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2999 #endif /* not __cplusplus */
3000 #else /* not YYPARSE_PARAM */
3001 #define YYPARSE_PARAM_ARG
3002 #define YYPARSE_PARAM_DECL
3003 #endif /* not YYPARSE_PARAM */
3005 /* Prevent warning if -Wstrict-prototypes.  */
3006 #ifdef __GNUC__
3007 #ifdef YYPARSE_PARAM
3008 int yyparse (void *);
3009 #else
3010 int yyparse (void);
3011 #endif
3012 #endif
3015 yyparse(YYPARSE_PARAM_ARG)
3016      YYPARSE_PARAM_DECL
3018   register int yystate;
3019   register int yyn;
3020   register short *yyssp;
3021   register YYSTYPE *yyvsp;
3022   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
3023   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
3025   short yyssa[YYINITDEPTH];     /*  the state stack                     */
3026   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
3028   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
3029   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
3031 #ifdef YYLSP_NEEDED
3032   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
3033   YYLTYPE *yyls = yylsa;
3034   YYLTYPE *yylsp;
3036 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
3037 #else
3038 #define YYPOPSTACK   (yyvsp--, yyssp--)
3039 #endif
3041   int yystacksize = YYINITDEPTH;
3042   int yyfree_stacks = 0;
3044 #ifdef YYPURE
3045   int yychar;
3046   YYSTYPE yylval;
3047   int yynerrs;
3048 #ifdef YYLSP_NEEDED
3049   YYLTYPE yylloc;
3050 #endif
3051 #endif
3053   YYSTYPE yyval;                /*  the variable used to return         */
3054                                 /*  semantic values from the action     */
3055                                 /*  routines                            */
3057   int yylen;
3059 #if YYDEBUG != 0
3060   if (yydebug)
3061     fprintf(stderr, "Starting parse\n");
3062 #endif
3064   yystate = 0;
3065   yyerrstatus = 0;
3066   yynerrs = 0;
3067   yychar = YYEMPTY;             /* Cause a token to be read.  */
3069   /* Initialize stack pointers.
3070      Waste one element of value and location stack
3071      so that they stay on the same level as the state stack.
3072      The wasted elements are never initialized.  */
3074   yyssp = yyss - 1;
3075   yyvsp = yyvs;
3076 #ifdef YYLSP_NEEDED
3077   yylsp = yyls;
3078 #endif
3080 /* Push a new state, which is found in  yystate  .  */
3081 /* In all cases, when you get here, the value and location stacks
3082    have just been pushed. so pushing a state here evens the stacks.  */
3083 yynewstate:
3085   *++yyssp = yystate;
3087   if (yyssp >= yyss + yystacksize - 1)
3088     {
3089       /* Give user a chance to reallocate the stack */
3090       /* Use copies of these so that the &'s don't force the real ones into memory. */
3091       YYSTYPE *yyvs1 = yyvs;
3092       short *yyss1 = yyss;
3093 #ifdef YYLSP_NEEDED
3094       YYLTYPE *yyls1 = yyls;
3095 #endif
3097       /* Get the current used size of the three stacks, in elements.  */
3098       int size = yyssp - yyss + 1;
3100 #ifdef yyoverflow
3101       /* Each stack pointer address is followed by the size of
3102          the data in use in that stack, in bytes.  */
3103 #ifdef YYLSP_NEEDED
3104       /* This used to be a conditional around just the two extra args,
3105          but that might be undefined if yyoverflow is a macro.  */
3106       yyoverflow("parser stack overflow",
3107                  &yyss1, size * sizeof (*yyssp),
3108                  &yyvs1, size * sizeof (*yyvsp),
3109                  &yyls1, size * sizeof (*yylsp),
3110                  &yystacksize);
3111 #else
3112       yyoverflow("parser stack overflow",
3113                  &yyss1, size * sizeof (*yyssp),
3114                  &yyvs1, size * sizeof (*yyvsp),
3115                  &yystacksize);
3116 #endif
3118       yyss = yyss1; yyvs = yyvs1;
3119 #ifdef YYLSP_NEEDED
3120       yyls = yyls1;
3121 #endif
3122 #else /* no yyoverflow */
3123       /* Extend the stack our own way.  */
3124       if (yystacksize >= YYMAXDEPTH)
3125         {
3126           yyerror("parser stack overflow");
3127           if (yyfree_stacks)
3128             {
3129               free (yyss);
3130               free (yyvs);
3131 #ifdef YYLSP_NEEDED
3132               free (yyls);
3133 #endif
3134             }
3135           return 2;
3136         }
3137       yystacksize *= 2;
3138       if (yystacksize > YYMAXDEPTH)
3139         yystacksize = YYMAXDEPTH;
3140 #ifndef YYSTACK_USE_ALLOCA
3141       yyfree_stacks = 1;
3142 #endif
3143       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
3144       __yy_memcpy ((char *)yyss, (char *)yyss1,
3145                    size * (unsigned int) sizeof (*yyssp));
3146       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
3147       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
3148                    size * (unsigned int) sizeof (*yyvsp));
3149 #ifdef YYLSP_NEEDED
3150       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
3151       __yy_memcpy ((char *)yyls, (char *)yyls1,
3152                    size * (unsigned int) sizeof (*yylsp));
3153 #endif
3154 #endif /* no yyoverflow */
3156       yyssp = yyss + size - 1;
3157       yyvsp = yyvs + size - 1;
3158 #ifdef YYLSP_NEEDED
3159       yylsp = yyls + size - 1;
3160 #endif
3162 #if YYDEBUG != 0
3163       if (yydebug)
3164         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
3165 #endif
3167       if (yyssp >= yyss + yystacksize - 1)
3168         YYABORT;
3169     }
3171 #if YYDEBUG != 0
3172   if (yydebug)
3173     fprintf(stderr, "Entering state %d\n", yystate);
3174 #endif
3176   goto yybackup;
3177  yybackup:
3179 /* Do appropriate processing given the current state.  */
3180 /* Read a lookahead token if we need one and don't already have one.  */
3181 /* yyresume: */
3183   /* First try to decide what to do without reference to lookahead token.  */
3185   yyn = yypact[yystate];
3186   if (yyn == YYFLAG)
3187     goto yydefault;
3189   /* Not known => get a lookahead token if don't already have one.  */
3191   /* yychar is either YYEMPTY or YYEOF
3192      or a valid token in external form.  */
3194   if (yychar == YYEMPTY)
3195     {
3196 #if YYDEBUG != 0
3197       if (yydebug)
3198         fprintf(stderr, "Reading a token: ");
3199 #endif
3200       yychar = YYLEX;
3201     }
3203   /* Convert token to internal form (in yychar1) for indexing tables with */
3205   if (yychar <= 0)              /* This means end of input. */
3206     {
3207       yychar1 = 0;
3208       yychar = YYEOF;           /* Don't call YYLEX any more */
3210 #if YYDEBUG != 0
3211       if (yydebug)
3212         fprintf(stderr, "Now at end of input.\n");
3213 #endif
3214     }
3215   else
3216     {
3217       yychar1 = YYTRANSLATE(yychar);
3219 #if YYDEBUG != 0
3220       if (yydebug)
3221         {
3222           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
3223           /* Give the individual parser a way to print the precise meaning
3224              of a token, for further debugging info.  */
3225 #ifdef YYPRINT
3226           YYPRINT (stderr, yychar, yylval);
3227 #endif
3228           fprintf (stderr, ")\n");
3229         }
3230 #endif
3231     }
3233   yyn += yychar1;
3234   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
3235     goto yydefault;
3237   yyn = yytable[yyn];
3239   /* yyn is what to do for this token type in this state.
3240      Negative => reduce, -yyn is rule number.
3241      Positive => shift, yyn is new state.
3242        New state is final state => don't bother to shift,
3243        just return success.
3244      0, or most negative number => error.  */
3246   if (yyn < 0)
3247     {
3248       if (yyn == YYFLAG)
3249         goto yyerrlab;
3250       yyn = -yyn;
3251       goto yyreduce;
3252     }
3253   else if (yyn == 0)
3254     goto yyerrlab;
3256   if (yyn == YYFINAL)
3257     YYACCEPT;
3259   /* Shift the lookahead token.  */
3261 #if YYDEBUG != 0
3262   if (yydebug)
3263     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
3264 #endif
3266   /* Discard the token being shifted unless it is eof.  */
3267   if (yychar != YYEOF)
3268     yychar = YYEMPTY;
3270   *++yyvsp = yylval;
3271 #ifdef YYLSP_NEEDED
3272   *++yylsp = yylloc;
3273 #endif
3275   /* count tokens shifted since error; after three, turn off error status.  */
3276   if (yyerrstatus) yyerrstatus--;
3278   yystate = yyn;
3279   goto yynewstate;
3281 /* Do the default action for the current state.  */
3282 yydefault:
3284   yyn = yydefact[yystate];
3285   if (yyn == 0)
3286     goto yyerrlab;
3288 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
3289 yyreduce:
3290   yylen = yyr2[yyn];
3291   if (yylen > 0)
3292     yyval = yyvsp[1-yylen]; /* implement default value of the action */
3294 #if YYDEBUG != 0
3295   if (yydebug)
3296     {
3297       int i;
3299       fprintf (stderr, "Reducing via rule %d (line %d), ",
3300                yyn, yyrline[yyn]);
3302       /* Print the symbols being reduced, and their result.  */
3303       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
3304         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
3305       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
3306     }
3307 #endif
3310   switch (yyn) {
3312 case 2:
3313 #line 1895 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3315     if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX)     // Outside of my range!
3316       error("Value too large for type");
3317     yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
3318   ;
3319     break;}
3320 case 4:
3321 #line 1904 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3323     if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX)     // Outside of my range!
3324       error("Value too large for type");
3325     yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
3326   ;
3327     break;}
3328 case 25:
3329 #line 1926 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3330 { yyval.IPred = ICmpInst::ICMP_EQ; ;
3331     break;}
3332 case 26:
3333 #line 1926 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3334 { yyval.IPred = ICmpInst::ICMP_NE; ;
3335     break;}
3336 case 27:
3337 #line 1927 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3338 { yyval.IPred = ICmpInst::ICMP_SLT; ;
3339     break;}
3340 case 28:
3341 #line 1927 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3342 { yyval.IPred = ICmpInst::ICMP_SGT; ;
3343     break;}
3344 case 29:
3345 #line 1928 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3346 { yyval.IPred = ICmpInst::ICMP_SLE; ;
3347     break;}
3348 case 30:
3349 #line 1928 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3350 { yyval.IPred = ICmpInst::ICMP_SGE; ;
3351     break;}
3352 case 31:
3353 #line 1929 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3354 { yyval.IPred = ICmpInst::ICMP_ULT; ;
3355     break;}
3356 case 32:
3357 #line 1929 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3358 { yyval.IPred = ICmpInst::ICMP_UGT; ;
3359     break;}
3360 case 33:
3361 #line 1930 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3362 { yyval.IPred = ICmpInst::ICMP_ULE; ;
3363     break;}
3364 case 34:
3365 #line 1930 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3366 { yyval.IPred = ICmpInst::ICMP_UGE; ;
3367     break;}
3368 case 35:
3369 #line 1934 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3370 { yyval.FPred = FCmpInst::FCMP_OEQ; ;
3371     break;}
3372 case 36:
3373 #line 1934 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3374 { yyval.FPred = FCmpInst::FCMP_ONE; ;
3375     break;}
3376 case 37:
3377 #line 1935 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3378 { yyval.FPred = FCmpInst::FCMP_OLT; ;
3379     break;}
3380 case 38:
3381 #line 1935 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3382 { yyval.FPred = FCmpInst::FCMP_OGT; ;
3383     break;}
3384 case 39:
3385 #line 1936 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3386 { yyval.FPred = FCmpInst::FCMP_OLE; ;
3387     break;}
3388 case 40:
3389 #line 1936 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3390 { yyval.FPred = FCmpInst::FCMP_OGE; ;
3391     break;}
3392 case 41:
3393 #line 1937 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3394 { yyval.FPred = FCmpInst::FCMP_ORD; ;
3395     break;}
3396 case 42:
3397 #line 1937 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3398 { yyval.FPred = FCmpInst::FCMP_UNO; ;
3399     break;}
3400 case 43:
3401 #line 1938 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3402 { yyval.FPred = FCmpInst::FCMP_UEQ; ;
3403     break;}
3404 case 44:
3405 #line 1938 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3406 { yyval.FPred = FCmpInst::FCMP_UNE; ;
3407     break;}
3408 case 45:
3409 #line 1939 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3410 { yyval.FPred = FCmpInst::FCMP_ULT; ;
3411     break;}
3412 case 46:
3413 #line 1939 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3414 { yyval.FPred = FCmpInst::FCMP_UGT; ;
3415     break;}
3416 case 47:
3417 #line 1940 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3418 { yyval.FPred = FCmpInst::FCMP_ULE; ;
3419     break;}
3420 case 48:
3421 #line 1940 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3422 { yyval.FPred = FCmpInst::FCMP_UGE; ;
3423     break;}
3424 case 49:
3425 #line 1941 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3426 { yyval.FPred = FCmpInst::FCMP_TRUE; ;
3427     break;}
3428 case 50:
3429 #line 1942 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3430 { yyval.FPred = FCmpInst::FCMP_FALSE; ;
3431     break;}
3432 case 80:
3433 #line 1973 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3435     yyval.StrVal = yyvsp[-1].StrVal;
3436   ;
3437     break;}
3438 case 81:
3439 #line 1976 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3441     yyval.StrVal = 0;
3442   ;
3443     break;}
3444 case 82:
3445 #line 1981 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3446 { yyval.Linkage = GlobalValue::InternalLinkage; ;
3447     break;}
3448 case 83:
3449 #line 1982 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3450 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
3451     break;}
3452 case 84:
3453 #line 1983 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3454 { yyval.Linkage = GlobalValue::WeakLinkage; ;
3455     break;}
3456 case 85:
3457 #line 1984 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3458 { yyval.Linkage = GlobalValue::AppendingLinkage; ;
3459     break;}
3460 case 86:
3461 #line 1985 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3462 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;
3463     break;}
3464 case 87:
3465 #line 1986 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3466 { yyval.Linkage = GlobalValue::DLLExportLinkage; ;
3467     break;}
3468 case 88:
3469 #line 1987 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3470 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
3471     break;}
3472 case 89:
3473 #line 1988 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3474 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
3475     break;}
3476 case 90:
3477 #line 1992 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3478 { yyval.UIntVal = lastCallingConv = OldCallingConv::C; ;
3479     break;}
3480 case 91:
3481 #line 1993 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3482 { yyval.UIntVal = lastCallingConv = OldCallingConv::C; ;
3483     break;}
3484 case 92:
3485 #line 1994 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3486 { yyval.UIntVal = lastCallingConv = OldCallingConv::CSRet; ;
3487     break;}
3488 case 93:
3489 #line 1995 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3490 { yyval.UIntVal = lastCallingConv = OldCallingConv::Fast; ;
3491     break;}
3492 case 94:
3493 #line 1996 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3494 { yyval.UIntVal = lastCallingConv = OldCallingConv::Cold; ;
3495     break;}
3496 case 95:
3497 #line 1997 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3498 { yyval.UIntVal = lastCallingConv = OldCallingConv::X86_StdCall; ;
3499     break;}
3500 case 96:
3501 #line 1998 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3502 { yyval.UIntVal = lastCallingConv = OldCallingConv::X86_FastCall; ;
3503     break;}
3504 case 97:
3505 #line 1999 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3507     if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
3508       error("Calling conv too large");
3509     yyval.UIntVal = lastCallingConv = yyvsp[0].UInt64Val;
3510   ;
3511     break;}
3512 case 98:
3513 #line 2009 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3514 { yyval.UIntVal = 0; ;
3515     break;}
3516 case 99:
3517 #line 2010 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3519     yyval.UIntVal = yyvsp[0].UInt64Val;
3520     if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
3521       error("Alignment must be a power of two");
3522   ;
3523     break;}
3524 case 100:
3525 #line 2018 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3526 { yyval.UIntVal = 0; ;
3527     break;}
3528 case 101:
3529 #line 2019 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3531     yyval.UIntVal = yyvsp[0].UInt64Val;
3532     if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
3533       error("Alignment must be a power of two");
3534   ;
3535     break;}
3536 case 102:
3537 #line 2027 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3539     for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
3540       if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
3541         error("Invalid character in section name");
3542     yyval.StrVal = yyvsp[0].StrVal;
3543   ;
3544     break;}
3545 case 103:
3546 #line 2036 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3547 { yyval.StrVal = 0; ;
3548     break;}
3549 case 104:
3550 #line 2037 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3551 { yyval.StrVal = yyvsp[0].StrVal; ;
3552     break;}
3553 case 105:
3554 #line 2044 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3556     break;}
3557 case 106:
3558 #line 2045 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3560     break;}
3561 case 107:
3562 #line 2049 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3564     CurGV->setSection(yyvsp[0].StrVal);
3565     free(yyvsp[0].StrVal);
3566   ;
3567     break;}
3568 case 108:
3569 #line 2053 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3571     if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
3572       error("Alignment must be a power of two");
3573     CurGV->setAlignment(yyvsp[0].UInt64Val);
3574     
3575   ;
3576     break;}
3577 case 110:
3578 #line 2070 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3580     yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); 
3581     yyval.TypeVal.S.makeSignless();
3582   ;
3583     break;}
3584 case 112:
3585 #line 2078 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3587     yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T); 
3588     yyval.TypeVal.S.makeSignless();
3589   ;
3590     break;}
3591 case 113:
3592 #line 2085 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3594     if (!UpRefs.empty())
3595       error("Invalid upreference in type: " + (*yyvsp[0].TypeVal.PAT)->getDescription());
3596     yyval.TypeVal = yyvsp[0].TypeVal;
3597   ;
3598     break;}
3599 case 126:
3600 #line 2099 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3602     yyval.TypeVal.PAT = new PATypeHolder(yyvsp[0].PrimType.T);
3603     yyval.TypeVal.S.copy(yyvsp[0].PrimType.S);
3604   ;
3605     break;}
3606 case 127:
3607 #line 2103 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3609     yyval.TypeVal.PAT = new PATypeHolder(OpaqueType::get());
3610     yyval.TypeVal.S.makeSignless();
3611   ;
3612     break;}
3613 case 128:
3614 #line 2107 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3615 {            // Named types are also simple types...
3616     yyval.TypeVal.S.copy(getTypeSign(yyvsp[0].ValIDVal));
3617     const Type* tmp = getType(yyvsp[0].ValIDVal);
3618     yyval.TypeVal.PAT = new PATypeHolder(tmp);
3619   ;
3620     break;}
3621 case 129:
3622 #line 2112 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3623 {                   // Type UpReference
3624     if (yyvsp[0].UInt64Val > (uint64_t)~0U) 
3625       error("Value out of range");
3626     OpaqueType *OT = OpaqueType::get();        // Use temporary placeholder
3627     UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT));  // Add to vector...
3628     yyval.TypeVal.PAT = new PATypeHolder(OT);
3629     yyval.TypeVal.S.makeSignless();
3630     UR_OUT("New Upreference!\n");
3631   ;
3632     break;}
3633 case 130:
3634 #line 2121 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3635 {           // Function derived type?
3636     yyval.TypeVal.S.makeComposite(yyvsp[-3].TypeVal.S);
3637     std::vector<const Type*> Params;
3638     for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-1].TypeList->begin(),
3639            E = yyvsp[-1].TypeList->end(); I != E; ++I) {
3640       Params.push_back(I->PAT->get());
3641       yyval.TypeVal.S.add(I->S);
3642     }
3643     bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3644     if (isVarArg) Params.pop_back();
3646     ParamAttrsList *PAL = 0;
3647     if (lastCallingConv == OldCallingConv::CSRet) {
3648       ParamAttrsVector Attrs;
3649       ParamAttrsWithIndex PAWI;
3650       PAWI.index = 1;  PAWI.attrs = ParamAttr::StructRet; // first arg
3651       Attrs.push_back(PAWI);
3652       PAL = ParamAttrsList::get(Attrs);
3653     }
3655     const FunctionType *FTy =
3656       FunctionType::get(yyvsp[-3].TypeVal.PAT->get(), Params, isVarArg, PAL);
3658     yyval.TypeVal.PAT = new PATypeHolder( HandleUpRefs(FTy, yyval.TypeVal.S) );
3659     delete yyvsp[-3].TypeVal.PAT;  // Delete the return type handle
3660     delete yyvsp[-1].TypeList;      // Delete the argument list
3661   ;
3662     break;}
3663 case 131:
3664 #line 2148 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3665 {          // Sized array type?
3666     yyval.TypeVal.S.makeComposite(yyvsp[-1].TypeVal.S);
3667     yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(ArrayType::get(yyvsp[-1].TypeVal.PAT->get(), 
3668                                            (unsigned)yyvsp[-3].UInt64Val), yyval.TypeVal.S));
3669     delete yyvsp[-1].TypeVal.PAT;
3670   ;
3671     break;}
3672 case 132:
3673 #line 2154 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3674 {          // Vector type?
3675     const llvm::Type* ElemTy = yyvsp[-1].TypeVal.PAT->get();
3676     if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
3677        error("Unsigned result not equal to signed result");
3678     if (!(ElemTy->isInteger() || ElemTy->isFloatingPoint()))
3679        error("Elements of a VectorType must be integer or floating point");
3680     if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
3681       error("VectorType length should be a power of 2");
3682     yyval.TypeVal.S.makeComposite(yyvsp[-1].TypeVal.S);
3683     yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(VectorType::get(ElemTy, 
3684                                          (unsigned)yyvsp[-3].UInt64Val), yyval.TypeVal.S));
3685     delete yyvsp[-1].TypeVal.PAT;
3686   ;
3687     break;}
3688 case 133:
3689 #line 2167 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3690 {                        // Structure type?
3691     std::vector<const Type*> Elements;
3692     yyval.TypeVal.S.makeComposite();
3693     for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-1].TypeList->begin(),
3694            E = yyvsp[-1].TypeList->end(); I != E; ++I) {
3695       Elements.push_back(I->PAT->get());
3696       yyval.TypeVal.S.add(I->S);
3697     }
3698     yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements), yyval.TypeVal.S));
3699     delete yyvsp[-1].TypeList;
3700   ;
3701     break;}
3702 case 134:
3703 #line 2178 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3704 {                                  // Empty structure type?
3705     yyval.TypeVal.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>()));
3706     yyval.TypeVal.S.makeComposite();
3707   ;
3708     break;}
3709 case 135:
3710 #line 2182 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3711 {                // Packed Structure type?
3712     yyval.TypeVal.S.makeComposite();
3713     std::vector<const Type*> Elements;
3714     for (std::list<llvm::PATypeInfo>::iterator I = yyvsp[-2].TypeList->begin(),
3715            E = yyvsp[-2].TypeList->end(); I != E; ++I) {
3716       Elements.push_back(I->PAT->get());
3717       yyval.TypeVal.S.add(I->S);
3718       delete I->PAT;
3719     }
3720     yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true), 
3721                                            yyval.TypeVal.S));
3722     delete yyvsp[-2].TypeList;
3723   ;
3724     break;}
3725 case 136:
3726 #line 2195 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3727 {                          // Empty packed structure type?
3728     yyval.TypeVal.PAT = new PATypeHolder(StructType::get(std::vector<const Type*>(),true));
3729     yyval.TypeVal.S.makeComposite();
3730   ;
3731     break;}
3732 case 137:
3733 #line 2199 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3734 {                             // Pointer type?
3735     if (yyvsp[-1].TypeVal.PAT->get() == Type::LabelTy)
3736       error("Cannot form a pointer to a basic block");
3737     yyval.TypeVal.S.makeComposite(yyvsp[-1].TypeVal.S);
3738     yyval.TypeVal.PAT = new PATypeHolder(HandleUpRefs(PointerType::get(yyvsp[-1].TypeVal.PAT->get()),
3739                                            yyval.TypeVal.S));
3740     delete yyvsp[-1].TypeVal.PAT;
3741   ;
3742     break;}
3743 case 138:
3744 #line 2213 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3746     yyval.TypeList = new std::list<PATypeInfo>();
3747     yyval.TypeList->push_back(yyvsp[0].TypeVal); 
3748   ;
3749     break;}
3750 case 139:
3751 #line 2217 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3753     (yyval.TypeList=yyvsp[-2].TypeList)->push_back(yyvsp[0].TypeVal);
3754   ;
3755     break;}
3756 case 141:
3757 #line 2225 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3759     PATypeInfo VoidTI;
3760     VoidTI.PAT = new PATypeHolder(Type::VoidTy);
3761     VoidTI.S.makeSignless();
3762     (yyval.TypeList=yyvsp[-2].TypeList)->push_back(VoidTI);
3763   ;
3764     break;}
3765 case 142:
3766 #line 2231 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3768     yyval.TypeList = new std::list<PATypeInfo>();
3769     PATypeInfo VoidTI;
3770     VoidTI.PAT = new PATypeHolder(Type::VoidTy);
3771     VoidTI.S.makeSignless();
3772     yyval.TypeList->push_back(VoidTI);
3773   ;
3774     break;}
3775 case 143:
3776 #line 2238 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3778     yyval.TypeList = new std::list<PATypeInfo>();
3779   ;
3780     break;}
3781 case 144:
3782 #line 2250 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3783 { // Nonempty unsized arr
3784     const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal.PAT->get());
3785     if (ATy == 0)
3786       error("Cannot make array constant with type: '" + 
3787             yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'");
3788     const Type *ETy = ATy->getElementType();
3789     int NumElements = ATy->getNumElements();
3791     // Verify that we have the correct size...
3792     if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
3793       error("Type mismatch: constant sized array initialized with " +
3794             utostr(yyvsp[-1].ConstVector->size()) +  " arguments, but has size of " + 
3795             itostr(NumElements) + "");
3797     // Verify all elements are correct type!
3798     std::vector<Constant*> Elems;
3799     for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3800       Constant *C = (*yyvsp[-1].ConstVector)[i].C;
3801       const Type* ValTy = C->getType();
3802       if (ETy != ValTy)
3803         error("Element #" + utostr(i) + " is not of type '" + 
3804               ETy->getDescription() +"' as required!\nIt is of type '"+
3805               ValTy->getDescription() + "'");
3806       Elems.push_back(C);
3807     }
3808     yyval.ConstVal.C = ConstantArray::get(ATy, Elems);
3809     yyval.ConstVal.S.copy(yyvsp[-3].TypeVal.S);
3810     delete yyvsp[-3].TypeVal.PAT; 
3811     delete yyvsp[-1].ConstVector;
3812   ;
3813     break;}
3814 case 145:
3815 #line 2280 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3817     const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal.PAT->get());
3818     if (ATy == 0)
3819       error("Cannot make array constant with type: '" + 
3820             yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'");
3821     int NumElements = ATy->getNumElements();
3822     if (NumElements != -1 && NumElements != 0) 
3823       error("Type mismatch: constant sized array initialized with 0"
3824             " arguments, but has size of " + itostr(NumElements) +"");
3825     yyval.ConstVal.C = ConstantArray::get(ATy, std::vector<Constant*>());
3826     yyval.ConstVal.S.copy(yyvsp[-2].TypeVal.S);
3827     delete yyvsp[-2].TypeVal.PAT;
3828   ;
3829     break;}
3830 case 146:
3831 #line 2293 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3833     const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal.PAT->get());
3834     if (ATy == 0)
3835       error("Cannot make array constant with type: '" + 
3836             yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'");
3837     int NumElements = ATy->getNumElements();
3838     const Type *ETy = dyn_cast<IntegerType>(ATy->getElementType());
3839     if (!ETy || cast<IntegerType>(ETy)->getBitWidth() != 8)
3840       error("String arrays require type i8, not '" + ETy->getDescription() + 
3841             "'");
3842     char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3843     if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
3844       error("Can't build string constant of size " + 
3845             itostr((int)(EndStr-yyvsp[0].StrVal)) + " when array has size " + 
3846             itostr(NumElements) + "");
3847     std::vector<Constant*> Vals;
3848     for (char *C = (char *)yyvsp[0].StrVal; C != (char *)EndStr; ++C)
3849       Vals.push_back(ConstantInt::get(ETy, *C));
3850     free(yyvsp[0].StrVal);
3851     yyval.ConstVal.C = ConstantArray::get(ATy, Vals);
3852     yyval.ConstVal.S.copy(yyvsp[-2].TypeVal.S);
3853     delete yyvsp[-2].TypeVal.PAT;
3854   ;
3855     break;}
3856 case 147:
3857 #line 2316 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3858 { // Nonempty unsized arr
3859     const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal.PAT->get());
3860     if (PTy == 0)
3861       error("Cannot make packed constant with type: '" + 
3862             yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'");
3863     const Type *ETy = PTy->getElementType();
3864     int NumElements = PTy->getNumElements();
3865     // Verify that we have the correct size...
3866     if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
3867       error("Type mismatch: constant sized packed initialized with " +
3868             utostr(yyvsp[-1].ConstVector->size()) +  " arguments, but has size of " + 
3869             itostr(NumElements) + "");
3870     // Verify all elements are correct type!
3871     std::vector<Constant*> Elems;
3872     for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3873       Constant *C = (*yyvsp[-1].ConstVector)[i].C;
3874       const Type* ValTy = C->getType();
3875       if (ETy != ValTy)
3876         error("Element #" + utostr(i) + " is not of type '" + 
3877               ETy->getDescription() +"' as required!\nIt is of type '"+
3878               ValTy->getDescription() + "'");
3879       Elems.push_back(C);
3880     }
3881     yyval.ConstVal.C = ConstantVector::get(PTy, Elems);
3882     yyval.ConstVal.S.copy(yyvsp[-3].TypeVal.S);
3883     delete yyvsp[-3].TypeVal.PAT;
3884     delete yyvsp[-1].ConstVector;
3885   ;
3886     break;}
3887 case 148:
3888 #line 2344 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3890     const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal.PAT->get());
3891     if (STy == 0)
3892       error("Cannot make struct constant with type: '" + 
3893             yyvsp[-3].TypeVal.PAT->get()->getDescription() + "'");
3894     if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
3895       error("Illegal number of initializers for structure type");
3897     // Check to ensure that constants are compatible with the type initializer!
3898     std::vector<Constant*> Fields;
3899     for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) {
3900       Constant *C = (*yyvsp[-1].ConstVector)[i].C;
3901       if (C->getType() != STy->getElementType(i))
3902         error("Expected type '" + STy->getElementType(i)->getDescription() +
3903               "' for element #" + utostr(i) + " of structure initializer");
3904       Fields.push_back(C);
3905     }
3906     yyval.ConstVal.C = ConstantStruct::get(STy, Fields);
3907     yyval.ConstVal.S.copy(yyvsp[-3].TypeVal.S);
3908     delete yyvsp[-3].TypeVal.PAT;
3909     delete yyvsp[-1].ConstVector;
3910   ;
3911     break;}
3912 case 149:
3913 #line 2366 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3915     const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal.PAT->get());
3916     if (STy == 0)
3917       error("Cannot make struct constant with type: '" + 
3918               yyvsp[-2].TypeVal.PAT->get()->getDescription() + "'");
3919     if (STy->getNumContainedTypes() != 0)
3920       error("Illegal number of initializers for structure type");
3921     yyval.ConstVal.C = ConstantStruct::get(STy, std::vector<Constant*>());
3922     yyval.ConstVal.S.copy(yyvsp[-2].TypeVal.S);
3923     delete yyvsp[-2].TypeVal.PAT;
3924   ;
3925     break;}
3926 case 150:
3927 #line 2377 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3929     const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal.PAT->get());
3930     if (STy == 0)
3931       error("Cannot make packed struct constant with type: '" + 
3932             yyvsp[-5].TypeVal.PAT->get()->getDescription() + "'");
3933     if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
3934       error("Illegal number of initializers for packed structure type");
3936     // Check to ensure that constants are compatible with the type initializer!
3937     std::vector<Constant*> Fields;
3938     for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i) {
3939       Constant *C = (*yyvsp[-2].ConstVector)[i].C;
3940       if (C->getType() != STy->getElementType(i))
3941         error("Expected type '" + STy->getElementType(i)->getDescription() +
3942               "' for element #" + utostr(i) + " of packed struct initializer");
3943       Fields.push_back(C);
3944     }
3945     yyval.ConstVal.C = ConstantStruct::get(STy, Fields);
3946     yyval.ConstVal.S.copy(yyvsp[-5].TypeVal.S);
3947     delete yyvsp[-5].TypeVal.PAT; 
3948     delete yyvsp[-2].ConstVector;
3949   ;
3950     break;}
3951 case 151:
3952 #line 2399 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3954     const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal.PAT->get());
3955     if (STy == 0)
3956       error("Cannot make packed struct constant with type: '" + 
3957               yyvsp[-4].TypeVal.PAT->get()->getDescription() + "'");
3958     if (STy->getNumContainedTypes() != 0)
3959       error("Illegal number of initializers for packed structure type");
3960     yyval.ConstVal.C = ConstantStruct::get(STy, std::vector<Constant*>());
3961     yyval.ConstVal.S.copy(yyvsp[-4].TypeVal.S);
3962     delete yyvsp[-4].TypeVal.PAT;
3963   ;
3964     break;}
3965 case 152:
3966 #line 2410 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3968     const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get());
3969     if (PTy == 0)
3970       error("Cannot make null pointer constant with type: '" + 
3971             yyvsp[-1].TypeVal.PAT->get()->getDescription() + "'");
3972     yyval.ConstVal.C = ConstantPointerNull::get(PTy);
3973     yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S);
3974     delete yyvsp[-1].TypeVal.PAT;
3975   ;
3976     break;}
3977 case 153:
3978 #line 2419 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3980     yyval.ConstVal.C = UndefValue::get(yyvsp[-1].TypeVal.PAT->get());
3981     yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S);
3982     delete yyvsp[-1].TypeVal.PAT;
3983   ;
3984     break;}
3985 case 154:
3986 #line 2424 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
3988     const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get());
3989     if (Ty == 0)
3990       error("Global const reference must be a pointer type, not" +
3991             yyvsp[-1].TypeVal.PAT->get()->getDescription());
3993     // ConstExprs can exist in the body of a function, thus creating
3994     // GlobalValues whenever they refer to a variable.  Because we are in
3995     // the context of a function, getExistingValue will search the functions
3996     // symbol table instead of the module symbol table for the global symbol,
3997     // which throws things all off.  To get around this, we just tell
3998     // getExistingValue that we are at global scope here.
3999     //
4000     Function *SavedCurFn = CurFun.CurrentFunction;
4001     CurFun.CurrentFunction = 0;
4002     yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S);
4003     Value *V = getExistingValue(Ty, yyvsp[0].ValIDVal);
4004     CurFun.CurrentFunction = SavedCurFn;
4006     // If this is an initializer for a constant pointer, which is referencing a
4007     // (currently) undefined variable, create a stub now that shall be replaced
4008     // in the future with the right type of variable.
4009     //
4010     if (V == 0) {
4011       assert(isa<PointerType>(Ty) && "Globals may only be used as pointers");
4012       const PointerType *PT = cast<PointerType>(Ty);
4014       // First check to see if the forward references value is already created!
4015       PerModuleInfo::GlobalRefsType::iterator I =
4016         CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
4017     
4018       if (I != CurModule.GlobalRefs.end()) {
4019         V = I->second;             // Placeholder already exists, use it...
4020         yyvsp[0].ValIDVal.destroy();
4021       } else {
4022         std::string Name;
4023         if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
4025         // Create the forward referenced global.
4026         GlobalValue *GV;
4027         if (const FunctionType *FTy = 
4028                  dyn_cast<FunctionType>(PT->getElementType())) {
4029           GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
4030                             CurModule.CurrentModule);
4031         } else {
4032           GV = new GlobalVariable(PT->getElementType(), false,
4033                                   GlobalValue::ExternalLinkage, 0,
4034                                   Name, CurModule.CurrentModule);
4035         }
4037         // Keep track of the fact that we have a forward ref to recycle it
4038         CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
4039         V = GV;
4040       }
4041     }
4042     yyval.ConstVal.C = cast<GlobalValue>(V);
4043     yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S);
4044     delete yyvsp[-1].TypeVal.PAT;            // Free the type handle
4045   ;
4046     break;}
4047 case 155:
4048 #line 2483 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4050     if (yyvsp[-1].TypeVal.PAT->get() != yyvsp[0].ConstVal.C->getType())
4051       error("Mismatched types for constant expression");
4052     yyval.ConstVal = yyvsp[0].ConstVal;
4053     yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S);
4054     delete yyvsp[-1].TypeVal.PAT;
4055   ;
4056     break;}
4057 case 156:
4058 #line 2490 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4060     const Type *Ty = yyvsp[-1].TypeVal.PAT->get();
4061     if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
4062       error("Cannot create a null initialized value of this type");
4063     yyval.ConstVal.C = Constant::getNullValue(Ty);
4064     yyval.ConstVal.S.copy(yyvsp[-1].TypeVal.S);
4065     delete yyvsp[-1].TypeVal.PAT;
4066   ;
4067     break;}
4068 case 157:
4069 #line 2498 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4070 {      // integral constants
4071     const Type *Ty = yyvsp[-1].PrimType.T;
4072     if (!ConstantInt::isValueValidForType(Ty, yyvsp[0].SInt64Val))
4073       error("Constant value doesn't fit in type");
4074     yyval.ConstVal.C = ConstantInt::get(Ty, yyvsp[0].SInt64Val);
4075     yyval.ConstVal.S.makeSigned();
4076   ;
4077     break;}
4078 case 158:
4079 #line 2505 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4080 {            // integral constants
4081     const Type *Ty = yyvsp[-1].PrimType.T;
4082     if (!ConstantInt::isValueValidForType(Ty, yyvsp[0].UInt64Val))
4083       error("Constant value doesn't fit in type");
4084     yyval.ConstVal.C = ConstantInt::get(Ty, yyvsp[0].UInt64Val);
4085     yyval.ConstVal.S.makeUnsigned();
4086   ;
4087     break;}
4088 case 159:
4089 #line 2512 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4090 {                      // Boolean constants
4091     yyval.ConstVal.C = ConstantInt::get(Type::Int1Ty, true);
4092     yyval.ConstVal.S.makeUnsigned();
4093   ;
4094     break;}
4095 case 160:
4096 #line 2516 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4097 {                     // Boolean constants
4098     yyval.ConstVal.C = ConstantInt::get(Type::Int1Ty, false);
4099     yyval.ConstVal.S.makeUnsigned();
4100   ;
4101     break;}
4102 case 161:
4103 #line 2520 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4104 {                   // Float & Double constants
4105     if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType.T, *yyvsp[0].FPVal))
4106       error("Floating point constant invalid for type");
4107     // Lexer has no type info, so builds all FP constants as double.
4108     // Fix this here.
4109     if (yyvsp[-1].PrimType.T==Type::FloatTy)
4110       yyvsp[0].FPVal->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven);
4111     yyval.ConstVal.C = ConstantFP::get(yyvsp[-1].PrimType.T, *yyvsp[0].FPVal);
4112     delete yyvsp[0].FPVal;
4113     yyval.ConstVal.S.makeSignless();
4114   ;
4115     break;}
4116 case 162:
4117 #line 2534 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4119     const Type* SrcTy = yyvsp[-3].ConstVal.C->getType();
4120     const Type* DstTy = yyvsp[-1].TypeVal.PAT->get();
4121     Signedness SrcSign(yyvsp[-3].ConstVal.S);
4122     Signedness DstSign(yyvsp[-1].TypeVal.S);
4123     if (!SrcTy->isFirstClassType())
4124       error("cast constant expression from a non-primitive type: '" +
4125             SrcTy->getDescription() + "'");
4126     if (!DstTy->isFirstClassType())
4127       error("cast constant expression to a non-primitive type: '" +
4128             DstTy->getDescription() + "'");
4129     yyval.ConstVal.C = cast<Constant>(getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal.C, SrcSign, DstTy, DstSign));
4130     yyval.ConstVal.S.copy(DstSign);
4131     delete yyvsp[-1].TypeVal.PAT;
4132   ;
4133     break;}
4134 case 163:
4135 #line 2549 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4137     const Type *Ty = yyvsp[-2].ConstVal.C->getType();
4138     if (!isa<PointerType>(Ty))
4139       error("GetElementPtr requires a pointer operand");
4141     std::vector<Constant*> CIndices;
4142     upgradeGEPCEIndices(yyvsp[-2].ConstVal.C->getType(), yyvsp[-1].ValueList, CIndices);
4144     delete yyvsp[-1].ValueList;
4145     yyval.ConstVal.C = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal.C, &CIndices[0], CIndices.size());
4146     yyval.ConstVal.S.copy(getElementSign(yyvsp[-2].ConstVal, CIndices));
4147   ;
4148     break;}
4149 case 164:
4150 #line 2561 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4152     if (!yyvsp[-5].ConstVal.C->getType()->isInteger() ||
4153         cast<IntegerType>(yyvsp[-5].ConstVal.C->getType())->getBitWidth() != 1)
4154       error("Select condition must be bool type");
4155     if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType())
4156       error("Select operand types must match");
4157     yyval.ConstVal.C = ConstantExpr::getSelect(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C);
4158     yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S);
4159   ;
4160     break;}
4161 case 165:
4162 #line 2570 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4164     const Type *Ty = yyvsp[-3].ConstVal.C->getType();
4165     if (Ty != yyvsp[-1].ConstVal.C->getType())
4166       error("Binary operator types must match");
4167     // First, make sure we're dealing with the right opcode by upgrading from
4168     // obsolete versions.
4169     Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S);
4171     // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
4172     // To retain backward compatibility with these early compilers, we emit a
4173     // cast to the appropriate integer type automatically if we are in the
4174     // broken case.  See PR424 for more information.
4175     if (!isa<PointerType>(Ty)) {
4176       yyval.ConstVal.C = ConstantExpr::get(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C);
4177     } else {
4178       const Type *IntPtrTy = 0;
4179       switch (CurModule.CurrentModule->getPointerSize()) {
4180       case Module::Pointer32: IntPtrTy = Type::Int32Ty; break;
4181       case Module::Pointer64: IntPtrTy = Type::Int64Ty; break;
4182       default: error("invalid pointer binary constant expr");
4183       }
4184       yyval.ConstVal.C = ConstantExpr::get(Opcode, 
4185              ConstantExpr::getCast(Instruction::PtrToInt, yyvsp[-3].ConstVal.C, IntPtrTy),
4186              ConstantExpr::getCast(Instruction::PtrToInt, yyvsp[-1].ConstVal.C, IntPtrTy));
4187       yyval.ConstVal.C = ConstantExpr::getCast(Instruction::IntToPtr, yyval.ConstVal.C, Ty);
4188     }
4189     yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S); 
4190   ;
4191     break;}
4192 case 166:
4193 #line 2598 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4195     const Type* Ty = yyvsp[-3].ConstVal.C->getType();
4196     if (Ty != yyvsp[-1].ConstVal.C->getType())
4197       error("Logical operator types must match");
4198     if (!Ty->isInteger()) {
4199       if (!isa<VectorType>(Ty) || 
4200           !cast<VectorType>(Ty)->getElementType()->isInteger())
4201         error("Logical operator requires integer operands");
4202     }
4203     Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S);
4204     yyval.ConstVal.C = ConstantExpr::get(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C);
4205     yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S);
4206   ;
4207     break;}
4208 case 167:
4209 #line 2611 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4211     const Type* Ty = yyvsp[-3].ConstVal.C->getType();
4212     if (Ty != yyvsp[-1].ConstVal.C->getType())
4213       error("setcc operand types must match");
4214     unsigned short pred;
4215     Instruction::OtherOps Opcode = getCompareOp(yyvsp[-5].BinaryOpVal, pred, Ty, yyvsp[-3].ConstVal.S);
4216     yyval.ConstVal.C = ConstantExpr::getCompare(Opcode, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C);
4217     yyval.ConstVal.S.makeUnsigned();
4218   ;
4219     break;}
4220 case 168:
4221 #line 2620 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4223     if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) 
4224       error("icmp operand types must match");
4225     yyval.ConstVal.C = ConstantExpr::getCompare(yyvsp[-5].IPred, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C);
4226     yyval.ConstVal.S.makeUnsigned();
4227   ;
4228     break;}
4229 case 169:
4230 #line 2626 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4232     if (yyvsp[-3].ConstVal.C->getType() != yyvsp[-1].ConstVal.C->getType()) 
4233       error("fcmp operand types must match");
4234     yyval.ConstVal.C = ConstantExpr::getCompare(yyvsp[-5].FPred, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C);
4235     yyval.ConstVal.S.makeUnsigned();
4236   ;
4237     break;}
4238 case 170:
4239 #line 2632 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4241     if (!yyvsp[-1].ConstVal.C->getType()->isInteger() ||
4242         cast<IntegerType>(yyvsp[-1].ConstVal.C->getType())->getBitWidth() != 8)
4243       error("Shift count for shift constant must be unsigned byte");
4244     const Type* Ty = yyvsp[-3].ConstVal.C->getType();
4245     if (!yyvsp[-3].ConstVal.C->getType()->isInteger())
4246       error("Shift constant expression requires integer operand");
4247     Constant *ShiftAmt = ConstantExpr::getZExt(yyvsp[-1].ConstVal.C, Ty);
4248     yyval.ConstVal.C = ConstantExpr::get(getBinaryOp(yyvsp[-5].BinaryOpVal, Ty, yyvsp[-3].ConstVal.S), yyvsp[-3].ConstVal.C, ShiftAmt);
4249     yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S);
4250   ;
4251     break;}
4252 case 171:
4253 #line 2643 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4255     if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C))
4256       error("Invalid extractelement operands");
4257     yyval.ConstVal.C = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C);
4258     yyval.ConstVal.S.copy(yyvsp[-3].ConstVal.S.get(0));
4259   ;
4260     break;}
4261 case 172:
4262 #line 2649 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4264     if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C))
4265       error("Invalid insertelement operands");
4266     yyval.ConstVal.C = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C);
4267     yyval.ConstVal.S.copy(yyvsp[-5].ConstVal.S);
4268   ;
4269     break;}
4270 case 173:
4271 #line 2655 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4273     if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C))
4274       error("Invalid shufflevector operands");
4275     yyval.ConstVal.C = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal.C, yyvsp[-3].ConstVal.C, yyvsp[-1].ConstVal.C);
4276     yyval.ConstVal.S.copy(yyvsp[-5].ConstVal.S);
4277   ;
4278     break;}
4279 case 174:
4280 #line 2666 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4281 { (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); ;
4282     break;}
4283 case 175:
4284 #line 2667 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4286     yyval.ConstVector = new std::vector<ConstInfo>();
4287     yyval.ConstVector->push_back(yyvsp[0].ConstVal);
4288   ;
4289     break;}
4290 case 176:
4291 #line 2676 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4292 { yyval.BoolVal = false; ;
4293     break;}
4294 case 177:
4295 #line 2677 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4296 { yyval.BoolVal = true; ;
4297     break;}
4298 case 178:
4299 #line 2689 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4301     yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
4302     CurModule.ModuleDone();
4303   ;
4304     break;}
4305 case 179:
4306 #line 2698 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4307 { yyval.ModuleVal = yyvsp[-1].ModuleVal; CurFun.FunctionDone(); ;
4308     break;}
4309 case 180:
4310 #line 2699 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4311 { yyval.ModuleVal = yyvsp[-1].ModuleVal; ;
4312     break;}
4313 case 181:
4314 #line 2700 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4315 { yyval.ModuleVal = yyvsp[-3].ModuleVal; ;
4316     break;}
4317 case 182:
4318 #line 2701 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4319 { yyval.ModuleVal = yyvsp[-1].ModuleVal; ;
4320     break;}
4321 case 183:
4322 #line 2702 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4324     yyval.ModuleVal = CurModule.CurrentModule;
4325     // Emit an error if there are any unresolved types left.
4326     if (!CurModule.LateResolveTypes.empty()) {
4327       const ValID &DID = CurModule.LateResolveTypes.begin()->first;
4328       if (DID.Type == ValID::NameVal) {
4329         error("Reference to an undefined type: '"+DID.getName() + "'");
4330       } else {
4331         error("Reference to an undefined type: #" + itostr(DID.Num));
4332       }
4333     }
4334   ;
4335     break;}
4336 case 184:
4337 #line 2718 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4339     // Eagerly resolve types.  This is not an optimization, this is a
4340     // requirement that is due to the fact that we could have this:
4341     //
4342     // %list = type { %list * }
4343     // %list = type { %list * }    ; repeated type decl
4344     //
4345     // If types are not resolved eagerly, then the two types will not be
4346     // determined to be the same type!
4347     //
4348     ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].TypeVal.PAT->get(), yyvsp[0].TypeVal.S);
4350     if (!setTypeName(yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
4351       // If this is a numbered type that is not a redefinition, add it to the 
4352       // slot table.
4353       CurModule.Types.push_back(yyvsp[0].TypeVal.PAT->get());
4354       CurModule.TypeSigns.push_back(yyvsp[0].TypeVal.S);
4355     }
4356     delete yyvsp[0].TypeVal.PAT;
4357   ;
4358     break;}
4359 case 185:
4360 #line 2738 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4361 {       // Function prototypes can be in const pool
4362   ;
4363     break;}
4364 case 186:
4365 #line 2740 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4366 {  // Asm blocks can be in the const pool
4367   ;
4368     break;}
4369 case 187:
4370 #line 2742 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4372     if (yyvsp[0].ConstVal.C == 0) 
4373       error("Global value initializer is not a constant");
4374     CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal.C->getType(), yyvsp[0].ConstVal.C, yyvsp[0].ConstVal.S);
4375   ;
4376     break;}
4377 case 188:
4378 #line 2746 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4380     CurGV = 0;
4381   ;
4382     break;}
4383 case 189:
4384 #line 2749 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4386     const Type *Ty = yyvsp[0].TypeVal.PAT->get();
4387     CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, Ty, 0,
4388                                 yyvsp[0].TypeVal.S);
4389     delete yyvsp[0].TypeVal.PAT;
4390   ;
4391     break;}
4392 case 190:
4393 #line 2754 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4395     CurGV = 0;
4396   ;
4397     break;}
4398 case 191:
4399 #line 2757 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4401     const Type *Ty = yyvsp[0].TypeVal.PAT->get();
4402     CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::DLLImportLinkage, yyvsp[-1].BoolVal, Ty, 0,
4403                                 yyvsp[0].TypeVal.S);
4404     delete yyvsp[0].TypeVal.PAT;
4405   ;
4406     break;}
4407 case 192:
4408 #line 2762 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4410     CurGV = 0;
4411   ;
4412     break;}
4413 case 193:
4414 #line 2765 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4416     const Type *Ty = yyvsp[0].TypeVal.PAT->get();
4417     CurGV = 
4418       ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalWeakLinkage, yyvsp[-1].BoolVal, Ty, 0, 
4419                           yyvsp[0].TypeVal.S);
4420     delete yyvsp[0].TypeVal.PAT;
4421   ;
4422     break;}
4423 case 194:
4424 #line 2771 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4426     CurGV = 0;
4427   ;
4428     break;}
4429 case 195:
4430 #line 2774 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4432   ;
4433     break;}
4434 case 196:
4435 #line 2776 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4437   ;
4438     break;}
4439 case 197:
4440 #line 2778 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4442   ;
4443     break;}
4444 case 198:
4445 #line 2783 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4447     const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
4448     char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
4449     std::string NewAsm(yyvsp[0].StrVal, EndStr);
4450     free(yyvsp[0].StrVal);
4452     if (AsmSoFar.empty())
4453       CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4454     else
4455       CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
4456   ;
4457     break;}
4458 case 199:
4459 #line 2797 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4460 { yyval.Endianness = Module::BigEndian; ;
4461     break;}
4462 case 200:
4463 #line 2798 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4464 { yyval.Endianness = Module::LittleEndian; ;
4465     break;}
4466 case 201:
4467 #line 2802 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4469     CurModule.setEndianness(yyvsp[0].Endianness);
4470   ;
4471     break;}
4472 case 202:
4473 #line 2805 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4475     if (yyvsp[0].UInt64Val == 32)
4476       CurModule.setPointerSize(Module::Pointer32);
4477     else if (yyvsp[0].UInt64Val == 64)
4478       CurModule.setPointerSize(Module::Pointer64);
4479     else
4480       error("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'");
4481   ;
4482     break;}
4483 case 203:
4484 #line 2813 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4486     CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
4487     free(yyvsp[0].StrVal);
4488   ;
4489     break;}
4490 case 204:
4491 #line 2817 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4493     CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal);
4494     free(yyvsp[0].StrVal);
4495   ;
4496     break;}
4497 case 206:
4498 #line 2828 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4500       CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
4501       free(yyvsp[0].StrVal);
4502   ;
4503     break;}
4504 case 207:
4505 #line 2832 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4507     CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
4508     free(yyvsp[0].StrVal);
4509   ;
4510     break;}
4511 case 208:
4512 #line 2836 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4513 { ;
4514     break;}
4515 case 212:
4516 #line 2849 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4517 { yyval.StrVal = 0; ;
4518     break;}
4519 case 213:
4520 #line 2853 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4522     if (yyvsp[-1].TypeVal.PAT->get() == Type::VoidTy)
4523       error("void typed arguments are invalid");
4524     yyval.ArgVal = new std::pair<PATypeInfo, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
4525   ;
4526     break;}
4527 case 214:
4528 #line 2861 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4530     yyval.ArgList = yyvsp[-2].ArgList;
4531     yyval.ArgList->push_back(*yyvsp[0].ArgVal);
4532     delete yyvsp[0].ArgVal;
4533   ;
4534     break;}
4535 case 215:
4536 #line 2866 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4538     yyval.ArgList = new std::vector<std::pair<PATypeInfo,char*> >();
4539     yyval.ArgList->push_back(*yyvsp[0].ArgVal);
4540     delete yyvsp[0].ArgVal;
4541   ;
4542     break;}
4543 case 216:
4544 #line 2874 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4545 { yyval.ArgList = yyvsp[0].ArgList; ;
4546     break;}
4547 case 217:
4548 #line 2875 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4550     yyval.ArgList = yyvsp[-2].ArgList;
4551     PATypeInfo VoidTI;
4552     VoidTI.PAT = new PATypeHolder(Type::VoidTy);
4553     VoidTI.S.makeSignless();
4554     yyval.ArgList->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
4555   ;
4556     break;}
4557 case 218:
4558 #line 2882 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4560     yyval.ArgList = new std::vector<std::pair<PATypeInfo,char*> >();
4561     PATypeInfo VoidTI;
4562     VoidTI.PAT = new PATypeHolder(Type::VoidTy);
4563     VoidTI.S.makeSignless();
4564     yyval.ArgList->push_back(std::pair<PATypeInfo, char*>(VoidTI, 0));
4565   ;
4566     break;}
4567 case 219:
4568 #line 2889 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4569 { yyval.ArgList = 0; ;
4570     break;}
4571 case 220:
4572 #line 2893 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4574     UnEscapeLexed(yyvsp[-5].StrVal);
4575     std::string FunctionName(yyvsp[-5].StrVal);
4576     free(yyvsp[-5].StrVal);  // Free strdup'd memory!
4578     const Type* RetTy = yyvsp[-6].TypeVal.PAT->get();
4579     
4580     if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
4581       error("LLVM functions cannot return aggregate types");
4583     Signedness FTySign;
4584     FTySign.makeComposite(yyvsp[-6].TypeVal.S);
4585     std::vector<const Type*> ParamTyList;
4587     // In LLVM 2.0 the signatures of three varargs intrinsics changed to take
4588     // i8*. We check here for those names and override the parameter list
4589     // types to ensure the prototype is correct.
4590     if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
4591       ParamTyList.push_back(PointerType::get(Type::Int8Ty));
4592     } else if (FunctionName == "llvm.va_copy") {
4593       ParamTyList.push_back(PointerType::get(Type::Int8Ty));
4594       ParamTyList.push_back(PointerType::get(Type::Int8Ty));
4595     } else if (yyvsp[-3].ArgList) {   // If there are arguments...
4596       for (std::vector<std::pair<PATypeInfo,char*> >::iterator 
4597            I = yyvsp[-3].ArgList->begin(), E = yyvsp[-3].ArgList->end(); I != E; ++I) {
4598         const Type *Ty = I->first.PAT->get();
4599         ParamTyList.push_back(Ty);
4600         FTySign.add(I->first.S);
4601       }
4602     }
4604     bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
4605     if (isVarArg) 
4606       ParamTyList.pop_back();
4608     // Convert the CSRet calling convention into the corresponding parameter
4609     // attribute.
4610     ParamAttrsList *PAL = 0;
4611     if (yyvsp[-7].UIntVal == OldCallingConv::CSRet) {
4612       ParamAttrsVector Attrs;
4613       ParamAttrsWithIndex PAWI;
4614       PAWI.index = 1;  PAWI.attrs = ParamAttr::StructRet; // first arg
4615       Attrs.push_back(PAWI);
4616       PAL = ParamAttrsList::get(Attrs);
4617     }
4619     const FunctionType *FT = 
4620       FunctionType::get(RetTy, ParamTyList, isVarArg, PAL);
4621     const PointerType *PFT = PointerType::get(FT);
4622     delete yyvsp[-6].TypeVal.PAT;
4624     ValID ID;
4625     if (!FunctionName.empty()) {
4626       ID = ValID::create((char*)FunctionName.c_str());
4627     } else {
4628       ID = ValID::create((int)CurModule.Values[PFT].size());
4629     }
4630     ID.S.makeComposite(FTySign);
4632     Function *Fn = 0;
4633     Module* M = CurModule.CurrentModule;
4635     // See if this function was forward referenced.  If so, recycle the object.
4636     if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4637       // Move the function to the end of the list, from whereever it was 
4638       // previously inserted.
4639       Fn = cast<Function>(FWRef);
4640       M->getFunctionList().remove(Fn);
4641       M->getFunctionList().push_back(Fn);
4642     } else if (!FunctionName.empty()) {
4643       GlobalValue *Conflict = M->getFunction(FunctionName);
4644       if (!Conflict)
4645         Conflict = M->getNamedGlobal(FunctionName);
4646       if (Conflict && PFT == Conflict->getType()) {
4647         if (!CurFun.isDeclare && !Conflict->isDeclaration()) {
4648           // We have two function definitions that conflict, same type, same
4649           // name. We should really check to make sure that this is the result
4650           // of integer type planes collapsing and generate an error if it is
4651           // not, but we'll just rename on the assumption that it is. However,
4652           // let's do it intelligently and rename the internal linkage one
4653           // if there is one.
4654           std::string NewName(makeNameUnique(FunctionName));
4655           if (Conflict->hasInternalLinkage()) {
4656             Conflict->setName(NewName);
4657             RenameMapKey Key = 
4658               makeRenameMapKey(FunctionName, Conflict->getType(), ID.S);
4659             CurModule.RenameMap[Key] = NewName;
4660             Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
4661             InsertValue(Fn, CurModule.Values);
4662           } else {
4663             Fn = new Function(FT, CurFun.Linkage, NewName, M);
4664             InsertValue(Fn, CurModule.Values);
4665             RenameMapKey Key = 
4666               makeRenameMapKey(FunctionName, PFT, ID.S);
4667             CurModule.RenameMap[Key] = NewName;
4668           }
4669         } else {
4670           // If they are not both definitions, then just use the function we
4671           // found since the types are the same.
4672           Fn = cast<Function>(Conflict);
4674           // Make sure to strip off any argument names so we can't get 
4675           // conflicts.
4676           if (Fn->isDeclaration())
4677             for (Function::arg_iterator AI = Fn->arg_begin(), 
4678                  AE = Fn->arg_end(); AI != AE; ++AI)
4679               AI->setName("");
4680         }
4681       } else if (Conflict) {
4682         // We have two globals with the same name and different types. 
4683         // Previously, this was permitted because the symbol table had 
4684         // "type planes" and names only needed to be distinct within a 
4685         // type plane. After PR411 was fixed, this is no loner the case. 
4686         // To resolve this we must rename one of the two. 
4687         if (Conflict->hasInternalLinkage()) {
4688           // We can safely rename the Conflict.
4689           RenameMapKey Key = 
4690             makeRenameMapKey(Conflict->getName(), Conflict->getType(), 
4691               CurModule.NamedValueSigns[Conflict->getName()]);
4692           Conflict->setName(makeNameUnique(Conflict->getName()));
4693           CurModule.RenameMap[Key] = Conflict->getName();
4694           Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
4695           InsertValue(Fn, CurModule.Values);
4696         } else { 
4697           // We can't quietly rename either of these things, but we must
4698           // rename one of them. Only if the function's linkage is internal can
4699           // we forgo a warning message about the renamed function. 
4700           std::string NewName = makeNameUnique(FunctionName);
4701           if (CurFun.Linkage != GlobalValue::InternalLinkage) {
4702             warning("Renaming function '" + FunctionName + "' as '" + NewName +
4703                     "' may cause linkage errors");
4704           }
4705           // Elect to rename the thing we're now defining.
4706           Fn = new Function(FT, CurFun.Linkage, NewName, M);
4707           InsertValue(Fn, CurModule.Values);
4708           RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S);
4709           CurModule.RenameMap[Key] = NewName;
4710         } 
4711       } else {
4712         // There's no conflict, just define the function
4713         Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
4714         InsertValue(Fn, CurModule.Values);
4715       }
4716     } else {
4717       // There's no conflict, just define the function
4718       Fn = new Function(FT, CurFun.Linkage, FunctionName, M);
4719       InsertValue(Fn, CurModule.Values);
4720     }
4723     CurFun.FunctionStart(Fn);
4725     if (CurFun.isDeclare) {
4726       // If we have declaration, always overwrite linkage.  This will allow us 
4727       // to correctly handle cases, when pointer to function is passed as 
4728       // argument to another function.
4729       Fn->setLinkage(CurFun.Linkage);
4730     }
4731     Fn->setCallingConv(upgradeCallingConv(yyvsp[-7].UIntVal));
4732     Fn->setAlignment(yyvsp[0].UIntVal);
4733     if (yyvsp[-1].StrVal) {
4734       Fn->setSection(yyvsp[-1].StrVal);
4735       free(yyvsp[-1].StrVal);
4736     }
4738     // Add all of the arguments we parsed to the function...
4739     if (yyvsp[-3].ArgList) {                     // Is null if empty...
4740       if (isVarArg) {  // Nuke the last entry
4741         assert(yyvsp[-3].ArgList->back().first.PAT->get() == Type::VoidTy && 
4742                yyvsp[-3].ArgList->back().second == 0 && "Not a varargs marker");
4743         delete yyvsp[-3].ArgList->back().first.PAT;
4744         yyvsp[-3].ArgList->pop_back();  // Delete the last entry
4745       }
4746       Function::arg_iterator ArgIt = Fn->arg_begin();
4747       Function::arg_iterator ArgEnd = Fn->arg_end();
4748       std::vector<std::pair<PATypeInfo,char*> >::iterator I = yyvsp[-3].ArgList->begin();
4749       std::vector<std::pair<PATypeInfo,char*> >::iterator E = yyvsp[-3].ArgList->end();
4750       for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
4751         delete I->first.PAT;                      // Delete the typeholder...
4752         ValueInfo VI; VI.V = ArgIt; VI.S.copy(I->first.S); 
4753         setValueName(VI, I->second);           // Insert arg into symtab...
4754         InsertValue(ArgIt);
4755       }
4756       delete yyvsp[-3].ArgList;                     // We're now done with the argument list
4757     }
4758     lastCallingConv = OldCallingConv::C;
4759   ;
4760     break;}
4761 case 223:
4762 #line 3087 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4763 { CurFun.Linkage = yyvsp[0].Linkage; ;
4764     break;}
4765 case 224:
4766 #line 3087 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4768     yyval.FunctionVal = CurFun.CurrentFunction;
4770     // Make sure that we keep track of the linkage type even if there was a
4771     // previous "declare".
4772     yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4773   ;
4774     break;}
4775 case 227:
4776 #line 3101 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4778     yyval.FunctionVal = yyvsp[-1].FunctionVal;
4779   ;
4780     break;}
4781 case 228:
4782 #line 3106 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4783 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
4784     break;}
4785 case 229:
4786 #line 3107 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4787 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;
4788     break;}
4789 case 230:
4790 #line 3108 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4791 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
4792     break;}
4793 case 231:
4794 #line 3112 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4795 { CurFun.isDeclare = true; ;
4796     break;}
4797 case 232:
4798 #line 3113 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4799 { CurFun.Linkage = yyvsp[0].Linkage; ;
4800     break;}
4801 case 233:
4802 #line 3113 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4804     yyval.FunctionVal = CurFun.CurrentFunction;
4805     CurFun.FunctionDone();
4806     
4807   ;
4808     break;}
4809 case 234:
4810 #line 3125 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4811 { yyval.BoolVal = false; ;
4812     break;}
4813 case 235:
4814 #line 3126 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4815 { yyval.BoolVal = true; ;
4816     break;}
4817 case 236:
4818 #line 3131 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4819 { yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); ;
4820     break;}
4821 case 237:
4822 #line 3132 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4823 { yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); ;
4824     break;}
4825 case 238:
4826 #line 3133 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4827 { yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); ;
4828     break;}
4829 case 239:
4830 #line 3134 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4832     yyval.ValIDVal = ValID::create(ConstantInt::get(Type::Int1Ty, true));
4833     yyval.ValIDVal.S.makeUnsigned();
4834   ;
4835     break;}
4836 case 240:
4837 #line 3138 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4839     yyval.ValIDVal = ValID::create(ConstantInt::get(Type::Int1Ty, false)); 
4840     yyval.ValIDVal.S.makeUnsigned();
4841   ;
4842     break;}
4843 case 241:
4844 #line 3142 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4845 { yyval.ValIDVal = ValID::createNull(); ;
4846     break;}
4847 case 242:
4848 #line 3143 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4849 { yyval.ValIDVal = ValID::createUndef(); ;
4850     break;}
4851 case 243:
4852 #line 3144 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4853 { yyval.ValIDVal = ValID::createZeroInit(); ;
4854     break;}
4855 case 244:
4856 #line 3145 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4857 { // Nonempty unsized packed vector
4858     const Type *ETy = (*yyvsp[-1].ConstVector)[0].C->getType();
4859     int NumElements = yyvsp[-1].ConstVector->size(); 
4860     VectorType* pt = VectorType::get(ETy, NumElements);
4861     yyval.ValIDVal.S.makeComposite((*yyvsp[-1].ConstVector)[0].S);
4862     PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt, yyval.ValIDVal.S));
4863     
4864     // Verify all elements are correct type!
4865     std::vector<Constant*> Elems;
4866     for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
4867       Constant *C = (*yyvsp[-1].ConstVector)[i].C;
4868       const Type *CTy = C->getType();
4869       if (ETy != CTy)
4870         error("Element #" + utostr(i) + " is not of type '" + 
4871               ETy->getDescription() +"' as required!\nIt is of type '" +
4872               CTy->getDescription() + "'");
4873       Elems.push_back(C);
4874     }
4875     yyval.ValIDVal = ValID::create(ConstantVector::get(pt, Elems));
4876     delete PTy; delete yyvsp[-1].ConstVector;
4877   ;
4878     break;}
4879 case 245:
4880 #line 3166 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4882     yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal.C);
4883     yyval.ValIDVal.S.copy(yyvsp[0].ConstVal.S);
4884   ;
4885     break;}
4886 case 246:
4887 #line 3170 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4889     char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
4890     std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
4891     End = UnEscapeLexed(yyvsp[0].StrVal, true);
4892     std::string Constraints = std::string(yyvsp[0].StrVal, End);
4893     yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
4894     free(yyvsp[-2].StrVal);
4895     free(yyvsp[0].StrVal);
4896   ;
4897     break;}
4898 case 247:
4899 #line 3184 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4900 {  yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal); yyval.ValIDVal.S.makeSignless(); ;
4901     break;}
4902 case 248:
4903 #line 3185 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4904 {  yyval.ValIDVal = ValID::create(yyvsp[0].StrVal); yyval.ValIDVal.S.makeSignless(); ;
4905     break;}
4906 case 251:
4907 #line 3198 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4909     const Type *Ty = yyvsp[-1].TypeVal.PAT->get();
4910     yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S);
4911     yyval.ValueVal.V = getVal(Ty, yyvsp[0].ValIDVal); 
4912     yyval.ValueVal.S.copy(yyvsp[-1].TypeVal.S);
4913     delete yyvsp[-1].TypeVal.PAT;
4914   ;
4915     break;}
4916 case 252:
4917 #line 3208 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4919     yyval.FunctionVal = yyvsp[-1].FunctionVal;
4920   ;
4921     break;}
4922 case 253:
4923 #line 3211 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4924 { // Do not allow functions with 0 basic blocks   
4925     yyval.FunctionVal = yyvsp[-1].FunctionVal;
4926   ;
4927     break;}
4928 case 254:
4929 #line 3220 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4931     ValueInfo VI; VI.V = yyvsp[0].TermInstVal.TI; VI.S.copy(yyvsp[0].TermInstVal.S);
4932     setValueName(VI, yyvsp[-1].StrVal);
4933     InsertValue(yyvsp[0].TermInstVal.TI);
4934     yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal.TI);
4935     InsertValue(yyvsp[-2].BasicBlockVal);
4936     yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
4937   ;
4938     break;}
4939 case 255:
4940 #line 3231 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4942     if (yyvsp[0].InstVal.I)
4943       yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal.I);
4944     yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
4945   ;
4946     break;}
4947 case 256:
4948 #line 3236 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4950     yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++),true);
4951     // Make sure to move the basic block to the correct location in the
4952     // function, instead of leaving it inserted wherever it was first
4953     // referenced.
4954     Function::BasicBlockListType &BBL = 
4955       CurFun.CurrentFunction->getBasicBlockList();
4956     BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
4957   ;
4958     break;}
4959 case 257:
4960 #line 3245 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4962     yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
4963     // Make sure to move the basic block to the correct location in the
4964     // function, instead of leaving it inserted wherever it was first
4965     // referenced.
4966     Function::BasicBlockListType &BBL = 
4967       CurFun.CurrentFunction->getBasicBlockList();
4968     BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
4969   ;
4970     break;}
4971 case 260:
4972 #line 3259 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4973 {              // Return with a result...
4974     yyval.TermInstVal.TI = new ReturnInst(yyvsp[0].ValueVal.V);
4975     yyval.TermInstVal.S.makeSignless();
4976   ;
4977     break;}
4978 case 261:
4979 #line 3263 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4980 {                                       // Return with no result...
4981     yyval.TermInstVal.TI = new ReturnInst();
4982     yyval.TermInstVal.S.makeSignless();
4983   ;
4984     break;}
4985 case 262:
4986 #line 3267 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4987 {                         // Unconditional Branch...
4988     BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4989     yyval.TermInstVal.TI = new BranchInst(tmpBB);
4990     yyval.TermInstVal.S.makeSignless();
4991   ;
4992     break;}
4993 case 263:
4994 #line 3272 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
4995 {  
4996     yyvsp[-3].ValIDVal.S.makeSignless();
4997     yyvsp[0].ValIDVal.S.makeSignless();
4998     BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4999     BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
5000     yyvsp[-6].ValIDVal.S.makeUnsigned();
5001     Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
5002     yyval.TermInstVal.TI = new BranchInst(tmpBBA, tmpBBB, tmpVal);
5003     yyval.TermInstVal.S.makeSignless();
5004   ;
5005     break;}
5006 case 264:
5007 #line 3282 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5009     yyvsp[-6].ValIDVal.S.copy(yyvsp[-7].PrimType.S);
5010     Value* tmpVal = getVal(yyvsp[-7].PrimType.T, yyvsp[-6].ValIDVal);
5011     yyvsp[-3].ValIDVal.S.makeSignless();
5012     BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
5013     SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
5014     yyval.TermInstVal.TI = S;
5015     yyval.TermInstVal.S.makeSignless();
5016     std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
5017       E = yyvsp[-1].JumpTable->end();
5018     for (; I != E; ++I) {
5019       if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
5020           S->addCase(CI, I->second);
5021       else
5022         error("Switch case is constant, but not a simple integer");
5023     }
5024     delete yyvsp[-1].JumpTable;
5025   ;
5026     break;}
5027 case 265:
5028 #line 3300 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5030     yyvsp[-5].ValIDVal.S.copy(yyvsp[-6].PrimType.S);
5031     Value* tmpVal = getVal(yyvsp[-6].PrimType.T, yyvsp[-5].ValIDVal);
5032     yyvsp[-2].ValIDVal.S.makeSignless();
5033     BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
5034     SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
5035     yyval.TermInstVal.TI = S;
5036     yyval.TermInstVal.S.makeSignless();
5037   ;
5038     break;}
5039 case 266:
5040 #line 3310 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5042     const PointerType *PFTy;
5043     const FunctionType *Ty;
5044     Signedness FTySign;
5046     if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal.PAT->get())) ||
5047         !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5048       // Pull out the types of all of the arguments...
5049       std::vector<const Type*> ParamTypes;
5050       FTySign.makeComposite(yyvsp[-10].TypeVal.S);
5051       if (yyvsp[-7].ValueList) {
5052         for (std::vector<ValueInfo>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
5053              I != E; ++I) {
5054           ParamTypes.push_back((*I).V->getType());
5055           FTySign.add(I->S);
5056         }
5057       }
5058       ParamAttrsList *PAL = 0;
5059       if (yyvsp[-11].UIntVal == OldCallingConv::CSRet) {
5060         ParamAttrsVector Attrs;
5061         ParamAttrsWithIndex PAWI;
5062         PAWI.index = 1;  PAWI.attrs = ParamAttr::StructRet; // first arg
5063         Attrs.push_back(PAWI);
5064         PAL = ParamAttrsList::get(Attrs);
5065       }
5066       bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5067       if (isVarArg) ParamTypes.pop_back();
5068       Ty = FunctionType::get(yyvsp[-10].TypeVal.PAT->get(), ParamTypes, isVarArg, PAL);
5069       PFTy = PointerType::get(Ty);
5070       yyval.TermInstVal.S.copy(yyvsp[-10].TypeVal.S);
5071     } else {
5072       FTySign = yyvsp[-10].TypeVal.S;
5073       // Get the signedness of the result type. $3 is the pointer to the
5074       // function type so we get the 0th element to extract the function type,
5075       // and then the 0th element again to get the result type.
5076       yyval.TermInstVal.S.copy(yyvsp[-10].TypeVal.S.get(0).get(0)); 
5077     }
5079     yyvsp[-9].ValIDVal.S.makeComposite(FTySign);
5080     Value *V = getVal(PFTy, yyvsp[-9].ValIDVal);   // Get the function we're calling...
5081     BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
5082     BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
5084     // Create the call node...
5085     if (!yyvsp[-7].ValueList) {                                   // Has no arguments?
5086       std::vector<Value*> Args;
5087       yyval.TermInstVal.TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
5088     } else {                                     // Has arguments?
5089       // Loop through FunctionType's arguments and ensure they are specified
5090       // correctly!
5091       //
5092       FunctionType::param_iterator I = Ty->param_begin();
5093       FunctionType::param_iterator E = Ty->param_end();
5094       std::vector<ValueInfo>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
5096       std::vector<Value*> Args;
5097       for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
5098         if ((*ArgI).V->getType() != *I)
5099           error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5100                 (*I)->getDescription() + "'");
5101         Args.push_back((*ArgI).V);
5102       }
5104       if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
5105         error("Invalid number of parameters detected");
5107       yyval.TermInstVal.TI = new InvokeInst(V, Normal, Except, Args.begin(), Args.end());
5108     }
5109     cast<InvokeInst>(yyval.TermInstVal.TI)->setCallingConv(upgradeCallingConv(yyvsp[-11].UIntVal));
5110     delete yyvsp[-10].TypeVal.PAT;
5111     delete yyvsp[-7].ValueList;
5112     lastCallingConv = OldCallingConv::C;
5113   ;
5114     break;}
5115 case 267:
5116 #line 3383 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5118     yyval.TermInstVal.TI = new UnwindInst();
5119     yyval.TermInstVal.S.makeSignless();
5120   ;
5121     break;}
5122 case 268:
5123 #line 3387 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5125     yyval.TermInstVal.TI = new UnreachableInst();
5126     yyval.TermInstVal.S.makeSignless();
5127   ;
5128     break;}
5129 case 269:
5130 #line 3394 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5132     yyval.JumpTable = yyvsp[-5].JumpTable;
5133     yyvsp[-3].ValIDVal.S.copy(yyvsp[-4].PrimType.S);
5134     Constant *V = cast<Constant>(getExistingValue(yyvsp[-4].PrimType.T, yyvsp[-3].ValIDVal));
5135     
5136     if (V == 0)
5137       error("May only switch on a constant pool value");
5139     yyvsp[0].ValIDVal.S.makeSignless();
5140     BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
5141     yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
5142   ;
5143     break;}
5144 case 270:
5145 #line 3406 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5147     yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
5148     yyvsp[-3].ValIDVal.S.copy(yyvsp[-4].PrimType.S);
5149     Constant *V = cast<Constant>(getExistingValue(yyvsp[-4].PrimType.T, yyvsp[-3].ValIDVal));
5151     if (V == 0)
5152       error("May only switch on a constant pool value");
5154     yyvsp[0].ValIDVal.S.makeSignless();
5155     BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
5156     yyval.JumpTable->push_back(std::make_pair(V, tmpBB)); 
5157   ;
5158     break;}
5159 case 271:
5160 #line 3421 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5162     bool omit = false;
5163     if (yyvsp[-1].StrVal)
5164       if (BitCastInst *BCI = dyn_cast<BitCastInst>(yyvsp[0].InstVal.I))
5165         if (BCI->getSrcTy() == BCI->getDestTy() && 
5166             BCI->getOperand(0)->getName() == yyvsp[-1].StrVal)
5167           // This is a useless bit cast causing a name redefinition. It is
5168           // a bit cast from a type to the same type of an operand with the
5169           // same name as the name we would give this instruction. Since this
5170           // instruction results in no code generation, it is safe to omit
5171           // the instruction. This situation can occur because of collapsed
5172           // type planes. For example:
5173           //   %X = add int %Y, %Z
5174           //   %X = cast int %Y to uint
5175           // After upgrade, this looks like:
5176           //   %X = add i32 %Y, %Z
5177           //   %X = bitcast i32 to i32
5178           // The bitcast is clearly useless so we omit it.
5179           omit = true;
5180     if (omit) {
5181       yyval.InstVal.I = 0;
5182       yyval.InstVal.S.makeSignless();
5183     } else {
5184       ValueInfo VI; VI.V = yyvsp[0].InstVal.I; VI.S.copy(yyvsp[0].InstVal.S);
5185       setValueName(VI, yyvsp[-1].StrVal);
5186       InsertValue(yyvsp[0].InstVal.I);
5187       yyval.InstVal = yyvsp[0].InstVal;
5188     }
5189   ;
5190     break;}
5191 case 272:
5192 #line 3451 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5193 {    // Used for PHI nodes
5194     yyval.PHIList.P = new std::list<std::pair<Value*, BasicBlock*> >();
5195     yyval.PHIList.S.copy(yyvsp[-5].TypeVal.S);
5196     yyvsp[-3].ValIDVal.S.copy(yyvsp[-5].TypeVal.S);
5197     Value* tmpVal = getVal(yyvsp[-5].TypeVal.PAT->get(), yyvsp[-3].ValIDVal);
5198     yyvsp[-1].ValIDVal.S.makeSignless();
5199     BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
5200     yyval.PHIList.P->push_back(std::make_pair(tmpVal, tmpBB));
5201     delete yyvsp[-5].TypeVal.PAT;
5202   ;
5203     break;}
5204 case 273:
5205 #line 3461 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5207     yyval.PHIList = yyvsp[-6].PHIList;
5208     yyvsp[-3].ValIDVal.S.copy(yyvsp[-6].PHIList.S);
5209     Value* tmpVal = getVal(yyvsp[-6].PHIList.P->front().first->getType(), yyvsp[-3].ValIDVal);
5210     yyvsp[-1].ValIDVal.S.makeSignless();
5211     BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
5212     yyvsp[-6].PHIList.P->push_back(std::make_pair(tmpVal, tmpBB));
5213   ;
5214     break;}
5215 case 274:
5216 #line 3471 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5217 {    // Used for call statements, and memory insts...
5218     yyval.ValueList = new std::vector<ValueInfo>();
5219     yyval.ValueList->push_back(yyvsp[0].ValueVal);
5220   ;
5221     break;}
5222 case 275:
5223 #line 3475 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5225     yyval.ValueList = yyvsp[-2].ValueList;
5226     yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
5227   ;
5228     break;}
5229 case 277:
5230 #line 3483 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5231 { yyval.ValueList = 0; ;
5232     break;}
5233 case 278:
5234 #line 3487 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5236     yyval.BoolVal = true;
5237   ;
5238     break;}
5239 case 279:
5240 #line 3490 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5242     yyval.BoolVal = false;
5243   ;
5244     break;}
5245 case 280:
5246 #line 3496 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5248     yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S);
5249     yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S);
5250     const Type* Ty = yyvsp[-3].TypeVal.PAT->get();
5251     if (!Ty->isInteger() && !Ty->isFloatingPoint() && !isa<VectorType>(Ty))
5252       error("Arithmetic operator requires integer, FP, or packed operands");
5253     if (isa<VectorType>(Ty) && 
5254         (yyvsp[-4].BinaryOpVal == URemOp || yyvsp[-4].BinaryOpVal == SRemOp || yyvsp[-4].BinaryOpVal == FRemOp || yyvsp[-4].BinaryOpVal == RemOp))
5255       error("Remainder not supported on vector types");
5256     // Upgrade the opcode from obsolete versions before we do anything with it.
5257     Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-4].BinaryOpVal, Ty, yyvsp[-3].TypeVal.S);
5258     Value* val1 = getVal(Ty, yyvsp[-2].ValIDVal); 
5259     Value* val2 = getVal(Ty, yyvsp[0].ValIDVal);
5260     yyval.InstVal.I = BinaryOperator::create(Opcode, val1, val2);
5261     if (yyval.InstVal.I == 0)
5262       error("binary operator returned null");
5263     yyval.InstVal.S.copy(yyvsp[-3].TypeVal.S);
5264     delete yyvsp[-3].TypeVal.PAT;
5265   ;
5266     break;}
5267 case 281:
5268 #line 3515 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5270     yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S);
5271     yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S);
5272     const Type *Ty = yyvsp[-3].TypeVal.PAT->get();
5273     if (!Ty->isInteger()) {
5274       if (!isa<VectorType>(Ty) ||
5275           !cast<VectorType>(Ty)->getElementType()->isInteger())
5276         error("Logical operator requires integral operands");
5277     }
5278     Instruction::BinaryOps Opcode = getBinaryOp(yyvsp[-4].BinaryOpVal, Ty, yyvsp[-3].TypeVal.S);
5279     Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal);
5280     Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal);
5281     yyval.InstVal.I = BinaryOperator::create(Opcode, tmpVal1, tmpVal2);
5282     if (yyval.InstVal.I == 0)
5283       error("binary operator returned null");
5284     yyval.InstVal.S.copy(yyvsp[-3].TypeVal.S);
5285     delete yyvsp[-3].TypeVal.PAT;
5286   ;
5287     break;}
5288 case 282:
5289 #line 3533 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5291     yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S);
5292     yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S);
5293     const Type* Ty = yyvsp[-3].TypeVal.PAT->get();
5294     if(isa<VectorType>(Ty))
5295       error("VectorTypes currently not supported in setcc instructions");
5296     unsigned short pred;
5297     Instruction::OtherOps Opcode = getCompareOp(yyvsp[-4].BinaryOpVal, pred, Ty, yyvsp[-3].TypeVal.S);
5298     Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal);
5299     Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal);
5300     yyval.InstVal.I = CmpInst::create(Opcode, pred, tmpVal1, tmpVal2);
5301     if (yyval.InstVal.I == 0)
5302       error("binary operator returned null");
5303     yyval.InstVal.S.makeUnsigned();
5304     delete yyvsp[-3].TypeVal.PAT;
5305   ;
5306     break;}
5307 case 283:
5308 #line 3549 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5310     yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S);
5311     yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S);
5312     const Type *Ty = yyvsp[-3].TypeVal.PAT->get();
5313     if (isa<VectorType>(Ty)) 
5314       error("VectorTypes currently not supported in icmp instructions");
5315     else if (!Ty->isInteger() && !isa<PointerType>(Ty))
5316       error("icmp requires integer or pointer typed operands");
5317     Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal);
5318     Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal);
5319     yyval.InstVal.I = new ICmpInst(yyvsp[-4].IPred, tmpVal1, tmpVal2);
5320     yyval.InstVal.S.makeUnsigned();
5321     delete yyvsp[-3].TypeVal.PAT;
5322   ;
5323     break;}
5324 case 284:
5325 #line 3563 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5327     yyvsp[-2].ValIDVal.S.copy(yyvsp[-3].TypeVal.S);
5328     yyvsp[0].ValIDVal.S.copy(yyvsp[-3].TypeVal.S);
5329     const Type *Ty = yyvsp[-3].TypeVal.PAT->get();
5330     if (isa<VectorType>(Ty))
5331       error("VectorTypes currently not supported in fcmp instructions");
5332     else if (!Ty->isFloatingPoint())
5333       error("fcmp instruction requires floating point operands");
5334     Value* tmpVal1 = getVal(Ty, yyvsp[-2].ValIDVal);
5335     Value* tmpVal2 = getVal(Ty, yyvsp[0].ValIDVal);
5336     yyval.InstVal.I = new FCmpInst(yyvsp[-4].FPred, tmpVal1, tmpVal2);
5337     yyval.InstVal.S.makeUnsigned();
5338     delete yyvsp[-3].TypeVal.PAT;
5339   ;
5340     break;}
5341 case 285:
5342 #line 3577 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5344     warning("Use of obsolete 'not' instruction: Replacing with 'xor");
5345     const Type *Ty = yyvsp[0].ValueVal.V->getType();
5346     Value *Ones = ConstantInt::getAllOnesValue(Ty);
5347     if (Ones == 0)
5348       error("Expected integral type for not instruction");
5349     yyval.InstVal.I = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal.V, Ones);
5350     if (yyval.InstVal.I == 0)
5351       error("Could not create a xor instruction");
5352     yyval.InstVal.S.copy(yyvsp[0].ValueVal.S);
5353   ;
5354     break;}
5355 case 286:
5356 #line 3588 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5358     if (!yyvsp[0].ValueVal.V->getType()->isInteger() ||
5359         cast<IntegerType>(yyvsp[0].ValueVal.V->getType())->getBitWidth() != 8)
5360       error("Shift amount must be int8");
5361     const Type* Ty = yyvsp[-2].ValueVal.V->getType();
5362     if (!Ty->isInteger())
5363       error("Shift constant expression requires integer operand");
5364     Value* ShiftAmt = 0;
5365     if (cast<IntegerType>(Ty)->getBitWidth() > Type::Int8Ty->getBitWidth())
5366       if (Constant *C = dyn_cast<Constant>(yyvsp[0].ValueVal.V))
5367         ShiftAmt = ConstantExpr::getZExt(C, Ty);
5368       else
5369         ShiftAmt = new ZExtInst(yyvsp[0].ValueVal.V, Ty, makeNameUnique("shift"), CurBB);
5370     else
5371       ShiftAmt = yyvsp[0].ValueVal.V;
5372     yyval.InstVal.I = BinaryOperator::create(getBinaryOp(yyvsp[-3].BinaryOpVal, Ty, yyvsp[-2].ValueVal.S), yyvsp[-2].ValueVal.V, ShiftAmt);
5373     yyval.InstVal.S.copy(yyvsp[-2].ValueVal.S);
5374   ;
5375     break;}
5376 case 287:
5377 #line 3606 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5379     const Type *DstTy = yyvsp[0].TypeVal.PAT->get();
5380     if (!DstTy->isFirstClassType())
5381       error("cast instruction to a non-primitive type: '" +
5382             DstTy->getDescription() + "'");
5383     yyval.InstVal.I = cast<Instruction>(getCast(yyvsp[-3].CastOpVal, yyvsp[-2].ValueVal.V, yyvsp[-2].ValueVal.S, DstTy, yyvsp[0].TypeVal.S, true));
5384     yyval.InstVal.S.copy(yyvsp[0].TypeVal.S);
5385     delete yyvsp[0].TypeVal.PAT;
5386   ;
5387     break;}
5388 case 288:
5389 #line 3615 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5391     if (!yyvsp[-4].ValueVal.V->getType()->isInteger() ||
5392         cast<IntegerType>(yyvsp[-4].ValueVal.V->getType())->getBitWidth() != 1)
5393       error("select condition must be bool");
5394     if (yyvsp[-2].ValueVal.V->getType() != yyvsp[0].ValueVal.V->getType())
5395       error("select value types should match");
5396     yyval.InstVal.I = new SelectInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V);
5397     yyval.InstVal.S.copy(yyvsp[-2].ValueVal.S);
5398   ;
5399     break;}
5400 case 289:
5401 #line 3624 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5403     const Type *Ty = yyvsp[0].TypeVal.PAT->get();
5404     NewVarArgs = true;
5405     yyval.InstVal.I = new VAArgInst(yyvsp[-2].ValueVal.V, Ty);
5406     yyval.InstVal.S.copy(yyvsp[0].TypeVal.S);
5407     delete yyvsp[0].TypeVal.PAT;
5408   ;
5409     break;}
5410 case 290:
5411 #line 3631 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5413     const Type* ArgTy = yyvsp[-2].ValueVal.V->getType();
5414     const Type* DstTy = yyvsp[0].TypeVal.PAT->get();
5415     ObsoleteVarArgs = true;
5416     Function* NF = cast<Function>(CurModule.CurrentModule->
5417       getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5419     //b = vaarg a, t -> 
5420     //foo = alloca 1 of t
5421     //bar = vacopy a 
5422     //store bar -> foo
5423     //b = vaarg foo, t
5424     AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5425     CurBB->getInstList().push_back(foo);
5426     CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal.V);
5427     CurBB->getInstList().push_back(bar);
5428     CurBB->getInstList().push_back(new StoreInst(bar, foo));
5429     yyval.InstVal.I = new VAArgInst(foo, DstTy);
5430     yyval.InstVal.S.copy(yyvsp[0].TypeVal.S);
5431     delete yyvsp[0].TypeVal.PAT;
5432   ;
5433     break;}
5434 case 291:
5435 #line 3652 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5437     const Type* ArgTy = yyvsp[-2].ValueVal.V->getType();
5438     const Type* DstTy = yyvsp[0].TypeVal.PAT->get();
5439     ObsoleteVarArgs = true;
5440     Function* NF = cast<Function>(CurModule.CurrentModule->
5441       getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0));
5443     //b = vanext a, t ->
5444     //foo = alloca 1 of t
5445     //bar = vacopy a
5446     //store bar -> foo
5447     //tmp = vaarg foo, t
5448     //b = load foo
5449     AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5450     CurBB->getInstList().push_back(foo);
5451     CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal.V);
5452     CurBB->getInstList().push_back(bar);
5453     CurBB->getInstList().push_back(new StoreInst(bar, foo));
5454     Instruction* tmp = new VAArgInst(foo, DstTy);
5455     CurBB->getInstList().push_back(tmp);
5456     yyval.InstVal.I = new LoadInst(foo);
5457     yyval.InstVal.S.copy(yyvsp[0].TypeVal.S);
5458     delete yyvsp[0].TypeVal.PAT;
5459   ;
5460     break;}
5461 case 292:
5462 #line 3676 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5464     if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V))
5465       error("Invalid extractelement operands");
5466     yyval.InstVal.I = new ExtractElementInst(yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V);
5467     yyval.InstVal.S.copy(yyvsp[-2].ValueVal.S.get(0));
5468   ;
5469     break;}
5470 case 293:
5471 #line 3682 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5473     if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V))
5474       error("Invalid insertelement operands");
5475     yyval.InstVal.I = new InsertElementInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V);
5476     yyval.InstVal.S.copy(yyvsp[-4].ValueVal.S);
5477   ;
5478     break;}
5479 case 294:
5480 #line 3688 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5482     if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V))
5483       error("Invalid shufflevector operands");
5484     yyval.InstVal.I = new ShuffleVectorInst(yyvsp[-4].ValueVal.V, yyvsp[-2].ValueVal.V, yyvsp[0].ValueVal.V);
5485     yyval.InstVal.S.copy(yyvsp[-4].ValueVal.S);
5486   ;
5487     break;}
5488 case 295:
5489 #line 3694 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5491     const Type *Ty = yyvsp[0].PHIList.P->front().first->getType();
5492     if (!Ty->isFirstClassType())
5493       error("PHI node operands must be of first class type");
5494     PHINode *PHI = new PHINode(Ty);
5495     PHI->reserveOperandSpace(yyvsp[0].PHIList.P->size());
5496     while (yyvsp[0].PHIList.P->begin() != yyvsp[0].PHIList.P->end()) {
5497       if (yyvsp[0].PHIList.P->front().first->getType() != Ty) 
5498         error("All elements of a PHI node must be of the same type");
5499       PHI->addIncoming(yyvsp[0].PHIList.P->front().first, yyvsp[0].PHIList.P->front().second);
5500       yyvsp[0].PHIList.P->pop_front();
5501     }
5502     yyval.InstVal.I = PHI;
5503     yyval.InstVal.S.copy(yyvsp[0].PHIList.S);
5504     delete yyvsp[0].PHIList.P;  // Free the list...
5505   ;
5506     break;}
5507 case 296:
5508 #line 3710 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5510     // Handle the short call syntax
5511     const PointerType *PFTy;
5512     const FunctionType *FTy;
5513     Signedness FTySign;
5514     if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal.PAT->get())) ||
5515         !(FTy = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5516       // Pull out the types of all of the arguments...
5517       std::vector<const Type*> ParamTypes;
5518       FTySign.makeComposite(yyvsp[-4].TypeVal.S);
5519       if (yyvsp[-1].ValueList) {
5520         for (std::vector<ValueInfo>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
5521              I != E; ++I) {
5522           ParamTypes.push_back((*I).V->getType());
5523           FTySign.add(I->S);
5524         }
5525       }
5527       bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5528       if (isVarArg) ParamTypes.pop_back();
5530       const Type *RetTy = yyvsp[-4].TypeVal.PAT->get();
5531       if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
5532         error("Functions cannot return aggregate types");
5534       // Deal with CSRetCC
5535       ParamAttrsList *PAL = 0;
5536       if (yyvsp[-5].UIntVal == OldCallingConv::CSRet) {
5537         ParamAttrsVector Attrs;
5538         ParamAttrsWithIndex PAWI;
5539         PAWI.index = 1;  PAWI.attrs = ParamAttr::StructRet; // first arg
5540         Attrs.push_back(PAWI);
5541         PAL = ParamAttrsList::get(Attrs);
5542       }
5544       FTy = FunctionType::get(RetTy, ParamTypes, isVarArg, PAL);
5545       PFTy = PointerType::get(FTy);
5546       yyval.InstVal.S.copy(yyvsp[-4].TypeVal.S);
5547     } else {
5548       FTySign = yyvsp[-4].TypeVal.S;
5549       // Get the signedness of the result type. $3 is the pointer to the
5550       // function type so we get the 0th element to extract the function type,
5551       // and then the 0th element again to get the result type.
5552       yyval.InstVal.S.copy(yyvsp[-4].TypeVal.S.get(0).get(0)); 
5553     }
5554     yyvsp[-3].ValIDVal.S.makeComposite(FTySign);
5556     // First upgrade any intrinsic calls.
5557     std::vector<Value*> Args;
5558     if (yyvsp[-1].ValueList)
5559       for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i < e; ++i) 
5560         Args.push_back((*yyvsp[-1].ValueList)[i].V);
5561     Instruction *Inst = upgradeIntrinsicCall(FTy->getReturnType(), yyvsp[-3].ValIDVal, Args);
5563     // If we got an upgraded intrinsic
5564     if (Inst) {
5565       yyval.InstVal.I = Inst;
5566     } else {
5567       // Get the function we're calling
5568       Value *V = getVal(PFTy, yyvsp[-3].ValIDVal);
5570       // Check the argument values match
5571       if (!yyvsp[-1].ValueList) {                                   // Has no arguments?
5572         // Make sure no arguments is a good thing!
5573         if (FTy->getNumParams() != 0)
5574           error("No arguments passed to a function that expects arguments");
5575       } else {                                     // Has arguments?
5576         // Loop through FunctionType's arguments and ensure they are specified
5577         // correctly!
5578         //
5579         FunctionType::param_iterator I = FTy->param_begin();
5580         FunctionType::param_iterator E = FTy->param_end();
5581         std::vector<ValueInfo>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
5583         for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5584           if ((*ArgI).V->getType() != *I)
5585             error("Parameter " +(*ArgI).V->getName()+ " is not of type '" +
5586                   (*I)->getDescription() + "'");
5588         if (I != E || (ArgI != ArgE && !FTy->isVarArg()))
5589           error("Invalid number of parameters detected");
5590       }
5592       // Create the call instruction
5593       CallInst *CI = new CallInst(V, Args.begin(), Args.end());
5594       CI->setTailCall(yyvsp[-6].BoolVal);
5595       CI->setCallingConv(upgradeCallingConv(yyvsp[-5].UIntVal));
5596       yyval.InstVal.I = CI;
5597     }
5598     delete yyvsp[-4].TypeVal.PAT;
5599     delete yyvsp[-1].ValueList;
5600     lastCallingConv = OldCallingConv::C;
5601   ;
5602     break;}
5603 case 297:
5604 #line 3803 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5606     yyval.InstVal = yyvsp[0].InstVal;
5607   ;
5608     break;}
5609 case 298:
5610 #line 3811 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5611 { yyval.ValueList = yyvsp[0].ValueList; ;
5612     break;}
5613 case 299:
5614 #line 3812 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5615 { yyval.ValueList = new std::vector<ValueInfo>(); ;
5616     break;}
5617 case 300:
5618 #line 3816 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5619 { yyval.BoolVal = true; ;
5620     break;}
5621 case 301:
5622 #line 3817 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5623 { yyval.BoolVal = false; ;
5624     break;}
5625 case 302:
5626 #line 3821 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5628     const Type *Ty = yyvsp[-1].TypeVal.PAT->get();
5629     yyval.InstVal.S.makeComposite(yyvsp[-1].TypeVal.S);
5630     yyval.InstVal.I = new MallocInst(Ty, 0, yyvsp[0].UIntVal);
5631     delete yyvsp[-1].TypeVal.PAT;
5632   ;
5633     break;}
5634 case 303:
5635 #line 3827 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5637     const Type *Ty = yyvsp[-4].TypeVal.PAT->get();
5638     yyvsp[-1].ValIDVal.S.makeUnsigned();
5639     yyval.InstVal.S.makeComposite(yyvsp[-4].TypeVal.S);
5640     yyval.InstVal.I = new MallocInst(Ty, getVal(yyvsp[-2].PrimType.T, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
5641     delete yyvsp[-4].TypeVal.PAT;
5642   ;
5643     break;}
5644 case 304:
5645 #line 3834 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5647     const Type *Ty = yyvsp[-1].TypeVal.PAT->get();
5648     yyval.InstVal.S.makeComposite(yyvsp[-1].TypeVal.S);
5649     yyval.InstVal.I = new AllocaInst(Ty, 0, yyvsp[0].UIntVal);
5650     delete yyvsp[-1].TypeVal.PAT;
5651   ;
5652     break;}
5653 case 305:
5654 #line 3840 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5656     const Type *Ty = yyvsp[-4].TypeVal.PAT->get();
5657     yyvsp[-1].ValIDVal.S.makeUnsigned();
5658     yyval.InstVal.S.makeComposite(yyvsp[-2].PrimType.S);
5659     yyval.InstVal.I = new AllocaInst(Ty, getVal(yyvsp[-2].PrimType.T, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal);
5660     delete yyvsp[-4].TypeVal.PAT;
5661   ;
5662     break;}
5663 case 306:
5664 #line 3847 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5666     const Type *PTy = yyvsp[0].ValueVal.V->getType();
5667     if (!isa<PointerType>(PTy))
5668       error("Trying to free nonpointer type '" + PTy->getDescription() + "'");
5669     yyval.InstVal.I = new FreeInst(yyvsp[0].ValueVal.V);
5670     yyval.InstVal.S.makeSignless();
5671   ;
5672     break;}
5673 case 307:
5674 #line 3854 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5676     const Type* Ty = yyvsp[-1].TypeVal.PAT->get();
5677     yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S);
5678     if (!isa<PointerType>(Ty))
5679       error("Can't load from nonpointer type: " + Ty->getDescription());
5680     if (!cast<PointerType>(Ty)->getElementType()->isFirstClassType())
5681       error("Can't load from pointer of non-first-class type: " +
5682                      Ty->getDescription());
5683     Value* tmpVal = getVal(Ty, yyvsp[0].ValIDVal);
5684     yyval.InstVal.I = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal);
5685     yyval.InstVal.S.copy(yyvsp[-1].TypeVal.S.get(0));
5686     delete yyvsp[-1].TypeVal.PAT;
5687   ;
5688     break;}
5689 case 308:
5690 #line 3867 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5692     yyvsp[0].ValIDVal.S.copy(yyvsp[-1].TypeVal.S);
5693     const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal.PAT->get());
5694     if (!PTy)
5695       error("Can't store to a nonpointer type: " + 
5696              yyvsp[-1].TypeVal.PAT->get()->getDescription());
5697     const Type *ElTy = PTy->getElementType();
5698     Value *StoreVal = yyvsp[-3].ValueVal.V;
5699     Value* tmpVal = getVal(PTy, yyvsp[0].ValIDVal);
5700     if (ElTy != yyvsp[-3].ValueVal.V->getType()) {
5701       StoreVal = handleSRetFuncTypeMerge(yyvsp[-3].ValueVal.V, ElTy);
5702       if (!StoreVal)
5703         error("Can't store '" + yyvsp[-3].ValueVal.V->getType()->getDescription() +
5704               "' into space of type '" + ElTy->getDescription() + "'");
5705       else {
5706         PTy = PointerType::get(StoreVal->getType());
5707         if (Constant *C = dyn_cast<Constant>(tmpVal))
5708           tmpVal = ConstantExpr::getBitCast(C, PTy);
5709         else
5710           tmpVal = new BitCastInst(tmpVal, PTy, "upgrd.cast", CurBB);
5711       }
5712     }
5713     yyval.InstVal.I = new StoreInst(StoreVal, tmpVal, yyvsp[-5].BoolVal);
5714     yyval.InstVal.S.makeSignless();
5715     delete yyvsp[-1].TypeVal.PAT;
5716   ;
5717     break;}
5718 case 309:
5719 #line 3893 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5721     yyvsp[-1].ValIDVal.S.copy(yyvsp[-2].TypeVal.S);
5722     const Type* Ty = yyvsp[-2].TypeVal.PAT->get();
5723     if (!isa<PointerType>(Ty))
5724       error("getelementptr insn requires pointer operand");
5726     std::vector<Value*> VIndices;
5727     upgradeGEPInstIndices(Ty, yyvsp[0].ValueList, VIndices);
5729     Value* tmpVal = getVal(Ty, yyvsp[-1].ValIDVal);
5730     yyval.InstVal.I = new GetElementPtrInst(tmpVal, VIndices.begin(), VIndices.end());
5731     ValueInfo VI; VI.V = tmpVal; VI.S.copy(yyvsp[-2].TypeVal.S);
5732     yyval.InstVal.S.copy(getElementSign(VI, VIndices));
5733     delete yyvsp[-2].TypeVal.PAT;
5734     delete yyvsp[0].ValueList;
5735   ;
5736     break;}
5738    /* the action file gets copied in in place of this dollarsign */
5739 #line 543 "/usr/share/bison.simple"
5741   yyvsp -= yylen;
5742   yyssp -= yylen;
5743 #ifdef YYLSP_NEEDED
5744   yylsp -= yylen;
5745 #endif
5747 #if YYDEBUG != 0
5748   if (yydebug)
5749     {
5750       short *ssp1 = yyss - 1;
5751       fprintf (stderr, "state stack now");
5752       while (ssp1 != yyssp)
5753         fprintf (stderr, " %d", *++ssp1);
5754       fprintf (stderr, "\n");
5755     }
5756 #endif
5758   *++yyvsp = yyval;
5760 #ifdef YYLSP_NEEDED
5761   yylsp++;
5762   if (yylen == 0)
5763     {
5764       yylsp->first_line = yylloc.first_line;
5765       yylsp->first_column = yylloc.first_column;
5766       yylsp->last_line = (yylsp-1)->last_line;
5767       yylsp->last_column = (yylsp-1)->last_column;
5768       yylsp->text = 0;
5769     }
5770   else
5771     {
5772       yylsp->last_line = (yylsp+yylen-1)->last_line;
5773       yylsp->last_column = (yylsp+yylen-1)->last_column;
5774     }
5775 #endif
5777   /* Now "shift" the result of the reduction.
5778      Determine what state that goes to,
5779      based on the state we popped back to
5780      and the rule number reduced by.  */
5782   yyn = yyr1[yyn];
5784   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5785   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
5786     yystate = yytable[yystate];
5787   else
5788     yystate = yydefgoto[yyn - YYNTBASE];
5790   goto yynewstate;
5792 yyerrlab:   /* here on detecting error */
5794   if (! yyerrstatus)
5795     /* If not already recovering from an error, report this error.  */
5796     {
5797       ++yynerrs;
5799 #ifdef YYERROR_VERBOSE
5800       yyn = yypact[yystate];
5802       if (yyn > YYFLAG && yyn < YYLAST)
5803         {
5804           int size = 0;
5805           char *msg;
5806           int x, count;
5808           count = 0;
5809           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
5810           for (x = (yyn < 0 ? -yyn : 0);
5811                x < (sizeof(yytname) / sizeof(char *)); x++)
5812             if (yycheck[x + yyn] == x)
5813               size += strlen(yytname[x]) + 15, count++;
5814           msg = (char *) malloc(size + 15);
5815           if (msg != 0)
5816             {
5817               strcpy(msg, "parse error");
5819               if (count < 5)
5820                 {
5821                   count = 0;
5822                   for (x = (yyn < 0 ? -yyn : 0);
5823                        x < (sizeof(yytname) / sizeof(char *)); x++)
5824                     if (yycheck[x + yyn] == x)
5825                       {
5826                         strcat(msg, count == 0 ? ", expecting `" : " or `");
5827                         strcat(msg, yytname[x]);
5828                         strcat(msg, "'");
5829                         count++;
5830                       }
5831                 }
5832               yyerror(msg);
5833               free(msg);
5834             }
5835           else
5836             yyerror ("parse error; also virtual memory exceeded");
5837         }
5838       else
5839 #endif /* YYERROR_VERBOSE */
5840         yyerror("parse error");
5841     }
5843   goto yyerrlab1;
5844 yyerrlab1:   /* here on error raised explicitly by an action */
5846   if (yyerrstatus == 3)
5847     {
5848       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
5850       /* return failure if at end of input */
5851       if (yychar == YYEOF)
5852         YYABORT;
5854 #if YYDEBUG != 0
5855       if (yydebug)
5856         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5857 #endif
5859       yychar = YYEMPTY;
5860     }
5862   /* Else will try to reuse lookahead token
5863      after shifting the error token.  */
5865   yyerrstatus = 3;              /* Each real token shifted decrements this */
5867   goto yyerrhandle;
5869 yyerrdefault:  /* current state does not do anything special for the error token. */
5871 #if 0
5872   /* This is wrong; only states that explicitly want error tokens
5873      should shift them.  */
5874   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
5875   if (yyn) goto yydefault;
5876 #endif
5878 yyerrpop:   /* pop the current state because it cannot handle the error token */
5880   if (yyssp == yyss) YYABORT;
5881   yyvsp--;
5882   yystate = *--yyssp;
5883 #ifdef YYLSP_NEEDED
5884   yylsp--;
5885 #endif
5887 #if YYDEBUG != 0
5888   if (yydebug)
5889     {
5890       short *ssp1 = yyss - 1;
5891       fprintf (stderr, "Error: state stack now");
5892       while (ssp1 != yyssp)
5893         fprintf (stderr, " %d", *++ssp1);
5894       fprintf (stderr, "\n");
5895     }
5896 #endif
5898 yyerrhandle:
5900   yyn = yypact[yystate];
5901   if (yyn == YYFLAG)
5902     goto yyerrdefault;
5904   yyn += YYTERROR;
5905   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5906     goto yyerrdefault;
5908   yyn = yytable[yyn];
5909   if (yyn < 0)
5910     {
5911       if (yyn == YYFLAG)
5912         goto yyerrpop;
5913       yyn = -yyn;
5914       goto yyreduce;
5915     }
5916   else if (yyn == 0)
5917     goto yyerrpop;
5919   if (yyn == YYFINAL)
5920     YYACCEPT;
5922 #if YYDEBUG != 0
5923   if (yydebug)
5924     fprintf(stderr, "Shifting error token, ");
5925 #endif
5927   *++yyvsp = yylval;
5928 #ifdef YYLSP_NEEDED
5929   *++yylsp = yylloc;
5930 #endif
5932   yystate = yyn;
5933   goto yynewstate;
5935  yyacceptlab:
5936   /* YYACCEPT comes here.  */
5937   if (yyfree_stacks)
5938     {
5939       free (yyss);
5940       free (yyvs);
5941 #ifdef YYLSP_NEEDED
5942       free (yyls);
5943 #endif
5944     }
5945   return 0;
5947  yyabortlab:
5948   /* YYABORT comes here.  */
5949   if (yyfree_stacks)
5950     {
5951       free (yyss);
5952       free (yyvs);
5953 #ifdef YYLSP_NEEDED
5954       free (yyls);
5955 #endif
5956     }
5957   return 1;
5959 #line 3911 "/Volumes/MacOS9/gcc/llvm/tools/llvm-upgrade/UpgradeParser.y"
5962 int yyerror(const char *ErrorMsg) {
5963   std::string where 
5964     = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5965                   + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
5966   std::string errMsg = where + "error: " + std::string(ErrorMsg);
5967   if (yychar != YYEMPTY && yychar != 0)
5968     errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
5969               "'.";
5970   std::cerr << "llvm-upgrade: " << errMsg << '\n';
5971   std::cout << "llvm-upgrade: parse failed.\n";
5972   exit(1);
5975 void warning(const std::string& ErrorMsg) {
5976   std::string where 
5977     = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5978                   + ":" + llvm::utostr((unsigned) Upgradelineno) + ": ";
5979   std::string errMsg = where + "warning: " + std::string(ErrorMsg);
5980   if (yychar != YYEMPTY && yychar != 0)
5981     errMsg += " while reading token '" + std::string(Upgradetext, Upgradeleng) +
5982               "'.";
5983   std::cerr << "llvm-upgrade: " << errMsg << '\n';
5986 void error(const std::string& ErrorMsg, int LineNo) {
5987   if (LineNo == -1) LineNo = Upgradelineno;
5988   Upgradelineno = LineNo;
5989   yyerror(ErrorMsg.c_str());