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