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