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