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