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