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