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