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