Make sure that types go in the constant pool if they are used.
[oota-llvm.git] / lib / AsmParser / llvmAsmParser.cpp
1
2 /*  A Bison parser, made from llvmAsmParser.y
3     by GNU Bison version 1.28  */
4
5 #define YYBISON 1  /* Identify Bison output.  */
6
7 #define yyparse llvmAsmparse
8 #define yylex llvmAsmlex
9 #define yyerror llvmAsmerror
10 #define yylval llvmAsmlval
11 #define yychar llvmAsmchar
12 #define yydebug llvmAsmdebug
13 #define yynerrs llvmAsmnerrs
14 #define ESINT64VAL      257
15 #define EUINT64VAL      258
16 #define SINTVAL 259
17 #define UINTVAL 260
18 #define VOID    261
19 #define BOOL    262
20 #define SBYTE   263
21 #define UBYTE   264
22 #define SHORT   265
23 #define USHORT  266
24 #define INT     267
25 #define UINT    268
26 #define LONG    269
27 #define ULONG   270
28 #define FLOAT   271
29 #define DOUBLE  272
30 #define STRING  273
31 #define TYPE    274
32 #define LABEL   275
33 #define VAR_ID  276
34 #define LABELSTR        277
35 #define STRINGCONSTANT  278
36 #define IMPLEMENTATION  279
37 #define TRUE    280
38 #define FALSE   281
39 #define BEGINTOK        282
40 #define END     283
41 #define DECLARE 284
42 #define TO      285
43 #define RET     286
44 #define BR      287
45 #define SWITCH  288
46 #define NOT     289
47 #define ADD     290
48 #define SUB     291
49 #define MUL     292
50 #define DIV     293
51 #define REM     294
52 #define SETLE   295
53 #define SETGE   296
54 #define SETLT   297
55 #define SETGT   298
56 #define SETEQ   299
57 #define SETNE   300
58 #define MALLOC  301
59 #define ALLOCA  302
60 #define FREE    303
61 #define LOAD    304
62 #define STORE   305
63 #define GETELEMENTPTR   306
64 #define PHI     307
65 #define CALL    308
66 #define CAST    309
67 #define SHL     310
68 #define SHR     311
69
70 #line 13 "llvmAsmParser.y"
71
72 #include "ParserInternals.h"
73 #include "llvm/BasicBlock.h"
74 #include "llvm/Method.h"
75 #include "llvm/SymbolTable.h"
76 #include "llvm/Module.h"
77 #include "llvm/Type.h"
78 #include "llvm/DerivedTypes.h"
79 #include "llvm/Assembly/Parser.h"
80 #include "llvm/ConstantPool.h"
81 #include "llvm/iTerminators.h"
82 #include "llvm/iMemory.h"
83 #include <list>
84 #include <utility>            // Get definition of pair class
85 #include <algorithm>          // Get definition of find_if
86 #include <stdio.h>            // This embarasment is due to our flex lexer...
87
88 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit 
89 int yylex();                       // declaration" of xxx warnings.
90 int yyparse();
91
92 static Module *ParserResult;
93 const ToolCommandLine *CurOptions = 0;
94
95 // This contains info used when building the body of a method.  It is destroyed
96 // when the method is completed.
97 //
98 typedef vector<Value *> ValueList;           // Numbered defs
99 static void ResolveDefinitions(vector<ValueList> &LateResolvers);
100
101 static struct PerModuleInfo {
102   Module *CurrentModule;
103   vector<ValueList> Values;     // Module level numbered definitions
104   vector<ValueList> LateResolveValues;
105
106   void ModuleDone() {
107     // If we could not resolve some blocks at parsing time (forward branches)
108     // resolve the branches now...
109     ResolveDefinitions(LateResolveValues);
110
111     Values.clear();         // Clear out method local definitions
112     CurrentModule = 0;
113   }
114 } CurModule;
115
116 static struct PerMethodInfo {
117   Method *CurrentMethod;         // Pointer to current method being created
118
119   vector<ValueList> Values;          // Keep track of numbered definitions
120   vector<ValueList> LateResolveValues;
121
122   inline PerMethodInfo() {
123     CurrentMethod = 0;
124   }
125
126   inline ~PerMethodInfo() {}
127
128   inline void MethodStart(Method *M) {
129     CurrentMethod = M;
130   }
131
132   void MethodDone() {
133     // If we could not resolve some blocks at parsing time (forward branches)
134     // resolve the branches now...
135     ResolveDefinitions(LateResolveValues);
136
137     Values.clear();         // Clear out method local definitions
138     CurrentMethod = 0;
139   }
140 } CurMeth;  // Info for the current method...
141
142
143 //===----------------------------------------------------------------------===//
144 //               Code to handle definitions of all the types
145 //===----------------------------------------------------------------------===//
146
147 static void InsertValue(Value *D, vector<ValueList> &ValueTab = CurMeth.Values) {
148   if (!D->hasName()) {             // Is this a numbered definition?
149     unsigned type = D->getType()->getUniqueID();
150     if (ValueTab.size() <= type)
151       ValueTab.resize(type+1, ValueList());
152     //printf("Values[%d][%d] = %d\n", type, ValueTab[type].size(), D);
153     ValueTab[type].push_back(D);
154   }
155 }
156
157 static Value *getVal(const Type *Type, ValID &D, 
158                      bool DoNotImprovise = false) {
159   switch (D.Type) {
160   case 0: {                 // Is it a numbered definition?
161     unsigned type = Type->getUniqueID();
162     unsigned Num = (unsigned)D.Num;
163
164     // Module constants occupy the lowest numbered slots...
165     if (type < CurModule.Values.size()) {
166       if (Num < CurModule.Values[type].size()) 
167         return CurModule.Values[type][Num];
168
169       Num -= CurModule.Values[type].size();
170     }
171
172     // Make sure that our type is within bounds
173     if (CurMeth.Values.size() <= type)
174       break;
175
176     // Check that the number is within bounds...
177     if (CurMeth.Values[type].size() <= Num)
178       break;
179   
180     return CurMeth.Values[type][Num];
181   }
182   case 1: {                // Is it a named definition?
183     string Name(D.Name);
184     SymbolTable *SymTab = 0;
185     if (CurMeth.CurrentMethod) 
186       SymTab = CurMeth.CurrentMethod->getSymbolTable();
187     Value *N = SymTab ? SymTab->lookup(Type, Name) : 0;
188
189     if (N == 0) {
190       SymTab = CurModule.CurrentModule->getSymbolTable();
191       if (SymTab)
192         N = SymTab->lookup(Type, Name);
193       if (N == 0) break;
194     }
195
196     D.destroy();  // Free old strdup'd memory...
197     return N;
198   }
199
200   case 2:                 // Is it a constant pool reference??
201   case 3:                 // Is it an unsigned const pool reference?
202   case 4:{                // Is it a string const pool reference?
203     ConstPoolVal *CPV = 0;
204
205     // Check to make sure that "Type" is an integral type, and that our 
206     // value will fit into the specified type...
207     switch (D.Type) {
208     case 2:
209       if (Type == Type::BoolTy) {  // Special handling for boolean data
210         CPV = new ConstPoolBool(D.ConstPool64 != 0);
211       } else {
212         if (!ConstPoolSInt::isValueValidForType(Type, D.ConstPool64))
213           ThrowException("Symbolic constant pool reference is invalid!");
214         CPV = new ConstPoolSInt(Type, D.ConstPool64);
215       }
216       break;
217     case 3:
218       if (!ConstPoolUInt::isValueValidForType(Type, D.UConstPool64)) {
219         if (!ConstPoolSInt::isValueValidForType(Type, D.ConstPool64)) {
220           ThrowException("Symbolic constant pool reference is invalid!");
221         } else {     // This is really a signed reference.  Transmogrify.
222           CPV = new ConstPoolSInt(Type, D.ConstPool64);
223         }
224       } else {
225         CPV = new ConstPoolUInt(Type, D.UConstPool64);
226       }
227       break;
228     case 4:
229       cerr << "FIXME: TODO: String constants [sbyte] not implemented yet!\n";
230       abort();
231       //CPV = new ConstPoolString(D.Name);
232       D.destroy();   // Free the string memory
233       break;
234     }
235     assert(CPV && "How did we escape creating a constant??");
236
237     // Scan through the constant table and see if we already have loaded this
238     // constant.
239     //
240     ConstantPool &CP = CurMeth.CurrentMethod ? 
241                          CurMeth.CurrentMethod->getConstantPool() :
242                            CurModule.CurrentModule->getConstantPool();
243     ConstPoolVal *C = CP.find(CPV);      // Already have this constant?
244     if (C) {
245       delete CPV;  // Didn't need this after all, oh well.
246       return C;    // Yup, we already have one, recycle it!
247     }
248     CP.insert(CPV);
249       
250     // Success, everything is kosher. Lets go!
251     return CPV;
252   }   // End of case 2,3,4
253   }   // End of switch
254
255
256   // If we reached here, we referenced either a symbol that we don't know about
257   // or an id number that hasn't been read yet.  We may be referencing something
258   // forward, so just create an entry to be resolved later and get to it...
259   //
260   if (DoNotImprovise) return 0;  // Do we just want a null to be returned?
261
262   // TODO: Attempt to coallecse nodes that are the same with previous ones.
263   Value *d = 0;
264   switch (Type->getPrimitiveID()) {
265   case Type::LabelTyID: d = new    BBPlaceHolder(Type, D); break;
266   case Type::MethodTyID:
267     d = new MethPlaceHolder(Type, D); 
268     InsertValue(d, CurModule.LateResolveValues);
269     return d;
270 //case Type::ClassTyID:      d = new ClassPlaceHolder(Type, D); break;
271   default:                   d = new   DefPlaceHolder(Type, D); break;
272   }
273
274   assert(d != 0 && "How did we not make something?");
275   InsertValue(d, CurMeth.LateResolveValues);
276   return d;
277 }
278
279
280 //===----------------------------------------------------------------------===//
281 //              Code to handle forward references in instructions
282 //===----------------------------------------------------------------------===//
283 //
284 // This code handles the late binding needed with statements that reference
285 // values not defined yet... for example, a forward branch, or the PHI node for
286 // a loop body.
287 //
288 // This keeps a table (CurMeth.LateResolveValues) of all such forward references
289 // and back patchs after we are done.
290 //
291
292 // ResolveDefinitions - If we could not resolve some defs at parsing 
293 // time (forward branches, phi functions for loops, etc...) resolve the 
294 // defs now...
295 //
296 static void ResolveDefinitions(vector<ValueList> &LateResolvers) {
297   // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
298   for (unsigned ty = 0; ty < LateResolvers.size(); ty++) {
299     while (!LateResolvers[ty].empty()) {
300       Value *V = LateResolvers[ty].back();
301       LateResolvers[ty].pop_back();
302       ValID &DID = getValIDFromPlaceHolder(V);
303
304       Value *TheRealValue = getVal(Type::getUniqueIDType(ty), DID, true);
305
306       if (TheRealValue == 0 && DID.Type == 1)
307         ThrowException("Reference to an invalid definition: '" +DID.getName() +
308                        "' of type '" + V->getType()->getName() + "'");
309       else if (TheRealValue == 0)
310         ThrowException("Reference to an invalid definition: #" +itostr(DID.Num)+
311                        " of type '" + V->getType()->getName() + "'");
312
313       V->replaceAllUsesWith(TheRealValue);
314       assert(V->use_empty());
315       delete V;
316     }
317   }
318
319   LateResolvers.clear();
320 }
321
322 // addConstValToConstantPool - This code is used to insert a constant into the
323 // current constant pool.  This is designed to make maximal (but not more than
324 // possible) reuse (merging) of constants in the constant pool.  This means that
325 // multiple references to %4, for example will all get merged.
326 //
327 static ConstPoolVal *addConstValToConstantPool(ConstPoolVal *C) {
328   vector<ValueList> &ValTab = CurMeth.CurrentMethod ? 
329                                   CurMeth.Values : CurModule.Values;
330   ConstantPool &CP = CurMeth.CurrentMethod ? 
331                           CurMeth.CurrentMethod->getConstantPool() : 
332                           CurModule.CurrentModule->getConstantPool();
333
334   if (ConstPoolVal *CPV = CP.find(C)) {
335     // Constant already in constant pool. Try to merge the two constants
336     if (CPV->hasName() && !C->hasName()) {
337       // Merge the two values, we inherit the existing CPV's name.  
338       // InsertValue requires that the value have no name to insert correctly
339       // (because we want to fill the slot this constant would have filled)
340       //
341       string Name = CPV->getName();
342       CPV->setName("");
343       InsertValue(CPV, ValTab);
344       CPV->setName(Name);
345       delete C;
346       return CPV;
347     } else if (!CPV->hasName() && C->hasName()) {
348       // If we have a name on this value and there isn't one in the const 
349       // pool val already, propogate it.
350       //
351       CPV->setName(C->getName());
352       delete C;   // Sorry, you're toast
353       return CPV;
354     } else if (CPV->hasName() && C->hasName()) {
355       // Both values have distinct names.  We cannot merge them.
356       CP.insert(C);
357       InsertValue(C, ValTab);
358       return C;
359     } else if (!CPV->hasName() && !C->hasName()) {
360       // Neither value has a name, trivially merge them.
361       InsertValue(CPV, ValTab);
362       delete C;
363       return CPV;
364     }
365
366     assert(0 && "Not reached!");
367     return 0;
368   } else {           // No duplication of value.
369     CP.insert(C);
370     InsertValue(C, ValTab);
371     return C;
372   } 
373 }
374
375
376 struct EqualsType {
377   const Type *T;
378   inline EqualsType(const Type *t) { T = t; }
379   inline bool operator()(const ConstPoolVal *CPV) const {
380     return static_cast<const ConstPoolType*>(CPV)->getValue() == T;
381   }
382 };
383
384
385 // checkNewType - We have to be careful to add all types referenced by the
386 // program to the constant pool of the method or module.  Because of this, we
387 // often want to check to make sure that types used are in the constant pool,
388 // and add them if they aren't.  That's what this function does.
389 //
390 static const Type *checkNewType(const Type *Ty) {
391   ConstantPool &CP = CurMeth.CurrentMethod ? 
392                           CurMeth.CurrentMethod->getConstantPool() : 
393                           CurModule.CurrentModule->getConstantPool();
394
395   // Get the type type plane...
396   ConstantPool::PlaneType &P = CP.getPlane(Type::TypeTy);
397   ConstantPool::PlaneType::const_iterator PI = find_if(P.begin(), P.end(), 
398                                                        EqualsType(Ty));
399   if (PI == P.end()) {
400     vector<ValueList> &ValTab = CurMeth.CurrentMethod ? 
401                                 CurMeth.Values : CurModule.Values;
402     ConstPoolVal *CPT = new ConstPoolType(Ty);
403     CP.insert(CPT);
404     InsertValue(CPT, ValTab);
405   }
406   return Ty;
407 }
408
409
410 //===----------------------------------------------------------------------===//
411 //            RunVMAsmParser - Define an interface to this parser
412 //===----------------------------------------------------------------------===//
413 //
414 Module *RunVMAsmParser(const ToolCommandLine &Opts, FILE *F) {
415   llvmAsmin = F;
416   CurOptions = &Opts;
417   llvmAsmlineno = 1;      // Reset the current line number...
418
419   CurModule.CurrentModule = new Module();  // Allocate a new module to read
420   yyparse();       // Parse the file.
421   Module *Result = ParserResult;
422   CurOptions = 0;
423   llvmAsmin = stdin;    // F is about to go away, don't use it anymore...
424   ParserResult = 0;
425
426   return Result;
427 }
428
429
430 #line 373 "llvmAsmParser.y"
431 typedef union {
432   Module                  *ModuleVal;
433   Method                  *MethodVal;
434   MethodArgument          *MethArgVal;
435   BasicBlock              *BasicBlockVal;
436   TerminatorInst          *TermInstVal;
437   Instruction             *InstVal;
438   ConstPoolVal            *ConstVal;
439   const Type              *TypeVal;
440
441   list<MethodArgument*>   *MethodArgList;
442   list<Value*>            *ValueList;
443   list<const Type*>       *TypeList;
444   list<pair<Value*, BasicBlock*> > *PHIList;   // Represent the RHS of PHI node
445   list<pair<ConstPoolVal*, BasicBlock*> > *JumpTable;
446   vector<ConstPoolVal*>   *ConstVector;
447
448   int64_t                  SInt64Val;
449   uint64_t                 UInt64Val;
450   int                      SIntVal;
451   unsigned                 UIntVal;
452
453   char                    *StrVal;   // This memory is allocated by strdup!
454   ValID                    ValIDVal; // May contain memory allocated by strdup
455
456   Instruction::UnaryOps    UnaryOpVal;
457   Instruction::BinaryOps   BinaryOpVal;
458   Instruction::TermOps     TermOpVal;
459   Instruction::MemoryOps   MemOpVal;
460   Instruction::OtherOps    OtherOpVal;
461 } YYSTYPE;
462 #include <stdio.h>
463
464 #ifndef __cplusplus
465 #ifndef __STDC__
466 #define const
467 #endif
468 #endif
469
470
471
472 #define YYFINAL         260
473 #define YYFLAG          -32768
474 #define YYNTBASE        68
475
476 #define YYTRANSLATE(x) ((unsigned)(x) <= 311 ? yytranslate[x] : 106)
477
478 static const char yytranslate[] = {     0,
479      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
480      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
481      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
482      2,     2,     2,     2,     2,     2,     2,     2,     2,    65,
483     66,    67,     2,    64,     2,     2,     2,     2,     2,     2,
484      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
485     58,     2,     2,     2,     2,     2,     2,     2,     2,     2,
486      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
487      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
488     59,     2,    60,     2,     2,     2,     2,     2,     2,     2,
489      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
490      2,     2,     2,     2,     2,     2,     2,     2,     2,    61,
491      2,     2,    62,     2,    63,     2,     2,     2,     2,     2,
492      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
493      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
494      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
495      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
496      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
497      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
498      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
499      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
500      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
501      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
502      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
503      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
504      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
505      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
506     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
507     27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
508     37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
509     47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
510     57
511 };
512
513 #if YYDEBUG != 0
514 static const short yyprhs[] = {     0,
515      0,     2,     4,     6,     8,    10,    12,    14,    16,    18,
516     20,    22,    24,    26,    28,    30,    32,    34,    36,    38,
517     40,    42,    44,    46,    48,    50,    52,    54,    56,    58,
518     60,    62,    64,    66,    68,    70,    72,    74,    76,    78,
519     80,    82,    84,    86,    88,    91,    92,    95,    98,   101,
520    104,   107,   110,   117,   123,   132,   140,   147,   152,   156,
521    158,   162,   163,   165,   168,   171,   173,   174,   177,   181,
522    183,   185,   186,   192,   196,   199,   201,   203,   205,   207,
523    209,   211,   213,   215,   217,   222,   226,   230,   236,   240,
524    243,   246,   248,   252,   255,   258,   261,   265,   268,   269,
525    273,   276,   280,   290,   300,   307,   313,   316,   323,   331,
526    334,   339,   341,   342,   348,   352,   359,   365,   368,   375,
527    377,   380,   381,   384,   390,   393,   399,   403,   408,   416
528 };
529
530 static const short yyrhs[] = {     5,
531      0,     6,     0,     3,     0,     4,     0,     8,     0,     9,
532      0,    10,     0,    11,     0,    12,     0,    13,     0,    14,
533      0,    15,     0,    16,     0,    17,     0,    18,     0,    19,
534      0,    20,     0,    21,     0,    70,     0,     7,     0,    35,
535      0,    36,     0,    37,     0,    38,     0,    39,     0,    40,
536      0,    41,     0,    42,     0,    43,     0,    44,     0,    45,
537      0,    46,     0,    56,     0,    57,     0,    15,     0,    13,
538      0,    11,     0,     9,     0,    16,     0,    14,     0,    12,
539      0,    10,     0,    75,     0,    76,     0,    22,    58,     0,
540      0,    75,    69,     0,    76,     4,     0,     8,    26,     0,
541      8,    27,     0,    19,    24,     0,    20,    70,     0,    59,
542     70,    60,    59,    80,    60,     0,    59,    70,    60,    59,
543     60,     0,    59,     4,    61,    70,    60,    59,    80,    60,
544      0,    59,     4,    61,    70,    60,    59,    60,     0,    62,
545     93,    63,    62,    80,    63,     0,    62,    63,    62,    63,
546      0,    80,    64,    79,     0,    79,     0,    81,    78,    79,
547      0,     0,    83,     0,    83,    90,     0,    81,    25,     0,
548     22,     0,     0,    70,    84,     0,    85,    64,    86,     0,
549     85,     0,    86,     0,     0,    71,    24,    65,    87,    66,
550      0,    88,    81,    28,     0,    94,    29,     0,     3,     0,
551      4,     0,    26,     0,    27,     0,    24,     0,    68,     0,
552     22,     0,    91,     0,    92,     0,    71,    65,    93,    66,
553      0,    71,    65,    66,     0,    59,    70,    60,     0,    59,
554      4,    61,    70,    60,     0,    62,    93,    63,     0,    62,
555     63,     0,    70,    67,     0,    70,     0,    93,    64,    70,
556      0,    94,    95,     0,    89,    95,     0,    96,    97,     0,
557     23,    96,    97,     0,    96,    99,     0,     0,    32,    70,
558     92,     0,    32,     7,     0,    33,    21,    92,     0,    33,
559      8,    92,    64,    21,    92,    64,    21,    92,     0,    34,
560     77,    92,    64,    21,    92,    59,    98,    60,     0,    98,
561     77,    91,    64,    21,    92,     0,    77,    91,    64,    21,
562     92,     0,    78,   103,     0,    70,    59,    92,    64,    92,
563     60,     0,   100,    64,    59,    92,    64,    92,    60,     0,
564     70,    92,     0,   101,    64,    70,    92,     0,   101,     0,
565      0,    73,    70,    92,    64,    92,     0,    72,    70,    92,
566      0,    74,    70,    92,    64,    70,    92,     0,    55,    70,
567     92,    31,    70,     0,    53,   100,     0,    54,    70,    92,
568     65,   102,    66,     0,   105,     0,    64,    80,     0,     0,
569     47,    70,     0,    47,    70,    64,    14,    92,     0,    48,
570     70,     0,    48,    70,    64,    14,    92,     0,    49,    70,
571     92,     0,    50,    70,    92,   104,     0,    51,    70,    92,
572     64,    70,    92,   104,     0,    52,    70,    92,   104,     0
573 };
574
575 #endif
576
577 #if YYDEBUG != 0
578 static const short yyrline[] = { 0,
579    470,   471,   478,   479,   490,   490,   490,   490,   490,   490,
580    490,   491,   491,   491,   491,   491,   491,   491,   494,   494,
581    499,   500,   500,   500,   500,   500,   501,   501,   501,   501,
582    501,   501,   502,   502,   506,   506,   506,   506,   507,   507,
583    507,   507,   508,   508,   510,   513,   517,   522,   527,   530,
584    533,   539,   542,   555,   559,   577,   584,   592,   606,   609,
585    615,   623,   634,   639,   644,   653,   653,   655,   663,   667,
586    672,   675,   679,   706,   710,   719,   722,   725,   728,   731,
587    736,   739,   742,   749,   757,   762,   766,   769,   772,   777,
588    780,   785,   789,   794,   798,   807,   812,   821,   825,   829,
589    832,   835,   838,   843,   854,   862,   872,   880,   885,   892,
590    896,   902,   902,   904,   909,   914,   918,   921,   932,   969,
591    974,   976,   980,   983,   990,   993,  1001,  1007,  1016,  1028
592 };
593 #endif
594
595
596 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
597
598 static const char * const yytname[] = {   "$","error","$undefined.","ESINT64VAL",
599 "EUINT64VAL","SINTVAL","UINTVAL","VOID","BOOL","SBYTE","UBYTE","SHORT","USHORT",
600 "INT","UINT","LONG","ULONG","FLOAT","DOUBLE","STRING","TYPE","LABEL","VAR_ID",
601 "LABELSTR","STRINGCONSTANT","IMPLEMENTATION","TRUE","FALSE","BEGINTOK","END",
602 "DECLARE","TO","RET","BR","SWITCH","NOT","ADD","SUB","MUL","DIV","REM","SETLE",
603 "SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE",
604 "GETELEMENTPTR","PHI","CALL","CAST","SHL","SHR","'='","'['","']'","'x'","'{'",
605 "'}'","','","'('","')'","'*'","INTVAL","EINT64VAL","Types","TypesV","UnaryOps",
606 "BinaryOps","ShiftOps","SIntType","UIntType","IntType","OptAssign","ConstVal",
607 "ConstVector","ConstPool","Module","MethodList","OptVAR_ID","ArgVal","ArgListH",
608 "ArgList","MethodHeaderH","MethodHeader","Method","ConstValueRef","ValueRef",
609 "TypeList","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
610 "JumpTable","Inst","PHIList","ValueRefList","ValueRefListE","InstVal","UByteList",
611 "MemoryInst", NULL
612 };
613 #endif
614
615 static const short yyr1[] = {     0,
616     68,    68,    69,    69,    70,    70,    70,    70,    70,    70,
617     70,    70,    70,    70,    70,    70,    70,    70,    71,    71,
618     72,    73,    73,    73,    73,    73,    73,    73,    73,    73,
619     73,    73,    74,    74,    75,    75,    75,    75,    76,    76,
620     76,    76,    77,    77,    78,    78,    79,    79,    79,    79,
621     79,    79,    79,    79,    79,    79,    79,    79,    80,    80,
622     81,    81,    82,    83,    83,    84,    84,    85,    86,    86,
623     87,    87,    88,    89,    90,    91,    91,    91,    91,    91,
624     92,    92,    92,    70,    70,    70,    70,    70,    70,    70,
625     70,    93,    93,    94,    94,    95,    95,    96,    96,    97,
626     97,    97,    97,    97,    98,    98,    99,   100,   100,   101,
627    101,   102,   102,   103,   103,   103,   103,   103,   103,   103,
628    104,   104,   105,   105,   105,   105,   105,   105,   105,   105
629 };
630
631 static const short yyr2[] = {     0,
632      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
633      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
634      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
635      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
636      1,     1,     1,     1,     2,     0,     2,     2,     2,     2,
637      2,     2,     6,     5,     8,     7,     6,     4,     3,     1,
638      3,     0,     1,     2,     2,     1,     0,     2,     3,     1,
639      1,     0,     5,     3,     2,     1,     1,     1,     1,     1,
640      1,     1,     1,     1,     4,     3,     3,     5,     3,     2,
641      2,     1,     3,     2,     2,     2,     3,     2,     0,     3,
642      2,     3,     9,     9,     6,     5,     2,     6,     7,     2,
643      4,     1,     0,     5,     3,     6,     5,     2,     6,     1,
644      2,     0,     2,     5,     2,     5,     3,     4,     7,     4
645 };
646
647 static const short yydefact[] = {    62,
648     46,    63,     0,    65,     0,    76,    77,     1,     2,    20,
649      5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
650     15,    16,    17,    18,    82,    80,    78,    79,     0,     0,
651     81,    19,     0,    62,    99,    64,    83,    84,    99,    45,
652      0,    38,    42,    37,    41,    36,    40,    35,    39,     0,
653      0,     0,     0,     0,     0,    61,    77,    19,     0,    90,
654     92,     0,    91,     0,     0,    46,    99,    95,    46,    75,
655     94,    49,    50,    51,    52,    77,    19,     0,     0,     3,
656      4,    47,    48,     0,    87,    89,     0,    72,    86,     0,
657     74,    46,     0,     0,     0,     0,    96,    98,     0,     0,
658      0,     0,    19,    93,    67,    70,    71,     0,    85,    97,
659    101,    19,     0,     0,    43,    44,     0,    21,    22,    23,
660     24,    25,    26,    27,    28,    29,    30,    31,    32,     0,
661      0,     0,     0,     0,     0,     0,     0,     0,    33,    34,
662      0,     0,     0,   107,   120,    19,     0,    58,     0,    88,
663     66,    68,     0,    73,   100,     0,   102,     0,   123,   125,
664     19,    19,    19,    19,    19,   118,    19,    19,    19,    19,
665     19,     0,    54,    60,     0,     0,    69,     0,     0,     0,
666      0,   127,   122,     0,   122,     0,     0,     0,     0,   115,
667      0,     0,     0,    53,     0,    57,     0,     0,     0,     0,
668      0,   128,     0,   130,     0,     0,   113,     0,     0,     0,
669     56,     0,    59,     0,     0,   124,   126,   121,    19,     0,
670      0,    19,   112,     0,   117,   114,    19,    55,     0,     0,
671    122,     0,     0,   110,     0,   119,   116,     0,     0,     0,
672    129,   108,     0,    19,   103,     0,   104,     0,   109,   111,
673      0,     0,     0,     0,   106,     0,   105,     0,     0,     0
674 };
675
676 static const short yydefgoto[] = {    31,
677     82,    61,    59,   141,   142,   143,    54,    55,   117,     5,
678    174,   175,     1,   258,     2,   152,   106,   107,   108,    34,
679     35,    36,    37,    38,    62,    39,    68,    69,    97,   240,
680     98,   166,   223,   224,   144,   202,   145
681 };
682
683 static const short yypact[] = {-32768,
684     70,   321,    -6,-32768,    90,-32768,-32768,-32768,-32768,-32768,
685 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
686 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   381,   235,
687 -32768,    45,   -20,-32768,    98,-32768,-32768,-32768,    93,-32768,
688     67,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,    56,
689    321,   406,   296,   181,   142,-32768,    97,   -14,    96,-32768,
690     46,   123,-32768,   101,   210,   122,-32768,-32768,   135,-32768,
691 -32768,-32768,-32768,-32768,    46,   111,    29,   112,   129,-32768,
692 -32768,-32768,-32768,   321,-32768,-32768,   321,   321,-32768,    79,
693 -32768,   135,   466,    13,   268,   461,-32768,-32768,   321,   118,
694    125,   119,    47,    46,    10,   126,-32768,   131,-32768,-32768,
695    133,     4,    52,    52,-32768,-32768,    52,-32768,-32768,-32768,
696 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   321,
697    321,   321,   321,   321,   321,   321,   321,   321,-32768,-32768,
698    321,   321,   321,-32768,-32768,    48,     3,-32768,    90,-32768,
699 -32768,-32768,   321,-32768,-32768,   138,-32768,   139,   106,   115,
700      4,     4,     4,     4,     0,   140,     4,     4,     4,     4,
701      4,   148,-32768,-32768,    99,   132,-32768,   178,   189,   197,
702    221,-32768,   194,   196,   194,    52,   204,   199,   234,-32768,
703    202,   203,    28,-32768,    90,-32768,    52,    52,    52,    52,
704     90,-32768,   321,-32768,   206,    52,   321,   321,    52,   321,
705 -32768,   100,-32768,   207,   209,-32768,-32768,   211,     4,    52,
706    222,     4,   223,   208,    46,-32768,     4,-32768,   252,   268,
707    194,   225,    52,-32768,   321,-32768,-32768,    52,    57,   435,
708 -32768,-32768,   228,     4,-32768,   226,-32768,    57,-32768,-32768,
709    270,   229,    52,   271,-32768,    52,-32768,   289,   295,-32768
710 };
711
712 static const short yypgoto[] = {-32768,
713 -32768,    -2,   294,-32768,-32768,-32768,   -93,   -92,  -205,   -63,
714     -4,  -129,   285,-32768,-32768,-32768,-32768,   168,-32768,-32768,
715 -32768,-32768,  -215,   -44,     1,-32768,   305,   279,   257,-32768,
716 -32768,-32768,-32768,-32768,-32768,  -180,-32768
717 };
718
719
720 #define YYLAST          528
721
722
723 static const short yytable[] = {    32,
724     56,   115,   116,    64,   204,    96,     6,     7,     8,     9,
725     41,    42,    43,    44,    45,    46,    47,    48,    49,   176,
726    113,    50,    51,   246,   239,    25,    58,    26,    96,    27,
727     28,   151,   252,   114,   248,    41,    42,    43,    44,    45,
728     46,    47,    48,    49,    65,    85,    50,    51,    75,    77,
729    241,    40,    63,    79,     6,     7,     8,     9,   186,     6,
730      7,    52,   173,   212,    53,    90,    63,   155,   156,   157,
731     63,   218,   158,    25,   -19,    26,    63,    27,    28,    74,
732     26,   103,    27,    28,   104,   105,    52,   211,   100,    53,
733    112,     3,    72,    73,     4,    63,   146,    41,    42,    43,
734     44,    45,    46,    47,    48,    49,   150,   172,    50,    51,
735    -19,    63,    63,    63,    63,    67,   182,   183,   184,   185,
736     67,    70,   188,   189,   190,   191,   192,   159,   160,   161,
737    162,   163,   164,   165,   167,   168,   115,   116,   169,   170,
738    171,   205,    87,     3,   109,    83,   115,   116,    52,    91,
739    105,    53,   214,   215,   216,   217,     3,    84,   194,   228,
740     65,   221,   195,   195,   226,    88,    93,    94,    95,   180,
741    -19,    99,    63,   101,   231,   232,   147,   234,   181,   -19,
742    149,    63,   237,    80,    81,    86,    87,   148,   243,   153,
743    213,   102,    87,   245,   196,   195,   154,   -20,   197,   250,
744    219,   178,   179,   187,   222,   225,   193,   227,   255,   198,
745    199,   257,     6,     7,     8,     9,    10,    11,    12,    13,
746     14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
747     24,    25,   244,    26,   200,    27,    28,     6,     7,     8,
748      9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
749     19,    20,    21,    22,    23,    24,    25,   201,    26,   203,
750     27,    28,   206,   207,   208,   209,   210,   230,    29,   220,
751    229,    30,   238,   236,   195,    89,    42,    43,    44,    45,
752     46,    47,    48,    49,   242,   233,   235,   249,   259,   251,
753    253,   256,   254,    29,   260,    33,    30,    60,     6,     7,
754      8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
755     18,    19,    20,    21,    22,    23,    24,    25,    66,    26,
756    177,    27,    28,     6,     7,     8,     9,    10,    11,    12,
757     13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
758     23,    24,    25,    71,    26,    92,    27,    28,   110,     0,
759      0,     0,     0,     0,    29,     0,     0,    30,    78,     0,
760      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
761      0,     0,     0,     0,     0,     0,     0,     0,     0,    29,
762      0,     0,    30,     6,    57,     8,     9,    10,    11,    12,
763     13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
764     23,    24,    25,     0,    26,     0,    27,    28,     6,    76,
765      8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
766     18,    19,    20,    21,    22,    23,    24,    25,     0,    26,
767      0,    27,    28,     0,     0,     0,     0,     0,     0,    29,
768      0,     0,    30,    42,    43,    44,    45,    46,    47,    48,
769     49,     0,     0,     0,     0,     0,     0,     0,     0,     0,
770      0,     0,     0,     0,    29,     0,     0,    30,     6,     7,
771      8,     9,   111,    11,    12,    13,    14,    15,    16,    17,
772     18,    19,    20,    21,    22,    23,    24,    25,     0,    26,
773      0,    27,    28,     0,   247,   118,   119,   120,   121,   122,
774    123,   124,   125,   126,   127,   128,   129,   130,   131,   132,
775    133,   134,   135,   136,   137,   138,   139,   140,     0,     0,
776      0,     0,     0,     0,    29,     0,     0,    30
777 };
778
779 static const short yycheck[] = {     2,
780      5,    95,    95,    24,   185,    69,     3,     4,     5,     6,
781      8,     9,    10,    11,    12,    13,    14,    15,    16,   149,
782      8,    19,    20,   239,   230,    22,    29,    24,    92,    26,
783     27,    22,   248,    21,   240,     8,     9,    10,    11,    12,
784     13,    14,    15,    16,    65,    60,    19,    20,    51,    52,
785    231,    58,    67,    53,     3,     4,     5,     6,    59,     3,
786      4,    59,    60,   193,    62,    65,    67,   112,   113,   114,
787     67,   201,   117,    22,    65,    24,    67,    26,    27,    24,
788     24,    84,    26,    27,    87,    88,    59,    60,    60,    62,
789     93,    22,    26,    27,    25,    67,    99,     8,     9,    10,
790     11,    12,    13,    14,    15,    16,    60,    60,    19,    20,
791     65,    67,    67,    67,    67,    23,   161,   162,   163,   164,
792     23,    29,   167,   168,   169,   170,   171,   130,   131,   132,
793    133,   134,   135,   136,   137,   138,   230,   230,   141,   142,
794    143,   186,    64,    22,    66,     4,   240,   240,    59,    28,
795    153,    62,   197,   198,   199,   200,    22,    61,    60,    60,
796     65,   206,    64,    64,   209,    65,    32,    33,    34,    64,
797     65,    61,    67,    62,   219,   220,    59,   222,    64,    65,
798     62,    67,   227,     3,     4,    63,    64,    63,   233,    64,
799    195,    63,    64,   238,    63,    64,    66,    65,    21,   244,
800    203,    64,    64,    64,   207,   208,    59,   210,   253,    21,
801     14,   256,     3,     4,     5,     6,     7,     8,     9,    10,
802     11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
803     21,    22,   235,    24,    14,    26,    27,     3,     4,     5,
804      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
805     16,    17,    18,    19,    20,    21,    22,    64,    24,    64,
806     26,    27,    59,    65,    31,    64,    64,    59,    59,    64,
807     64,    62,    21,    66,    64,    66,     9,    10,    11,    12,
808     13,    14,    15,    16,    60,    64,    64,    60,     0,    64,
809     21,    21,    64,    59,     0,     2,    62,    63,     3,     4,
810      5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
811     15,    16,    17,    18,    19,    20,    21,    22,    34,    24,
812    153,    26,    27,     3,     4,     5,     6,     7,     8,     9,
813     10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
814     20,    21,    22,    39,    24,    67,    26,    27,    92,    -1,
815     -1,    -1,    -1,    -1,    59,    -1,    -1,    62,    63,    -1,
816     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
817     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    59,
818     -1,    -1,    62,     3,     4,     5,     6,     7,     8,     9,
819     10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
820     20,    21,    22,    -1,    24,    -1,    26,    27,     3,     4,
821      5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
822     15,    16,    17,    18,    19,    20,    21,    22,    -1,    24,
823     -1,    26,    27,    -1,    -1,    -1,    -1,    -1,    -1,    59,
824     -1,    -1,    62,     9,    10,    11,    12,    13,    14,    15,
825     16,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
826     -1,    -1,    -1,    -1,    59,    -1,    -1,    62,     3,     4,
827      5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
828     15,    16,    17,    18,    19,    20,    21,    22,    -1,    24,
829     -1,    26,    27,    -1,    60,    35,    36,    37,    38,    39,
830     40,    41,    42,    43,    44,    45,    46,    47,    48,    49,
831     50,    51,    52,    53,    54,    55,    56,    57,    -1,    -1,
832     -1,    -1,    -1,    -1,    59,    -1,    -1,    62
833 };
834 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
835 #line 3 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
836 /* This file comes from bison-1.28.  */
837
838 /* Skeleton output parser for bison,
839    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
840
841    This program is free software; you can redistribute it and/or modify
842    it under the terms of the GNU General Public License as published by
843    the Free Software Foundation; either version 2, or (at your option)
844    any later version.
845
846    This program is distributed in the hope that it will be useful,
847    but WITHOUT ANY WARRANTY; without even the implied warranty of
848    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
849    GNU General Public License for more details.
850
851    You should have received a copy of the GNU General Public License
852    along with this program; if not, write to the Free Software
853    Foundation, Inc., 59 Temple Place - Suite 330,
854    Boston, MA 02111-1307, USA.  */
855
856 /* As a special exception, when this file is copied by Bison into a
857    Bison output file, you may use that output file without restriction.
858    This special exception was added by the Free Software Foundation
859    in version 1.24 of Bison.  */
860
861 /* This is the parser code that is written into each bison parser
862   when the %semantic_parser declaration is not specified in the grammar.
863   It was written by Richard Stallman by simplifying the hairy parser
864   used when %semantic_parser is specified.  */
865
866 #ifndef YYSTACK_USE_ALLOCA
867 #ifdef alloca
868 #define YYSTACK_USE_ALLOCA
869 #else /* alloca not defined */
870 #ifdef __GNUC__
871 #define YYSTACK_USE_ALLOCA
872 #define alloca __builtin_alloca
873 #else /* not GNU C.  */
874 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
875 #define YYSTACK_USE_ALLOCA
876 #include <alloca.h>
877 #else /* not sparc */
878 /* We think this test detects Watcom and Microsoft C.  */
879 /* This used to test MSDOS, but that is a bad idea
880    since that symbol is in the user namespace.  */
881 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
882 #if 0 /* No need for malloc.h, which pollutes the namespace;
883          instead, just don't use alloca.  */
884 #include <malloc.h>
885 #endif
886 #else /* not MSDOS, or __TURBOC__ */
887 #if defined(_AIX)
888 /* I don't know what this was needed for, but it pollutes the namespace.
889    So I turned it off.   rms, 2 May 1997.  */
890 /* #include <malloc.h>  */
891  #pragma alloca
892 #define YYSTACK_USE_ALLOCA
893 #else /* not MSDOS, or __TURBOC__, or _AIX */
894 #if 0
895 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
896                  and on HPUX 10.  Eventually we can turn this on.  */
897 #define YYSTACK_USE_ALLOCA
898 #define alloca __builtin_alloca
899 #endif /* __hpux */
900 #endif
901 #endif /* not _AIX */
902 #endif /* not MSDOS, or __TURBOC__ */
903 #endif /* not sparc */
904 #endif /* not GNU C */
905 #endif /* alloca not defined */
906 #endif /* YYSTACK_USE_ALLOCA not defined */
907
908 #ifdef YYSTACK_USE_ALLOCA
909 #define YYSTACK_ALLOC alloca
910 #else
911 #define YYSTACK_ALLOC malloc
912 #endif
913
914 /* Note: there must be only one dollar sign in this file.
915    It is replaced by the list of actions, each action
916    as one case of the switch.  */
917
918 #define yyerrok         (yyerrstatus = 0)
919 #define yyclearin       (yychar = YYEMPTY)
920 #define YYEMPTY         -2
921 #define YYEOF           0
922 #define YYACCEPT        goto yyacceptlab
923 #define YYABORT         goto yyabortlab
924 #define YYERROR         goto yyerrlab1
925 /* Like YYERROR except do call yyerror.
926    This remains here temporarily to ease the
927    transition to the new meaning of YYERROR, for GCC.
928    Once GCC version 2 has supplanted version 1, this can go.  */
929 #define YYFAIL          goto yyerrlab
930 #define YYRECOVERING()  (!!yyerrstatus)
931 #define YYBACKUP(token, value) \
932 do                                                              \
933   if (yychar == YYEMPTY && yylen == 1)                          \
934     { yychar = (token), yylval = (value);                       \
935       yychar1 = YYTRANSLATE (yychar);                           \
936       YYPOPSTACK;                                               \
937       goto yybackup;                                            \
938     }                                                           \
939   else                                                          \
940     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
941 while (0)
942
943 #define YYTERROR        1
944 #define YYERRCODE       256
945
946 #ifndef YYPURE
947 #define YYLEX           yylex()
948 #endif
949
950 #ifdef YYPURE
951 #ifdef YYLSP_NEEDED
952 #ifdef YYLEX_PARAM
953 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
954 #else
955 #define YYLEX           yylex(&yylval, &yylloc)
956 #endif
957 #else /* not YYLSP_NEEDED */
958 #ifdef YYLEX_PARAM
959 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
960 #else
961 #define YYLEX           yylex(&yylval)
962 #endif
963 #endif /* not YYLSP_NEEDED */
964 #endif
965
966 /* If nonreentrant, generate the variables here */
967
968 #ifndef YYPURE
969
970 int     yychar;                 /*  the lookahead symbol                */
971 YYSTYPE yylval;                 /*  the semantic value of the           */
972                                 /*  lookahead symbol                    */
973
974 #ifdef YYLSP_NEEDED
975 YYLTYPE yylloc;                 /*  location data for the lookahead     */
976                                 /*  symbol                              */
977 #endif
978
979 int yynerrs;                    /*  number of parse errors so far       */
980 #endif  /* not YYPURE */
981
982 #if YYDEBUG != 0
983 int yydebug;                    /*  nonzero means print parse trace     */
984 /* Since this is uninitialized, it does not stop multiple parsers
985    from coexisting.  */
986 #endif
987
988 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
989
990 #ifndef YYINITDEPTH
991 #define YYINITDEPTH 200
992 #endif
993
994 /*  YYMAXDEPTH is the maximum size the stacks can grow to
995     (effective only if the built-in stack extension method is used).  */
996
997 #if YYMAXDEPTH == 0
998 #undef YYMAXDEPTH
999 #endif
1000
1001 #ifndef YYMAXDEPTH
1002 #define YYMAXDEPTH 10000
1003 #endif
1004 \f
1005 /* Define __yy_memcpy.  Note that the size argument
1006    should be passed with type unsigned int, because that is what the non-GCC
1007    definitions require.  With GCC, __builtin_memcpy takes an arg
1008    of type size_t, but it can handle unsigned int.  */
1009
1010 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
1011 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
1012 #else                           /* not GNU C or C++ */
1013 #ifndef __cplusplus
1014
1015 /* This is the most reliable way to avoid incompatibilities
1016    in available built-in functions on various systems.  */
1017 static void
1018 __yy_memcpy (to, from, count)
1019      char *to;
1020      char *from;
1021      unsigned int count;
1022 {
1023   register char *f = from;
1024   register char *t = to;
1025   register int i = count;
1026
1027   while (i-- > 0)
1028     *t++ = *f++;
1029 }
1030
1031 #else /* __cplusplus */
1032
1033 /* This is the most reliable way to avoid incompatibilities
1034    in available built-in functions on various systems.  */
1035 static void
1036 __yy_memcpy (char *to, char *from, unsigned int count)
1037 {
1038   register char *t = to;
1039   register char *f = from;
1040   register int i = count;
1041
1042   while (i-- > 0)
1043     *t++ = *f++;
1044 }
1045
1046 #endif
1047 #endif
1048 \f
1049 #line 217 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
1050
1051 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
1052    into yyparse.  The argument should have type void *.
1053    It should actually point to an object.
1054    Grammar actions can access the variable by casting it
1055    to the proper pointer type.  */
1056
1057 #ifdef YYPARSE_PARAM
1058 #ifdef __cplusplus
1059 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
1060 #define YYPARSE_PARAM_DECL
1061 #else /* not __cplusplus */
1062 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1063 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
1064 #endif /* not __cplusplus */
1065 #else /* not YYPARSE_PARAM */
1066 #define YYPARSE_PARAM_ARG
1067 #define YYPARSE_PARAM_DECL
1068 #endif /* not YYPARSE_PARAM */
1069
1070 /* Prevent warning if -Wstrict-prototypes.  */
1071 #ifdef __GNUC__
1072 #ifdef YYPARSE_PARAM
1073 int yyparse (void *);
1074 #else
1075 int yyparse (void);
1076 #endif
1077 #endif
1078
1079 int
1080 yyparse(YYPARSE_PARAM_ARG)
1081      YYPARSE_PARAM_DECL
1082 {
1083   register int yystate;
1084   register int yyn;
1085   register short *yyssp;
1086   register YYSTYPE *yyvsp;
1087   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
1088   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
1089
1090   short yyssa[YYINITDEPTH];     /*  the state stack                     */
1091   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
1092
1093   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
1094   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
1095
1096 #ifdef YYLSP_NEEDED
1097   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
1098   YYLTYPE *yyls = yylsa;
1099   YYLTYPE *yylsp;
1100
1101 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
1102 #else
1103 #define YYPOPSTACK   (yyvsp--, yyssp--)
1104 #endif
1105
1106   int yystacksize = YYINITDEPTH;
1107   int yyfree_stacks = 0;
1108
1109 #ifdef YYPURE
1110   int yychar;
1111   YYSTYPE yylval;
1112   int yynerrs;
1113 #ifdef YYLSP_NEEDED
1114   YYLTYPE yylloc;
1115 #endif
1116 #endif
1117
1118   YYSTYPE yyval;                /*  the variable used to return         */
1119                                 /*  semantic values from the action     */
1120                                 /*  routines                            */
1121
1122   int yylen;
1123
1124 #if YYDEBUG != 0
1125   if (yydebug)
1126     fprintf(stderr, "Starting parse\n");
1127 #endif
1128
1129   yystate = 0;
1130   yyerrstatus = 0;
1131   yynerrs = 0;
1132   yychar = YYEMPTY;             /* Cause a token to be read.  */
1133
1134   /* Initialize stack pointers.
1135      Waste one element of value and location stack
1136      so that they stay on the same level as the state stack.
1137      The wasted elements are never initialized.  */
1138
1139   yyssp = yyss - 1;
1140   yyvsp = yyvs;
1141 #ifdef YYLSP_NEEDED
1142   yylsp = yyls;
1143 #endif
1144
1145 /* Push a new state, which is found in  yystate  .  */
1146 /* In all cases, when you get here, the value and location stacks
1147    have just been pushed. so pushing a state here evens the stacks.  */
1148 yynewstate:
1149
1150   *++yyssp = yystate;
1151
1152   if (yyssp >= yyss + yystacksize - 1)
1153     {
1154       /* Give user a chance to reallocate the stack */
1155       /* Use copies of these so that the &'s don't force the real ones into memory. */
1156       YYSTYPE *yyvs1 = yyvs;
1157       short *yyss1 = yyss;
1158 #ifdef YYLSP_NEEDED
1159       YYLTYPE *yyls1 = yyls;
1160 #endif
1161
1162       /* Get the current used size of the three stacks, in elements.  */
1163       int size = yyssp - yyss + 1;
1164
1165 #ifdef yyoverflow
1166       /* Each stack pointer address is followed by the size of
1167          the data in use in that stack, in bytes.  */
1168 #ifdef YYLSP_NEEDED
1169       /* This used to be a conditional around just the two extra args,
1170          but that might be undefined if yyoverflow is a macro.  */
1171       yyoverflow("parser stack overflow",
1172                  &yyss1, size * sizeof (*yyssp),
1173                  &yyvs1, size * sizeof (*yyvsp),
1174                  &yyls1, size * sizeof (*yylsp),
1175                  &yystacksize);
1176 #else
1177       yyoverflow("parser stack overflow",
1178                  &yyss1, size * sizeof (*yyssp),
1179                  &yyvs1, size * sizeof (*yyvsp),
1180                  &yystacksize);
1181 #endif
1182
1183       yyss = yyss1; yyvs = yyvs1;
1184 #ifdef YYLSP_NEEDED
1185       yyls = yyls1;
1186 #endif
1187 #else /* no yyoverflow */
1188       /* Extend the stack our own way.  */
1189       if (yystacksize >= YYMAXDEPTH)
1190         {
1191           yyerror("parser stack overflow");
1192           if (yyfree_stacks)
1193             {
1194               free (yyss);
1195               free (yyvs);
1196 #ifdef YYLSP_NEEDED
1197               free (yyls);
1198 #endif
1199             }
1200           return 2;
1201         }
1202       yystacksize *= 2;
1203       if (yystacksize > YYMAXDEPTH)
1204         yystacksize = YYMAXDEPTH;
1205 #ifndef YYSTACK_USE_ALLOCA
1206       yyfree_stacks = 1;
1207 #endif
1208       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
1209       __yy_memcpy ((char *)yyss, (char *)yyss1,
1210                    size * (unsigned int) sizeof (*yyssp));
1211       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
1212       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
1213                    size * (unsigned int) sizeof (*yyvsp));
1214 #ifdef YYLSP_NEEDED
1215       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
1216       __yy_memcpy ((char *)yyls, (char *)yyls1,
1217                    size * (unsigned int) sizeof (*yylsp));
1218 #endif
1219 #endif /* no yyoverflow */
1220
1221       yyssp = yyss + size - 1;
1222       yyvsp = yyvs + size - 1;
1223 #ifdef YYLSP_NEEDED
1224       yylsp = yyls + size - 1;
1225 #endif
1226
1227 #if YYDEBUG != 0
1228       if (yydebug)
1229         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
1230 #endif
1231
1232       if (yyssp >= yyss + yystacksize - 1)
1233         YYABORT;
1234     }
1235
1236 #if YYDEBUG != 0
1237   if (yydebug)
1238     fprintf(stderr, "Entering state %d\n", yystate);
1239 #endif
1240
1241   goto yybackup;
1242  yybackup:
1243
1244 /* Do appropriate processing given the current state.  */
1245 /* Read a lookahead token if we need one and don't already have one.  */
1246 /* yyresume: */
1247
1248   /* First try to decide what to do without reference to lookahead token.  */
1249
1250   yyn = yypact[yystate];
1251   if (yyn == YYFLAG)
1252     goto yydefault;
1253
1254   /* Not known => get a lookahead token if don't already have one.  */
1255
1256   /* yychar is either YYEMPTY or YYEOF
1257      or a valid token in external form.  */
1258
1259   if (yychar == YYEMPTY)
1260     {
1261 #if YYDEBUG != 0
1262       if (yydebug)
1263         fprintf(stderr, "Reading a token: ");
1264 #endif
1265       yychar = YYLEX;
1266     }
1267
1268   /* Convert token to internal form (in yychar1) for indexing tables with */
1269
1270   if (yychar <= 0)              /* This means end of input. */
1271     {
1272       yychar1 = 0;
1273       yychar = YYEOF;           /* Don't call YYLEX any more */
1274
1275 #if YYDEBUG != 0
1276       if (yydebug)
1277         fprintf(stderr, "Now at end of input.\n");
1278 #endif
1279     }
1280   else
1281     {
1282       yychar1 = YYTRANSLATE(yychar);
1283
1284 #if YYDEBUG != 0
1285       if (yydebug)
1286         {
1287           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
1288           /* Give the individual parser a way to print the precise meaning
1289              of a token, for further debugging info.  */
1290 #ifdef YYPRINT
1291           YYPRINT (stderr, yychar, yylval);
1292 #endif
1293           fprintf (stderr, ")\n");
1294         }
1295 #endif
1296     }
1297
1298   yyn += yychar1;
1299   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
1300     goto yydefault;
1301
1302   yyn = yytable[yyn];
1303
1304   /* yyn is what to do for this token type in this state.
1305      Negative => reduce, -yyn is rule number.
1306      Positive => shift, yyn is new state.
1307        New state is final state => don't bother to shift,
1308        just return success.
1309      0, or most negative number => error.  */
1310
1311   if (yyn < 0)
1312     {
1313       if (yyn == YYFLAG)
1314         goto yyerrlab;
1315       yyn = -yyn;
1316       goto yyreduce;
1317     }
1318   else if (yyn == 0)
1319     goto yyerrlab;
1320
1321   if (yyn == YYFINAL)
1322     YYACCEPT;
1323
1324   /* Shift the lookahead token.  */
1325
1326 #if YYDEBUG != 0
1327   if (yydebug)
1328     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
1329 #endif
1330
1331   /* Discard the token being shifted unless it is eof.  */
1332   if (yychar != YYEOF)
1333     yychar = YYEMPTY;
1334
1335   *++yyvsp = yylval;
1336 #ifdef YYLSP_NEEDED
1337   *++yylsp = yylloc;
1338 #endif
1339
1340   /* count tokens shifted since error; after three, turn off error status.  */
1341   if (yyerrstatus) yyerrstatus--;
1342
1343   yystate = yyn;
1344   goto yynewstate;
1345
1346 /* Do the default action for the current state.  */
1347 yydefault:
1348
1349   yyn = yydefact[yystate];
1350   if (yyn == 0)
1351     goto yyerrlab;
1352
1353 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
1354 yyreduce:
1355   yylen = yyr2[yyn];
1356   if (yylen > 0)
1357     yyval = yyvsp[1-yylen]; /* implement default value of the action */
1358
1359 #if YYDEBUG != 0
1360   if (yydebug)
1361     {
1362       int i;
1363
1364       fprintf (stderr, "Reducing via rule %d (line %d), ",
1365                yyn, yyrline[yyn]);
1366
1367       /* Print the symbols being reduced, and their result.  */
1368       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
1369         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
1370       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1371     }
1372 #endif
1373
1374
1375   switch (yyn) {
1376
1377 case 2:
1378 #line 471 "llvmAsmParser.y"
1379 {
1380   if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX)     // Outside of my range!
1381     ThrowException("Value too large for type!");
1382   yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
1383 ;
1384     break;}
1385 case 4:
1386 #line 479 "llvmAsmParser.y"
1387 {
1388   if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX)     // Outside of my range!
1389     ThrowException("Value too large for type!");
1390   yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
1391 ;
1392     break;}
1393 case 45:
1394 #line 510 "llvmAsmParser.y"
1395 {
1396     yyval.StrVal = yyvsp[-1].StrVal;
1397   ;
1398     break;}
1399 case 46:
1400 #line 513 "llvmAsmParser.y"
1401
1402     yyval.StrVal = 0; 
1403   ;
1404     break;}
1405 case 47:
1406 #line 517 "llvmAsmParser.y"
1407 {     // integral constants
1408     if (!ConstPoolSInt::isValueValidForType(yyvsp[-1].TypeVal, yyvsp[0].SInt64Val))
1409       ThrowException("Constant value doesn't fit in type!");
1410     yyval.ConstVal = new ConstPoolSInt(yyvsp[-1].TypeVal, yyvsp[0].SInt64Val);
1411   ;
1412     break;}
1413 case 48:
1414 #line 522 "llvmAsmParser.y"
1415 {           // integral constants
1416     if (!ConstPoolUInt::isValueValidForType(yyvsp[-1].TypeVal, yyvsp[0].UInt64Val))
1417       ThrowException("Constant value doesn't fit in type!");
1418     yyval.ConstVal = new ConstPoolUInt(yyvsp[-1].TypeVal, yyvsp[0].UInt64Val);
1419   ;
1420     break;}
1421 case 49:
1422 #line 527 "llvmAsmParser.y"
1423 {                     // Boolean constants
1424     yyval.ConstVal = new ConstPoolBool(true);
1425   ;
1426     break;}
1427 case 50:
1428 #line 530 "llvmAsmParser.y"
1429 {                    // Boolean constants
1430     yyval.ConstVal = new ConstPoolBool(false);
1431   ;
1432     break;}
1433 case 51:
1434 #line 533 "llvmAsmParser.y"
1435 {         // String constants
1436     cerr << "FIXME: TODO: String constants [sbyte] not implemented yet!\n";
1437     abort();
1438     //$$ = new ConstPoolString($2);
1439     free(yyvsp[0].StrVal);
1440   ;
1441     break;}
1442 case 52:
1443 #line 539 "llvmAsmParser.y"
1444 {                    // Type constants
1445     yyval.ConstVal = new ConstPoolType(yyvsp[0].TypeVal);
1446   ;
1447     break;}
1448 case 53:
1449 #line 542 "llvmAsmParser.y"
1450 {      // Nonempty array constant
1451     // Verify all elements are correct type!
1452     const ArrayType *AT = ArrayType::getArrayType(yyvsp[-4].TypeVal);
1453     for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
1454       if (yyvsp[-4].TypeVal != (*yyvsp[-1].ConstVector)[i]->getType())
1455         ThrowException("Element #" + utostr(i) + " is not of type '" + 
1456                        yyvsp[-4].TypeVal->getName() + "' as required!\nIt is of type '" +
1457                        (*yyvsp[-1].ConstVector)[i]->getType()->getName() + "'.");
1458     }
1459
1460     yyval.ConstVal = new ConstPoolArray(AT, *yyvsp[-1].ConstVector);
1461     delete yyvsp[-1].ConstVector;
1462   ;
1463     break;}
1464 case 54:
1465 #line 555 "llvmAsmParser.y"
1466 {                  // Empty array constant
1467     vector<ConstPoolVal*> Empty;
1468     yyval.ConstVal = new ConstPoolArray(ArrayType::getArrayType(yyvsp[-3].TypeVal), Empty);
1469   ;
1470     break;}
1471 case 55:
1472 #line 559 "llvmAsmParser.y"
1473 {
1474     // Verify all elements are correct type!
1475     const ArrayType *AT = ArrayType::getArrayType(yyvsp[-4].TypeVal, (int)yyvsp[-6].UInt64Val);
1476     if (yyvsp[-6].UInt64Val != yyvsp[-1].ConstVector->size())
1477       ThrowException("Type mismatch: constant sized array initialized with " +
1478                      utostr(yyvsp[-1].ConstVector->size()) +  " arguments, but has size of " + 
1479                      itostr((int)yyvsp[-6].UInt64Val) + "!");
1480
1481     for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
1482       if (yyvsp[-4].TypeVal != (*yyvsp[-1].ConstVector)[i]->getType())
1483         ThrowException("Element #" + utostr(i) + " is not of type '" + 
1484                        yyvsp[-4].TypeVal->getName() + "' as required!\nIt is of type '" +
1485                        (*yyvsp[-1].ConstVector)[i]->getType()->getName() + "'.");
1486     }
1487
1488     yyval.ConstVal = new ConstPoolArray(AT, *yyvsp[-1].ConstVector);
1489     delete yyvsp[-1].ConstVector;
1490   ;
1491     break;}
1492 case 56:
1493 #line 577 "llvmAsmParser.y"
1494 {
1495     if (yyvsp[-5].UInt64Val != 0) 
1496       ThrowException("Type mismatch: constant sized array initialized with 0"
1497                      " arguments, but has size of " + itostr((int)yyvsp[-5].UInt64Val) + "!");
1498     vector<ConstPoolVal*> Empty;
1499     yyval.ConstVal = new ConstPoolArray(ArrayType::getArrayType(yyvsp[-3].TypeVal, 0), Empty);
1500   ;
1501     break;}
1502 case 57:
1503 #line 584 "llvmAsmParser.y"
1504 {
1505     StructType::ElementTypes Types(yyvsp[-4].TypeList->begin(), yyvsp[-4].TypeList->end());
1506     delete yyvsp[-4].TypeList;
1507
1508     const StructType *St = StructType::getStructType(Types);
1509     yyval.ConstVal = new ConstPoolStruct(St, *yyvsp[-1].ConstVector);
1510     delete yyvsp[-1].ConstVector;
1511   ;
1512     break;}
1513 case 58:
1514 #line 592 "llvmAsmParser.y"
1515 {
1516     const StructType *St = 
1517       StructType::getStructType(StructType::ElementTypes());
1518     vector<ConstPoolVal*> Empty;
1519     yyval.ConstVal = new ConstPoolStruct(St, Empty);
1520   ;
1521     break;}
1522 case 59:
1523 #line 606 "llvmAsmParser.y"
1524 {
1525     (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(addConstValToConstantPool(yyvsp[0].ConstVal));
1526   ;
1527     break;}
1528 case 60:
1529 #line 609 "llvmAsmParser.y"
1530 {
1531     yyval.ConstVector = new vector<ConstPoolVal*>();
1532     yyval.ConstVector->push_back(addConstValToConstantPool(yyvsp[0].ConstVal));
1533   ;
1534     break;}
1535 case 61:
1536 #line 615 "llvmAsmParser.y"
1537
1538     if (yyvsp[-1].StrVal) {
1539       yyvsp[0].ConstVal->setName(yyvsp[-1].StrVal);
1540       free(yyvsp[-1].StrVal);
1541     }
1542
1543     addConstValToConstantPool(yyvsp[0].ConstVal);
1544   ;
1545     break;}
1546 case 62:
1547 #line 623 "llvmAsmParser.y"
1548
1549   ;
1550     break;}
1551 case 63:
1552 #line 634 "llvmAsmParser.y"
1553 {
1554   yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
1555   CurModule.ModuleDone();
1556 ;
1557     break;}
1558 case 64:
1559 #line 639 "llvmAsmParser.y"
1560 {
1561     yyvsp[-1].ModuleVal->getMethodList().push_back(yyvsp[0].MethodVal);
1562     CurMeth.MethodDone();
1563     yyval.ModuleVal = yyvsp[-1].ModuleVal;
1564   ;
1565     break;}
1566 case 65:
1567 #line 644 "llvmAsmParser.y"
1568 {
1569     yyval.ModuleVal = CurModule.CurrentModule;
1570   ;
1571     break;}
1572 case 67:
1573 #line 653 "llvmAsmParser.y"
1574 { yyval.StrVal = 0; ;
1575     break;}
1576 case 68:
1577 #line 655 "llvmAsmParser.y"
1578 {
1579   yyval.MethArgVal = new MethodArgument(yyvsp[-1].TypeVal);
1580   if (yyvsp[0].StrVal) {      // Was the argument named?
1581     yyval.MethArgVal->setName(yyvsp[0].StrVal); 
1582     free(yyvsp[0].StrVal);    // The string was strdup'd, so free it now.
1583   }
1584 ;
1585     break;}
1586 case 69:
1587 #line 663 "llvmAsmParser.y"
1588 {
1589     yyval.MethodArgList = yyvsp[0].MethodArgList;
1590     yyvsp[0].MethodArgList->push_front(yyvsp[-2].MethArgVal);
1591   ;
1592     break;}
1593 case 70:
1594 #line 667 "llvmAsmParser.y"
1595 {
1596     yyval.MethodArgList = new list<MethodArgument*>();
1597     yyval.MethodArgList->push_front(yyvsp[0].MethArgVal);
1598   ;
1599     break;}
1600 case 71:
1601 #line 672 "llvmAsmParser.y"
1602 {
1603     yyval.MethodArgList = yyvsp[0].MethodArgList;
1604   ;
1605     break;}
1606 case 72:
1607 #line 675 "llvmAsmParser.y"
1608 {
1609     yyval.MethodArgList = 0;
1610   ;
1611     break;}
1612 case 73:
1613 #line 679 "llvmAsmParser.y"
1614 {
1615   MethodType::ParamTypes ParamTypeList;
1616   if (yyvsp[-1].MethodArgList)
1617     for (list<MethodArgument*>::iterator I = yyvsp[-1].MethodArgList->begin(); I != yyvsp[-1].MethodArgList->end(); ++I)
1618       ParamTypeList.push_back((*I)->getType());
1619
1620   const MethodType *MT = MethodType::getMethodType(yyvsp[-4].TypeVal, ParamTypeList);
1621
1622   Method *M = new Method(MT, yyvsp[-3].StrVal);
1623   free(yyvsp[-3].StrVal);  // Free strdup'd memory!
1624
1625   InsertValue(M, CurModule.Values);
1626
1627   CurMeth.MethodStart(M);
1628
1629   // Add all of the arguments we parsed to the method...
1630   if (yyvsp[-1].MethodArgList) {        // Is null if empty...
1631     Method::ArgumentListType &ArgList = M->getArgumentList();
1632
1633     for (list<MethodArgument*>::iterator I = yyvsp[-1].MethodArgList->begin(); I != yyvsp[-1].MethodArgList->end(); ++I) {
1634       InsertValue(*I);
1635       ArgList.push_back(*I);
1636     }
1637     delete yyvsp[-1].MethodArgList;                     // We're now done with the argument list
1638   }
1639 ;
1640     break;}
1641 case 74:
1642 #line 706 "llvmAsmParser.y"
1643 {
1644   yyval.MethodVal = CurMeth.CurrentMethod;
1645 ;
1646     break;}
1647 case 75:
1648 #line 710 "llvmAsmParser.y"
1649 {
1650   yyval.MethodVal = yyvsp[-1].MethodVal;
1651 ;
1652     break;}
1653 case 76:
1654 #line 719 "llvmAsmParser.y"
1655 {    // A reference to a direct constant
1656     yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
1657   ;
1658     break;}
1659 case 77:
1660 #line 722 "llvmAsmParser.y"
1661 {
1662     yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
1663   ;
1664     break;}
1665 case 78:
1666 #line 725 "llvmAsmParser.y"
1667 {
1668     yyval.ValIDVal = ValID::create((int64_t)1);
1669   ;
1670     break;}
1671 case 79:
1672 #line 728 "llvmAsmParser.y"
1673 {
1674     yyval.ValIDVal = ValID::create((int64_t)0);
1675   ;
1676     break;}
1677 case 80:
1678 #line 731 "llvmAsmParser.y"
1679 {        // Quoted strings work too... especially for methods
1680     yyval.ValIDVal = ValID::create_conststr(yyvsp[0].StrVal);
1681   ;
1682     break;}
1683 case 81:
1684 #line 736 "llvmAsmParser.y"
1685 {           // Is it an integer reference...?
1686     yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
1687   ;
1688     break;}
1689 case 82:
1690 #line 739 "llvmAsmParser.y"
1691 {                // It must be a named reference then...
1692     yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
1693   ;
1694     break;}
1695 case 83:
1696 #line 742 "llvmAsmParser.y"
1697 {
1698     yyval.ValIDVal = yyvsp[0].ValIDVal;
1699   ;
1700     break;}
1701 case 84:
1702 #line 749 "llvmAsmParser.y"
1703 {
1704     Value *D = getVal(Type::TypeTy, yyvsp[0].ValIDVal, true);
1705     if (D == 0) ThrowException("Invalid user defined type: " + yyvsp[0].ValIDVal.getName());
1706
1707     // User defined type not in const pool!
1708     ConstPoolType *CPT = (ConstPoolType*)D->castConstantAsserting();
1709     yyval.TypeVal = CPT->getValue();
1710   ;
1711     break;}
1712 case 85:
1713 #line 757 "llvmAsmParser.y"
1714 {               // Method derived type?
1715     MethodType::ParamTypes Params(yyvsp[-1].TypeList->begin(), yyvsp[-1].TypeList->end());
1716     delete yyvsp[-1].TypeList;
1717     yyval.TypeVal = checkNewType(MethodType::getMethodType(yyvsp[-3].TypeVal, Params));
1718   ;
1719     break;}
1720 case 86:
1721 #line 762 "llvmAsmParser.y"
1722 {               // Method derived type?
1723     MethodType::ParamTypes Params;     // Empty list
1724     yyval.TypeVal = checkNewType(MethodType::getMethodType(yyvsp[-2].TypeVal, Params));
1725   ;
1726     break;}
1727 case 87:
1728 #line 766 "llvmAsmParser.y"
1729 {
1730     yyval.TypeVal = checkNewType(ArrayType::getArrayType(yyvsp[-1].TypeVal));
1731   ;
1732     break;}
1733 case 88:
1734 #line 769 "llvmAsmParser.y"
1735 {
1736     yyval.TypeVal = checkNewType(ArrayType::getArrayType(yyvsp[-1].TypeVal, (int)yyvsp[-3].UInt64Val));
1737   ;
1738     break;}
1739 case 89:
1740 #line 772 "llvmAsmParser.y"
1741 {
1742     StructType::ElementTypes Elements(yyvsp[-1].TypeList->begin(), yyvsp[-1].TypeList->end());
1743     delete yyvsp[-1].TypeList;
1744     yyval.TypeVal = checkNewType(StructType::getStructType(Elements));
1745   ;
1746     break;}
1747 case 90:
1748 #line 777 "llvmAsmParser.y"
1749 {
1750     yyval.TypeVal = checkNewType(StructType::getStructType(StructType::ElementTypes()));
1751   ;
1752     break;}
1753 case 91:
1754 #line 780 "llvmAsmParser.y"
1755 {
1756     yyval.TypeVal = checkNewType(PointerType::getPointerType(yyvsp[-1].TypeVal));
1757   ;
1758     break;}
1759 case 92:
1760 #line 785 "llvmAsmParser.y"
1761 {
1762     yyval.TypeList = new list<const Type*>();
1763     yyval.TypeList->push_back(yyvsp[0].TypeVal);
1764   ;
1765     break;}
1766 case 93:
1767 #line 789 "llvmAsmParser.y"
1768 {
1769     (yyval.TypeList=yyvsp[-2].TypeList)->push_back(yyvsp[0].TypeVal);
1770   ;
1771     break;}
1772 case 94:
1773 #line 794 "llvmAsmParser.y"
1774 {
1775     yyvsp[-1].MethodVal->getBasicBlocks().push_back(yyvsp[0].BasicBlockVal);
1776     yyval.MethodVal = yyvsp[-1].MethodVal;
1777   ;
1778     break;}
1779 case 95:
1780 #line 798 "llvmAsmParser.y"
1781 { // Do not allow methods with 0 basic blocks   
1782     yyval.MethodVal = yyvsp[-1].MethodVal;                  // in them...
1783     yyvsp[-1].MethodVal->getBasicBlocks().push_back(yyvsp[0].BasicBlockVal);
1784   ;
1785     break;}
1786 case 96:
1787 #line 807 "llvmAsmParser.y"
1788 {
1789     yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
1790     InsertValue(yyvsp[-1].BasicBlockVal);
1791     yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1792   ;
1793     break;}
1794 case 97:
1795 #line 812 "llvmAsmParser.y"
1796 {
1797     yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
1798     yyvsp[-1].BasicBlockVal->setName(yyvsp[-2].StrVal);
1799     free(yyvsp[-2].StrVal);         // Free the strdup'd memory...
1800
1801     InsertValue(yyvsp[-1].BasicBlockVal);
1802     yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1803   ;
1804     break;}
1805 case 98:
1806 #line 821 "llvmAsmParser.y"
1807 {
1808     yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
1809     yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
1810   ;
1811     break;}
1812 case 99:
1813 #line 825 "llvmAsmParser.y"
1814 {
1815     yyval.BasicBlockVal = new BasicBlock();
1816   ;
1817     break;}
1818 case 100:
1819 #line 829 "llvmAsmParser.y"
1820 {              // Return with a result...
1821     yyval.TermInstVal = new ReturnInst(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1822   ;
1823     break;}
1824 case 101:
1825 #line 832 "llvmAsmParser.y"
1826 {                                       // Return with no result...
1827     yyval.TermInstVal = new ReturnInst();
1828   ;
1829     break;}
1830 case 102:
1831 #line 835 "llvmAsmParser.y"
1832 {                         // Unconditional Branch...
1833     yyval.TermInstVal = new BranchInst((BasicBlock*)getVal(Type::LabelTy, yyvsp[0].ValIDVal));
1834   ;
1835     break;}
1836 case 103:
1837 #line 838 "llvmAsmParser.y"
1838 {  
1839     yyval.TermInstVal = new BranchInst((BasicBlock*)getVal(Type::LabelTy, yyvsp[-3].ValIDVal), 
1840                         (BasicBlock*)getVal(Type::LabelTy, yyvsp[0].ValIDVal),
1841                         getVal(Type::BoolTy, yyvsp[-6].ValIDVal));
1842   ;
1843     break;}
1844 case 104:
1845 #line 843 "llvmAsmParser.y"
1846 {
1847     SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].TypeVal, yyvsp[-6].ValIDVal), 
1848                                    (BasicBlock*)getVal(Type::LabelTy, yyvsp[-3].ValIDVal));
1849     yyval.TermInstVal = S;
1850
1851     list<pair<ConstPoolVal*, BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), 
1852                                                       end = yyvsp[-1].JumpTable->end();
1853     for (; I != end; ++I)
1854       S->dest_push_back(I->first, I->second);
1855   ;
1856     break;}
1857 case 105:
1858 #line 854 "llvmAsmParser.y"
1859 {
1860     yyval.JumpTable = yyvsp[-5].JumpTable;
1861     ConstPoolVal *V = (ConstPoolVal*)getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal, true);
1862     if (V == 0)
1863       ThrowException("May only switch on a constant pool value!");
1864
1865     yyval.JumpTable->push_back(make_pair(V, (BasicBlock*)getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal)));
1866   ;
1867     break;}
1868 case 106:
1869 #line 862 "llvmAsmParser.y"
1870 {
1871     yyval.JumpTable = new list<pair<ConstPoolVal*, BasicBlock*> >();
1872     ConstPoolVal *V = (ConstPoolVal*)getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal, true);
1873
1874     if (V == 0)
1875       ThrowException("May only switch on a constant pool value!");
1876
1877     yyval.JumpTable->push_back(make_pair(V, (BasicBlock*)getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal)));
1878   ;
1879     break;}
1880 case 107:
1881 #line 872 "llvmAsmParser.y"
1882 {
1883   if (yyvsp[-1].StrVal)              // Is this definition named??
1884     yyvsp[0].InstVal->setName(yyvsp[-1].StrVal);   // if so, assign the name...
1885
1886   InsertValue(yyvsp[0].InstVal);
1887   yyval.InstVal = yyvsp[0].InstVal;
1888 ;
1889     break;}
1890 case 108:
1891 #line 880 "llvmAsmParser.y"
1892 {    // Used for PHI nodes
1893     yyval.PHIList = new list<pair<Value*, BasicBlock*> >();
1894     yyval.PHIList->push_back(make_pair(getVal(yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), 
1895                             (BasicBlock*)getVal(Type::LabelTy, yyvsp[-1].ValIDVal)));
1896   ;
1897     break;}
1898 case 109:
1899 #line 885 "llvmAsmParser.y"
1900 {
1901     yyval.PHIList = yyvsp[-6].PHIList;
1902     yyvsp[-6].PHIList->push_back(make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal),
1903                             (BasicBlock*)getVal(Type::LabelTy, yyvsp[-1].ValIDVal)));
1904   ;
1905     break;}
1906 case 110:
1907 #line 892 "llvmAsmParser.y"
1908 {    // Used for call statements...
1909     yyval.ValueList = new list<Value*>();
1910     yyval.ValueList->push_back(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1911   ;
1912     break;}
1913 case 111:
1914 #line 896 "llvmAsmParser.y"
1915 {
1916     yyval.ValueList = yyvsp[-3].ValueList;
1917     yyvsp[-3].ValueList->push_back(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1918   ;
1919     break;}
1920 case 113:
1921 #line 902 "llvmAsmParser.y"
1922 { yyval.ValueList = 0; ;
1923     break;}
1924 case 114:
1925 #line 904 "llvmAsmParser.y"
1926 {
1927     yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(yyvsp[-3].TypeVal, yyvsp[0].ValIDVal));
1928     if (yyval.InstVal == 0)
1929       ThrowException("binary operator returned null!");
1930   ;
1931     break;}
1932 case 115:
1933 #line 909 "llvmAsmParser.y"
1934 {
1935     yyval.InstVal = UnaryOperator::create(yyvsp[-2].UnaryOpVal, getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1936     if (yyval.InstVal == 0)
1937       ThrowException("unary operator returned null!");
1938   ;
1939     break;}
1940 case 116:
1941 #line 914 "llvmAsmParser.y"
1942 {
1943     if (yyvsp[-1].TypeVal != Type::UByteTy) ThrowException("Shift amount must be ubyte!");
1944     yyval.InstVal = new ShiftInst(yyvsp[-5].OtherOpVal, getVal(yyvsp[-4].TypeVal, yyvsp[-3].ValIDVal), getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
1945   ;
1946     break;}
1947 case 117:
1948 #line 918 "llvmAsmParser.y"
1949 {
1950     yyval.InstVal = new CastInst(getVal(yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), yyvsp[0].TypeVal);
1951   ;
1952     break;}
1953 case 118:
1954 #line 921 "llvmAsmParser.y"
1955 {
1956     const Type *Ty = yyvsp[0].PHIList->front().first->getType();
1957     yyval.InstVal = new PHINode(Ty);
1958     while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
1959       if (yyvsp[0].PHIList->front().first->getType() != Ty) 
1960         ThrowException("All elements of a PHI node must be of the same type!");
1961       ((PHINode*)yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
1962       yyvsp[0].PHIList->pop_front();
1963     }
1964     delete yyvsp[0].PHIList;  // Free the list...
1965   ;
1966     break;}
1967 case 119:
1968 #line 932 "llvmAsmParser.y"
1969 {
1970     if (!yyvsp[-4].TypeVal->isMethodType())
1971       ThrowException("Can only call methods: invalid type '" + 
1972                      yyvsp[-4].TypeVal->getName() + "'!");
1973
1974     const MethodType *Ty = (const MethodType*)yyvsp[-4].TypeVal;
1975
1976     Value *V = getVal(Ty, yyvsp[-3].ValIDVal);
1977     if (!V->isMethod() || V->getType() != Ty)
1978       ThrowException("Cannot call: " + yyvsp[-3].ValIDVal.getName() + "!");
1979
1980     // Create or access a new type that corresponds to the function call...
1981     vector<Value *> Params;
1982
1983     if (yyvsp[-1].ValueList) {
1984       // Pull out just the arguments...
1985       Params.insert(Params.begin(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
1986       delete yyvsp[-1].ValueList;
1987
1988       // Loop through MethodType's arguments and ensure they are specified
1989       // correctly!
1990       //
1991       MethodType::ParamTypes::const_iterator I = Ty->getParamTypes().begin();
1992       unsigned i;
1993       for (i = 0; i < Params.size() && I != Ty->getParamTypes().end(); ++i,++I){
1994         if (Params[i]->getType() != *I)
1995           ThrowException("Parameter " + utostr(i) + " is not of type '" + 
1996                          (*I)->getName() + "'!");
1997       }
1998
1999       if (i != Params.size() || I != Ty->getParamTypes().end())
2000         ThrowException("Invalid number of parameters detected!");
2001     }
2002
2003     // Create the call node...
2004     yyval.InstVal = new CallInst((Method*)V, Params);
2005   ;
2006     break;}
2007 case 120:
2008 #line 969 "llvmAsmParser.y"
2009 {
2010     yyval.InstVal = yyvsp[0].InstVal;
2011   ;
2012     break;}
2013 case 121:
2014 #line 974 "llvmAsmParser.y"
2015
2016   yyval.ConstVector = yyvsp[0].ConstVector; 
2017 ;
2018     break;}
2019 case 122:
2020 #line 976 "llvmAsmParser.y"
2021
2022   yyval.ConstVector = new vector<ConstPoolVal*>(); 
2023 ;
2024     break;}
2025 case 123:
2026 #line 980 "llvmAsmParser.y"
2027 {
2028     yyval.InstVal = new MallocInst(checkNewType(PointerType::getPointerType(yyvsp[0].TypeVal)));
2029   ;
2030     break;}
2031 case 124:
2032 #line 983 "llvmAsmParser.y"
2033 {
2034     if (!yyvsp[-3].TypeVal->isArrayType() || ((const ArrayType*)yyvsp[-3].TypeVal)->isSized())
2035       ThrowException("Trying to allocate " + yyvsp[-3].TypeVal->getName() + 
2036                      " as unsized array!");
2037     const Type *Ty = checkNewType(PointerType::getPointerType(yyvsp[-3].TypeVal));
2038     yyval.InstVal = new MallocInst(Ty, getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
2039   ;
2040     break;}
2041 case 125:
2042 #line 990 "llvmAsmParser.y"
2043 {
2044     yyval.InstVal = new AllocaInst(checkNewType(PointerType::getPointerType(yyvsp[0].TypeVal)));
2045   ;
2046     break;}
2047 case 126:
2048 #line 993 "llvmAsmParser.y"
2049 {
2050     if (!yyvsp[-3].TypeVal->isArrayType() || ((const ArrayType*)yyvsp[-3].TypeVal)->isSized())
2051       ThrowException("Trying to allocate " + yyvsp[-3].TypeVal->getName() + 
2052                      " as unsized array!");
2053     const Type *Ty = checkNewType(PointerType::getPointerType(yyvsp[-3].TypeVal));    
2054     Value *ArrSize = getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
2055     yyval.InstVal = new AllocaInst(Ty, ArrSize);
2056   ;
2057     break;}
2058 case 127:
2059 #line 1001 "llvmAsmParser.y"
2060 {
2061     if (!yyvsp[-1].TypeVal->isPointerType())
2062       ThrowException("Trying to free nonpointer type " + yyvsp[-1].TypeVal->getName() + "!");
2063     yyval.InstVal = new FreeInst(getVal(yyvsp[-1].TypeVal, yyvsp[0].ValIDVal));
2064   ;
2065     break;}
2066 case 128:
2067 #line 1007 "llvmAsmParser.y"
2068 {
2069     if (!yyvsp[-2].TypeVal->isPointerType())
2070       ThrowException("Can't load from nonpointer type: " + yyvsp[-2].TypeVal->getName());
2071     if (LoadInst::getIndexedType(yyvsp[-2].TypeVal, *yyvsp[0].ConstVector) == 0)
2072       ThrowException("Invalid indices for load instruction!");
2073
2074     yyval.InstVal = new LoadInst(getVal(yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ConstVector);
2075     delete yyvsp[0].ConstVector;   // Free the vector...
2076   ;
2077     break;}
2078 case 129:
2079 #line 1016 "llvmAsmParser.y"
2080 {
2081     if (!yyvsp[-2].TypeVal->isPointerType())
2082       ThrowException("Can't store to a nonpointer type: " + yyvsp[-2].TypeVal->getName());
2083     const Type *ElTy = StoreInst::getIndexedType(yyvsp[-2].TypeVal, *yyvsp[0].ConstVector);
2084     if (ElTy == 0)
2085       ThrowException("Can't store into that field list!");
2086     if (ElTy != yyvsp[-5].TypeVal)
2087       ThrowException("Can't store '" + yyvsp[-5].TypeVal->getName() + "' into space of type '"+
2088                      ElTy->getName() + "'!");
2089     yyval.InstVal = new StoreInst(getVal(yyvsp[-5].TypeVal, yyvsp[-4].ValIDVal), getVal(yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ConstVector);
2090     delete yyvsp[0].ConstVector;
2091   ;
2092     break;}
2093 case 130:
2094 #line 1028 "llvmAsmParser.y"
2095 {
2096     if (!yyvsp[-2].TypeVal->isPointerType())
2097       ThrowException("getelementptr insn requires pointer operand!");
2098     if (!GetElementPtrInst::getIndexedType(yyvsp[-2].TypeVal, *yyvsp[0].ConstVector, true))
2099       ThrowException("Can't get element ptr '" + yyvsp[-2].TypeVal->getName() + "'!");
2100     yyval.InstVal = new GetElementPtrInst(getVal(yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ConstVector);
2101     delete yyvsp[0].ConstVector;
2102     checkNewType(yyval.InstVal->getType());
2103   ;
2104     break;}
2105 }
2106    /* the action file gets copied in in place of this dollarsign */
2107 #line 543 "/usr/dcs/software/supported/encap/bison-1.28/share/bison.simple"
2108 \f
2109   yyvsp -= yylen;
2110   yyssp -= yylen;
2111 #ifdef YYLSP_NEEDED
2112   yylsp -= yylen;
2113 #endif
2114
2115 #if YYDEBUG != 0
2116   if (yydebug)
2117     {
2118       short *ssp1 = yyss - 1;
2119       fprintf (stderr, "state stack now");
2120       while (ssp1 != yyssp)
2121         fprintf (stderr, " %d", *++ssp1);
2122       fprintf (stderr, "\n");
2123     }
2124 #endif
2125
2126   *++yyvsp = yyval;
2127
2128 #ifdef YYLSP_NEEDED
2129   yylsp++;
2130   if (yylen == 0)
2131     {
2132       yylsp->first_line = yylloc.first_line;
2133       yylsp->first_column = yylloc.first_column;
2134       yylsp->last_line = (yylsp-1)->last_line;
2135       yylsp->last_column = (yylsp-1)->last_column;
2136       yylsp->text = 0;
2137     }
2138   else
2139     {
2140       yylsp->last_line = (yylsp+yylen-1)->last_line;
2141       yylsp->last_column = (yylsp+yylen-1)->last_column;
2142     }
2143 #endif
2144
2145   /* Now "shift" the result of the reduction.
2146      Determine what state that goes to,
2147      based on the state we popped back to
2148      and the rule number reduced by.  */
2149
2150   yyn = yyr1[yyn];
2151
2152   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
2153   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2154     yystate = yytable[yystate];
2155   else
2156     yystate = yydefgoto[yyn - YYNTBASE];
2157
2158   goto yynewstate;
2159
2160 yyerrlab:   /* here on detecting error */
2161
2162   if (! yyerrstatus)
2163     /* If not already recovering from an error, report this error.  */
2164     {
2165       ++yynerrs;
2166
2167 #ifdef YYERROR_VERBOSE
2168       yyn = yypact[yystate];
2169
2170       if (yyn > YYFLAG && yyn < YYLAST)
2171         {
2172           int size = 0;
2173           char *msg;
2174           int x, count;
2175
2176           count = 0;
2177           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
2178           for (x = (yyn < 0 ? -yyn : 0);
2179                x < (sizeof(yytname) / sizeof(char *)); x++)
2180             if (yycheck[x + yyn] == x)
2181               size += strlen(yytname[x]) + 15, count++;
2182           msg = (char *) malloc(size + 15);
2183           if (msg != 0)
2184             {
2185               strcpy(msg, "parse error");
2186
2187               if (count < 5)
2188                 {
2189                   count = 0;
2190                   for (x = (yyn < 0 ? -yyn : 0);
2191                        x < (sizeof(yytname) / sizeof(char *)); x++)
2192                     if (yycheck[x + yyn] == x)
2193                       {
2194                         strcat(msg, count == 0 ? ", expecting `" : " or `");
2195                         strcat(msg, yytname[x]);
2196                         strcat(msg, "'");
2197                         count++;
2198                       }
2199                 }
2200               yyerror(msg);
2201               free(msg);
2202             }
2203           else
2204             yyerror ("parse error; also virtual memory exceeded");
2205         }
2206       else
2207 #endif /* YYERROR_VERBOSE */
2208         yyerror("parse error");
2209     }
2210
2211   goto yyerrlab1;
2212 yyerrlab1:   /* here on error raised explicitly by an action */
2213
2214   if (yyerrstatus == 3)
2215     {
2216       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
2217
2218       /* return failure if at end of input */
2219       if (yychar == YYEOF)
2220         YYABORT;
2221
2222 #if YYDEBUG != 0
2223       if (yydebug)
2224         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
2225 #endif
2226
2227       yychar = YYEMPTY;
2228     }
2229
2230   /* Else will try to reuse lookahead token
2231      after shifting the error token.  */
2232
2233   yyerrstatus = 3;              /* Each real token shifted decrements this */
2234
2235   goto yyerrhandle;
2236
2237 yyerrdefault:  /* current state does not do anything special for the error token. */
2238
2239 #if 0
2240   /* This is wrong; only states that explicitly want error tokens
2241      should shift them.  */
2242   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
2243   if (yyn) goto yydefault;
2244 #endif
2245
2246 yyerrpop:   /* pop the current state because it cannot handle the error token */
2247
2248   if (yyssp == yyss) YYABORT;
2249   yyvsp--;
2250   yystate = *--yyssp;
2251 #ifdef YYLSP_NEEDED
2252   yylsp--;
2253 #endif
2254
2255 #if YYDEBUG != 0
2256   if (yydebug)
2257     {
2258       short *ssp1 = yyss - 1;
2259       fprintf (stderr, "Error: state stack now");
2260       while (ssp1 != yyssp)
2261         fprintf (stderr, " %d", *++ssp1);
2262       fprintf (stderr, "\n");
2263     }
2264 #endif
2265
2266 yyerrhandle:
2267
2268   yyn = yypact[yystate];
2269   if (yyn == YYFLAG)
2270     goto yyerrdefault;
2271
2272   yyn += YYTERROR;
2273   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
2274     goto yyerrdefault;
2275
2276   yyn = yytable[yyn];
2277   if (yyn < 0)
2278     {
2279       if (yyn == YYFLAG)
2280         goto yyerrpop;
2281       yyn = -yyn;
2282       goto yyreduce;
2283     }
2284   else if (yyn == 0)
2285     goto yyerrpop;
2286
2287   if (yyn == YYFINAL)
2288     YYACCEPT;
2289
2290 #if YYDEBUG != 0
2291   if (yydebug)
2292     fprintf(stderr, "Shifting error token, ");
2293 #endif
2294
2295   *++yyvsp = yylval;
2296 #ifdef YYLSP_NEEDED
2297   *++yylsp = yylloc;
2298 #endif
2299
2300   yystate = yyn;
2301   goto yynewstate;
2302
2303  yyacceptlab:
2304   /* YYACCEPT comes here.  */
2305   if (yyfree_stacks)
2306     {
2307       free (yyss);
2308       free (yyvs);
2309 #ifdef YYLSP_NEEDED
2310       free (yyls);
2311 #endif
2312     }
2313   return 0;
2314
2315  yyabortlab:
2316   /* YYABORT comes here.  */
2317   if (yyfree_stacks)
2318     {
2319       free (yyss);
2320       free (yyvs);
2321 #ifdef YYLSP_NEEDED
2322       free (yyls);
2323 #endif
2324     }
2325   return 1;
2326 }
2327 #line 1038 "llvmAsmParser.y"
2328
2329 int yyerror(const char *ErrorMsg) {
2330   ThrowException(string("Parse error: ") + ErrorMsg);
2331   return 0;
2332 }