Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 1 | /* A Bison parser, made by GNU Bison 1.875c. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3 | /* Skeleton parser for Yacc-like parsing with Bison, |
| 4 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2, or (at your option) |
| 9 | any later version. |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 10 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 | Boston, MA 02111-1307, USA. */ |
| 20 | |
| 21 | /* As a special exception, when this file is copied by Bison into a |
| 22 | Bison output file, you may use that output file without restriction. |
| 23 | This special exception was added by the Free Software Foundation |
| 24 | in version 1.24 of Bison. */ |
| 25 | |
| 26 | /* Written by Richard Stallman by simplifying the original so called |
| 27 | ``semantic'' parser. */ |
| 28 | |
| 29 | /* All symbols defined below should begin with yy or YY, to avoid |
| 30 | infringing on user name space. This should be done even for local |
| 31 | variables, as they might otherwise be expanded by user macros. |
| 32 | There are some unavoidable exceptions within include files to |
| 33 | define necessary library symbols; they are noted "INFRINGES ON |
| 34 | USER NAME SPACE" below. */ |
| 35 | |
| 36 | /* Identify Bison output. */ |
| 37 | #define YYBISON 1 |
| 38 | |
| 39 | /* Skeleton name. */ |
| 40 | #define YYSKELETON_NAME "yacc.c" |
| 41 | |
| 42 | /* Pure parsers. */ |
| 43 | #define YYPURE 0 |
| 44 | |
| 45 | /* Using locations. */ |
| 46 | #define YYLSP_NEEDED 0 |
| 47 | |
| 48 | /* If NAME_PREFIX is specified substitute the variables and functions |
| 49 | names. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 50 | #define yyparse llvmAsmparse |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 51 | #define yylex llvmAsmlex |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 52 | #define yyerror llvmAsmerror |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 53 | #define yylval llvmAsmlval |
| 54 | #define yychar llvmAsmchar |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 55 | #define yydebug llvmAsmdebug |
| 56 | #define yynerrs llvmAsmnerrs |
| 57 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 58 | |
| 59 | /* Tokens. */ |
| 60 | #ifndef YYTOKENTYPE |
| 61 | # define YYTOKENTYPE |
| 62 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
| 63 | know about them. */ |
| 64 | enum yytokentype { |
| 65 | ESINT64VAL = 258, |
| 66 | EUINT64VAL = 259, |
| 67 | SINTVAL = 260, |
| 68 | UINTVAL = 261, |
| 69 | FPVAL = 262, |
| 70 | VOID = 263, |
| 71 | BOOL = 264, |
| 72 | SBYTE = 265, |
| 73 | UBYTE = 266, |
| 74 | SHORT = 267, |
| 75 | USHORT = 268, |
| 76 | INT = 269, |
| 77 | UINT = 270, |
| 78 | LONG = 271, |
| 79 | ULONG = 272, |
| 80 | FLOAT = 273, |
| 81 | DOUBLE = 274, |
| 82 | TYPE = 275, |
| 83 | LABEL = 276, |
| 84 | VAR_ID = 277, |
| 85 | LABELSTR = 278, |
| 86 | STRINGCONSTANT = 279, |
| 87 | IMPLEMENTATION = 280, |
| 88 | ZEROINITIALIZER = 281, |
| 89 | TRUETOK = 282, |
| 90 | FALSETOK = 283, |
| 91 | BEGINTOK = 284, |
| 92 | ENDTOK = 285, |
| 93 | DECLARE = 286, |
| 94 | GLOBAL = 287, |
| 95 | CONSTANT = 288, |
| 96 | SECTION = 289, |
| 97 | VOLATILE = 290, |
| 98 | TO = 291, |
| 99 | DOTDOTDOT = 292, |
| 100 | NULL_TOK = 293, |
| 101 | UNDEF = 294, |
| 102 | CONST = 295, |
| 103 | INTERNAL = 296, |
| 104 | LINKONCE = 297, |
| 105 | WEAK = 298, |
| 106 | APPENDING = 299, |
| 107 | OPAQUE = 300, |
| 108 | NOT = 301, |
| 109 | EXTERNAL = 302, |
| 110 | TARGET = 303, |
| 111 | TRIPLE = 304, |
| 112 | ENDIAN = 305, |
| 113 | POINTERSIZE = 306, |
| 114 | LITTLE = 307, |
| 115 | BIG = 308, |
| 116 | ALIGN = 309, |
| 117 | DEPLIBS = 310, |
| 118 | CALL = 311, |
| 119 | TAIL = 312, |
| 120 | CC_TOK = 313, |
| 121 | CCC_TOK = 314, |
| 122 | FASTCC_TOK = 315, |
| 123 | COLDCC_TOK = 316, |
| 124 | RET = 317, |
| 125 | BR = 318, |
| 126 | SWITCH = 319, |
| 127 | INVOKE = 320, |
| 128 | UNWIND = 321, |
| 129 | UNREACHABLE = 322, |
| 130 | ADD = 323, |
| 131 | SUB = 324, |
| 132 | MUL = 325, |
| 133 | DIV = 326, |
| 134 | REM = 327, |
| 135 | AND = 328, |
| 136 | OR = 329, |
| 137 | XOR = 330, |
| 138 | SETLE = 331, |
| 139 | SETGE = 332, |
| 140 | SETLT = 333, |
| 141 | SETGT = 334, |
| 142 | SETEQ = 335, |
| 143 | SETNE = 336, |
| 144 | MALLOC = 337, |
| 145 | ALLOCA = 338, |
| 146 | FREE = 339, |
| 147 | LOAD = 340, |
| 148 | STORE = 341, |
| 149 | GETELEMENTPTR = 342, |
| 150 | PHI_TOK = 343, |
| 151 | CAST = 344, |
| 152 | SELECT = 345, |
| 153 | SHL = 346, |
| 154 | SHR = 347, |
| 155 | VAARG = 348, |
| 156 | EXTRACTELEMENT = 349, |
| 157 | INSERTELEMENT = 350, |
| 158 | VAARG_old = 351, |
| 159 | VANEXT_old = 352 |
| 160 | }; |
| 161 | #endif |
| 162 | #define ESINT64VAL 258 |
| 163 | #define EUINT64VAL 259 |
| 164 | #define SINTVAL 260 |
| 165 | #define UINTVAL 261 |
| 166 | #define FPVAL 262 |
| 167 | #define VOID 263 |
| 168 | #define BOOL 264 |
| 169 | #define SBYTE 265 |
| 170 | #define UBYTE 266 |
| 171 | #define SHORT 267 |
| 172 | #define USHORT 268 |
| 173 | #define INT 269 |
| 174 | #define UINT 270 |
| 175 | #define LONG 271 |
| 176 | #define ULONG 272 |
| 177 | #define FLOAT 273 |
| 178 | #define DOUBLE 274 |
| 179 | #define TYPE 275 |
| 180 | #define LABEL 276 |
| 181 | #define VAR_ID 277 |
| 182 | #define LABELSTR 278 |
| 183 | #define STRINGCONSTANT 279 |
| 184 | #define IMPLEMENTATION 280 |
| 185 | #define ZEROINITIALIZER 281 |
| 186 | #define TRUETOK 282 |
| 187 | #define FALSETOK 283 |
| 188 | #define BEGINTOK 284 |
| 189 | #define ENDTOK 285 |
| 190 | #define DECLARE 286 |
| 191 | #define GLOBAL 287 |
| 192 | #define CONSTANT 288 |
| 193 | #define SECTION 289 |
| 194 | #define VOLATILE 290 |
| 195 | #define TO 291 |
| 196 | #define DOTDOTDOT 292 |
| 197 | #define NULL_TOK 293 |
| 198 | #define UNDEF 294 |
| 199 | #define CONST 295 |
| 200 | #define INTERNAL 296 |
| 201 | #define LINKONCE 297 |
| 202 | #define WEAK 298 |
| 203 | #define APPENDING 299 |
| 204 | #define OPAQUE 300 |
| 205 | #define NOT 301 |
| 206 | #define EXTERNAL 302 |
| 207 | #define TARGET 303 |
| 208 | #define TRIPLE 304 |
| 209 | #define ENDIAN 305 |
| 210 | #define POINTERSIZE 306 |
| 211 | #define LITTLE 307 |
| 212 | #define BIG 308 |
| 213 | #define ALIGN 309 |
| 214 | #define DEPLIBS 310 |
| 215 | #define CALL 311 |
| 216 | #define TAIL 312 |
| 217 | #define CC_TOK 313 |
| 218 | #define CCC_TOK 314 |
| 219 | #define FASTCC_TOK 315 |
| 220 | #define COLDCC_TOK 316 |
| 221 | #define RET 317 |
| 222 | #define BR 318 |
| 223 | #define SWITCH 319 |
| 224 | #define INVOKE 320 |
| 225 | #define UNWIND 321 |
| 226 | #define UNREACHABLE 322 |
| 227 | #define ADD 323 |
| 228 | #define SUB 324 |
| 229 | #define MUL 325 |
| 230 | #define DIV 326 |
| 231 | #define REM 327 |
| 232 | #define AND 328 |
| 233 | #define OR 329 |
| 234 | #define XOR 330 |
| 235 | #define SETLE 331 |
| 236 | #define SETGE 332 |
| 237 | #define SETLT 333 |
| 238 | #define SETGT 334 |
| 239 | #define SETEQ 335 |
| 240 | #define SETNE 336 |
| 241 | #define MALLOC 337 |
| 242 | #define ALLOCA 338 |
| 243 | #define FREE 339 |
| 244 | #define LOAD 340 |
| 245 | #define STORE 341 |
| 246 | #define GETELEMENTPTR 342 |
| 247 | #define PHI_TOK 343 |
| 248 | #define CAST 344 |
| 249 | #define SELECT 345 |
| 250 | #define SHL 346 |
| 251 | #define SHR 347 |
| 252 | #define VAARG 348 |
| 253 | #define EXTRACTELEMENT 349 |
| 254 | #define INSERTELEMENT 350 |
| 255 | #define VAARG_old 351 |
| 256 | #define VANEXT_old 352 |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | /* Copy the first part of user declarations. */ |
| 262 | #line 14 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 263 | |
| 264 | #include "ParserInternals.h" |
| 265 | #include "llvm/CallingConv.h" |
| 266 | #include "llvm/Instructions.h" |
| 267 | #include "llvm/Module.h" |
| 268 | #include "llvm/SymbolTable.h" |
Reid Spencer | b4f9a6f | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 269 | #include "llvm/Assembly/AutoUpgrade.h" |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 270 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
| 271 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 272 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 273 | #include <algorithm> |
| 274 | #include <iostream> |
| 275 | #include <list> |
| 276 | #include <utility> |
| 277 | |
| 278 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 279 | int yylex(); // declaration" of xxx warnings. |
| 280 | int yyparse(); |
| 281 | |
| 282 | namespace llvm { |
| 283 | std::string CurFilename; |
| 284 | } |
| 285 | using namespace llvm; |
| 286 | |
| 287 | static Module *ParserResult; |
| 288 | |
| 289 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 290 | // relating to upreferences in the input stream. |
| 291 | // |
| 292 | //#define DEBUG_UPREFS 1 |
| 293 | #ifdef DEBUG_UPREFS |
| 294 | #define UR_OUT(X) std::cerr << X |
| 295 | #else |
| 296 | #define UR_OUT(X) |
| 297 | #endif |
| 298 | |
| 299 | #define YYERROR_VERBOSE 1 |
| 300 | |
| 301 | static bool ObsoleteVarArgs; |
| 302 | static bool NewVarArgs; |
Chris Lattner | 11ca4d6 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 303 | static BasicBlock *CurBB; |
| 304 | static GlobalVariable *CurGV; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 305 | |
| 306 | |
| 307 | // This contains info used when building the body of a function. It is |
| 308 | // destroyed when the function is completed. |
| 309 | // |
| 310 | typedef std::vector<Value *> ValueList; // Numbered defs |
| 311 | static void |
| 312 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 313 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 314 | |
| 315 | static struct PerModuleInfo { |
| 316 | Module *CurrentModule; |
| 317 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 318 | std::map<const Type *,ValueList> LateResolveValues; |
| 319 | std::vector<PATypeHolder> Types; |
| 320 | std::map<ValID, PATypeHolder> LateResolveTypes; |
| 321 | |
| 322 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
| 323 | /// how they were referenced and one which line of the input they came from so |
| 324 | /// that we can resolve them later and print error messages as appropriate. |
| 325 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 326 | |
| 327 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 328 | // references to global values. Global values may be referenced before they |
| 329 | // are defined, and if so, the temporary object that they represent is held |
| 330 | // here. This is used for forward references of GlobalValues. |
| 331 | // |
| 332 | typedef std::map<std::pair<const PointerType *, |
| 333 | ValID>, GlobalValue*> GlobalRefsType; |
| 334 | GlobalRefsType GlobalRefs; |
| 335 | |
| 336 | void ModuleDone() { |
| 337 | // If we could not resolve some functions at function compilation time |
| 338 | // (calls to functions before they are defined), resolve them now... Types |
| 339 | // are resolved when the constant pool has been completely parsed. |
| 340 | // |
| 341 | ResolveDefinitions(LateResolveValues); |
| 342 | |
| 343 | // Check to make sure that all global value forward references have been |
| 344 | // resolved! |
| 345 | // |
| 346 | if (!GlobalRefs.empty()) { |
| 347 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 348 | |
| 349 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 350 | I != E; ++I) { |
| 351 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 352 | I->first.second.getName() + "\n"; |
| 353 | } |
| 354 | ThrowException(UndefinedReferences); |
| 355 | } |
| 356 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 357 | // Look for intrinsic functions and CallInst that need to be upgraded |
| 358 | for (Module::iterator FI = CurrentModule->begin(),FE = CurrentModule->end(); |
| 359 | FI != FE; ++FI) |
| 360 | UpgradeCallsToIntrinsic(FI); |
Reid Spencer | b4f9a6f | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 361 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 362 | Values.clear(); // Clear out function local definitions |
| 363 | Types.clear(); |
| 364 | CurrentModule = 0; |
| 365 | } |
| 366 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 367 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 368 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 369 | // If not, just return null. |
| 370 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 371 | // Check to see if there is a forward reference to this global variable... |
| 372 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 373 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 374 | GlobalValue *Ret = 0; |
| 375 | if (I != GlobalRefs.end()) { |
| 376 | Ret = I->second; |
| 377 | GlobalRefs.erase(I); |
| 378 | } |
| 379 | return Ret; |
| 380 | } |
| 381 | } CurModule; |
| 382 | |
| 383 | static struct PerFunctionInfo { |
| 384 | Function *CurrentFunction; // Pointer to current function being created |
| 385 | |
| 386 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
| 387 | std::map<const Type*, ValueList> LateResolveValues; |
| 388 | bool isDeclare; // Is this function a forward declararation? |
| 389 | |
| 390 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 391 | /// track of them here. |
| 392 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 393 | std::vector<BasicBlock*> NumberedBlocks; |
| 394 | unsigned NextBBNum; |
| 395 | |
| 396 | inline PerFunctionInfo() { |
| 397 | CurrentFunction = 0; |
| 398 | isDeclare = false; |
| 399 | } |
| 400 | |
| 401 | inline void FunctionStart(Function *M) { |
| 402 | CurrentFunction = M; |
| 403 | NextBBNum = 0; |
| 404 | } |
| 405 | |
| 406 | void FunctionDone() { |
| 407 | NumberedBlocks.clear(); |
| 408 | |
| 409 | // Any forward referenced blocks left? |
| 410 | if (!BBForwardRefs.empty()) |
| 411 | ThrowException("Undefined reference to label " + |
| 412 | BBForwardRefs.begin()->first->getName()); |
| 413 | |
| 414 | // Resolve all forward references now. |
| 415 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 416 | |
| 417 | Values.clear(); // Clear out function local definitions |
| 418 | CurrentFunction = 0; |
| 419 | isDeclare = false; |
| 420 | } |
| 421 | } CurFun; // Info for the current function... |
| 422 | |
| 423 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 424 | |
| 425 | |
| 426 | //===----------------------------------------------------------------------===// |
| 427 | // Code to handle definitions of all the types |
| 428 | //===----------------------------------------------------------------------===// |
| 429 | |
| 430 | static int InsertValue(Value *V, |
| 431 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 432 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 433 | |
| 434 | // Yes, insert the value into the value table... |
| 435 | ValueList &List = ValueTab[V->getType()]; |
| 436 | List.push_back(V); |
| 437 | return List.size()-1; |
| 438 | } |
| 439 | |
| 440 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 441 | switch (D.Type) { |
| 442 | case ValID::NumberVal: // Is it a numbered definition? |
| 443 | // Module constants occupy the lowest numbered slots... |
| 444 | if ((unsigned)D.Num < CurModule.Types.size()) |
| 445 | return CurModule.Types[(unsigned)D.Num]; |
| 446 | break; |
| 447 | case ValID::NameVal: // Is it a named definition? |
| 448 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 449 | D.destroy(); // Free old strdup'd memory... |
| 450 | return N; |
| 451 | } |
| 452 | break; |
| 453 | default: |
| 454 | ThrowException("Internal parser error: Invalid symbol type reference!"); |
| 455 | } |
| 456 | |
| 457 | // If we reached here, we referenced either a symbol that we don't know about |
| 458 | // or an id number that hasn't been read yet. We may be referencing something |
| 459 | // forward, so just create an entry to be resolved later and get to it... |
| 460 | // |
| 461 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 462 | |
| 463 | |
| 464 | if (inFunctionScope()) { |
| 465 | if (D.Type == ValID::NameVal) |
| 466 | ThrowException("Reference to an undefined type: '" + D.getName() + "'"); |
| 467 | else |
| 468 | ThrowException("Reference to an undefined type: #" + itostr(D.Num)); |
| 469 | } |
| 470 | |
| 471 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
| 472 | if (I != CurModule.LateResolveTypes.end()) |
| 473 | return I->second; |
| 474 | |
| 475 | Type *Typ = OpaqueType::get(); |
| 476 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 477 | return Typ; |
| 478 | } |
| 479 | |
| 480 | static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) { |
| 481 | SymbolTable &SymTab = |
| 482 | inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() : |
| 483 | CurModule.CurrentModule->getSymbolTable(); |
| 484 | return SymTab.lookup(Ty, Name); |
| 485 | } |
| 486 | |
| 487 | // getValNonImprovising - Look up the value specified by the provided type and |
| 488 | // the provided ValID. If the value exists and has already been defined, return |
| 489 | // it. Otherwise return null. |
| 490 | // |
| 491 | static Value *getValNonImprovising(const Type *Ty, const ValID &D) { |
| 492 | if (isa<FunctionType>(Ty)) |
| 493 | ThrowException("Functions are not values and " |
| 494 | "must be referenced as pointers"); |
| 495 | |
| 496 | switch (D.Type) { |
| 497 | case ValID::NumberVal: { // Is it a numbered definition? |
| 498 | unsigned Num = (unsigned)D.Num; |
| 499 | |
| 500 | // Module constants occupy the lowest numbered slots... |
| 501 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
| 502 | if (VI != CurModule.Values.end()) { |
| 503 | if (Num < VI->second.size()) |
| 504 | return VI->second[Num]; |
| 505 | Num -= VI->second.size(); |
| 506 | } |
| 507 | |
| 508 | // Make sure that our type is within bounds |
| 509 | VI = CurFun.Values.find(Ty); |
| 510 | if (VI == CurFun.Values.end()) return 0; |
| 511 | |
| 512 | // Check that the number is within bounds... |
| 513 | if (VI->second.size() <= Num) return 0; |
| 514 | |
| 515 | return VI->second[Num]; |
| 516 | } |
| 517 | |
| 518 | case ValID::NameVal: { // Is it a named definition? |
| 519 | Value *N = lookupInSymbolTable(Ty, std::string(D.Name)); |
| 520 | if (N == 0) return 0; |
| 521 | |
| 522 | D.destroy(); // Free old strdup'd memory... |
| 523 | return N; |
| 524 | } |
| 525 | |
| 526 | // Check to make sure that "Ty" is an integral type, and that our |
| 527 | // value will fit into the specified type... |
| 528 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
| 529 | if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) |
| 530 | ThrowException("Signed integral constant '" + |
| 531 | itostr(D.ConstPool64) + "' is invalid for type '" + |
| 532 | Ty->getDescription() + "'!"); |
| 533 | return ConstantSInt::get(Ty, D.ConstPool64); |
| 534 | |
| 535 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
| 536 | if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 537 | if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) { |
| 538 | ThrowException("Integral constant '" + utostr(D.UConstPool64) + |
| 539 | "' is invalid or out of range!"); |
| 540 | } else { // This is really a signed reference. Transmogrify. |
| 541 | return ConstantSInt::get(Ty, D.ConstPool64); |
| 542 | } |
| 543 | } else { |
| 544 | return ConstantUInt::get(Ty, D.UConstPool64); |
| 545 | } |
| 546 | |
| 547 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
| 548 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) |
| 549 | ThrowException("FP constant invalid for type!!"); |
| 550 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 551 | |
| 552 | case ValID::ConstNullVal: // Is it a null value? |
| 553 | if (!isa<PointerType>(Ty)) |
| 554 | ThrowException("Cannot create a a non pointer null!"); |
| 555 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 556 | |
| 557 | case ValID::ConstUndefVal: // Is it an undef value? |
| 558 | return UndefValue::get(Ty); |
| 559 | |
Chris Lattner | a054d12 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 560 | case ValID::ConstZeroVal: // Is it a zero value? |
| 561 | return Constant::getNullValue(Ty); |
| 562 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 563 | case ValID::ConstantVal: // Fully resolved constant? |
| 564 | if (D.ConstantValue->getType() != Ty) |
| 565 | ThrowException("Constant expression type different from required type!"); |
| 566 | return D.ConstantValue; |
| 567 | |
| 568 | default: |
| 569 | assert(0 && "Unhandled case!"); |
| 570 | return 0; |
| 571 | } // End of switch |
| 572 | |
| 573 | assert(0 && "Unhandled case!"); |
| 574 | return 0; |
| 575 | } |
| 576 | |
| 577 | // getVal - This function is identical to getValNonImprovising, except that if a |
| 578 | // value is not already defined, it "improvises" by creating a placeholder var |
| 579 | // that looks and acts just like the requested variable. When the value is |
| 580 | // defined later, all uses of the placeholder variable are replaced with the |
| 581 | // real thing. |
| 582 | // |
| 583 | static Value *getVal(const Type *Ty, const ValID &ID) { |
| 584 | if (Ty == Type::LabelTy) |
| 585 | ThrowException("Cannot use a basic block here"); |
| 586 | |
| 587 | // See if the value has already been defined. |
| 588 | Value *V = getValNonImprovising(Ty, ID); |
| 589 | if (V) return V; |
| 590 | |
| 591 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) |
| 592 | ThrowException("Invalid use of a composite type!"); |
| 593 | |
| 594 | // If we reached here, we referenced either a symbol that we don't know about |
| 595 | // or an id number that hasn't been read yet. We may be referencing something |
| 596 | // forward, so just create an entry to be resolved later and get to it... |
| 597 | // |
| 598 | V = new Argument(Ty); |
| 599 | |
| 600 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 601 | // to recycle these things?? |
| 602 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 603 | llvmAsmlineno))); |
| 604 | |
| 605 | if (inFunctionScope()) |
| 606 | InsertValue(V, CurFun.LateResolveValues); |
| 607 | else |
| 608 | InsertValue(V, CurModule.LateResolveValues); |
| 609 | return V; |
| 610 | } |
| 611 | |
| 612 | /// getBBVal - This is used for two purposes: |
| 613 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 614 | /// defined. |
| 615 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 616 | /// or may not be a forward reference. |
| 617 | /// |
| 618 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
| 619 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 620 | |
| 621 | std::string Name; |
| 622 | BasicBlock *BB = 0; |
| 623 | switch (ID.Type) { |
| 624 | default: ThrowException("Illegal label reference " + ID.getName()); |
| 625 | case ValID::NumberVal: // Is it a numbered definition? |
| 626 | if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) |
| 627 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 628 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 629 | break; |
| 630 | case ValID::NameVal: // Is it a named definition? |
| 631 | Name = ID.Name; |
| 632 | if (Value *N = CurFun.CurrentFunction-> |
| 633 | getSymbolTable().lookup(Type::LabelTy, Name)) |
| 634 | BB = cast<BasicBlock>(N); |
| 635 | break; |
| 636 | } |
| 637 | |
| 638 | // See if the block has already been defined. |
| 639 | if (BB) { |
| 640 | // If this is the definition of the block, make sure the existing value was |
| 641 | // just a forward reference. If it was a forward reference, there will be |
| 642 | // an entry for it in the PlaceHolderInfo map. |
| 643 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) |
| 644 | // The existing value was a definition, not a forward reference. |
| 645 | ThrowException("Redefinition of label " + ID.getName()); |
| 646 | |
| 647 | ID.destroy(); // Free strdup'd memory. |
| 648 | return BB; |
| 649 | } |
| 650 | |
| 651 | // Otherwise this block has not been seen before. |
| 652 | BB = new BasicBlock("", CurFun.CurrentFunction); |
| 653 | if (ID.Type == ValID::NameVal) { |
| 654 | BB->setName(ID.Name); |
| 655 | } else { |
| 656 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 657 | } |
| 658 | |
| 659 | // If this is not a definition, keep track of it so we can use it as a forward |
| 660 | // reference. |
| 661 | if (!isDefinition) { |
| 662 | // Remember where this forward reference came from. |
| 663 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno); |
| 664 | } else { |
| 665 | // The forward declaration could have been inserted anywhere in the |
| 666 | // function: insert it into the correct place now. |
| 667 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 668 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 669 | } |
| 670 | ID.destroy(); |
| 671 | return BB; |
| 672 | } |
| 673 | |
| 674 | |
| 675 | //===----------------------------------------------------------------------===// |
| 676 | // Code to handle forward references in instructions |
| 677 | //===----------------------------------------------------------------------===// |
| 678 | // |
| 679 | // This code handles the late binding needed with statements that reference |
| 680 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 681 | // a loop body. |
| 682 | // |
| 683 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 684 | // and back patchs after we are done. |
| 685 | // |
| 686 | |
| 687 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 688 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 689 | // defs now... |
| 690 | // |
| 691 | static void |
| 692 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 693 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
| 694 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 695 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 696 | E = LateResolvers.end(); LRI != E; ++LRI) { |
| 697 | ValueList &List = LRI->second; |
| 698 | while (!List.empty()) { |
| 699 | Value *V = List.back(); |
| 700 | List.pop_back(); |
| 701 | |
| 702 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 703 | CurModule.PlaceHolderInfo.find(V); |
| 704 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
| 705 | |
| 706 | ValID &DID = PHI->second.first; |
| 707 | |
| 708 | Value *TheRealValue = getValNonImprovising(LRI->first, DID); |
| 709 | if (TheRealValue) { |
| 710 | V->replaceAllUsesWith(TheRealValue); |
| 711 | delete V; |
| 712 | CurModule.PlaceHolderInfo.erase(PHI); |
| 713 | } else if (FutureLateResolvers) { |
| 714 | // Functions have their unresolved items forwarded to the module late |
| 715 | // resolver table |
| 716 | InsertValue(V, *FutureLateResolvers); |
| 717 | } else { |
| 718 | if (DID.Type == ValID::NameVal) |
| 719 | ThrowException("Reference to an invalid definition: '" +DID.getName()+ |
| 720 | "' of type '" + V->getType()->getDescription() + "'", |
| 721 | PHI->second.second); |
| 722 | else |
| 723 | ThrowException("Reference to an invalid definition: #" + |
| 724 | itostr(DID.Num) + " of type '" + |
| 725 | V->getType()->getDescription() + "'", |
| 726 | PHI->second.second); |
| 727 | } |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | LateResolvers.clear(); |
| 732 | } |
| 733 | |
| 734 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 735 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 736 | // refering to the number can be resolved. Do this now. |
| 737 | // |
| 738 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 739 | ValID D; |
| 740 | if (Name) D = ValID::create(Name); |
| 741 | else D = ValID::create((int)CurModule.Types.size()); |
| 742 | |
| 743 | std::map<ValID, PATypeHolder>::iterator I = |
| 744 | CurModule.LateResolveTypes.find(D); |
| 745 | if (I != CurModule.LateResolveTypes.end()) { |
| 746 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
| 747 | CurModule.LateResolveTypes.erase(I); |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | // setValueName - Set the specified value to the name given. The name may be |
| 752 | // null potentially, in which case this is a noop. The string passed in is |
| 753 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 754 | // |
| 755 | static void setValueName(Value *V, char *NameStr) { |
| 756 | if (NameStr) { |
| 757 | std::string Name(NameStr); // Copy string |
| 758 | free(NameStr); // Free old string |
| 759 | |
| 760 | if (V->getType() == Type::VoidTy) |
| 761 | ThrowException("Can't assign name '" + Name+"' to value with void type!"); |
| 762 | |
| 763 | assert(inFunctionScope() && "Must be in function scope!"); |
| 764 | SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable(); |
| 765 | if (ST.lookup(V->getType(), Name)) |
| 766 | ThrowException("Redefinition of value named '" + Name + "' in the '" + |
| 767 | V->getType()->getDescription() + "' type plane!"); |
| 768 | |
| 769 | // Set the name. |
| 770 | V->setName(Name); |
| 771 | } |
| 772 | } |
| 773 | |
| 774 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 775 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | 11ca4d6 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 776 | static GlobalVariable * |
| 777 | ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, |
| 778 | bool isConstantGlobal, const Type *Ty, |
| 779 | Constant *Initializer) { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 780 | if (isa<FunctionType>(Ty)) |
| 781 | ThrowException("Cannot declare global vars of function type!"); |
| 782 | |
| 783 | const PointerType *PTy = PointerType::get(Ty); |
| 784 | |
| 785 | std::string Name; |
| 786 | if (NameStr) { |
| 787 | Name = NameStr; // Copy string |
| 788 | free(NameStr); // Free old string |
| 789 | } |
| 790 | |
| 791 | // See if this global value was forward referenced. If so, recycle the |
| 792 | // object. |
| 793 | ValID ID; |
| 794 | if (!Name.empty()) { |
| 795 | ID = ValID::create((char*)Name.c_str()); |
| 796 | } else { |
| 797 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
| 798 | } |
| 799 | |
| 800 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 801 | // Move the global to the end of the list, from whereever it was |
| 802 | // previously inserted. |
| 803 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 804 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 805 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 806 | GV->setInitializer(Initializer); |
| 807 | GV->setLinkage(Linkage); |
| 808 | GV->setConstant(isConstantGlobal); |
| 809 | InsertValue(GV, CurModule.Values); |
Chris Lattner | 11ca4d6 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 810 | return GV; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 811 | } |
| 812 | |
| 813 | // If this global has a name, check to see if there is already a definition |
| 814 | // of this global in the module. If so, merge as appropriate. Note that |
| 815 | // this is really just a hack around problems in the CFE. :( |
| 816 | if (!Name.empty()) { |
| 817 | // We are a simple redefinition of a value, check to see if it is defined |
| 818 | // the same as the old one. |
| 819 | if (GlobalVariable *EGV = |
| 820 | CurModule.CurrentModule->getGlobalVariable(Name, Ty)) { |
| 821 | // We are allowed to redefine a global variable in two circumstances: |
| 822 | // 1. If at least one of the globals is uninitialized or |
| 823 | // 2. If both initializers have the same value. |
| 824 | // |
| 825 | if (!EGV->hasInitializer() || !Initializer || |
| 826 | EGV->getInitializer() == Initializer) { |
| 827 | |
| 828 | // Make sure the existing global version gets the initializer! Make |
| 829 | // sure that it also gets marked const if the new version is. |
| 830 | if (Initializer && !EGV->hasInitializer()) |
| 831 | EGV->setInitializer(Initializer); |
| 832 | if (isConstantGlobal) |
| 833 | EGV->setConstant(true); |
| 834 | EGV->setLinkage(Linkage); |
Chris Lattner | 11ca4d6 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 835 | return EGV; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 836 | } |
| 837 | |
| 838 | ThrowException("Redefinition of global variable named '" + Name + |
| 839 | "' in the '" + Ty->getDescription() + "' type plane!"); |
| 840 | } |
| 841 | } |
| 842 | |
| 843 | // Otherwise there is no existing GV to use, create one now. |
| 844 | GlobalVariable *GV = |
| 845 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 846 | CurModule.CurrentModule); |
| 847 | InsertValue(GV, CurModule.Values); |
Chris Lattner | 11ca4d6 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 848 | return GV; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 849 | } |
| 850 | |
| 851 | // setTypeName - Set the specified type to the name given. The name may be |
| 852 | // null potentially, in which case this is a noop. The string passed in is |
| 853 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 854 | // |
| 855 | // This function returns true if the type has already been defined, but is |
| 856 | // allowed to be redefined in the specified context. If the name is a new name |
| 857 | // for the type plane, it is inserted and false is returned. |
| 858 | static bool setTypeName(const Type *T, char *NameStr) { |
| 859 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
| 860 | if (NameStr == 0) return false; |
| 861 | |
| 862 | std::string Name(NameStr); // Copy string |
| 863 | free(NameStr); // Free old string |
| 864 | |
| 865 | // We don't allow assigning names to void type |
| 866 | if (T == Type::VoidTy) |
| 867 | ThrowException("Can't assign name '" + Name + "' to the void type!"); |
| 868 | |
| 869 | // Set the type name, checking for conflicts as we do so. |
| 870 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 871 | |
| 872 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 873 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 874 | assert(Existing && "Conflict but no matching type?"); |
| 875 | |
| 876 | // There is only one case where this is allowed: when we are refining an |
| 877 | // opaque type. In this case, Existing will be an opaque type. |
| 878 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 879 | // We ARE replacing an opaque type! |
| 880 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 881 | return true; |
| 882 | } |
| 883 | |
| 884 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 885 | // the redefinition is identical to the original. This will be so if |
| 886 | // Existing and T point to the same Type object. In this one case we |
| 887 | // allow the equivalent redefinition. |
| 888 | if (Existing == T) return true; // Yes, it's equal. |
| 889 | |
| 890 | // Any other kind of (non-equivalent) redefinition is an error. |
| 891 | ThrowException("Redefinition of type named '" + Name + "' in the '" + |
| 892 | T->getDescription() + "' type plane!"); |
| 893 | } |
| 894 | |
| 895 | return false; |
| 896 | } |
| 897 | |
| 898 | //===----------------------------------------------------------------------===// |
| 899 | // Code for handling upreferences in type names... |
| 900 | // |
| 901 | |
| 902 | // TypeContains - Returns true if Ty directly contains E in it. |
| 903 | // |
| 904 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 905 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 906 | E) != Ty->subtype_end(); |
| 907 | } |
| 908 | |
| 909 | namespace { |
| 910 | struct UpRefRecord { |
| 911 | // NestingLevel - The number of nesting levels that need to be popped before |
| 912 | // this type is resolved. |
| 913 | unsigned NestingLevel; |
| 914 | |
| 915 | // LastContainedTy - This is the type at the current binding level for the |
| 916 | // type. Every time we reduce the nesting level, this gets updated. |
| 917 | const Type *LastContainedTy; |
| 918 | |
| 919 | // UpRefTy - This is the actual opaque type that the upreference is |
| 920 | // represented with. |
| 921 | OpaqueType *UpRefTy; |
| 922 | |
| 923 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 924 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 925 | }; |
| 926 | } |
| 927 | |
| 928 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 929 | static std::vector<UpRefRecord> UpRefs; |
| 930 | |
| 931 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 932 | /// called. It loops through the UpRefs vector, which is a list of the |
| 933 | /// currently active types. For each type, if the up reference is contained in |
| 934 | /// the newly completed type, we decrement the level count. When the level |
| 935 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 936 | /// thus we can complete the cycle. |
| 937 | /// |
| 938 | static PATypeHolder HandleUpRefs(const Type *ty) { |
| 939 | if (!ty->isAbstract()) return ty; |
| 940 | PATypeHolder Ty(ty); |
| 941 | UR_OUT("Type '" << Ty->getDescription() << |
| 942 | "' newly formed. Resolving upreferences.\n" << |
| 943 | UpRefs.size() << " upreferences active!\n"); |
| 944 | |
| 945 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 946 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 947 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 948 | // this variable. |
| 949 | OpaqueType *TypeToResolve = 0; |
| 950 | |
| 951 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 952 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 953 | << UpRefs[i].second->getDescription() << ") = " |
| 954 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 955 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 956 | // Decrement level of upreference |
| 957 | unsigned Level = --UpRefs[i].NestingLevel; |
| 958 | UpRefs[i].LastContainedTy = Ty; |
| 959 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 960 | if (Level == 0) { // Upreference should be resolved! |
| 961 | if (!TypeToResolve) { |
| 962 | TypeToResolve = UpRefs[i].UpRefTy; |
| 963 | } else { |
| 964 | UR_OUT(" * Resolving upreference for " |
| 965 | << UpRefs[i].second->getDescription() << "\n"; |
| 966 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 967 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 968 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 969 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 970 | } |
| 971 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 972 | --i; // Do not skip the next element... |
| 973 | } |
| 974 | } |
| 975 | } |
| 976 | |
| 977 | if (TypeToResolve) { |
| 978 | UR_OUT(" * Resolving upreference for " |
| 979 | << UpRefs[i].second->getDescription() << "\n"; |
| 980 | std::string OldName = TypeToResolve->getDescription()); |
| 981 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 982 | } |
| 983 | |
| 984 | return Ty; |
| 985 | } |
| 986 | |
| 987 | |
| 988 | // common code from the two 'RunVMAsmParser' functions |
| 989 | static Module * RunParser(Module * M) { |
| 990 | |
| 991 | llvmAsmlineno = 1; // Reset the current line number... |
| 992 | ObsoleteVarArgs = false; |
| 993 | NewVarArgs = false; |
| 994 | |
| 995 | CurModule.CurrentModule = M; |
| 996 | yyparse(); // Parse the file, potentially throwing exception |
| 997 | |
| 998 | Module *Result = ParserResult; |
| 999 | ParserResult = 0; |
| 1000 | |
| 1001 | //Not all functions use vaarg, so make a second check for ObsoleteVarArgs |
| 1002 | { |
| 1003 | Function* F; |
| 1004 | if ((F = Result->getNamedFunction("llvm.va_start")) |
| 1005 | && F->getFunctionType()->getNumParams() == 0) |
| 1006 | ObsoleteVarArgs = true; |
| 1007 | if((F = Result->getNamedFunction("llvm.va_copy")) |
| 1008 | && F->getFunctionType()->getNumParams() == 1) |
| 1009 | ObsoleteVarArgs = true; |
| 1010 | } |
| 1011 | |
| 1012 | if (ObsoleteVarArgs && NewVarArgs) |
| 1013 | ThrowException("This file is corrupt: it uses both new and old style varargs"); |
| 1014 | |
| 1015 | if(ObsoleteVarArgs) { |
| 1016 | if(Function* F = Result->getNamedFunction("llvm.va_start")) { |
| 1017 | if (F->arg_size() != 0) |
| 1018 | ThrowException("Obsolete va_start takes 0 argument!"); |
| 1019 | |
| 1020 | //foo = va_start() |
| 1021 | // -> |
| 1022 | //bar = alloca typeof(foo) |
| 1023 | //va_start(bar) |
| 1024 | //foo = load bar |
| 1025 | |
| 1026 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1027 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 1028 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1029 | Function* NF = Result->getOrInsertFunction("llvm.va_start", |
Jeff Cohen | 11e26b5 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 1030 | RetTy, ArgTyPtr, (Type *)0); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1031 | |
| 1032 | while (!F->use_empty()) { |
| 1033 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1034 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); |
| 1035 | new CallInst(NF, bar, "", CI); |
| 1036 | Value* foo = new LoadInst(bar, "vastart.fix.2", CI); |
| 1037 | CI->replaceAllUsesWith(foo); |
| 1038 | CI->getParent()->getInstList().erase(CI); |
| 1039 | } |
| 1040 | Result->getFunctionList().erase(F); |
| 1041 | } |
| 1042 | |
| 1043 | if(Function* F = Result->getNamedFunction("llvm.va_end")) { |
| 1044 | if(F->arg_size() != 1) |
| 1045 | ThrowException("Obsolete va_end takes 1 argument!"); |
| 1046 | |
| 1047 | //vaend foo |
| 1048 | // -> |
| 1049 | //bar = alloca 1 of typeof(foo) |
| 1050 | //vaend bar |
| 1051 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1052 | const Type* ArgTy = F->getFunctionType()->getParamType(0); |
| 1053 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1054 | Function* NF = Result->getOrInsertFunction("llvm.va_end", |
Jeff Cohen | 11e26b5 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 1055 | RetTy, ArgTyPtr, (Type *)0); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1056 | |
| 1057 | while (!F->use_empty()) { |
| 1058 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1059 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); |
| 1060 | new StoreInst(CI->getOperand(1), bar, CI); |
| 1061 | new CallInst(NF, bar, "", CI); |
| 1062 | CI->getParent()->getInstList().erase(CI); |
| 1063 | } |
| 1064 | Result->getFunctionList().erase(F); |
| 1065 | } |
| 1066 | |
| 1067 | if(Function* F = Result->getNamedFunction("llvm.va_copy")) { |
| 1068 | if(F->arg_size() != 1) |
| 1069 | ThrowException("Obsolete va_copy takes 1 argument!"); |
| 1070 | //foo = vacopy(bar) |
| 1071 | // -> |
| 1072 | //a = alloca 1 of typeof(foo) |
| 1073 | //b = alloca 1 of typeof(foo) |
| 1074 | //store bar -> b |
| 1075 | //vacopy(a, b) |
| 1076 | //foo = load a |
| 1077 | |
| 1078 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1079 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 1080 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1081 | Function* NF = Result->getOrInsertFunction("llvm.va_copy", |
Jeff Cohen | 11e26b5 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 1082 | RetTy, ArgTyPtr, ArgTyPtr, |
| 1083 | (Type *)0); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1084 | |
| 1085 | while (!F->use_empty()) { |
| 1086 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1087 | AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI); |
| 1088 | AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI); |
| 1089 | new StoreInst(CI->getOperand(1), b, CI); |
| 1090 | new CallInst(NF, a, b, "", CI); |
| 1091 | Value* foo = new LoadInst(a, "vacopy.fix.3", CI); |
| 1092 | CI->replaceAllUsesWith(foo); |
| 1093 | CI->getParent()->getInstList().erase(CI); |
| 1094 | } |
| 1095 | Result->getFunctionList().erase(F); |
| 1096 | } |
| 1097 | } |
| 1098 | |
| 1099 | return Result; |
| 1100 | |
| 1101 | } |
| 1102 | |
| 1103 | //===----------------------------------------------------------------------===// |
| 1104 | // RunVMAsmParser - Define an interface to this parser |
| 1105 | //===----------------------------------------------------------------------===// |
| 1106 | // |
| 1107 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1108 | set_scan_file(F); |
| 1109 | |
| 1110 | CurFilename = Filename; |
| 1111 | return RunParser(new Module(CurFilename)); |
| 1112 | } |
| 1113 | |
| 1114 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1115 | set_scan_string(AsmString); |
| 1116 | |
| 1117 | CurFilename = "from_memory"; |
| 1118 | if (M == NULL) { |
| 1119 | return RunParser(new Module (CurFilename)); |
| 1120 | } else { |
| 1121 | return RunParser(M); |
| 1122 | } |
| 1123 | } |
| 1124 | |
| 1125 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 1126 | |
| 1127 | /* Enabling traces. */ |
| 1128 | #ifndef YYDEBUG |
| 1129 | # define YYDEBUG 0 |
| 1130 | #endif |
| 1131 | |
| 1132 | /* Enabling verbose error messages. */ |
| 1133 | #ifdef YYERROR_VERBOSE |
| 1134 | # undef YYERROR_VERBOSE |
| 1135 | # define YYERROR_VERBOSE 1 |
| 1136 | #else |
| 1137 | # define YYERROR_VERBOSE 0 |
| 1138 | #endif |
| 1139 | |
| 1140 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
| 1141 | #line 878 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 1142 | typedef union YYSTYPE { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1143 | llvm::Module *ModuleVal; |
| 1144 | llvm::Function *FunctionVal; |
| 1145 | std::pair<llvm::PATypeHolder*, char*> *ArgVal; |
| 1146 | llvm::BasicBlock *BasicBlockVal; |
| 1147 | llvm::TerminatorInst *TermInstVal; |
| 1148 | llvm::Instruction *InstVal; |
| 1149 | llvm::Constant *ConstVal; |
| 1150 | |
| 1151 | const llvm::Type *PrimType; |
| 1152 | llvm::PATypeHolder *TypeVal; |
| 1153 | llvm::Value *ValueVal; |
| 1154 | |
| 1155 | std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList; |
| 1156 | std::vector<llvm::Value*> *ValueList; |
| 1157 | std::list<llvm::PATypeHolder> *TypeList; |
| 1158 | // Represent the RHS of PHI node |
| 1159 | std::list<std::pair<llvm::Value*, |
| 1160 | llvm::BasicBlock*> > *PHIList; |
| 1161 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
| 1162 | std::vector<llvm::Constant*> *ConstVector; |
| 1163 | |
| 1164 | llvm::GlobalValue::LinkageTypes Linkage; |
| 1165 | int64_t SInt64Val; |
| 1166 | uint64_t UInt64Val; |
| 1167 | int SIntVal; |
| 1168 | unsigned UIntVal; |
| 1169 | double FPVal; |
| 1170 | bool BoolVal; |
| 1171 | |
| 1172 | char *StrVal; // This memory is strdup'd! |
| 1173 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
| 1174 | |
| 1175 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1176 | llvm::Instruction::TermOps TermOpVal; |
| 1177 | llvm::Instruction::MemoryOps MemOpVal; |
| 1178 | llvm::Instruction::OtherOps OtherOpVal; |
| 1179 | llvm::Module::Endianness Endianness; |
| 1180 | } YYSTYPE; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 1181 | /* Line 191 of yacc.c. */ |
| 1182 | #line 1183 "llvmAsmParser.tab.c" |
| 1183 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 1184 | # define YYSTYPE_IS_DECLARED 1 |
| 1185 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1186 | #endif |
| 1187 | |
| 1188 | |
| 1189 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 1190 | /* Copy the second part of user declarations. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1191 | |
| 1192 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 1193 | /* Line 214 of yacc.c. */ |
| 1194 | #line 1195 "llvmAsmParser.tab.c" |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1195 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 1196 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1197 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 1198 | # ifndef YYFREE |
| 1199 | # define YYFREE free |
| 1200 | # endif |
| 1201 | # ifndef YYMALLOC |
| 1202 | # define YYMALLOC malloc |
| 1203 | # endif |
| 1204 | |
| 1205 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 1206 | |
| 1207 | # ifdef YYSTACK_USE_ALLOCA |
| 1208 | # if YYSTACK_USE_ALLOCA |
| 1209 | # define YYSTACK_ALLOC alloca |
| 1210 | # endif |
| 1211 | # else |
| 1212 | # if defined (alloca) || defined (_ALLOCA_H) |
| 1213 | # define YYSTACK_ALLOC alloca |
| 1214 | # else |
| 1215 | # ifdef __GNUC__ |
| 1216 | # define YYSTACK_ALLOC __builtin_alloca |
| 1217 | # endif |
| 1218 | # endif |
| 1219 | # endif |
| 1220 | |
| 1221 | # ifdef YYSTACK_ALLOC |
| 1222 | /* Pacify GCC's `empty if-body' warning. */ |
| 1223 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
| 1224 | # else |
| 1225 | # if defined (__STDC__) || defined (__cplusplus) |
| 1226 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 1227 | # define YYSIZE_T size_t |
| 1228 | # endif |
| 1229 | # define YYSTACK_ALLOC YYMALLOC |
| 1230 | # define YYSTACK_FREE YYFREE |
| 1231 | # endif |
| 1232 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
| 1233 | |
| 1234 | |
| 1235 | #if (! defined (yyoverflow) \ |
| 1236 | && (! defined (__cplusplus) \ |
| 1237 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
| 1238 | |
| 1239 | /* A type that is properly aligned for any stack member. */ |
| 1240 | union yyalloc |
| 1241 | { |
| 1242 | short yyss; |
| 1243 | YYSTYPE yyvs; |
| 1244 | }; |
| 1245 | |
| 1246 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 1247 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 1248 | |
| 1249 | /* The size of an array large to enough to hold all stacks, each with |
| 1250 | N elements. */ |
| 1251 | # define YYSTACK_BYTES(N) \ |
| 1252 | ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ |
| 1253 | + YYSTACK_GAP_MAXIMUM) |
| 1254 | |
| 1255 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 1256 | not overlap. */ |
| 1257 | # ifndef YYCOPY |
| 1258 | # if defined (__GNUC__) && 1 < __GNUC__ |
| 1259 | # define YYCOPY(To, From, Count) \ |
| 1260 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 1261 | # else |
| 1262 | # define YYCOPY(To, From, Count) \ |
| 1263 | do \ |
| 1264 | { \ |
| 1265 | register YYSIZE_T yyi; \ |
| 1266 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 1267 | (To)[yyi] = (From)[yyi]; \ |
| 1268 | } \ |
| 1269 | while (0) |
| 1270 | # endif |
| 1271 | # endif |
| 1272 | |
| 1273 | /* Relocate STACK from its old location to the new one. The |
| 1274 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 1275 | elements in the stack, and YYPTR gives the new location of the |
| 1276 | stack. Advance YYPTR to a properly aligned location for the next |
| 1277 | stack. */ |
| 1278 | # define YYSTACK_RELOCATE(Stack) \ |
| 1279 | do \ |
| 1280 | { \ |
| 1281 | YYSIZE_T yynewbytes; \ |
| 1282 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 1283 | Stack = &yyptr->Stack; \ |
| 1284 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 1285 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 1286 | } \ |
| 1287 | while (0) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1288 | |
| 1289 | #endif |
| 1290 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 1291 | #if defined (__STDC__) || defined (__cplusplus) |
| 1292 | typedef signed char yysigned_char; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1293 | #else |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 1294 | typedef short yysigned_char; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1295 | #endif |
| 1296 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 1297 | /* YYFINAL -- State number of the termination state. */ |
| 1298 | #define YYFINAL 4 |
| 1299 | /* YYLAST -- Last index in YYTABLE. */ |
| 1300 | #define YYLAST 1210 |
| 1301 | |
| 1302 | /* YYNTOKENS -- Number of terminals. */ |
| 1303 | #define YYNTOKENS 112 |
| 1304 | /* YYNNTS -- Number of nonterminals. */ |
| 1305 | #define YYNNTS 70 |
| 1306 | /* YYNRULES -- Number of rules. */ |
| 1307 | #define YYNRULES 229 |
| 1308 | /* YYNRULES -- Number of states. */ |
| 1309 | #define YYNSTATES 460 |
| 1310 | |
| 1311 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 1312 | #define YYUNDEFTOK 2 |
| 1313 | #define YYMAXUTOK 352 |
| 1314 | |
| 1315 | #define YYTRANSLATE(YYX) \ |
| 1316 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 1317 | |
| 1318 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 1319 | static const unsigned char yytranslate[] = |
| 1320 | { |
| 1321 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1322 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1323 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1324 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1325 | 101, 102, 110, 2, 99, 2, 2, 2, 2, 2, |
| 1326 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1327 | 106, 98, 107, 2, 2, 2, 2, 2, 2, 2, |
| 1328 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1329 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1330 | 2, 103, 100, 105, 2, 2, 2, 2, 2, 111, |
| 1331 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1332 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1333 | 104, 2, 2, 108, 2, 109, 2, 2, 2, 2, |
| 1334 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1335 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1336 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1337 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1338 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1339 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1340 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1341 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1342 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1343 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1344 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1345 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1346 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 1347 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 1348 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 1349 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 1350 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 1351 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 1352 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 1353 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 1354 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 1355 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1356 | 95, 96, 97 |
| 1357 | }; |
| 1358 | |
| 1359 | #if YYDEBUG |
| 1360 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 1361 | YYRHS. */ |
| 1362 | static const unsigned short yyprhs[] = |
| 1363 | { |
| 1364 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 1365 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 1366 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 1367 | 59, 61, 63, 65, 67, 70, 71, 73, 75, 77, |
| 1368 | 79, 80, 81, 83, 85, 87, 90, 91, 94, 95, |
| 1369 | 99, 102, 103, 105, 106, 110, 112, 115, 117, 119, |
| 1370 | 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, |
| 1371 | 141, 143, 145, 147, 149, 151, 153, 155, 157, 160, |
| 1372 | 165, 171, 177, 181, 184, 187, 189, 193, 195, 199, |
| 1373 | 201, 202, 207, 211, 215, 220, 225, 229, 232, 235, |
| 1374 | 238, 241, 244, 247, 250, 253, 256, 259, 266, 272, |
| 1375 | 281, 288, 295, 302, 309, 316, 320, 322, 324, 326, |
| 1376 | 328, 331, 334, 337, 339, 344, 347, 348, 356, 357, |
| 1377 | 365, 369, 374, 375, 377, 379, 383, 387, 391, 395, |
| 1378 | 399, 401, 402, 404, 406, 408, 409, 412, 416, 418, |
| 1379 | 420, 424, 426, 427, 436, 438, 440, 444, 446, 448, |
| 1380 | 451, 452, 456, 458, 460, 462, 464, 466, 468, 470, |
| 1381 | 472, 476, 478, 480, 482, 484, 486, 489, 492, 495, |
| 1382 | 499, 502, 503, 505, 508, 511, 515, 525, 535, 544, |
| 1383 | 558, 560, 562, 569, 575, 578, 585, 593, 595, 599, |
| 1384 | 601, 602, 605, 607, 613, 619, 625, 628, 633, 638, |
| 1385 | 645, 650, 655, 660, 665, 672, 675, 683, 685, 688, |
| 1386 | 689, 691, 692, 696, 703, 707, 714, 717, 722, 729 |
| 1387 | }; |
| 1388 | |
| 1389 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 1390 | static const short yyrhs[] = |
| 1391 | { |
| 1392 | 143, 0, -1, 5, -1, 6, -1, 3, -1, 4, |
| 1393 | -1, 68, -1, 69, -1, 70, -1, 71, -1, 72, |
| 1394 | -1, 73, -1, 74, -1, 75, -1, 76, -1, 77, |
| 1395 | -1, 78, -1, 79, -1, 80, -1, 81, -1, 91, |
| 1396 | -1, 92, -1, 16, -1, 14, -1, 12, -1, 10, |
| 1397 | -1, 17, -1, 15, -1, 13, -1, 11, -1, 119, |
| 1398 | -1, 120, -1, 18, -1, 19, -1, 152, 98, -1, |
| 1399 | -1, 41, -1, 42, -1, 43, -1, 44, -1, -1, |
| 1400 | -1, 59, -1, 60, -1, 61, -1, 58, 4, -1, |
| 1401 | -1, 54, 4, -1, -1, 99, 54, 4, -1, 34, |
| 1402 | 24, -1, -1, 128, -1, -1, 99, 131, 130, -1, |
| 1403 | 128, -1, 54, 4, -1, 134, -1, 8, -1, 136, |
| 1404 | -1, 8, -1, 136, -1, 9, -1, 10, -1, 11, |
| 1405 | -1, 12, -1, 13, -1, 14, -1, 15, -1, 16, |
| 1406 | -1, 17, -1, 18, -1, 19, -1, 20, -1, 21, |
| 1407 | -1, 45, -1, 135, -1, 165, -1, 100, 4, -1, |
| 1408 | 133, 101, 138, 102, -1, 103, 4, 104, 136, 105, |
| 1409 | -1, 106, 4, 104, 136, 107, -1, 108, 137, 109, |
| 1410 | -1, 108, 109, -1, 136, 110, -1, 136, -1, 137, |
| 1411 | 99, 136, -1, 137, -1, 137, 99, 37, -1, 37, |
| 1412 | -1, -1, 134, 103, 141, 105, -1, 134, 103, 105, |
| 1413 | -1, 134, 111, 24, -1, 134, 106, 141, 107, -1, |
| 1414 | 134, 108, 141, 109, -1, 134, 108, 109, -1, 134, |
| 1415 | 38, -1, 134, 39, -1, 134, 165, -1, 134, 140, |
| 1416 | -1, 134, 26, -1, 119, 114, -1, 120, 4, -1, |
| 1417 | 9, 27, -1, 9, 28, -1, 122, 7, -1, 89, |
| 1418 | 101, 139, 36, 134, 102, -1, 87, 101, 139, 179, |
| 1419 | 102, -1, 90, 101, 139, 99, 139, 99, 139, 102, |
| 1420 | -1, 115, 101, 139, 99, 139, 102, -1, 116, 101, |
| 1421 | 139, 99, 139, 102, -1, 117, 101, 139, 99, 139, |
| 1422 | 102, -1, 118, 101, 139, 99, 139, 102, -1, 94, |
| 1423 | 101, 139, 99, 139, 102, -1, 141, 99, 139, -1, |
| 1424 | 139, -1, 32, -1, 33, -1, 144, -1, 144, 161, |
| 1425 | -1, 144, 162, -1, 144, 25, -1, 145, -1, 145, |
| 1426 | 123, 20, 132, -1, 145, 162, -1, -1, 145, 123, |
| 1427 | 124, 142, 139, 146, 130, -1, -1, 145, 123, 47, |
| 1428 | 142, 134, 147, 130, -1, 145, 48, 149, -1, 145, |
| 1429 | 55, 98, 150, -1, -1, 53, -1, 52, -1, 50, |
| 1430 | 98, 148, -1, 51, 98, 4, -1, 49, 98, 24, |
| 1431 | -1, 103, 151, 105, -1, 151, 99, 24, -1, 24, |
| 1432 | -1, -1, 22, -1, 24, -1, 152, -1, -1, 134, |
| 1433 | 153, -1, 155, 99, 154, -1, 154, -1, 155, -1, |
| 1434 | 155, 99, 37, -1, 37, -1, -1, 125, 132, 152, |
| 1435 | 101, 156, 102, 129, 126, -1, 29, -1, 108, -1, |
| 1436 | 124, 157, 158, -1, 30, -1, 109, -1, 168, 160, |
| 1437 | -1, -1, 31, 163, 157, -1, 3, -1, 4, -1, |
| 1438 | 7, -1, 27, -1, 28, -1, 38, -1, 39, -1, |
| 1439 | 26, -1, 106, 141, 107, -1, 140, -1, 113, -1, |
| 1440 | 152, -1, 165, -1, 164, -1, 134, 166, -1, 168, |
| 1441 | 169, -1, 159, 169, -1, 170, 123, 171, -1, 170, |
| 1442 | 173, -1, -1, 23, -1, 62, 167, -1, 62, 8, |
| 1443 | -1, 63, 21, 166, -1, 63, 9, 166, 99, 21, |
| 1444 | 166, 99, 21, 166, -1, 64, 121, 166, 99, 21, |
| 1445 | 166, 103, 172, 105, -1, 64, 121, 166, 99, 21, |
| 1446 | 166, 103, 105, -1, 65, 125, 132, 166, 101, 176, |
| 1447 | 102, 36, 21, 166, 66, 21, 166, -1, 66, -1, |
| 1448 | 67, -1, 172, 121, 164, 99, 21, 166, -1, 121, |
| 1449 | 164, 99, 21, 166, -1, 123, 178, -1, 134, 103, |
| 1450 | 166, 99, 166, 105, -1, 174, 99, 103, 166, 99, |
| 1451 | 166, 105, -1, 167, -1, 175, 99, 167, -1, 175, |
| 1452 | -1, -1, 57, 56, -1, 56, -1, 115, 134, 166, |
| 1453 | 99, 166, -1, 116, 134, 166, 99, 166, -1, 117, |
| 1454 | 134, 166, 99, 166, -1, 46, 167, -1, 118, 167, |
| 1455 | 99, 167, -1, 89, 167, 36, 134, -1, 90, 167, |
| 1456 | 99, 167, 99, 167, -1, 93, 167, 99, 134, -1, |
| 1457 | 96, 167, 99, 134, -1, 97, 167, 99, 134, -1, |
| 1458 | 94, 167, 99, 167, -1, 95, 167, 99, 167, 99, |
| 1459 | 167, -1, 88, 174, -1, 177, 125, 132, 166, 101, |
| 1460 | 176, 102, -1, 181, -1, 99, 175, -1, -1, 35, |
| 1461 | -1, -1, 82, 134, 127, -1, 82, 134, 99, 15, |
| 1462 | 166, 127, -1, 83, 134, 127, -1, 83, 134, 99, |
| 1463 | 15, 166, 127, -1, 84, 167, -1, 180, 85, 134, |
| 1464 | 166, -1, 180, 86, 167, 99, 134, 166, -1, 87, |
| 1465 | 134, 166, 179, -1 |
| 1466 | }; |
| 1467 | |
| 1468 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 1469 | static const unsigned short yyrline[] = |
| 1470 | { |
| 1471 | 0, 997, 997, 998, 1005, 1006, 1015, 1015, 1015, 1015, |
| 1472 | 1015, 1016, 1016, 1016, 1017, 1017, 1017, 1017, 1017, 1017, |
| 1473 | 1019, 1019, 1023, 1023, 1023, 1023, 1024, 1024, 1024, 1024, |
| 1474 | 1025, 1025, 1026, 1026, 1029, 1032, 1036, 1037, 1038, 1039, |
| 1475 | 1040, 1042, 1043, 1044, 1045, 1046, 1054, 1055, 1060, 1061, |
| 1476 | 1068, 1075, 1076, 1081, 1082, 1083, 1087, 1100, 1100, 1101, |
| 1477 | 1101, 1103, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1113, |
| 1478 | 1113, 1113, 1113, 1113, 1113, 1114, 1117, 1120, 1126, 1133, |
| 1479 | 1145, 1149, 1160, 1169, 1172, 1180, 1184, 1189, 1190, 1193, |
| 1480 | 1196, 1206, 1231, 1244, 1272, 1297, 1317, 1329, 1338, 1342, |
| 1481 | 1401, 1407, 1415, 1420, 1425, 1428, 1431, 1438, 1448, 1479, |
| 1482 | 1486, 1507, 1517, 1522, 1529, 1539, 1542, 1549, 1549, 1559, |
| 1483 | 1566, 1570, 1573, 1576, 1589, 1609, 1611, 1611, 1617, 1617, |
| 1484 | 1624, 1626, 1628, 1633, 1634, 1636, 1639, 1647, 1652, 1654, |
| 1485 | 1658, 1662, 1670, 1670, 1671, 1671, 1673, 1679, 1684, 1690, |
| 1486 | 1693, 1698, 1702, 1706, 1792, 1792, 1794, 1802, 1802, 1804, |
| 1487 | 1808, 1808, 1817, 1820, 1823, 1826, 1829, 1832, 1835, 1838, |
| 1488 | 1841, 1865, 1872, 1875, 1880, 1880, 1886, 1890, 1893, 1901, |
| 1489 | 1910, 1914, 1924, 1935, 1938, 1941, 1944, 1947, 1961, 1965, |
| 1490 | 2018, 2021, 2027, 2035, 2045, 2052, 2057, 2064, 2068, 2074, |
| 1491 | 2074, 2076, 2079, 2085, 2097, 2108, 2118, 2130, 2137, 2144, |
| 1492 | 2151, 2156, 2175, 2197, 2205, 2217, 2231, 2288, 2294, 2296, |
| 1493 | 2300, 2303, 2309, 2313, 2317, 2321, 2325, 2332, 2342, 2355 |
| 1494 | }; |
| 1495 | #endif |
| 1496 | |
| 1497 | #if YYDEBUG || YYERROR_VERBOSE |
| 1498 | /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 1499 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 1500 | static const char *const yytname[] = |
| 1501 | { |
| 1502 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", |
| 1503 | "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT", |
| 1504 | "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL", |
| 1505 | "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION", |
| 1506 | "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", |
| 1507 | "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", |
| 1508 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", |
| 1509 | "WEAK", "APPENDING", "OPAQUE", "NOT", "EXTERNAL", "TARGET", "TRIPLE", |
| 1510 | "ENDIAN", "POINTERSIZE", "LITTLE", "BIG", "ALIGN", "DEPLIBS", "CALL", |
| 1511 | "TAIL", "CC_TOK", "CCC_TOK", "FASTCC_TOK", "COLDCC_TOK", "RET", "BR", |
| 1512 | "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "DIV", |
| 1513 | "REM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", |
| 1514 | "SETNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", |
| 1515 | "PHI_TOK", "CAST", "SELECT", "SHL", "SHR", "VAARG", "EXTRACTELEMENT", |
| 1516 | "INSERTELEMENT", "VAARG_old", "VANEXT_old", "'='", "','", "'\\\\'", |
| 1517 | "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'*'", |
| 1518 | "'c'", "$accept", "INTVAL", "EINT64VAL", "ArithmeticOps", "LogicalOps", |
| 1519 | "SetCondOps", "ShiftOps", "SIntType", "UIntType", "IntType", "FPType", |
| 1520 | "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign", "OptCAlign", |
| 1521 | "SectionString", "OptSection", "GlobalVarAttributes", |
| 1522 | "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType", |
| 1523 | "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr", |
| 1524 | "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1", |
| 1525 | "@2", "BigOrLittle", "TargetDefinition", "LibrariesDefinition", |
| 1526 | "LibList", "Name", "OptName", "ArgVal", "ArgListH", "ArgList", |
| 1527 | "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", "Function", |
| 1528 | "FunctionProto", "@3", "ConstValueRef", "SymbolicValueRef", "ValueRef", |
| 1529 | "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList", |
| 1530 | "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ValueRefList", |
| 1531 | "ValueRefListE", "OptTailCall", "InstVal", "IndexList", "OptVolatile", |
| 1532 | "MemoryInst", 0 |
| 1533 | }; |
| 1534 | #endif |
| 1535 | |
| 1536 | # ifdef YYPRINT |
| 1537 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 1538 | token YYLEX-NUM. */ |
| 1539 | static const unsigned short yytoknum[] = |
| 1540 | { |
| 1541 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 1542 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 1543 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 1544 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 1545 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 1546 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 1547 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 1548 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 1549 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 1550 | 345, 346, 347, 348, 349, 350, 351, 352, 61, 44, |
| 1551 | 92, 40, 41, 91, 120, 93, 60, 62, 123, 125, |
| 1552 | 42, 99 |
| 1553 | }; |
| 1554 | # endif |
| 1555 | |
| 1556 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 1557 | static const unsigned char yyr1[] = |
| 1558 | { |
| 1559 | 0, 112, 113, 113, 114, 114, 115, 115, 115, 115, |
| 1560 | 115, 116, 116, 116, 117, 117, 117, 117, 117, 117, |
| 1561 | 118, 118, 119, 119, 119, 119, 120, 120, 120, 120, |
| 1562 | 121, 121, 122, 122, 123, 123, 124, 124, 124, 124, |
| 1563 | 124, 125, 125, 125, 125, 125, 126, 126, 127, 127, |
| 1564 | 128, 129, 129, 130, 130, 131, 131, 132, 132, 133, |
| 1565 | 133, 134, 135, 135, 135, 135, 135, 135, 135, 135, |
| 1566 | 135, 135, 135, 135, 135, 136, 136, 136, 136, 136, |
| 1567 | 136, 136, 136, 136, 136, 137, 137, 138, 138, 138, |
| 1568 | 138, 139, 139, 139, 139, 139, 139, 139, 139, 139, |
| 1569 | 139, 139, 139, 139, 139, 139, 139, 140, 140, 140, |
| 1570 | 140, 140, 140, 140, 140, 141, 141, 142, 142, 143, |
| 1571 | 144, 144, 144, 144, 145, 145, 146, 145, 147, 145, |
| 1572 | 145, 145, 145, 148, 148, 149, 149, 149, 150, 151, |
| 1573 | 151, 151, 152, 152, 153, 153, 154, 155, 155, 156, |
| 1574 | 156, 156, 156, 157, 158, 158, 159, 160, 160, 161, |
| 1575 | 163, 162, 164, 164, 164, 164, 164, 164, 164, 164, |
| 1576 | 164, 164, 165, 165, 166, 166, 167, 168, 168, 169, |
| 1577 | 170, 170, 170, 171, 171, 171, 171, 171, 171, 171, |
| 1578 | 171, 171, 172, 172, 173, 174, 174, 175, 175, 176, |
| 1579 | 176, 177, 177, 178, 178, 178, 178, 178, 178, 178, |
| 1580 | 178, 178, 178, 178, 178, 178, 178, 178, 179, 179, |
| 1581 | 180, 180, 181, 181, 181, 181, 181, 181, 181, 181 |
| 1582 | }; |
| 1583 | |
| 1584 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 1585 | static const unsigned char yyr2[] = |
| 1586 | { |
| 1587 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1588 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1589 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1590 | 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, |
| 1591 | 0, 0, 1, 1, 1, 2, 0, 2, 0, 3, |
| 1592 | 2, 0, 1, 0, 3, 1, 2, 1, 1, 1, |
| 1593 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1594 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, |
| 1595 | 5, 5, 3, 2, 2, 1, 3, 1, 3, 1, |
| 1596 | 0, 4, 3, 3, 4, 4, 3, 2, 2, 2, |
| 1597 | 2, 2, 2, 2, 2, 2, 2, 6, 5, 8, |
| 1598 | 6, 6, 6, 6, 6, 3, 1, 1, 1, 1, |
| 1599 | 2, 2, 2, 1, 4, 2, 0, 7, 0, 7, |
| 1600 | 3, 4, 0, 1, 1, 3, 3, 3, 3, 3, |
| 1601 | 1, 0, 1, 1, 1, 0, 2, 3, 1, 1, |
| 1602 | 3, 1, 0, 8, 1, 1, 3, 1, 1, 2, |
| 1603 | 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1604 | 3, 1, 1, 1, 1, 1, 2, 2, 2, 3, |
| 1605 | 2, 0, 1, 2, 2, 3, 9, 9, 8, 13, |
| 1606 | 1, 1, 6, 5, 2, 6, 7, 1, 3, 1, |
| 1607 | 0, 2, 1, 5, 5, 5, 2, 4, 4, 6, |
| 1608 | 4, 4, 4, 4, 6, 2, 7, 1, 2, 0, |
| 1609 | 1, 0, 3, 6, 3, 6, 2, 4, 6, 4 |
| 1610 | }; |
| 1611 | |
| 1612 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 1613 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 1614 | means the default is an error. */ |
| 1615 | static const unsigned char yydefact[] = |
| 1616 | { |
| 1617 | 132, 0, 40, 123, 1, 122, 160, 36, 37, 38, |
| 1618 | 39, 41, 181, 120, 121, 181, 142, 143, 0, 0, |
| 1619 | 40, 0, 125, 41, 0, 42, 43, 44, 0, 0, |
| 1620 | 182, 178, 35, 157, 158, 159, 177, 0, 0, 0, |
| 1621 | 130, 0, 0, 0, 0, 34, 161, 45, 2, 3, |
| 1622 | 58, 62, 63, 64, 65, 66, 67, 68, 69, 70, |
| 1623 | 71, 72, 73, 74, 75, 0, 0, 0, 0, 172, |
| 1624 | 0, 0, 57, 76, 61, 173, 77, 154, 155, 156, |
| 1625 | 221, 180, 0, 0, 0, 141, 131, 124, 117, 118, |
| 1626 | 0, 0, 78, 0, 0, 60, 83, 85, 0, 0, |
| 1627 | 90, 84, 220, 0, 202, 0, 0, 0, 0, 41, |
| 1628 | 190, 191, 6, 7, 8, 9, 10, 11, 12, 13, |
| 1629 | 14, 15, 16, 17, 18, 19, 0, 0, 0, 0, |
| 1630 | 0, 0, 0, 20, 21, 0, 0, 0, 0, 0, |
| 1631 | 0, 0, 0, 0, 179, 41, 194, 0, 217, 137, |
| 1632 | 134, 133, 135, 136, 140, 0, 128, 62, 63, 64, |
| 1633 | 65, 66, 67, 68, 69, 70, 71, 72, 0, 0, |
| 1634 | 0, 0, 126, 0, 0, 0, 82, 152, 89, 87, |
| 1635 | 0, 0, 206, 201, 184, 183, 0, 0, 25, 29, |
| 1636 | 24, 28, 23, 27, 22, 26, 30, 31, 0, 0, |
| 1637 | 48, 48, 226, 0, 0, 215, 0, 0, 0, 0, |
| 1638 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1639 | 0, 138, 53, 104, 105, 4, 5, 102, 103, 106, |
| 1640 | 101, 97, 98, 0, 0, 0, 0, 0, 0, 0, |
| 1641 | 0, 0, 0, 0, 0, 100, 99, 53, 59, 59, |
| 1642 | 86, 151, 145, 148, 149, 0, 0, 79, 162, 163, |
| 1643 | 164, 169, 165, 166, 167, 168, 0, 171, 175, 174, |
| 1644 | 176, 0, 185, 0, 0, 0, 222, 0, 224, 219, |
| 1645 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1646 | 0, 0, 0, 0, 0, 0, 139, 0, 129, 0, |
| 1647 | 0, 0, 0, 92, 116, 0, 0, 96, 0, 93, |
| 1648 | 0, 0, 0, 0, 127, 80, 81, 144, 146, 0, |
| 1649 | 51, 88, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1650 | 229, 0, 0, 208, 0, 210, 213, 0, 211, 212, |
| 1651 | 0, 0, 0, 207, 0, 227, 0, 0, 0, 55, |
| 1652 | 53, 219, 0, 0, 0, 0, 91, 94, 95, 0, |
| 1653 | 0, 0, 0, 150, 147, 52, 46, 170, 0, 0, |
| 1654 | 200, 48, 49, 48, 197, 218, 0, 0, 0, 0, |
| 1655 | 203, 204, 205, 200, 0, 50, 56, 54, 0, 0, |
| 1656 | 0, 0, 115, 0, 0, 0, 0, 0, 153, 0, |
| 1657 | 0, 199, 0, 0, 223, 225, 0, 0, 0, 209, |
| 1658 | 214, 0, 228, 108, 0, 0, 0, 0, 0, 0, |
| 1659 | 0, 47, 0, 0, 0, 198, 195, 0, 216, 107, |
| 1660 | 0, 114, 110, 111, 112, 113, 0, 188, 0, 0, |
| 1661 | 0, 196, 0, 186, 0, 187, 0, 0, 109, 0, |
| 1662 | 0, 0, 0, 0, 0, 193, 0, 0, 192, 189 |
| 1663 | }; |
| 1664 | |
| 1665 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 1666 | static const short yydefgoto[] = |
| 1667 | { |
| 1668 | -1, 69, 227, 241, 242, 243, 244, 168, 169, 198, |
| 1669 | 170, 20, 11, 28, 398, 276, 349, 366, 298, 350, |
| 1670 | 70, 71, 181, 73, 74, 98, 180, 304, 267, 305, |
| 1671 | 90, 1, 2, 3, 247, 222, 152, 40, 86, 155, |
| 1672 | 75, 318, 253, 254, 255, 29, 79, 12, 35, 13, |
| 1673 | 14, 23, 268, 76, 270, 374, 15, 31, 32, 144, |
| 1674 | 439, 81, 205, 401, 402, 145, 146, 330, 147, 148 |
| 1675 | }; |
| 1676 | |
| 1677 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 1678 | STATE-NUM. */ |
| 1679 | #define YYPACT_NINF -407 |
| 1680 | static const short yypact[] = |
| 1681 | { |
| 1682 | -407, 19, 94, 198, -407, -407, -407, -407, -407, -407, |
| 1683 | -407, 71, 28, -407, -407, -14, -407, -407, 58, -7, |
| 1684 | 80, 22, -407, 71, 60, -407, -407, -407, 976, -16, |
| 1685 | -407, -407, 121, -407, -407, -407, -407, 46, 69, 72, |
| 1686 | -407, -35, 976, 3, 3, -407, -407, -407, -407, -407, |
| 1687 | 49, -407, -407, -407, -407, -407, -407, -407, -407, -407, |
| 1688 | -407, -407, -407, -407, -407, 161, 173, 175, 66, -407, |
| 1689 | 121, 87, -407, -407, -67, -407, -407, -407, -407, -407, |
| 1690 | 1095, -407, 167, 52, 189, 172, -407, -407, -407, -407, |
| 1691 | 998, 1042, -407, 93, 95, -407, -407, -67, -6, 99, |
| 1692 | 729, -407, -407, 998, -407, 146, 1102, -1, 369, 71, |
| 1693 | -407, -407, -407, -407, -407, -407, -407, -407, -407, -407, |
| 1694 | -407, -407, -407, -407, -407, -407, 998, 998, 998, 998, |
| 1695 | 998, 998, 998, -407, -407, 998, 998, 998, 998, 998, |
| 1696 | 998, 998, 998, 998, -407, 71, -407, 67, -407, -407, |
| 1697 | -407, -407, -407, -407, -407, 34, -407, 131, 151, 199, |
| 1698 | 157, 200, 160, 201, 178, 202, 209, 210, 183, 203, |
| 1699 | 212, 371, -407, 998, 998, 998, -407, 767, -407, 109, |
| 1700 | 119, 549, -407, -407, 49, -407, 549, 549, -407, -407, |
| 1701 | -407, -407, -407, -407, -407, -407, -407, -407, 549, 976, |
| 1702 | 128, 129, -407, 549, 130, 133, 207, 135, 136, 137, |
| 1703 | 138, 148, 149, 549, 549, 549, 150, 976, 998, 998, |
| 1704 | 227, -407, 156, -407, -407, -407, -407, -407, -407, -407, |
| 1705 | -407, -407, -407, 164, 165, 166, 168, 833, 1042, 504, |
| 1706 | 233, 169, 174, 176, 177, -407, -407, 156, 37, -89, |
| 1707 | -67, -407, 121, -407, 159, 179, 871, -407, -407, -407, |
| 1708 | -407, -407, -407, -407, -407, -407, 1042, -407, -407, -407, |
| 1709 | -407, 162, -407, 163, 549, -4, -407, 7, -407, 180, |
| 1710 | 549, 186, 998, 998, 998, 998, 998, 998, 998, 181, |
| 1711 | 187, 191, 998, 549, 549, 193, -407, 15, -407, 1042, |
| 1712 | 1042, 1042, 1042, -407, -407, 41, -34, -407, -3, -407, |
| 1713 | 1042, 1042, 1042, 1042, -407, -407, -407, -407, -407, 938, |
| 1714 | 242, -407, -10, 272, 273, 194, 549, 293, 549, 998, |
| 1715 | -407, 206, 549, -407, 220, -407, -407, 221, -407, -407, |
| 1716 | 549, 549, 549, -407, 222, -407, 998, 275, 296, -407, |
| 1717 | 156, 180, 265, 223, 225, 1042, -407, -407, -407, 229, |
| 1718 | 230, 232, 235, -407, -407, -407, 267, -407, 549, 549, |
| 1719 | 998, 236, -407, 236, -407, 237, 549, 238, 998, 998, |
| 1720 | -407, -407, -407, 998, 549, -407, -407, -407, 224, 998, |
| 1721 | 1042, 1042, -407, 1042, 1042, 1042, 1042, 340, -407, 246, |
| 1722 | 244, 237, 247, 294, -407, -407, 998, 245, 549, -407, |
| 1723 | -407, 249, -407, -407, 250, 254, 253, 255, 256, 257, |
| 1724 | 258, -407, 335, 13, 328, -407, -407, 264, -407, -407, |
| 1725 | 1042, -407, -407, -407, -407, -407, 549, -407, 630, 43, |
| 1726 | 349, -407, 269, -407, 274, -407, 630, 549, -407, 351, |
| 1727 | 276, 308, 549, 366, 367, -407, 549, 549, -407, -407 |
| 1728 | }; |
| 1729 | |
| 1730 | /* YYPGOTO[NTERM-NUM]. */ |
| 1731 | static const short yypgoto[] = |
| 1732 | { |
| 1733 | -407, -407, -407, 309, 310, 311, 312, -107, -106, -406, |
| 1734 | -407, 362, 376, -78, -407, -195, 78, -407, -240, -407, |
| 1735 | -37, -407, -28, -407, -58, 299, -407, -87, 234, -200, |
| 1736 | 356, -407, -407, -407, -407, -407, -407, -407, -407, -407, |
| 1737 | 0, -407, 84, -407, -407, 381, -407, -407, -407, -407, |
| 1738 | 405, -407, -312, -30, 127, -91, -407, 396, -407, -407, |
| 1739 | -407, -407, -407, 83, 30, -407, -407, 63, -407, -407 |
| 1740 | }; |
| 1741 | |
| 1742 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 1743 | positive, shift that token. If negative, reduce the rule which |
| 1744 | number is the opposite. If zero, do what YYDEFACT says. |
| 1745 | If YYTABLE_NINF, syntax error. */ |
| 1746 | #define YYTABLE_NINF -120 |
| 1747 | static const short yytable[] = |
| 1748 | { |
| 1749 | 72, 196, 197, 21, 172, 87, 278, 314, 186, 30, |
| 1750 | 97, 326, 182, 77, 72, 185, 33, 438, 316, 4, |
| 1751 | 187, 101, 328, 188, 189, 190, 191, 192, 193, 194, |
| 1752 | 195, 199, 21, 446, -59, 88, 89, 202, 306, 308, |
| 1753 | 206, 207, 97, 101, 208, 209, 210, 211, 212, 347, |
| 1754 | 327, 30, 216, 188, 189, 190, 191, 192, 193, 194, |
| 1755 | 195, 327, 156, 171, 47, 355, 322, 217, 85, 348, |
| 1756 | 99, 48, 49, 357, 95, 51, 52, 53, 54, 55, |
| 1757 | 56, 57, 58, 59, 60, 61, 62, 63, 16, 355, |
| 1758 | 17, 41, 78, 175, -119, 34, 355, 367, 200, 201, |
| 1759 | 42, 203, 204, 176, 150, 151, 358, 37, 38, 39, |
| 1760 | 387, 64, 213, 214, 215, 248, 249, 250, 437, 5, |
| 1761 | 45, 7, 8, 9, 10, 6, 444, 43, 295, 24, |
| 1762 | 25, 26, 27, 220, 450, 7, 8, 9, 10, 221, |
| 1763 | 355, 246, 315, 16, 82, 17, 356, 101, 445, 252, |
| 1764 | -60, 269, 218, 219, -25, -25, 269, 269, 223, 224, |
| 1765 | -24, -24, 274, -23, -23, 92, 65, 83, 269, 66, |
| 1766 | 84, 72, 67, 269, 68, 96, 404, 93, 405, 94, |
| 1767 | 293, -22, -22, 269, 269, 269, 225, 226, 100, 72, |
| 1768 | 294, 149, 334, 153, 336, 337, 154, 173, 250, 174, |
| 1769 | 177, 343, 183, -29, -28, -27, -26, 228, 256, 171, |
| 1770 | 171, 171, 351, 352, 353, 354, -32, -33, -35, 229, |
| 1771 | 16, 257, 17, 359, 360, 361, 362, 275, 277, 6, |
| 1772 | -35, -35, 281, 280, 283, 284, 285, 286, 171, -35, |
| 1773 | -35, -35, -35, 282, 269, -35, 18, 287, 288, 292, |
| 1774 | 269, 296, 317, 19, 333, 297, 335, 309, 319, 338, |
| 1775 | 339, 323, 324, 269, 269, 299, 300, 301, 392, 302, |
| 1776 | 310, 171, 171, 171, 171, 311, 347, 312, 313, 329, |
| 1777 | 340, 320, 171, 171, 171, 171, 341, 409, 410, 332, |
| 1778 | 342, 252, 346, 368, 369, 370, 269, 372, 269, 385, |
| 1779 | 386, 389, 269, 415, 416, 376, 417, 418, 419, 420, |
| 1780 | 269, 269, 269, 271, 272, 425, 196, 197, 384, 378, |
| 1781 | 379, 397, 390, 383, 391, 273, 413, 171, 393, 394, |
| 1782 | 279, 395, 196, 197, 396, 403, 406, 408, 269, 269, |
| 1783 | 289, 290, 291, 442, 421, 422, 269, 423, 327, 424, |
| 1784 | 426, 428, 429, 430, 269, 431, 436, 432, 433, 434, |
| 1785 | 435, 414, 171, 171, 440, 171, 171, 171, 171, 441, |
| 1786 | 447, 448, 452, 449, 454, 453, 48, 49, 269, 188, |
| 1787 | 189, 190, 191, 192, 193, 194, 195, 456, 457, 140, |
| 1788 | 141, 142, 143, 16, 80, 17, 44, 230, 365, 179, |
| 1789 | 91, 325, 171, 364, 46, 245, 269, 331, 22, 231, |
| 1790 | 232, 36, 375, 411, 388, 0, 0, 269, 0, 0, |
| 1791 | 344, 345, 269, 0, 0, 0, 269, 269, 0, 0, |
| 1792 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, |
| 1793 | 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, |
| 1794 | 123, 124, 125, 371, 0, 373, 0, 0, 233, 377, |
| 1795 | 234, 235, 133, 134, 0, 236, 0, 380, 381, 382, |
| 1796 | 0, 0, 0, 0, 237, 0, 0, 238, 0, 239, |
| 1797 | 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, |
| 1798 | 0, 0, 0, 0, 0, 399, 400, 0, 0, 0, |
| 1799 | 0, 0, 0, 407, 0, 0, 0, 0, 0, 48, |
| 1800 | 49, 412, 95, 157, 158, 159, 160, 161, 162, 163, |
| 1801 | 164, 165, 166, 167, 62, 63, 16, 0, 17, 0, |
| 1802 | 0, 0, 0, 0, 0, 427, 0, 0, 0, 0, |
| 1803 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, |
| 1804 | 0, 0, 258, 259, 48, 49, 260, 0, 0, 0, |
| 1805 | 0, 0, 0, 443, 0, 0, 0, 0, 0, 0, |
| 1806 | 0, 16, 0, 17, 451, 261, 262, 263, 0, 455, |
| 1807 | 0, 0, 0, 458, 459, 0, 0, 264, 265, 0, |
| 1808 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1809 | 0, 0, 0, 0, 65, 0, 0, 66, 0, 0, |
| 1810 | 67, 0, 68, 307, 0, 0, 0, 112, 113, 114, |
| 1811 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 1812 | 125, 0, 0, 258, 259, 0, 233, 260, 234, 235, |
| 1813 | 133, 134, 0, 236, 0, 0, 0, 0, 0, 0, |
| 1814 | 0, 0, 0, 0, 0, 266, 261, 262, 263, 0, |
| 1815 | 0, 0, 0, 0, 0, 0, 0, 0, 264, 265, |
| 1816 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1817 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1818 | 0, 0, 0, 0, 0, 0, 0, 0, 112, 113, |
| 1819 | 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, |
| 1820 | 124, 125, 0, 0, 0, 0, 0, 233, 0, 234, |
| 1821 | 235, 133, 134, 0, 236, 0, 0, 0, 0, 0, |
| 1822 | 0, 0, 0, 0, 48, 49, 266, 95, 51, 52, |
| 1823 | 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, |
| 1824 | 63, 16, 0, 17, 0, 0, 0, 0, 0, 0, |
| 1825 | 0, 0, 0, 0, 0, 0, 178, 0, 0, 0, |
| 1826 | 0, 0, 48, 49, 64, 95, 51, 52, 53, 54, |
| 1827 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 16, |
| 1828 | 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1829 | 0, 0, 0, 0, 251, 0, 0, 0, 0, 0, |
| 1830 | 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, |
| 1831 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, |
| 1832 | 0, 0, 66, 0, 0, 67, 0, 68, 48, 49, |
| 1833 | 0, 95, 157, 158, 159, 160, 161, 162, 163, 164, |
| 1834 | 165, 166, 167, 62, 63, 16, 0, 17, 0, 0, |
| 1835 | 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, |
| 1836 | 66, 0, 0, 67, 0, 68, 48, 49, 64, 95, |
| 1837 | 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, |
| 1838 | 61, 62, 63, 16, 0, 17, 0, 0, 0, 0, |
| 1839 | 0, 0, 0, 0, 0, 0, 0, 0, 321, 0, |
| 1840 | 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, |
| 1841 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1842 | 0, 0, 0, 65, 0, 0, 66, 0, 303, 67, |
| 1843 | 0, 68, 0, 48, 49, 0, 95, 51, 52, 53, |
| 1844 | 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, |
| 1845 | 16, 0, 17, 0, 0, 0, 0, 0, 0, 0, |
| 1846 | 0, 65, 0, 0, 66, 363, 0, 67, 0, 68, |
| 1847 | 0, 48, 49, 64, 50, 51, 52, 53, 54, 55, |
| 1848 | 56, 57, 58, 59, 60, 61, 62, 63, 16, 0, |
| 1849 | 17, 0, 0, 48, 49, 0, 95, 51, 52, 53, |
| 1850 | 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, |
| 1851 | 16, 64, 17, 0, 0, 0, 0, 0, 0, 0, |
| 1852 | 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, |
| 1853 | 0, 66, 0, 64, 67, 0, 68, 48, 49, 0, |
| 1854 | 95, 157, 158, 159, 160, 161, 162, 163, 164, 165, |
| 1855 | 166, 167, 62, 63, 16, 0, 17, 0, 0, 0, |
| 1856 | 0, 0, 0, 0, 0, 0, 65, 0, 0, 66, |
| 1857 | 0, 0, 67, 0, 68, 0, 0, 64, 0, 0, |
| 1858 | 0, 0, 0, 0, 0, 0, 0, 0, 65, 0, |
| 1859 | 0, 66, 0, 0, 67, 0, 68, 48, 49, 0, |
| 1860 | 184, 51, 52, 53, 54, 55, 56, 57, 58, 59, |
| 1861 | 60, 61, 62, 63, 16, 0, 17, 0, 0, 0, |
| 1862 | 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1863 | 0, 103, 65, 0, 0, 66, 0, 64, 67, 0, |
| 1864 | 68, 104, 105, 0, 0, 0, 0, 106, 107, 108, |
| 1865 | 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, |
| 1866 | 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, |
| 1867 | 0, 0, 129, 130, 131, 132, 133, 134, 135, 136, |
| 1868 | 137, 138, 139, 0, 0, 0, 0, 0, 0, 0, |
| 1869 | 0, 0, 65, 0, 0, 66, 0, 0, 67, 0, |
| 1870 | 68 |
| 1871 | }; |
| 1872 | |
| 1873 | static const short yycheck[] = |
| 1874 | { |
| 1875 | 28, 108, 108, 3, 91, 42, 201, 247, 9, 23, |
| 1876 | 68, 15, 103, 29, 42, 106, 30, 423, 107, 0, |
| 1877 | 21, 110, 15, 10, 11, 12, 13, 14, 15, 16, |
| 1878 | 17, 109, 32, 439, 101, 32, 33, 128, 238, 239, |
| 1879 | 131, 132, 100, 110, 135, 136, 137, 138, 139, 34, |
| 1880 | 54, 23, 143, 10, 11, 12, 13, 14, 15, 16, |
| 1881 | 17, 54, 90, 91, 4, 99, 266, 145, 103, 54, |
| 1882 | 70, 5, 6, 107, 8, 9, 10, 11, 12, 13, |
| 1883 | 14, 15, 16, 17, 18, 19, 20, 21, 22, 99, |
| 1884 | 24, 98, 108, 99, 0, 109, 99, 107, 126, 127, |
| 1885 | 20, 129, 130, 109, 52, 53, 109, 49, 50, 51, |
| 1886 | 350, 45, 140, 141, 142, 173, 174, 175, 105, 25, |
| 1887 | 98, 41, 42, 43, 44, 31, 438, 47, 219, 58, |
| 1888 | 59, 60, 61, 99, 446, 41, 42, 43, 44, 105, |
| 1889 | 99, 171, 105, 22, 98, 24, 105, 110, 105, 177, |
| 1890 | 101, 181, 85, 86, 3, 4, 186, 187, 27, 28, |
| 1891 | 3, 4, 199, 3, 4, 4, 100, 98, 198, 103, |
| 1892 | 98, 199, 106, 203, 108, 109, 371, 4, 373, 4, |
| 1893 | 217, 3, 4, 213, 214, 215, 3, 4, 101, 217, |
| 1894 | 218, 24, 283, 4, 285, 286, 24, 104, 256, 104, |
| 1895 | 101, 292, 56, 4, 4, 4, 4, 4, 99, 237, |
| 1896 | 238, 239, 299, 300, 301, 302, 7, 7, 20, 7, |
| 1897 | 22, 102, 24, 310, 311, 312, 313, 99, 99, 31, |
| 1898 | 32, 33, 99, 103, 99, 99, 99, 99, 266, 41, |
| 1899 | 42, 43, 44, 36, 274, 47, 48, 99, 99, 99, |
| 1900 | 280, 24, 252, 55, 282, 99, 284, 24, 99, 287, |
| 1901 | 288, 99, 99, 293, 294, 101, 101, 101, 355, 101, |
| 1902 | 101, 299, 300, 301, 302, 101, 34, 101, 101, 99, |
| 1903 | 99, 102, 310, 311, 312, 313, 99, 378, 379, 103, |
| 1904 | 99, 319, 99, 21, 21, 101, 326, 4, 328, 24, |
| 1905 | 4, 36, 332, 390, 391, 99, 393, 394, 395, 396, |
| 1906 | 340, 341, 342, 186, 187, 406, 423, 423, 346, 99, |
| 1907 | 99, 54, 99, 101, 99, 198, 102, 355, 99, 99, |
| 1908 | 203, 99, 439, 439, 99, 99, 99, 99, 368, 369, |
| 1909 | 213, 214, 215, 430, 4, 99, 376, 103, 54, 102, |
| 1910 | 105, 102, 102, 99, 384, 102, 21, 102, 102, 102, |
| 1911 | 102, 389, 390, 391, 36, 393, 394, 395, 396, 105, |
| 1912 | 21, 102, 21, 99, 66, 99, 5, 6, 408, 10, |
| 1913 | 11, 12, 13, 14, 15, 16, 17, 21, 21, 80, |
| 1914 | 80, 80, 80, 22, 32, 24, 20, 26, 320, 100, |
| 1915 | 44, 274, 430, 319, 23, 171, 436, 280, 3, 38, |
| 1916 | 39, 15, 329, 383, 351, -1, -1, 447, -1, -1, |
| 1917 | 293, 294, 452, -1, -1, -1, 456, 457, -1, -1, |
| 1918 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, |
| 1919 | 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 1920 | 79, 80, 81, 326, -1, 328, -1, -1, 87, 332, |
| 1921 | 89, 90, 91, 92, -1, 94, -1, 340, 341, 342, |
| 1922 | -1, -1, -1, -1, 103, -1, -1, 106, -1, 108, |
| 1923 | -1, -1, 111, -1, -1, -1, -1, -1, -1, -1, |
| 1924 | -1, -1, -1, -1, -1, 368, 369, -1, -1, -1, |
| 1925 | -1, -1, -1, 376, -1, -1, -1, -1, -1, 5, |
| 1926 | 6, 384, 8, 9, 10, 11, 12, 13, 14, 15, |
| 1927 | 16, 17, 18, 19, 20, 21, 22, -1, 24, -1, |
| 1928 | -1, -1, -1, -1, -1, 408, -1, -1, -1, -1, |
| 1929 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, |
| 1930 | -1, -1, 3, 4, 5, 6, 7, -1, -1, -1, |
| 1931 | -1, -1, -1, 436, -1, -1, -1, -1, -1, -1, |
| 1932 | -1, 22, -1, 24, 447, 26, 27, 28, -1, 452, |
| 1933 | -1, -1, -1, 456, 457, -1, -1, 38, 39, -1, |
| 1934 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1935 | -1, -1, -1, -1, 100, -1, -1, 103, -1, -1, |
| 1936 | 106, -1, 108, 109, -1, -1, -1, 68, 69, 70, |
| 1937 | 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 1938 | 81, -1, -1, 3, 4, -1, 87, 7, 89, 90, |
| 1939 | 91, 92, -1, 94, -1, -1, -1, -1, -1, -1, |
| 1940 | -1, -1, -1, -1, -1, 106, 26, 27, 28, -1, |
| 1941 | -1, -1, -1, -1, -1, -1, -1, -1, 38, 39, |
| 1942 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1943 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1944 | -1, -1, -1, -1, -1, -1, -1, -1, 68, 69, |
| 1945 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 1946 | 80, 81, -1, -1, -1, -1, -1, 87, -1, 89, |
| 1947 | 90, 91, 92, -1, 94, -1, -1, -1, -1, -1, |
| 1948 | -1, -1, -1, -1, 5, 6, 106, 8, 9, 10, |
| 1949 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 1950 | 21, 22, -1, 24, -1, -1, -1, -1, -1, -1, |
| 1951 | -1, -1, -1, -1, -1, -1, 37, -1, -1, -1, |
| 1952 | -1, -1, 5, 6, 45, 8, 9, 10, 11, 12, |
| 1953 | 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, |
| 1954 | -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1955 | -1, -1, -1, -1, 37, -1, -1, -1, -1, -1, |
| 1956 | -1, -1, 45, -1, -1, -1, -1, -1, -1, -1, |
| 1957 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 100, |
| 1958 | -1, -1, 103, -1, -1, 106, -1, 108, 5, 6, |
| 1959 | -1, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
| 1960 | 17, 18, 19, 20, 21, 22, -1, 24, -1, -1, |
| 1961 | -1, -1, -1, -1, -1, -1, -1, 100, -1, -1, |
| 1962 | 103, -1, -1, 106, -1, 108, 5, 6, 45, 8, |
| 1963 | 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |
| 1964 | 19, 20, 21, 22, -1, 24, -1, -1, -1, -1, |
| 1965 | -1, -1, -1, -1, -1, -1, -1, -1, 37, -1, |
| 1966 | -1, -1, -1, -1, -1, -1, 45, -1, -1, -1, |
| 1967 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1968 | -1, -1, -1, 100, -1, -1, 103, -1, 105, 106, |
| 1969 | -1, 108, -1, 5, 6, -1, 8, 9, 10, 11, |
| 1970 | 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, |
| 1971 | 22, -1, 24, -1, -1, -1, -1, -1, -1, -1, |
| 1972 | -1, 100, -1, -1, 103, 37, -1, 106, -1, 108, |
| 1973 | -1, 5, 6, 45, 8, 9, 10, 11, 12, 13, |
| 1974 | 14, 15, 16, 17, 18, 19, 20, 21, 22, -1, |
| 1975 | 24, -1, -1, 5, 6, -1, 8, 9, 10, 11, |
| 1976 | 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, |
| 1977 | 22, 45, 24, -1, -1, -1, -1, -1, -1, -1, |
| 1978 | -1, -1, -1, -1, -1, -1, -1, -1, 100, -1, |
| 1979 | -1, 103, -1, 45, 106, -1, 108, 5, 6, -1, |
| 1980 | 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
| 1981 | 18, 19, 20, 21, 22, -1, 24, -1, -1, -1, |
| 1982 | -1, -1, -1, -1, -1, -1, 100, -1, -1, 103, |
| 1983 | -1, -1, 106, -1, 108, -1, -1, 45, -1, -1, |
| 1984 | -1, -1, -1, -1, -1, -1, -1, -1, 100, -1, |
| 1985 | -1, 103, -1, -1, 106, -1, 108, 5, 6, -1, |
| 1986 | 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
| 1987 | 18, 19, 20, 21, 22, -1, 24, -1, -1, -1, |
| 1988 | 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 1989 | -1, 46, 100, -1, -1, 103, -1, 45, 106, -1, |
| 1990 | 108, 56, 57, -1, -1, -1, -1, 62, 63, 64, |
| 1991 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 1992 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 1993 | -1, -1, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1994 | 95, 96, 97, -1, -1, -1, -1, -1, -1, -1, |
| 1995 | -1, -1, 100, -1, -1, 103, -1, -1, 106, -1, |
| 1996 | 108 |
| 1997 | }; |
| 1998 | |
| 1999 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 2000 | symbol of state STATE-NUM. */ |
| 2001 | static const unsigned char yystos[] = |
| 2002 | { |
| 2003 | 0, 143, 144, 145, 0, 25, 31, 41, 42, 43, |
| 2004 | 44, 124, 159, 161, 162, 168, 22, 24, 48, 55, |
| 2005 | 123, 152, 162, 163, 58, 59, 60, 61, 125, 157, |
| 2006 | 23, 169, 170, 30, 109, 160, 169, 49, 50, 51, |
| 2007 | 149, 98, 20, 47, 124, 98, 157, 4, 5, 6, |
| 2008 | 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
| 2009 | 18, 19, 20, 21, 45, 100, 103, 106, 108, 113, |
| 2010 | 132, 133, 134, 135, 136, 152, 165, 29, 108, 158, |
| 2011 | 123, 173, 98, 98, 98, 103, 150, 132, 32, 33, |
| 2012 | 142, 142, 4, 4, 4, 8, 109, 136, 137, 152, |
| 2013 | 101, 110, 35, 46, 56, 57, 62, 63, 64, 65, |
| 2014 | 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, |
| 2015 | 76, 77, 78, 79, 80, 81, 82, 83, 84, 87, |
| 2016 | 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, |
| 2017 | 115, 116, 117, 118, 171, 177, 178, 180, 181, 24, |
| 2018 | 52, 53, 148, 4, 24, 151, 134, 9, 10, 11, |
| 2019 | 12, 13, 14, 15, 16, 17, 18, 19, 119, 120, |
| 2020 | 122, 134, 139, 104, 104, 99, 109, 101, 37, 137, |
| 2021 | 138, 134, 167, 56, 8, 167, 9, 21, 10, 11, |
| 2022 | 12, 13, 14, 15, 16, 17, 119, 120, 121, 125, |
| 2023 | 134, 134, 167, 134, 134, 174, 167, 167, 167, 167, |
| 2024 | 167, 167, 167, 134, 134, 134, 167, 125, 85, 86, |
| 2025 | 99, 105, 147, 27, 28, 3, 4, 114, 4, 7, |
| 2026 | 26, 38, 39, 87, 89, 90, 94, 103, 106, 108, |
| 2027 | 111, 115, 116, 117, 118, 140, 165, 146, 136, 136, |
| 2028 | 136, 37, 134, 154, 155, 156, 99, 102, 3, 4, |
| 2029 | 7, 26, 27, 28, 38, 39, 106, 140, 164, 165, |
| 2030 | 166, 166, 166, 166, 132, 99, 127, 99, 127, 166, |
| 2031 | 103, 99, 36, 99, 99, 99, 99, 99, 99, 166, |
| 2032 | 166, 166, 99, 132, 134, 167, 24, 99, 130, 101, |
| 2033 | 101, 101, 101, 105, 139, 141, 141, 109, 141, 24, |
| 2034 | 101, 101, 101, 101, 130, 105, 107, 152, 153, 99, |
| 2035 | 102, 37, 141, 99, 99, 166, 15, 54, 15, 99, |
| 2036 | 179, 166, 103, 134, 167, 134, 167, 167, 134, 134, |
| 2037 | 99, 99, 99, 167, 166, 166, 99, 34, 54, 128, |
| 2038 | 131, 139, 139, 139, 139, 99, 105, 107, 109, 139, |
| 2039 | 139, 139, 139, 37, 154, 128, 129, 107, 21, 21, |
| 2040 | 101, 166, 4, 166, 167, 175, 99, 166, 99, 99, |
| 2041 | 166, 166, 166, 101, 134, 24, 4, 130, 179, 36, |
| 2042 | 99, 99, 139, 99, 99, 99, 99, 54, 126, 166, |
| 2043 | 166, 175, 176, 99, 127, 127, 99, 166, 99, 167, |
| 2044 | 167, 176, 166, 102, 134, 139, 139, 139, 139, 139, |
| 2045 | 139, 4, 99, 103, 102, 167, 105, 166, 102, 102, |
| 2046 | 99, 102, 102, 102, 102, 102, 21, 105, 121, 172, |
| 2047 | 36, 105, 139, 166, 164, 105, 121, 21, 102, 99, |
| 2048 | 164, 166, 21, 99, 66, 166, 21, 21, 166, 166 |
| 2049 | }; |
| 2050 | |
| 2051 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
| 2052 | # define YYSIZE_T __SIZE_TYPE__ |
| 2053 | #endif |
| 2054 | #if ! defined (YYSIZE_T) && defined (size_t) |
| 2055 | # define YYSIZE_T size_t |
| 2056 | #endif |
| 2057 | #if ! defined (YYSIZE_T) |
| 2058 | # if defined (__STDC__) || defined (__cplusplus) |
| 2059 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 2060 | # define YYSIZE_T size_t |
| 2061 | # endif |
| 2062 | #endif |
| 2063 | #if ! defined (YYSIZE_T) |
| 2064 | # define YYSIZE_T unsigned int |
| 2065 | #endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2066 | |
| 2067 | #define yyerrok (yyerrstatus = 0) |
| 2068 | #define yyclearin (yychar = YYEMPTY) |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2069 | #define YYEMPTY (-2) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2070 | #define YYEOF 0 |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2071 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2072 | #define YYACCEPT goto yyacceptlab |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2073 | #define YYABORT goto yyabortlab |
| 2074 | #define YYERROR goto yyerrorlab |
| 2075 | |
| 2076 | |
| 2077 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 2078 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2079 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2080 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2081 | #define YYFAIL goto yyerrlab |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2082 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2083 | #define YYRECOVERING() (!!yyerrstatus) |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2084 | |
| 2085 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2086 | do \ |
| 2087 | if (yychar == YYEMPTY && yylen == 1) \ |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2088 | { \ |
| 2089 | yychar = (Token); \ |
| 2090 | yylval = (Value); \ |
| 2091 | yytoken = YYTRANSLATE (yychar); \ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2092 | YYPOPSTACK; \ |
| 2093 | goto yybackup; \ |
| 2094 | } \ |
| 2095 | else \ |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2096 | { \ |
| 2097 | yyerror ("syntax error: cannot back up");\ |
| 2098 | YYERROR; \ |
| 2099 | } \ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2100 | while (0) |
| 2101 | |
| 2102 | #define YYTERROR 1 |
| 2103 | #define YYERRCODE 256 |
| 2104 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2105 | /* YYLLOC_DEFAULT -- Compute the default location (before the actions |
| 2106 | are run). */ |
| 2107 | |
| 2108 | #ifndef YYLLOC_DEFAULT |
| 2109 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 2110 | ((Current).first_line = (Rhs)[1].first_line, \ |
| 2111 | (Current).first_column = (Rhs)[1].first_column, \ |
| 2112 | (Current).last_line = (Rhs)[N].last_line, \ |
| 2113 | (Current).last_column = (Rhs)[N].last_column) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2114 | #endif |
| 2115 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2116 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 2117 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2118 | #ifdef YYLEX_PARAM |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2119 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2120 | #else |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2121 | # define YYLEX yylex () |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 2122 | #endif |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2123 | |
| 2124 | /* Enable debugging if requested. */ |
| 2125 | #if YYDEBUG |
| 2126 | |
| 2127 | # ifndef YYFPRINTF |
| 2128 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 2129 | # define YYFPRINTF fprintf |
| 2130 | # endif |
| 2131 | |
| 2132 | # define YYDPRINTF(Args) \ |
| 2133 | do { \ |
| 2134 | if (yydebug) \ |
| 2135 | YYFPRINTF Args; \ |
| 2136 | } while (0) |
| 2137 | |
| 2138 | # define YYDSYMPRINT(Args) \ |
| 2139 | do { \ |
| 2140 | if (yydebug) \ |
| 2141 | yysymprint Args; \ |
| 2142 | } while (0) |
| 2143 | |
| 2144 | # define YYDSYMPRINTF(Title, Token, Value, Location) \ |
| 2145 | do { \ |
| 2146 | if (yydebug) \ |
| 2147 | { \ |
| 2148 | YYFPRINTF (stderr, "%s ", Title); \ |
| 2149 | yysymprint (stderr, \ |
| 2150 | Token, Value); \ |
| 2151 | YYFPRINTF (stderr, "\n"); \ |
| 2152 | } \ |
| 2153 | } while (0) |
| 2154 | |
| 2155 | /*------------------------------------------------------------------. |
| 2156 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 2157 | | TOP (included). | |
| 2158 | `------------------------------------------------------------------*/ |
| 2159 | |
| 2160 | #if defined (__STDC__) || defined (__cplusplus) |
| 2161 | static void |
| 2162 | yy_stack_print (short *bottom, short *top) |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 2163 | #else |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2164 | static void |
| 2165 | yy_stack_print (bottom, top) |
| 2166 | short *bottom; |
| 2167 | short *top; |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 2168 | #endif |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2169 | { |
| 2170 | YYFPRINTF (stderr, "Stack now"); |
| 2171 | for (/* Nothing. */; bottom <= top; ++bottom) |
| 2172 | YYFPRINTF (stderr, " %d", *bottom); |
| 2173 | YYFPRINTF (stderr, "\n"); |
| 2174 | } |
| 2175 | |
| 2176 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 2177 | do { \ |
| 2178 | if (yydebug) \ |
| 2179 | yy_stack_print ((Bottom), (Top)); \ |
| 2180 | } while (0) |
| 2181 | |
| 2182 | |
| 2183 | /*------------------------------------------------. |
| 2184 | | Report that the YYRULE is going to be reduced. | |
| 2185 | `------------------------------------------------*/ |
| 2186 | |
| 2187 | #if defined (__STDC__) || defined (__cplusplus) |
| 2188 | static void |
| 2189 | yy_reduce_print (int yyrule) |
| 2190 | #else |
| 2191 | static void |
| 2192 | yy_reduce_print (yyrule) |
| 2193 | int yyrule; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2194 | #endif |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2195 | { |
| 2196 | int yyi; |
| 2197 | unsigned int yylno = yyrline[yyrule]; |
| 2198 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", |
| 2199 | yyrule - 1, yylno); |
| 2200 | /* Print the symbols being reduced, and their result. */ |
| 2201 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
| 2202 | YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); |
| 2203 | YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); |
| 2204 | } |
Reid Spencer | b4f9a6f | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 2205 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2206 | # define YY_REDUCE_PRINT(Rule) \ |
| 2207 | do { \ |
| 2208 | if (yydebug) \ |
| 2209 | yy_reduce_print (Rule); \ |
| 2210 | } while (0) |
Reid Spencer | b4f9a6f | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 2211 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2212 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 2213 | multiple parsers can coexist. */ |
| 2214 | int yydebug; |
| 2215 | #else /* !YYDEBUG */ |
| 2216 | # define YYDPRINTF(Args) |
| 2217 | # define YYDSYMPRINT(Args) |
| 2218 | # define YYDSYMPRINTF(Title, Token, Value, Location) |
| 2219 | # define YY_STACK_PRINT(Bottom, Top) |
| 2220 | # define YY_REDUCE_PRINT(Rule) |
| 2221 | #endif /* !YYDEBUG */ |
Reid Spencer | b4f9a6f | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 2222 | |
Reid Spencer | b4f9a6f | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 2223 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2224 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2225 | #ifndef YYINITDEPTH |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2226 | # define YYINITDEPTH 200 |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2227 | #endif |
| 2228 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2229 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 2230 | if the built-in stack extension method is used). |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2231 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2232 | Do not make this value too large; the results are undefined if |
| 2233 | SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) |
| 2234 | evaluated with infinite-precision integer arithmetic. */ |
| 2235 | |
| 2236 | #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 |
| 2237 | # undef YYMAXDEPTH |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2238 | #endif |
| 2239 | |
| 2240 | #ifndef YYMAXDEPTH |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2241 | # define YYMAXDEPTH 10000 |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2242 | #endif |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2243 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2244 | |
| 2245 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2246 | #if YYERROR_VERBOSE |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2247 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2248 | # ifndef yystrlen |
| 2249 | # if defined (__GLIBC__) && defined (_STRING_H) |
| 2250 | # define yystrlen strlen |
| 2251 | # else |
| 2252 | /* Return the length of YYSTR. */ |
| 2253 | static YYSIZE_T |
| 2254 | # if defined (__STDC__) || defined (__cplusplus) |
| 2255 | yystrlen (const char *yystr) |
| 2256 | # else |
| 2257 | yystrlen (yystr) |
| 2258 | const char *yystr; |
| 2259 | # endif |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 2260 | { |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2261 | register const char *yys = yystr; |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 2262 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2263 | while (*yys++ != '\0') |
| 2264 | continue; |
| 2265 | |
| 2266 | return yys - yystr - 1; |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 2267 | } |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2268 | # endif |
| 2269 | # endif |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 2270 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2271 | # ifndef yystpcpy |
| 2272 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
| 2273 | # define yystpcpy stpcpy |
| 2274 | # else |
| 2275 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 2276 | YYDEST. */ |
| 2277 | static char * |
| 2278 | # if defined (__STDC__) || defined (__cplusplus) |
| 2279 | yystpcpy (char *yydest, const char *yysrc) |
| 2280 | # else |
| 2281 | yystpcpy (yydest, yysrc) |
| 2282 | char *yydest; |
| 2283 | const char *yysrc; |
| 2284 | # endif |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 2285 | { |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2286 | register char *yyd = yydest; |
| 2287 | register const char *yys = yysrc; |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 2288 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2289 | while ((*yyd++ = *yys++) != '\0') |
| 2290 | continue; |
| 2291 | |
| 2292 | return yyd - 1; |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 2293 | } |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2294 | # endif |
| 2295 | # endif |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 2296 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2297 | #endif /* !YYERROR_VERBOSE */ |
| 2298 | |
Reid Spencer | b4f9a6f | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 2299 | |
| 2300 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2301 | #if YYDEBUG |
| 2302 | /*--------------------------------. |
| 2303 | | Print this symbol on YYOUTPUT. | |
| 2304 | `--------------------------------*/ |
Reid Spencer | b4f9a6f | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 2305 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2306 | #if defined (__STDC__) || defined (__cplusplus) |
| 2307 | static void |
| 2308 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 2309 | #else |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2310 | static void |
| 2311 | yysymprint (yyoutput, yytype, yyvaluep) |
| 2312 | FILE *yyoutput; |
| 2313 | int yytype; |
| 2314 | YYSTYPE *yyvaluep; |
Reid Spencer | b4f9a6f | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 2315 | #endif |
Reid Spencer | b4f9a6f | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 2316 | { |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2317 | /* Pacify ``unused variable'' warnings. */ |
| 2318 | (void) yyvaluep; |
| 2319 | |
| 2320 | if (yytype < YYNTOKENS) |
| 2321 | { |
| 2322 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 2323 | # ifdef YYPRINT |
| 2324 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 2325 | # endif |
| 2326 | } |
| 2327 | else |
| 2328 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 2329 | |
| 2330 | switch (yytype) |
| 2331 | { |
| 2332 | default: |
| 2333 | break; |
| 2334 | } |
| 2335 | YYFPRINTF (yyoutput, ")"); |
| 2336 | } |
| 2337 | |
| 2338 | #endif /* ! YYDEBUG */ |
| 2339 | /*-----------------------------------------------. |
| 2340 | | Release the memory associated to this symbol. | |
| 2341 | `-----------------------------------------------*/ |
| 2342 | |
| 2343 | #if defined (__STDC__) || defined (__cplusplus) |
| 2344 | static void |
| 2345 | yydestruct (int yytype, YYSTYPE *yyvaluep) |
| 2346 | #else |
| 2347 | static void |
| 2348 | yydestruct (yytype, yyvaluep) |
| 2349 | int yytype; |
| 2350 | YYSTYPE *yyvaluep; |
| 2351 | #endif |
| 2352 | { |
| 2353 | /* Pacify ``unused variable'' warnings. */ |
| 2354 | (void) yyvaluep; |
| 2355 | |
| 2356 | switch (yytype) |
| 2357 | { |
| 2358 | |
| 2359 | default: |
| 2360 | break; |
| 2361 | } |
| 2362 | } |
| 2363 | |
| 2364 | |
| 2365 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 2366 | |
| 2367 | #ifdef YYPARSE_PARAM |
| 2368 | # if defined (__STDC__) || defined (__cplusplus) |
| 2369 | int yyparse (void *YYPARSE_PARAM); |
| 2370 | # else |
| 2371 | int yyparse (); |
| 2372 | # endif |
| 2373 | #else /* ! YYPARSE_PARAM */ |
| 2374 | #if defined (__STDC__) || defined (__cplusplus) |
| 2375 | int yyparse (void); |
| 2376 | #else |
| 2377 | int yyparse (); |
| 2378 | #endif |
| 2379 | #endif /* ! YYPARSE_PARAM */ |
| 2380 | |
| 2381 | |
| 2382 | |
| 2383 | /* The lookahead symbol. */ |
| 2384 | int yychar; |
| 2385 | |
| 2386 | /* The semantic value of the lookahead symbol. */ |
| 2387 | YYSTYPE yylval; |
| 2388 | |
| 2389 | /* Number of syntax errors so far. */ |
| 2390 | int yynerrs; |
| 2391 | |
| 2392 | |
| 2393 | |
| 2394 | /*----------. |
| 2395 | | yyparse. | |
| 2396 | `----------*/ |
| 2397 | |
| 2398 | #ifdef YYPARSE_PARAM |
| 2399 | # if defined (__STDC__) || defined (__cplusplus) |
| 2400 | int yyparse (void *YYPARSE_PARAM) |
| 2401 | # else |
| 2402 | int yyparse (YYPARSE_PARAM) |
| 2403 | void *YYPARSE_PARAM; |
| 2404 | # endif |
| 2405 | #else /* ! YYPARSE_PARAM */ |
| 2406 | #if defined (__STDC__) || defined (__cplusplus) |
| 2407 | int |
| 2408 | yyparse (void) |
| 2409 | #else |
| 2410 | int |
| 2411 | yyparse () |
| 2412 | |
| 2413 | #endif |
| 2414 | #endif |
| 2415 | { |
| 2416 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2417 | register int yystate; |
| 2418 | register int yyn; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2419 | int yyresult; |
| 2420 | /* Number of tokens to shift before error messages enabled. */ |
| 2421 | int yyerrstatus; |
| 2422 | /* Lookahead token as an internal (translated) token number. */ |
| 2423 | int yytoken = 0; |
| 2424 | |
| 2425 | /* Three stacks and their tools: |
| 2426 | `yyss': related to states, |
| 2427 | `yyvs': related to semantic values, |
| 2428 | `yyls': related to locations. |
| 2429 | |
| 2430 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 2431 | to reallocate them elsewhere. */ |
| 2432 | |
| 2433 | /* The state stack. */ |
| 2434 | short yyssa[YYINITDEPTH]; |
| 2435 | short *yyss = yyssa; |
Nate Begeman | 848622f | 2005-11-05 09:21:28 +0000 | [diff] [blame] | 2436 | register short *yyssp; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2437 | |
| 2438 | /* The semantic value stack. */ |
| 2439 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 2440 | YYSTYPE *yyvs = yyvsa; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2441 | register YYSTYPE *yyvsp; |
| 2442 | |
| 2443 | |
| 2444 | |
| 2445 | #define YYPOPSTACK (yyvsp--, yyssp--) |
| 2446 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2447 | YYSIZE_T yystacksize = YYINITDEPTH; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2448 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2449 | /* The variables used to return semantic value and location from the |
| 2450 | action routines. */ |
| 2451 | YYSTYPE yyval; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2452 | |
| 2453 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2454 | /* When reducing, the number of symbols on the RHS of the reduced |
| 2455 | rule. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2456 | int yylen; |
| 2457 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2458 | YYDPRINTF ((stderr, "Starting parse\n")); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2459 | |
| 2460 | yystate = 0; |
| 2461 | yyerrstatus = 0; |
| 2462 | yynerrs = 0; |
| 2463 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2464 | |
| 2465 | /* Initialize stack pointers. |
| 2466 | Waste one element of value and location stack |
| 2467 | so that they stay on the same level as the state stack. |
| 2468 | The wasted elements are never initialized. */ |
| 2469 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2470 | yyssp = yyss; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2471 | yyvsp = yyvs; |
| 2472 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2473 | goto yysetstate; |
Jeff Cohen | 11e26b5 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2474 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2475 | /*------------------------------------------------------------. |
| 2476 | | yynewstate -- Push a new state, which is found in yystate. | |
| 2477 | `------------------------------------------------------------*/ |
| 2478 | yynewstate: |
| 2479 | /* In all cases, when you get here, the value and location stacks |
| 2480 | have just been pushed. so pushing a state here evens the stacks. |
| 2481 | */ |
| 2482 | yyssp++; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2483 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2484 | yysetstate: |
| 2485 | *yyssp = yystate; |
| 2486 | |
| 2487 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2488 | { |
| 2489 | /* Get the current used size of the three stacks, in elements. */ |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2490 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2491 | |
| 2492 | #ifdef yyoverflow |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2493 | { |
| 2494 | /* Give user a chance to reallocate the stack. Use copies of |
| 2495 | these so that the &'s don't force the real ones into |
| 2496 | memory. */ |
| 2497 | YYSTYPE *yyvs1 = yyvs; |
| 2498 | short *yyss1 = yyss; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2499 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2500 | |
| 2501 | /* Each stack pointer address is followed by the size of the |
| 2502 | data in use in that stack, in bytes. This used to be a |
| 2503 | conditional around just the two extra args, but that might |
| 2504 | be undefined if yyoverflow is a macro. */ |
| 2505 | yyoverflow ("parser stack overflow", |
| 2506 | &yyss1, yysize * sizeof (*yyssp), |
| 2507 | &yyvs1, yysize * sizeof (*yyvsp), |
| 2508 | |
| 2509 | &yystacksize); |
| 2510 | |
| 2511 | yyss = yyss1; |
| 2512 | yyvs = yyvs1; |
| 2513 | } |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2514 | #else /* no yyoverflow */ |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2515 | # ifndef YYSTACK_RELOCATE |
| 2516 | goto yyoverflowlab; |
| 2517 | # else |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2518 | /* Extend the stack our own way. */ |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2519 | if (YYMAXDEPTH <= yystacksize) |
| 2520 | goto yyoverflowlab; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2521 | yystacksize *= 2; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2522 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2523 | yystacksize = YYMAXDEPTH; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2524 | |
| 2525 | { |
| 2526 | short *yyss1 = yyss; |
| 2527 | union yyalloc *yyptr = |
| 2528 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 2529 | if (! yyptr) |
| 2530 | goto yyoverflowlab; |
| 2531 | YYSTACK_RELOCATE (yyss); |
| 2532 | YYSTACK_RELOCATE (yyvs); |
| 2533 | |
| 2534 | # undef YYSTACK_RELOCATE |
| 2535 | if (yyss1 != yyssa) |
| 2536 | YYSTACK_FREE (yyss1); |
| 2537 | } |
| 2538 | # endif |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2539 | #endif /* no yyoverflow */ |
| 2540 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2541 | yyssp = yyss + yysize - 1; |
| 2542 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2543 | |
| 2544 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2545 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 2546 | (unsigned long int) yystacksize)); |
| 2547 | |
| 2548 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2549 | YYABORT; |
| 2550 | } |
| 2551 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2552 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2553 | |
| 2554 | goto yybackup; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2555 | |
| 2556 | /*-----------. |
| 2557 | | yybackup. | |
| 2558 | `-----------*/ |
| 2559 | yybackup: |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2560 | |
| 2561 | /* Do appropriate processing given the current state. */ |
| 2562 | /* Read a lookahead token if we need one and don't already have one. */ |
| 2563 | /* yyresume: */ |
| 2564 | |
| 2565 | /* First try to decide what to do without reference to lookahead token. */ |
| 2566 | |
| 2567 | yyn = yypact[yystate]; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2568 | if (yyn == YYPACT_NINF) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2569 | goto yydefault; |
| 2570 | |
| 2571 | /* Not known => get a lookahead token if don't already have one. */ |
| 2572 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2573 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2574 | if (yychar == YYEMPTY) |
| 2575 | { |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2576 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2577 | yychar = YYLEX; |
| 2578 | } |
| 2579 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2580 | if (yychar <= YYEOF) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2581 | { |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2582 | yychar = yytoken = YYEOF; |
| 2583 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2584 | } |
| 2585 | else |
| 2586 | { |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2587 | yytoken = YYTRANSLATE (yychar); |
| 2588 | YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2589 | } |
| 2590 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2591 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 2592 | detect an error, take that action. */ |
| 2593 | yyn += yytoken; |
| 2594 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2595 | goto yydefault; |
| 2596 | yyn = yytable[yyn]; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2597 | if (yyn <= 0) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2598 | { |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2599 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2600 | goto yyerrlab; |
| 2601 | yyn = -yyn; |
| 2602 | goto yyreduce; |
| 2603 | } |
| 2604 | |
| 2605 | if (yyn == YYFINAL) |
| 2606 | YYACCEPT; |
| 2607 | |
| 2608 | /* Shift the lookahead token. */ |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2609 | YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2610 | |
| 2611 | /* Discard the token being shifted unless it is eof. */ |
| 2612 | if (yychar != YYEOF) |
| 2613 | yychar = YYEMPTY; |
| 2614 | |
| 2615 | *++yyvsp = yylval; |
| 2616 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2617 | |
| 2618 | /* Count tokens shifted since error; after three, turn off error |
| 2619 | status. */ |
| 2620 | if (yyerrstatus) |
| 2621 | yyerrstatus--; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2622 | |
| 2623 | yystate = yyn; |
| 2624 | goto yynewstate; |
| 2625 | |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 2626 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2627 | /*-----------------------------------------------------------. |
| 2628 | | yydefault -- do the default action for the current state. | |
| 2629 | `-----------------------------------------------------------*/ |
| 2630 | yydefault: |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2631 | yyn = yydefact[yystate]; |
| 2632 | if (yyn == 0) |
| 2633 | goto yyerrlab; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2634 | goto yyreduce; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2635 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2636 | |
| 2637 | /*-----------------------------. |
| 2638 | | yyreduce -- Do a reduction. | |
| 2639 | `-----------------------------*/ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2640 | yyreduce: |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2641 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2642 | yylen = yyr2[yyn]; |
| 2643 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2644 | /* If YYLEN is nonzero, implement the default value of the action: |
| 2645 | `$$ = $1'. |
| 2646 | |
| 2647 | Otherwise, the following line sets YYVAL to garbage. |
| 2648 | This behavior is undocumented and Bison |
| 2649 | users should not rely upon it. Assigning to YYVAL |
| 2650 | unconditionally makes the parser a bit smaller, and it avoids a |
| 2651 | GCC warning that YYVAL may be used uninitialized. */ |
| 2652 | yyval = yyvsp[1-yylen]; |
| 2653 | |
| 2654 | |
| 2655 | YY_REDUCE_PRINT (yyn); |
| 2656 | switch (yyn) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2657 | { |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2658 | case 3: |
| 2659 | #line 998 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2660 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2661 | if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range! |
| 2662 | ThrowException("Value too large for type!"); |
| 2663 | yyval.SIntVal = (int32_t)yyvsp[0].UIntVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2664 | ;} |
| 2665 | break; |
| 2666 | |
| 2667 | case 5: |
| 2668 | #line 1006 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2669 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2670 | if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range! |
| 2671 | ThrowException("Value too large for type!"); |
| 2672 | yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2673 | ;} |
| 2674 | break; |
| 2675 | |
| 2676 | case 34: |
| 2677 | #line 1029 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2678 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2679 | yyval.StrVal = yyvsp[-1].StrVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2680 | ;} |
| 2681 | break; |
| 2682 | |
| 2683 | case 35: |
| 2684 | #line 1032 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2685 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2686 | yyval.StrVal = 0; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2687 | ;} |
| 2688 | break; |
| 2689 | |
| 2690 | case 36: |
| 2691 | #line 1036 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2692 | { yyval.Linkage = GlobalValue::InternalLinkage; ;} |
| 2693 | break; |
| 2694 | |
| 2695 | case 37: |
| 2696 | #line 1037 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2697 | { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;} |
| 2698 | break; |
| 2699 | |
| 2700 | case 38: |
| 2701 | #line 1038 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2702 | { yyval.Linkage = GlobalValue::WeakLinkage; ;} |
| 2703 | break; |
| 2704 | |
| 2705 | case 39: |
| 2706 | #line 1039 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2707 | { yyval.Linkage = GlobalValue::AppendingLinkage; ;} |
| 2708 | break; |
| 2709 | |
| 2710 | case 40: |
| 2711 | #line 1040 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2712 | { yyval.Linkage = GlobalValue::ExternalLinkage; ;} |
| 2713 | break; |
| 2714 | |
| 2715 | case 41: |
| 2716 | #line 1042 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2717 | { yyval.UIntVal = CallingConv::C; ;} |
| 2718 | break; |
| 2719 | |
| 2720 | case 42: |
| 2721 | #line 1043 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2722 | { yyval.UIntVal = CallingConv::C; ;} |
| 2723 | break; |
| 2724 | |
| 2725 | case 43: |
| 2726 | #line 1044 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2727 | { yyval.UIntVal = CallingConv::Fast; ;} |
| 2728 | break; |
| 2729 | |
| 2730 | case 44: |
| 2731 | #line 1045 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2732 | { yyval.UIntVal = CallingConv::Cold; ;} |
| 2733 | break; |
| 2734 | |
| 2735 | case 45: |
| 2736 | #line 1046 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2737 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2738 | if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val) |
| 2739 | ThrowException("Calling conv too large!"); |
| 2740 | yyval.UIntVal = yyvsp[0].UInt64Val; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2741 | ;} |
| 2742 | break; |
| 2743 | |
| 2744 | case 46: |
| 2745 | #line 1054 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2746 | { yyval.UIntVal = 0; ;} |
| 2747 | break; |
| 2748 | |
| 2749 | case 47: |
| 2750 | #line 1055 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2751 | { |
Chris Lattner | 11ca4d6 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 2752 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2753 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
| 2754 | ThrowException("Alignment must be a power of two!"); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2755 | ;} |
| 2756 | break; |
| 2757 | |
| 2758 | case 48: |
| 2759 | #line 1060 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2760 | { yyval.UIntVal = 0; ;} |
| 2761 | break; |
| 2762 | |
| 2763 | case 49: |
| 2764 | #line 1061 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2765 | { |
Chris Lattner | 11ca4d6 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 2766 | yyval.UIntVal = yyvsp[0].UInt64Val; |
| 2767 | if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal)) |
| 2768 | ThrowException("Alignment must be a power of two!"); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2769 | ;} |
| 2770 | break; |
| 2771 | |
| 2772 | case 50: |
| 2773 | #line 1068 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2774 | { |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 2775 | for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i) |
| 2776 | if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\') |
| 2777 | ThrowException("Invalid character in section name!"); |
| 2778 | yyval.StrVal = yyvsp[0].StrVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2779 | ;} |
| 2780 | break; |
| 2781 | |
| 2782 | case 51: |
| 2783 | #line 1075 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2784 | { yyval.StrVal = 0; ;} |
| 2785 | break; |
| 2786 | |
| 2787 | case 52: |
| 2788 | #line 1076 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2789 | { yyval.StrVal = yyvsp[0].StrVal; ;} |
| 2790 | break; |
| 2791 | |
| 2792 | case 53: |
| 2793 | #line 1081 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2794 | {;} |
| 2795 | break; |
| 2796 | |
| 2797 | case 54: |
| 2798 | #line 1082 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2799 | {;} |
| 2800 | break; |
| 2801 | |
| 2802 | case 55: |
| 2803 | #line 1083 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2804 | { |
Chris Lattner | 11ca4d6 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 2805 | CurGV->setSection(yyvsp[0].StrVal); |
| 2806 | free(yyvsp[0].StrVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2807 | ;} |
| 2808 | break; |
| 2809 | |
| 2810 | case 56: |
| 2811 | #line 1087 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2812 | { |
Chris Lattner | a054d12 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 2813 | if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val)) |
| 2814 | ThrowException("Alignment must be a power of two!"); |
Chris Lattner | 11ca4d6 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 2815 | CurGV->setAlignment(yyvsp[0].UInt64Val); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2816 | ;} |
| 2817 | break; |
| 2818 | |
| 2819 | case 58: |
| 2820 | #line 1100 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2821 | { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;} |
| 2822 | break; |
| 2823 | |
| 2824 | case 60: |
| 2825 | #line 1101 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2826 | { yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;} |
| 2827 | break; |
| 2828 | |
| 2829 | case 61: |
| 2830 | #line 1103 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2831 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2832 | if (!UpRefs.empty()) |
| 2833 | ThrowException("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription()); |
| 2834 | yyval.TypeVal = yyvsp[0].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2835 | ;} |
| 2836 | break; |
| 2837 | |
| 2838 | case 75: |
| 2839 | #line 1114 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2840 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2841 | yyval.TypeVal = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2842 | ;} |
| 2843 | break; |
| 2844 | |
| 2845 | case 76: |
| 2846 | #line 1117 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2847 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2848 | yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2849 | ;} |
| 2850 | break; |
| 2851 | |
| 2852 | case 77: |
| 2853 | #line 1120 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2854 | { // Named types are also simple types... |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2855 | yyval.TypeVal = new PATypeHolder(getTypeVal(yyvsp[0].ValIDVal)); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2856 | ;} |
| 2857 | break; |
| 2858 | |
| 2859 | case 78: |
| 2860 | #line 1126 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2861 | { // Type UpReference |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2862 | if (yyvsp[0].UInt64Val > (uint64_t)~0U) ThrowException("Value out of range!"); |
| 2863 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
| 2864 | UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector... |
| 2865 | yyval.TypeVal = new PATypeHolder(OT); |
| 2866 | UR_OUT("New Upreference!\n"); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2867 | ;} |
| 2868 | break; |
| 2869 | |
| 2870 | case 79: |
| 2871 | #line 1133 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2872 | { // Function derived type? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2873 | std::vector<const Type*> Params; |
| 2874 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(), |
| 2875 | E = yyvsp[-1].TypeList->end(); I != E; ++I) |
| 2876 | Params.push_back(*I); |
| 2877 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 2878 | if (isVarArg) Params.pop_back(); |
| 2879 | |
| 2880 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg))); |
| 2881 | delete yyvsp[-1].TypeList; // Delete the argument list |
| 2882 | delete yyvsp[-3].TypeVal; // Delete the return type handle |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2883 | ;} |
| 2884 | break; |
| 2885 | |
| 2886 | case 80: |
| 2887 | #line 1145 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2888 | { // Sized array type? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2889 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2890 | delete yyvsp[-1].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2891 | ;} |
| 2892 | break; |
| 2893 | |
| 2894 | case 81: |
| 2895 | #line 1149 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2896 | { // Packed array type? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2897 | const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get(); |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame] | 2898 | if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2899 | ThrowException("Unsigned result not equal to signed result"); |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame] | 2900 | if (!ElemTy->isPrimitiveType()) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2901 | ThrowException("Elemental type of a PackedType must be primitive"); |
Chris Lattner | 625b9c8 | 2005-11-10 01:42:43 +0000 | [diff] [blame] | 2902 | if (!isPowerOf2_32(yyvsp[-3].UInt64Val)) |
| 2903 | ThrowException("Vector length should be a power of 2!"); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2904 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val))); |
| 2905 | delete yyvsp[-1].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2906 | ;} |
| 2907 | break; |
| 2908 | |
| 2909 | case 82: |
| 2910 | #line 1160 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2911 | { // Structure type? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2912 | std::vector<const Type*> Elements; |
| 2913 | for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(), |
| 2914 | E = yyvsp[-1].TypeList->end(); I != E; ++I) |
| 2915 | Elements.push_back(*I); |
| 2916 | |
| 2917 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 2918 | delete yyvsp[-1].TypeList; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2919 | ;} |
| 2920 | break; |
| 2921 | |
| 2922 | case 83: |
| 2923 | #line 1169 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2924 | { // Empty structure type? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2925 | yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2926 | ;} |
| 2927 | break; |
| 2928 | |
| 2929 | case 84: |
| 2930 | #line 1172 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2931 | { // Pointer type? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2932 | yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal))); |
| 2933 | delete yyvsp[-1].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2934 | ;} |
| 2935 | break; |
| 2936 | |
| 2937 | case 85: |
| 2938 | #line 1180 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2939 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2940 | yyval.TypeList = new std::list<PATypeHolder>(); |
| 2941 | yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2942 | ;} |
| 2943 | break; |
| 2944 | |
| 2945 | case 86: |
| 2946 | #line 1184 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2947 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2948 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2949 | ;} |
| 2950 | break; |
| 2951 | |
| 2952 | case 88: |
| 2953 | #line 1190 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2954 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2955 | (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2956 | ;} |
| 2957 | break; |
| 2958 | |
| 2959 | case 89: |
| 2960 | #line 1193 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2961 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2962 | (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2963 | ;} |
| 2964 | break; |
| 2965 | |
| 2966 | case 90: |
| 2967 | #line 1196 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2968 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2969 | yyval.TypeList = new std::list<PATypeHolder>(); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2970 | ;} |
| 2971 | break; |
| 2972 | |
| 2973 | case 91: |
| 2974 | #line 1206 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 2975 | { // Nonempty unsized arr |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2976 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get()); |
| 2977 | if (ATy == 0) |
| 2978 | ThrowException("Cannot make array constant with type: '" + |
| 2979 | (*yyvsp[-3].TypeVal)->getDescription() + "'!"); |
| 2980 | const Type *ETy = ATy->getElementType(); |
| 2981 | int NumElements = ATy->getNumElements(); |
| 2982 | |
| 2983 | // Verify that we have the correct size... |
| 2984 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
| 2985 | ThrowException("Type mismatch: constant sized array initialized with " + |
| 2986 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
| 2987 | itostr(NumElements) + "!"); |
| 2988 | |
| 2989 | // Verify all elements are correct type! |
| 2990 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 2991 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
| 2992 | ThrowException("Element #" + utostr(i) + " is not of type '" + |
| 2993 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 2994 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
| 2995 | } |
| 2996 | |
| 2997 | yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector); |
| 2998 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 2999 | ;} |
| 3000 | break; |
| 3001 | |
| 3002 | case 92: |
| 3003 | #line 1231 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3004 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3005 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
| 3006 | if (ATy == 0) |
| 3007 | ThrowException("Cannot make array constant with type: '" + |
| 3008 | (*yyvsp[-2].TypeVal)->getDescription() + "'!"); |
| 3009 | |
| 3010 | int NumElements = ATy->getNumElements(); |
| 3011 | if (NumElements != -1 && NumElements != 0) |
| 3012 | ThrowException("Type mismatch: constant sized array initialized with 0" |
| 3013 | " arguments, but has size of " + itostr(NumElements) +"!"); |
| 3014 | yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3015 | delete yyvsp[-2].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3016 | ;} |
| 3017 | break; |
| 3018 | |
| 3019 | case 93: |
| 3020 | #line 1244 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3021 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3022 | const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get()); |
| 3023 | if (ATy == 0) |
| 3024 | ThrowException("Cannot make array constant with type: '" + |
| 3025 | (*yyvsp[-2].TypeVal)->getDescription() + "'!"); |
| 3026 | |
| 3027 | int NumElements = ATy->getNumElements(); |
| 3028 | const Type *ETy = ATy->getElementType(); |
| 3029 | char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true); |
| 3030 | if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal)) |
| 3031 | ThrowException("Can't build string constant of size " + |
| 3032 | itostr((int)(EndStr-yyvsp[0].StrVal)) + |
| 3033 | " when array has size " + itostr(NumElements) + "!"); |
| 3034 | std::vector<Constant*> Vals; |
| 3035 | if (ETy == Type::SByteTy) { |
| 3036 | for (char *C = yyvsp[0].StrVal; C != EndStr; ++C) |
| 3037 | Vals.push_back(ConstantSInt::get(ETy, *C)); |
| 3038 | } else if (ETy == Type::UByteTy) { |
| 3039 | for (char *C = yyvsp[0].StrVal; C != EndStr; ++C) |
| 3040 | Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C)); |
| 3041 | } else { |
| 3042 | free(yyvsp[0].StrVal); |
| 3043 | ThrowException("Cannot build string arrays of non byte sized elements!"); |
| 3044 | } |
| 3045 | free(yyvsp[0].StrVal); |
| 3046 | yyval.ConstVal = ConstantArray::get(ATy, Vals); |
| 3047 | delete yyvsp[-2].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3048 | ;} |
| 3049 | break; |
| 3050 | |
| 3051 | case 94: |
| 3052 | #line 1272 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3053 | { // Nonempty unsized arr |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3054 | const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get()); |
| 3055 | if (PTy == 0) |
| 3056 | ThrowException("Cannot make packed constant with type: '" + |
| 3057 | (*yyvsp[-3].TypeVal)->getDescription() + "'!"); |
| 3058 | const Type *ETy = PTy->getElementType(); |
| 3059 | int NumElements = PTy->getNumElements(); |
| 3060 | |
| 3061 | // Verify that we have the correct size... |
| 3062 | if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size()) |
| 3063 | ThrowException("Type mismatch: constant sized packed initialized with " + |
| 3064 | utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " + |
| 3065 | itostr(NumElements) + "!"); |
| 3066 | |
| 3067 | // Verify all elements are correct type! |
| 3068 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3069 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
| 3070 | ThrowException("Element #" + utostr(i) + " is not of type '" + |
| 3071 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
| 3072 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
| 3073 | } |
| 3074 | |
| 3075 | yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector); |
| 3076 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3077 | ;} |
| 3078 | break; |
| 3079 | |
| 3080 | case 95: |
| 3081 | #line 1297 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3082 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3083 | const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get()); |
| 3084 | if (STy == 0) |
| 3085 | ThrowException("Cannot make struct constant with type: '" + |
| 3086 | (*yyvsp[-3].TypeVal)->getDescription() + "'!"); |
| 3087 | |
| 3088 | if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes()) |
| 3089 | ThrowException("Illegal number of initializers for structure type!"); |
| 3090 | |
| 3091 | // Check to ensure that constants are compatible with the type initializer! |
| 3092 | for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i) |
| 3093 | if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i)) |
| 3094 | ThrowException("Expected type '" + |
| 3095 | STy->getElementType(i)->getDescription() + |
| 3096 | "' for element #" + utostr(i) + |
| 3097 | " of structure initializer!"); |
| 3098 | |
| 3099 | yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector); |
| 3100 | delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3101 | ;} |
| 3102 | break; |
| 3103 | |
| 3104 | case 96: |
| 3105 | #line 1317 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3106 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3107 | const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get()); |
| 3108 | if (STy == 0) |
| 3109 | ThrowException("Cannot make struct constant with type: '" + |
| 3110 | (*yyvsp[-2].TypeVal)->getDescription() + "'!"); |
| 3111 | |
| 3112 | if (STy->getNumContainedTypes() != 0) |
| 3113 | ThrowException("Illegal number of initializers for structure type!"); |
| 3114 | |
| 3115 | yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3116 | delete yyvsp[-2].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3117 | ;} |
| 3118 | break; |
| 3119 | |
| 3120 | case 97: |
| 3121 | #line 1329 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3122 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3123 | const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
| 3124 | if (PTy == 0) |
| 3125 | ThrowException("Cannot make null pointer constant with type: '" + |
| 3126 | (*yyvsp[-1].TypeVal)->getDescription() + "'!"); |
| 3127 | |
| 3128 | yyval.ConstVal = ConstantPointerNull::get(PTy); |
| 3129 | delete yyvsp[-1].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3130 | ;} |
| 3131 | break; |
| 3132 | |
| 3133 | case 98: |
| 3134 | #line 1338 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3135 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3136 | yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get()); |
| 3137 | delete yyvsp[-1].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3138 | ;} |
| 3139 | break; |
| 3140 | |
| 3141 | case 99: |
| 3142 | #line 1342 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3143 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3144 | const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
| 3145 | if (Ty == 0) |
| 3146 | ThrowException("Global const reference must be a pointer type!"); |
| 3147 | |
| 3148 | // ConstExprs can exist in the body of a function, thus creating |
| 3149 | // GlobalValues whenever they refer to a variable. Because we are in |
| 3150 | // the context of a function, getValNonImprovising will search the functions |
| 3151 | // symbol table instead of the module symbol table for the global symbol, |
| 3152 | // which throws things all off. To get around this, we just tell |
| 3153 | // getValNonImprovising that we are at global scope here. |
| 3154 | // |
| 3155 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3156 | CurFun.CurrentFunction = 0; |
| 3157 | |
| 3158 | Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal); |
| 3159 | |
| 3160 | CurFun.CurrentFunction = SavedCurFn; |
| 3161 | |
| 3162 | // If this is an initializer for a constant pointer, which is referencing a |
| 3163 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3164 | // in the future with the right type of variable. |
| 3165 | // |
| 3166 | if (V == 0) { |
| 3167 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
| 3168 | const PointerType *PT = cast<PointerType>(Ty); |
| 3169 | |
| 3170 | // First check to see if the forward references value is already created! |
| 3171 | PerModuleInfo::GlobalRefsType::iterator I = |
| 3172 | CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal)); |
| 3173 | |
| 3174 | if (I != CurModule.GlobalRefs.end()) { |
| 3175 | V = I->second; // Placeholder already exists, use it... |
| 3176 | yyvsp[0].ValIDVal.destroy(); |
| 3177 | } else { |
| 3178 | std::string Name; |
| 3179 | if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name; |
| 3180 | |
| 3181 | // Create the forward referenced global. |
| 3182 | GlobalValue *GV; |
| 3183 | if (const FunctionType *FTy = |
| 3184 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 3185 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 3186 | CurModule.CurrentModule); |
| 3187 | } else { |
| 3188 | GV = new GlobalVariable(PT->getElementType(), false, |
| 3189 | GlobalValue::ExternalLinkage, 0, |
| 3190 | Name, CurModule.CurrentModule); |
| 3191 | } |
| 3192 | |
| 3193 | // Keep track of the fact that we have a forward ref to recycle it |
| 3194 | CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV)); |
| 3195 | V = GV; |
| 3196 | } |
| 3197 | } |
| 3198 | |
| 3199 | yyval.ConstVal = cast<GlobalValue>(V); |
| 3200 | delete yyvsp[-1].TypeVal; // Free the type handle |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3201 | ;} |
| 3202 | break; |
| 3203 | |
| 3204 | case 100: |
| 3205 | #line 1401 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3206 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3207 | if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType()) |
| 3208 | ThrowException("Mismatched types for constant expression!"); |
| 3209 | yyval.ConstVal = yyvsp[0].ConstVal; |
| 3210 | delete yyvsp[-1].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3211 | ;} |
| 3212 | break; |
| 3213 | |
| 3214 | case 101: |
| 3215 | #line 1407 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3216 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3217 | const Type *Ty = yyvsp[-1].TypeVal->get(); |
| 3218 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 3219 | ThrowException("Cannot create a null initialized value of this type!"); |
| 3220 | yyval.ConstVal = Constant::getNullValue(Ty); |
| 3221 | delete yyvsp[-1].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3222 | ;} |
| 3223 | break; |
| 3224 | |
| 3225 | case 102: |
| 3226 | #line 1415 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3227 | { // integral constants |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3228 | if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val)) |
| 3229 | ThrowException("Constant value doesn't fit in type!"); |
| 3230 | yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3231 | ;} |
| 3232 | break; |
| 3233 | |
| 3234 | case 103: |
| 3235 | #line 1420 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3236 | { // integral constants |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3237 | if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val)) |
| 3238 | ThrowException("Constant value doesn't fit in type!"); |
| 3239 | yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3240 | ;} |
| 3241 | break; |
| 3242 | |
| 3243 | case 104: |
| 3244 | #line 1425 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3245 | { // Boolean constants |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3246 | yyval.ConstVal = ConstantBool::True; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3247 | ;} |
| 3248 | break; |
| 3249 | |
| 3250 | case 105: |
| 3251 | #line 1428 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3252 | { // Boolean constants |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3253 | yyval.ConstVal = ConstantBool::False; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3254 | ;} |
| 3255 | break; |
| 3256 | |
| 3257 | case 106: |
| 3258 | #line 1431 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3259 | { // Float & Double constants |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3260 | if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal)) |
| 3261 | ThrowException("Floating point constant invalid for type!!"); |
| 3262 | yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3263 | ;} |
| 3264 | break; |
| 3265 | |
| 3266 | case 107: |
| 3267 | #line 1438 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3268 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3269 | if (!yyvsp[-3].ConstVal->getType()->isFirstClassType()) |
| 3270 | ThrowException("cast constant expression from a non-primitive type: '" + |
| 3271 | yyvsp[-3].ConstVal->getType()->getDescription() + "'!"); |
| 3272 | if (!yyvsp[-1].TypeVal->get()->isFirstClassType()) |
| 3273 | ThrowException("cast constant expression to a non-primitive type: '" + |
| 3274 | yyvsp[-1].TypeVal->get()->getDescription() + "'!"); |
| 3275 | yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get()); |
| 3276 | delete yyvsp[-1].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3277 | ;} |
| 3278 | break; |
| 3279 | |
| 3280 | case 108: |
| 3281 | #line 1448 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3282 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3283 | if (!isa<PointerType>(yyvsp[-2].ConstVal->getType())) |
| 3284 | ThrowException("GetElementPtr requires a pointer operand!"); |
| 3285 | |
| 3286 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct |
| 3287 | // indices to uint struct indices for compatibility. |
| 3288 | generic_gep_type_iterator<std::vector<Value*>::iterator> |
| 3289 | GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()), |
| 3290 | GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()); |
| 3291 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI) |
| 3292 | if (isa<StructType>(*GTI)) // Only change struct indices |
| 3293 | if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i])) |
| 3294 | if (CUI->getType() == Type::UByteTy) |
| 3295 | (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy); |
| 3296 | |
| 3297 | const Type *IdxTy = |
| 3298 | GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true); |
| 3299 | if (!IdxTy) |
| 3300 | ThrowException("Index list invalid for constant getelementptr!"); |
| 3301 | |
| 3302 | std::vector<Constant*> IdxVec; |
| 3303 | for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i) |
| 3304 | if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i])) |
| 3305 | IdxVec.push_back(C); |
| 3306 | else |
| 3307 | ThrowException("Indices to constant getelementptr must be constants!"); |
| 3308 | |
| 3309 | delete yyvsp[-1].ValueList; |
| 3310 | |
| 3311 | yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3312 | ;} |
| 3313 | break; |
| 3314 | |
| 3315 | case 109: |
| 3316 | #line 1479 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3317 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3318 | if (yyvsp[-5].ConstVal->getType() != Type::BoolTy) |
| 3319 | ThrowException("Select condition must be of boolean type!"); |
| 3320 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
| 3321 | ThrowException("Select operand types must match!"); |
| 3322 | yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3323 | ;} |
| 3324 | break; |
| 3325 | |
| 3326 | case 110: |
| 3327 | #line 1486 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3328 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3329 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
| 3330 | ThrowException("Binary operator types must match!"); |
| 3331 | // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. |
| 3332 | // To retain backward compatibility with these early compilers, we emit a |
| 3333 | // cast to the appropriate integer type automatically if we are in the |
| 3334 | // broken case. See PR424 for more information. |
| 3335 | if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) { |
| 3336 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
| 3337 | } else { |
| 3338 | const Type *IntPtrTy = 0; |
| 3339 | switch (CurModule.CurrentModule->getPointerSize()) { |
| 3340 | case Module::Pointer32: IntPtrTy = Type::IntTy; break; |
| 3341 | case Module::Pointer64: IntPtrTy = Type::LongTy; break; |
| 3342 | default: ThrowException("invalid pointer binary constant expr!"); |
| 3343 | } |
| 3344 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy), |
| 3345 | ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy)); |
| 3346 | yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType()); |
| 3347 | } |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3348 | ;} |
| 3349 | break; |
| 3350 | |
| 3351 | case 111: |
| 3352 | #line 1507 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3353 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3354 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
| 3355 | ThrowException("Logical operator types must match!"); |
Chris Lattner | 15f5a18 | 2005-12-21 18:31:50 +0000 | [diff] [blame] | 3356 | if (!yyvsp[-3].ConstVal->getType()->isIntegral()) { |
| 3357 | if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) || |
| 3358 | !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral()) |
| 3359 | ThrowException("Logical operator requires integral operands!"); |
| 3360 | } |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3361 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3362 | ;} |
| 3363 | break; |
| 3364 | |
| 3365 | case 112: |
| 3366 | #line 1517 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3367 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3368 | if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType()) |
| 3369 | ThrowException("setcc operand types must match!"); |
| 3370 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3371 | ;} |
| 3372 | break; |
| 3373 | |
| 3374 | case 113: |
| 3375 | #line 1522 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3376 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3377 | if (yyvsp[-1].ConstVal->getType() != Type::UByteTy) |
| 3378 | ThrowException("Shift count for shift constant must be unsigned byte!"); |
| 3379 | if (!yyvsp[-3].ConstVal->getType()->isInteger()) |
| 3380 | ThrowException("Shift constant expression requires integer operand!"); |
| 3381 | yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3382 | ;} |
| 3383 | break; |
| 3384 | |
| 3385 | case 114: |
| 3386 | #line 1529 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3387 | { |
Robert Bocchino | aa1cf54 | 2006-01-10 19:04:32 +0000 | [diff] [blame] | 3388 | if (!isa<PackedType>(yyvsp[-3].ConstVal->getType())) |
| 3389 | ThrowException("First operand of extractelement must be " |
| 3390 | "packed type!"); |
| 3391 | if (yyvsp[-1].ConstVal->getType() != Type::UIntTy) |
| 3392 | ThrowException("Second operand of extractelement must be uint!"); |
| 3393 | yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3394 | ;} |
| 3395 | break; |
| 3396 | |
| 3397 | case 115: |
| 3398 | #line 1539 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3399 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3400 | (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3401 | ;} |
| 3402 | break; |
| 3403 | |
| 3404 | case 116: |
| 3405 | #line 1542 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3406 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3407 | yyval.ConstVector = new std::vector<Constant*>(); |
| 3408 | yyval.ConstVector->push_back(yyvsp[0].ConstVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3409 | ;} |
| 3410 | break; |
| 3411 | |
| 3412 | case 117: |
| 3413 | #line 1549 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3414 | { yyval.BoolVal = false; ;} |
| 3415 | break; |
| 3416 | |
| 3417 | case 118: |
| 3418 | #line 1549 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3419 | { yyval.BoolVal = true; ;} |
| 3420 | break; |
| 3421 | |
| 3422 | case 119: |
| 3423 | #line 1559 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3424 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3425 | yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal; |
| 3426 | CurModule.ModuleDone(); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3427 | ;} |
| 3428 | break; |
| 3429 | |
| 3430 | case 120: |
| 3431 | #line 1566 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3432 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3433 | yyval.ModuleVal = yyvsp[-1].ModuleVal; |
| 3434 | CurFun.FunctionDone(); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3435 | ;} |
| 3436 | break; |
| 3437 | |
| 3438 | case 121: |
| 3439 | #line 1570 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3440 | { |
Chris Lattner | 15f5a18 | 2005-12-21 18:31:50 +0000 | [diff] [blame] | 3441 | yyval.ModuleVal = yyvsp[-1].ModuleVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3442 | ;} |
| 3443 | break; |
| 3444 | |
| 3445 | case 122: |
| 3446 | #line 1573 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3447 | { |
Robert Bocchino | aa1cf54 | 2006-01-10 19:04:32 +0000 | [diff] [blame] | 3448 | yyval.ModuleVal = yyvsp[-1].ModuleVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3449 | ;} |
| 3450 | break; |
| 3451 | |
| 3452 | case 123: |
| 3453 | #line 1576 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3454 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3455 | yyval.ModuleVal = CurModule.CurrentModule; |
| 3456 | // Emit an error if there are any unresolved types left. |
| 3457 | if (!CurModule.LateResolveTypes.empty()) { |
| 3458 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 3459 | if (DID.Type == ValID::NameVal) |
| 3460 | ThrowException("Reference to an undefined type: '"+DID.getName() + "'"); |
| 3461 | else |
| 3462 | ThrowException("Reference to an undefined type: #" + itostr(DID.Num)); |
| 3463 | } |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3464 | ;} |
| 3465 | break; |
| 3466 | |
| 3467 | case 124: |
| 3468 | #line 1589 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3469 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3470 | // Eagerly resolve types. This is not an optimization, this is a |
| 3471 | // requirement that is due to the fact that we could have this: |
| 3472 | // |
| 3473 | // %list = type { %list * } |
| 3474 | // %list = type { %list * } ; repeated type decl |
| 3475 | // |
| 3476 | // If types are not resolved eagerly, then the two types will not be |
| 3477 | // determined to be the same type! |
| 3478 | // |
| 3479 | ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal); |
| 3480 | |
| 3481 | if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) { |
| 3482 | // If this is a named type that is not a redefinition, add it to the slot |
| 3483 | // table. |
| 3484 | CurModule.Types.push_back(*yyvsp[0].TypeVal); |
| 3485 | } |
| 3486 | |
| 3487 | delete yyvsp[0].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3488 | ;} |
| 3489 | break; |
| 3490 | |
| 3491 | case 125: |
| 3492 | #line 1609 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3493 | { // Function prototypes can be in const pool |
| 3494 | ;} |
| 3495 | break; |
| 3496 | |
| 3497 | case 126: |
| 3498 | #line 1611 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3499 | { |
Chris Lattner | 11ca4d6 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 3500 | if (yyvsp[0].ConstVal == 0) ThrowException("Global value initializer is not a constant!"); |
| 3501 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3502 | ;} |
| 3503 | break; |
| 3504 | |
| 3505 | case 127: |
| 3506 | #line 1614 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3507 | { |
Chris Lattner | 11ca4d6 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 3508 | CurGV = 0; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3509 | ;} |
| 3510 | break; |
| 3511 | |
| 3512 | case 128: |
| 3513 | #line 1617 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3514 | { |
Chris Lattner | 11ca4d6 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 3515 | CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, |
| 3516 | yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0); |
| 3517 | delete yyvsp[0].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3518 | ;} |
| 3519 | break; |
| 3520 | |
| 3521 | case 129: |
| 3522 | #line 1621 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3523 | { |
Chris Lattner | 11ca4d6 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 3524 | CurGV = 0; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3525 | ;} |
| 3526 | break; |
| 3527 | |
| 3528 | case 130: |
| 3529 | #line 1624 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3530 | { |
| 3531 | ;} |
| 3532 | break; |
| 3533 | |
| 3534 | case 131: |
| 3535 | #line 1626 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3536 | { |
| 3537 | ;} |
| 3538 | break; |
| 3539 | |
| 3540 | case 132: |
| 3541 | #line 1628 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3542 | { |
| 3543 | ;} |
| 3544 | break; |
| 3545 | |
| 3546 | case 133: |
| 3547 | #line 1633 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3548 | { yyval.Endianness = Module::BigEndian; ;} |
| 3549 | break; |
| 3550 | |
| 3551 | case 134: |
| 3552 | #line 1634 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3553 | { yyval.Endianness = Module::LittleEndian; ;} |
| 3554 | break; |
| 3555 | |
| 3556 | case 135: |
| 3557 | #line 1636 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3558 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3559 | CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3560 | ;} |
| 3561 | break; |
| 3562 | |
| 3563 | case 136: |
| 3564 | #line 1639 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3565 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3566 | if (yyvsp[0].UInt64Val == 32) |
| 3567 | CurModule.CurrentModule->setPointerSize(Module::Pointer32); |
| 3568 | else if (yyvsp[0].UInt64Val == 64) |
| 3569 | CurModule.CurrentModule->setPointerSize(Module::Pointer64); |
| 3570 | else |
| 3571 | ThrowException("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!"); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3572 | ;} |
| 3573 | break; |
| 3574 | |
| 3575 | case 137: |
| 3576 | #line 1647 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3577 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3578 | CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal); |
| 3579 | free(yyvsp[0].StrVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3580 | ;} |
| 3581 | break; |
| 3582 | |
| 3583 | case 139: |
| 3584 | #line 1654 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3585 | { |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3586 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 3587 | free(yyvsp[0].StrVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3588 | ;} |
| 3589 | break; |
| 3590 | |
| 3591 | case 140: |
| 3592 | #line 1658 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3593 | { |
Robert Bocchino | aa1cf54 | 2006-01-10 19:04:32 +0000 | [diff] [blame] | 3594 | CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal); |
| 3595 | free(yyvsp[0].StrVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3596 | ;} |
| 3597 | break; |
| 3598 | |
| 3599 | case 141: |
| 3600 | #line 1662 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3601 | { |
| 3602 | ;} |
| 3603 | break; |
| 3604 | |
| 3605 | case 145: |
| 3606 | #line 1671 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3607 | { yyval.StrVal = 0; ;} |
| 3608 | break; |
| 3609 | |
| 3610 | case 146: |
| 3611 | #line 1673 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3612 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3613 | if (*yyvsp[-1].TypeVal == Type::VoidTy) |
| 3614 | ThrowException("void typed arguments are invalid!"); |
| 3615 | yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3616 | ;} |
| 3617 | break; |
| 3618 | |
| 3619 | case 147: |
| 3620 | #line 1679 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3621 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3622 | yyval.ArgList = yyvsp[-2].ArgList; |
| 3623 | yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal); |
| 3624 | delete yyvsp[0].ArgVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3625 | ;} |
| 3626 | break; |
| 3627 | |
| 3628 | case 148: |
| 3629 | #line 1684 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3630 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3631 | yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >(); |
| 3632 | yyval.ArgList->push_back(*yyvsp[0].ArgVal); |
| 3633 | delete yyvsp[0].ArgVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3634 | ;} |
| 3635 | break; |
| 3636 | |
| 3637 | case 149: |
| 3638 | #line 1690 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3639 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3640 | yyval.ArgList = yyvsp[0].ArgList; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3641 | ;} |
| 3642 | break; |
| 3643 | |
| 3644 | case 150: |
| 3645 | #line 1693 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3646 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3647 | yyval.ArgList = yyvsp[-2].ArgList; |
| 3648 | yyval.ArgList->push_back(std::pair<PATypeHolder*, |
| 3649 | char*>(new PATypeHolder(Type::VoidTy), 0)); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3650 | ;} |
| 3651 | break; |
| 3652 | |
| 3653 | case 151: |
| 3654 | #line 1698 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3655 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3656 | yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >(); |
| 3657 | yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0)); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3658 | ;} |
| 3659 | break; |
| 3660 | |
| 3661 | case 152: |
| 3662 | #line 1702 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3663 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3664 | yyval.ArgList = 0; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3665 | ;} |
| 3666 | break; |
| 3667 | |
| 3668 | case 153: |
| 3669 | #line 1707 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3670 | { |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3671 | UnEscapeLexed(yyvsp[-5].StrVal); |
| 3672 | std::string FunctionName(yyvsp[-5].StrVal); |
| 3673 | free(yyvsp[-5].StrVal); // Free strdup'd memory! |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3674 | |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3675 | if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3676 | ThrowException("LLVM functions cannot return aggregate types!"); |
| 3677 | |
| 3678 | std::vector<const Type*> ParamTypeList; |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3679 | if (yyvsp[-3].ArgList) { // If there are arguments... |
| 3680 | for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin(); |
| 3681 | I != yyvsp[-3].ArgList->end(); ++I) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3682 | ParamTypeList.push_back(I->first->get()); |
| 3683 | } |
| 3684 | |
| 3685 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 3686 | if (isVarArg) ParamTypeList.pop_back(); |
| 3687 | |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3688 | const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3689 | const PointerType *PFT = PointerType::get(FT); |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3690 | delete yyvsp[-6].TypeVal; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3691 | |
| 3692 | ValID ID; |
| 3693 | if (!FunctionName.empty()) { |
| 3694 | ID = ValID::create((char*)FunctionName.c_str()); |
| 3695 | } else { |
| 3696 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
| 3697 | } |
| 3698 | |
| 3699 | Function *Fn = 0; |
| 3700 | // See if this function was forward referenced. If so, recycle the object. |
| 3701 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 3702 | // Move the function to the end of the list, from whereever it was |
| 3703 | // previously inserted. |
| 3704 | Fn = cast<Function>(FWRef); |
| 3705 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 3706 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 3707 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
| 3708 | (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) { |
| 3709 | // If this is the case, either we need to be a forward decl, or it needs |
| 3710 | // to be. |
| 3711 | if (!CurFun.isDeclare && !Fn->isExternal()) |
| 3712 | ThrowException("Redefinition of function '" + FunctionName + "'!"); |
| 3713 | |
| 3714 | // Make sure to strip off any argument names so we can't get conflicts. |
| 3715 | if (Fn->isExternal()) |
| 3716 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 3717 | AI != AE; ++AI) |
| 3718 | AI->setName(""); |
| 3719 | |
| 3720 | } else { // Not already defined? |
| 3721 | Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, |
| 3722 | CurModule.CurrentModule); |
| 3723 | InsertValue(Fn, CurModule.Values); |
| 3724 | } |
| 3725 | |
| 3726 | CurFun.FunctionStart(Fn); |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3727 | Fn->setCallingConv(yyvsp[-7].UIntVal); |
Chris Lattner | 840f789 | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 3728 | Fn->setAlignment(yyvsp[0].UIntVal); |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3729 | if (yyvsp[-1].StrVal) { |
| 3730 | Fn->setSection(yyvsp[-1].StrVal); |
| 3731 | free(yyvsp[-1].StrVal); |
| 3732 | } |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3733 | |
| 3734 | // Add all of the arguments we parsed to the function... |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3735 | if (yyvsp[-3].ArgList) { // Is null if empty... |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3736 | if (isVarArg) { // Nuke the last entry |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3737 | assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&& |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3738 | "Not a varargs marker!"); |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3739 | delete yyvsp[-3].ArgList->back().first; |
| 3740 | yyvsp[-3].ArgList->pop_back(); // Delete the last entry |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3741 | } |
| 3742 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3743 | for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin(); |
| 3744 | I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3745 | delete I->first; // Delete the typeholder... |
| 3746 | |
| 3747 | setValueName(ArgIt, I->second); // Insert arg into symtab... |
| 3748 | InsertValue(ArgIt); |
| 3749 | } |
| 3750 | |
Chris Lattner | a0c20b4 | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 3751 | delete yyvsp[-3].ArgList; // We're now done with the argument list |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3752 | } |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3753 | ;} |
| 3754 | break; |
| 3755 | |
| 3756 | case 156: |
| 3757 | #line 1794 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3758 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3759 | yyval.FunctionVal = CurFun.CurrentFunction; |
| 3760 | |
| 3761 | // Make sure that we keep track of the linkage type even if there was a |
| 3762 | // previous "declare". |
| 3763 | yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3764 | ;} |
| 3765 | break; |
| 3766 | |
| 3767 | case 159: |
| 3768 | #line 1804 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3769 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3770 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3771 | ;} |
| 3772 | break; |
| 3773 | |
| 3774 | case 160: |
| 3775 | #line 1808 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3776 | { CurFun.isDeclare = true; ;} |
| 3777 | break; |
| 3778 | |
| 3779 | case 161: |
| 3780 | #line 1808 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3781 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3782 | yyval.FunctionVal = CurFun.CurrentFunction; |
| 3783 | CurFun.FunctionDone(); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3784 | ;} |
| 3785 | break; |
| 3786 | |
| 3787 | case 162: |
| 3788 | #line 1817 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3789 | { // A reference to a direct constant |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3790 | yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3791 | ;} |
| 3792 | break; |
| 3793 | |
| 3794 | case 163: |
| 3795 | #line 1820 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3796 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3797 | yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3798 | ;} |
| 3799 | break; |
| 3800 | |
| 3801 | case 164: |
| 3802 | #line 1823 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3803 | { // Perhaps it's an FP constant? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3804 | yyval.ValIDVal = ValID::create(yyvsp[0].FPVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3805 | ;} |
| 3806 | break; |
| 3807 | |
| 3808 | case 165: |
| 3809 | #line 1826 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3810 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3811 | yyval.ValIDVal = ValID::create(ConstantBool::True); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3812 | ;} |
| 3813 | break; |
| 3814 | |
| 3815 | case 166: |
| 3816 | #line 1829 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3817 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3818 | yyval.ValIDVal = ValID::create(ConstantBool::False); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3819 | ;} |
| 3820 | break; |
| 3821 | |
| 3822 | case 167: |
| 3823 | #line 1832 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3824 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3825 | yyval.ValIDVal = ValID::createNull(); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3826 | ;} |
| 3827 | break; |
| 3828 | |
| 3829 | case 168: |
| 3830 | #line 1835 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3831 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3832 | yyval.ValIDVal = ValID::createUndef(); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3833 | ;} |
| 3834 | break; |
| 3835 | |
| 3836 | case 169: |
| 3837 | #line 1838 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3838 | { // A vector zero constant. |
Chris Lattner | a054d12 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 3839 | yyval.ValIDVal = ValID::createZeroInit(); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3840 | ;} |
| 3841 | break; |
| 3842 | |
| 3843 | case 170: |
| 3844 | #line 1841 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3845 | { // Nonempty unsized packed vector |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3846 | const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType(); |
| 3847 | int NumElements = yyvsp[-1].ConstVector->size(); |
| 3848 | |
| 3849 | PackedType* pt = PackedType::get(ETy, NumElements); |
| 3850 | PATypeHolder* PTy = new PATypeHolder( |
| 3851 | HandleUpRefs( |
| 3852 | PackedType::get( |
| 3853 | ETy, |
| 3854 | NumElements) |
| 3855 | ) |
| 3856 | ); |
| 3857 | |
| 3858 | // Verify all elements are correct type! |
| 3859 | for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) { |
| 3860 | if (ETy != (*yyvsp[-1].ConstVector)[i]->getType()) |
| 3861 | ThrowException("Element #" + utostr(i) + " is not of type '" + |
| 3862 | ETy->getDescription() +"' as required!\nIt is of type '" + |
| 3863 | (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'."); |
| 3864 | } |
| 3865 | |
| 3866 | yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector)); |
| 3867 | delete PTy; delete yyvsp[-1].ConstVector; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3868 | ;} |
| 3869 | break; |
| 3870 | |
| 3871 | case 171: |
| 3872 | #line 1865 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3873 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3874 | yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3875 | ;} |
| 3876 | break; |
| 3877 | |
| 3878 | case 172: |
| 3879 | #line 1872 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3880 | { // Is it an integer reference...? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3881 | yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3882 | ;} |
| 3883 | break; |
| 3884 | |
| 3885 | case 173: |
| 3886 | #line 1875 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3887 | { // Is it a named reference...? |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3888 | yyval.ValIDVal = ValID::create(yyvsp[0].StrVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3889 | ;} |
| 3890 | break; |
| 3891 | |
| 3892 | case 176: |
| 3893 | #line 1886 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3894 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3895 | yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3896 | ;} |
| 3897 | break; |
| 3898 | |
| 3899 | case 177: |
| 3900 | #line 1890 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3901 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3902 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3903 | ;} |
| 3904 | break; |
| 3905 | |
| 3906 | case 178: |
| 3907 | #line 1893 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3908 | { // Do not allow functions with 0 basic blocks |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3909 | yyval.FunctionVal = yyvsp[-1].FunctionVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3910 | ;} |
| 3911 | break; |
| 3912 | |
| 3913 | case 179: |
| 3914 | #line 1901 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3915 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3916 | setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal); |
| 3917 | InsertValue(yyvsp[0].TermInstVal); |
| 3918 | |
| 3919 | yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal); |
| 3920 | InsertValue(yyvsp[-2].BasicBlockVal); |
| 3921 | yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3922 | ;} |
| 3923 | break; |
| 3924 | |
| 3925 | case 180: |
| 3926 | #line 1910 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3927 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3928 | yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal); |
| 3929 | yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3930 | ;} |
| 3931 | break; |
| 3932 | |
| 3933 | case 181: |
| 3934 | #line 1914 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3935 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3936 | yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); |
| 3937 | |
| 3938 | // Make sure to move the basic block to the correct location in the |
| 3939 | // function, instead of leaving it inserted wherever it was first |
| 3940 | // referenced. |
| 3941 | Function::BasicBlockListType &BBL = |
| 3942 | CurFun.CurrentFunction->getBasicBlockList(); |
| 3943 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3944 | ;} |
| 3945 | break; |
| 3946 | |
| 3947 | case 182: |
| 3948 | #line 1924 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3949 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3950 | yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true); |
| 3951 | |
| 3952 | // Make sure to move the basic block to the correct location in the |
| 3953 | // function, instead of leaving it inserted wherever it was first |
| 3954 | // referenced. |
| 3955 | Function::BasicBlockListType &BBL = |
| 3956 | CurFun.CurrentFunction->getBasicBlockList(); |
| 3957 | BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3958 | ;} |
| 3959 | break; |
| 3960 | |
| 3961 | case 183: |
| 3962 | #line 1935 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3963 | { // Return with a result... |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3964 | yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3965 | ;} |
| 3966 | break; |
| 3967 | |
| 3968 | case 184: |
| 3969 | #line 1938 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3970 | { // Return with no result... |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3971 | yyval.TermInstVal = new ReturnInst(); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3972 | ;} |
| 3973 | break; |
| 3974 | |
| 3975 | case 185: |
| 3976 | #line 1941 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3977 | { // Unconditional Branch... |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3978 | yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[0].ValIDVal)); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3979 | ;} |
| 3980 | break; |
| 3981 | |
| 3982 | case 186: |
| 3983 | #line 1944 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3984 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3985 | yyval.TermInstVal = new BranchInst(getBBVal(yyvsp[-3].ValIDVal), getBBVal(yyvsp[0].ValIDVal), getVal(Type::BoolTy, yyvsp[-6].ValIDVal)); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 3986 | ;} |
| 3987 | break; |
| 3988 | |
| 3989 | case 187: |
| 3990 | #line 1947 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 3991 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3992 | SwitchInst *S = new SwitchInst(getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal), getBBVal(yyvsp[-3].ValIDVal), yyvsp[-1].JumpTable->size()); |
| 3993 | yyval.TermInstVal = S; |
| 3994 | |
| 3995 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(), |
| 3996 | E = yyvsp[-1].JumpTable->end(); |
| 3997 | for (; I != E; ++I) { |
| 3998 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 3999 | S->addCase(CI, I->second); |
| 4000 | else |
| 4001 | ThrowException("Switch case is constant, but not a simple integer!"); |
| 4002 | } |
| 4003 | delete yyvsp[-1].JumpTable; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4004 | ;} |
| 4005 | break; |
| 4006 | |
| 4007 | case 188: |
| 4008 | #line 1961 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4009 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4010 | SwitchInst *S = new SwitchInst(getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal), getBBVal(yyvsp[-2].ValIDVal), 0); |
| 4011 | yyval.TermInstVal = S; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4012 | ;} |
| 4013 | break; |
| 4014 | |
| 4015 | case 189: |
| 4016 | #line 1966 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4017 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4018 | const PointerType *PFTy; |
| 4019 | const FunctionType *Ty; |
| 4020 | |
| 4021 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) || |
| 4022 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4023 | // Pull out the types of all of the arguments... |
| 4024 | std::vector<const Type*> ParamTypes; |
| 4025 | if (yyvsp[-7].ValueList) { |
| 4026 | for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end(); |
| 4027 | I != E; ++I) |
| 4028 | ParamTypes.push_back((*I)->getType()); |
| 4029 | } |
| 4030 | |
| 4031 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 4032 | if (isVarArg) ParamTypes.pop_back(); |
| 4033 | |
| 4034 | Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg); |
| 4035 | PFTy = PointerType::get(Ty); |
| 4036 | } |
| 4037 | |
| 4038 | Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling... |
| 4039 | |
| 4040 | BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal); |
| 4041 | BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal); |
| 4042 | |
| 4043 | // Create the call node... |
| 4044 | if (!yyvsp[-7].ValueList) { // Has no arguments? |
| 4045 | yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>()); |
| 4046 | } else { // Has arguments? |
| 4047 | // Loop through FunctionType's arguments and ensure they are specified |
| 4048 | // correctly! |
| 4049 | // |
| 4050 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4051 | FunctionType::param_iterator E = Ty->param_end(); |
| 4052 | std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end(); |
| 4053 | |
| 4054 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 4055 | if ((*ArgI)->getType() != *I) |
| 4056 | ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" + |
| 4057 | (*I)->getDescription() + "'!"); |
| 4058 | |
| 4059 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
| 4060 | ThrowException("Invalid number of parameters detected!"); |
| 4061 | |
| 4062 | yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList); |
| 4063 | } |
| 4064 | cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal); |
| 4065 | |
| 4066 | delete yyvsp[-10].TypeVal; |
| 4067 | delete yyvsp[-7].ValueList; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4068 | ;} |
| 4069 | break; |
| 4070 | |
| 4071 | case 190: |
| 4072 | #line 2018 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4073 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4074 | yyval.TermInstVal = new UnwindInst(); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4075 | ;} |
| 4076 | break; |
| 4077 | |
| 4078 | case 191: |
| 4079 | #line 2021 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4080 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4081 | yyval.TermInstVal = new UnreachableInst(); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4082 | ;} |
| 4083 | break; |
| 4084 | |
| 4085 | case 192: |
| 4086 | #line 2027 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4087 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4088 | yyval.JumpTable = yyvsp[-5].JumpTable; |
| 4089 | Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
| 4090 | if (V == 0) |
| 4091 | ThrowException("May only switch on a constant pool value!"); |
| 4092 | |
| 4093 | yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal))); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4094 | ;} |
| 4095 | break; |
| 4096 | |
| 4097 | case 193: |
| 4098 | #line 2035 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4099 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4100 | yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 4101 | Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal)); |
| 4102 | |
| 4103 | if (V == 0) |
| 4104 | ThrowException("May only switch on a constant pool value!"); |
| 4105 | |
| 4106 | yyval.JumpTable->push_back(std::make_pair(V, getBBVal(yyvsp[0].ValIDVal))); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4107 | ;} |
| 4108 | break; |
| 4109 | |
| 4110 | case 194: |
| 4111 | #line 2045 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4112 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4113 | // Is this definition named?? if so, assign the name... |
| 4114 | setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal); |
| 4115 | InsertValue(yyvsp[0].InstVal); |
| 4116 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4117 | ;} |
| 4118 | break; |
| 4119 | |
| 4120 | case 195: |
| 4121 | #line 2052 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4122 | { // Used for PHI nodes |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4123 | yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 4124 | yyval.PHIList->push_back(std::make_pair(getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal), getBBVal(yyvsp[-1].ValIDVal))); |
| 4125 | delete yyvsp[-5].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4126 | ;} |
| 4127 | break; |
| 4128 | |
| 4129 | case 196: |
| 4130 | #line 2057 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4131 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4132 | yyval.PHIList = yyvsp[-6].PHIList; |
| 4133 | yyvsp[-6].PHIList->push_back(std::make_pair(getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal), |
| 4134 | getBBVal(yyvsp[-1].ValIDVal))); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4135 | ;} |
| 4136 | break; |
| 4137 | |
| 4138 | case 197: |
| 4139 | #line 2064 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4140 | { // Used for call statements, and memory insts... |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4141 | yyval.ValueList = new std::vector<Value*>(); |
| 4142 | yyval.ValueList->push_back(yyvsp[0].ValueVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4143 | ;} |
| 4144 | break; |
| 4145 | |
| 4146 | case 198: |
| 4147 | #line 2068 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4148 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4149 | yyval.ValueList = yyvsp[-2].ValueList; |
| 4150 | yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4151 | ;} |
| 4152 | break; |
| 4153 | |
| 4154 | case 200: |
| 4155 | #line 2074 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4156 | { yyval.ValueList = 0; ;} |
| 4157 | break; |
| 4158 | |
| 4159 | case 201: |
| 4160 | #line 2076 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4161 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4162 | yyval.BoolVal = true; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4163 | ;} |
| 4164 | break; |
| 4165 | |
| 4166 | case 202: |
| 4167 | #line 2079 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4168 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4169 | yyval.BoolVal = false; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4170 | ;} |
| 4171 | break; |
| 4172 | |
| 4173 | case 203: |
| 4174 | #line 2085 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4175 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4176 | if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() && |
| 4177 | !isa<PackedType>((*yyvsp[-3].TypeVal).get())) |
| 4178 | ThrowException( |
| 4179 | "Arithmetic operator requires integer, FP, or packed operands!"); |
| 4180 | if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem) |
| 4181 | ThrowException("Rem not supported on packed types!"); |
| 4182 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal)); |
| 4183 | if (yyval.InstVal == 0) |
| 4184 | ThrowException("binary operator returned null!"); |
| 4185 | delete yyvsp[-3].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4186 | ;} |
| 4187 | break; |
| 4188 | |
| 4189 | case 204: |
| 4190 | #line 2097 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4191 | { |
Chris Lattner | 15f5a18 | 2005-12-21 18:31:50 +0000 | [diff] [blame] | 4192 | if (!(*yyvsp[-3].TypeVal)->isIntegral()) { |
| 4193 | if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) || |
| 4194 | !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral()) |
| 4195 | ThrowException("Logical operator requires integral operands!"); |
| 4196 | } |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4197 | yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal)); |
| 4198 | if (yyval.InstVal == 0) |
| 4199 | ThrowException("binary operator returned null!"); |
| 4200 | delete yyvsp[-3].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4201 | ;} |
| 4202 | break; |
| 4203 | |
| 4204 | case 205: |
| 4205 | #line 2108 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4206 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4207 | if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) { |
| 4208 | ThrowException( |
| 4209 | "PackedTypes currently not supported in setcc instructions!"); |
| 4210 | } |
| 4211 | yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal), getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal)); |
| 4212 | if (yyval.InstVal == 0) |
| 4213 | ThrowException("binary operator returned null!"); |
| 4214 | delete yyvsp[-3].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4215 | ;} |
| 4216 | break; |
| 4217 | |
| 4218 | case 206: |
| 4219 | #line 2118 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4220 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4221 | std::cerr << "WARNING: Use of eliminated 'not' instruction:" |
| 4222 | << " Replacing with 'xor'.\n"; |
| 4223 | |
| 4224 | Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType()); |
| 4225 | if (Ones == 0) |
| 4226 | ThrowException("Expected integral type for not instruction!"); |
| 4227 | |
| 4228 | yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones); |
| 4229 | if (yyval.InstVal == 0) |
| 4230 | ThrowException("Could not create a xor instruction!"); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4231 | ;} |
| 4232 | break; |
| 4233 | |
| 4234 | case 207: |
| 4235 | #line 2130 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4236 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4237 | if (yyvsp[0].ValueVal->getType() != Type::UByteTy) |
| 4238 | ThrowException("Shift amount must be ubyte!"); |
| 4239 | if (!yyvsp[-2].ValueVal->getType()->isInteger()) |
| 4240 | ThrowException("Shift constant expression requires integer operand!"); |
| 4241 | yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4242 | ;} |
| 4243 | break; |
| 4244 | |
| 4245 | case 208: |
| 4246 | #line 2137 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4247 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4248 | if (!yyvsp[0].TypeVal->get()->isFirstClassType()) |
| 4249 | ThrowException("cast instruction to a non-primitive type: '" + |
| 4250 | yyvsp[0].TypeVal->get()->getDescription() + "'!"); |
| 4251 | yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); |
| 4252 | delete yyvsp[0].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4253 | ;} |
| 4254 | break; |
| 4255 | |
| 4256 | case 209: |
| 4257 | #line 2144 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4258 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4259 | if (yyvsp[-4].ValueVal->getType() != Type::BoolTy) |
| 4260 | ThrowException("select condition must be boolean!"); |
| 4261 | if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType()) |
| 4262 | ThrowException("select value types should match!"); |
| 4263 | yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4264 | ;} |
| 4265 | break; |
| 4266 | |
| 4267 | case 210: |
| 4268 | #line 2151 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4269 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4270 | NewVarArgs = true; |
| 4271 | yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal); |
| 4272 | delete yyvsp[0].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4273 | ;} |
| 4274 | break; |
| 4275 | |
| 4276 | case 211: |
| 4277 | #line 2156 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4278 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4279 | ObsoleteVarArgs = true; |
| 4280 | const Type* ArgTy = yyvsp[-2].ValueVal->getType(); |
| 4281 | Function* NF = CurModule.CurrentModule-> |
Jeff Cohen | 11e26b5 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 4282 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4283 | |
| 4284 | //b = vaarg a, t -> |
| 4285 | //foo = alloca 1 of t |
| 4286 | //bar = vacopy a |
| 4287 | //store bar -> foo |
| 4288 | //b = vaarg foo, t |
| 4289 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); |
| 4290 | CurBB->getInstList().push_back(foo); |
| 4291 | CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal); |
| 4292 | CurBB->getInstList().push_back(bar); |
| 4293 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
| 4294 | yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal); |
| 4295 | delete yyvsp[0].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4296 | ;} |
| 4297 | break; |
| 4298 | |
| 4299 | case 212: |
| 4300 | #line 2175 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4301 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4302 | ObsoleteVarArgs = true; |
| 4303 | const Type* ArgTy = yyvsp[-2].ValueVal->getType(); |
| 4304 | Function* NF = CurModule.CurrentModule-> |
Jeff Cohen | 11e26b5 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 4305 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4306 | |
| 4307 | //b = vanext a, t -> |
| 4308 | //foo = alloca 1 of t |
| 4309 | //bar = vacopy a |
| 4310 | //store bar -> foo |
| 4311 | //tmp = vaarg foo, t |
| 4312 | //b = load foo |
| 4313 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); |
| 4314 | CurBB->getInstList().push_back(foo); |
| 4315 | CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal); |
| 4316 | CurBB->getInstList().push_back(bar); |
| 4317 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
| 4318 | Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal); |
| 4319 | CurBB->getInstList().push_back(tmp); |
| 4320 | yyval.InstVal = new LoadInst(foo); |
| 4321 | delete yyvsp[0].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4322 | ;} |
| 4323 | break; |
| 4324 | |
| 4325 | case 213: |
| 4326 | #line 2197 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4327 | { |
Robert Bocchino | aa1cf54 | 2006-01-10 19:04:32 +0000 | [diff] [blame] | 4328 | if (!isa<PackedType>(yyvsp[-2].ValueVal->getType())) |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 4329 | ThrowException("First operand of extractelement must be " |
| 4330 | "packed type!"); |
Robert Bocchino | aa1cf54 | 2006-01-10 19:04:32 +0000 | [diff] [blame] | 4331 | if (yyvsp[0].ValueVal->getType() != Type::UIntTy) |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 4332 | ThrowException("Second operand of extractelement must be uint!"); |
Robert Bocchino | aa1cf54 | 2006-01-10 19:04:32 +0000 | [diff] [blame] | 4333 | yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4334 | ;} |
| 4335 | break; |
| 4336 | |
| 4337 | case 214: |
| 4338 | #line 2205 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4339 | { |
Robert Bocchino | fdf9e41 | 2006-01-17 20:06:25 +0000 | [diff] [blame] | 4340 | if (!isa<PackedType>(yyvsp[-4].ValueVal->getType())) |
| 4341 | ThrowException("First operand of insertelement must be " |
| 4342 | "packed type!"); |
| 4343 | if (yyvsp[-2].ValueVal->getType() != |
| 4344 | cast<PackedType>(yyvsp[-4].ValueVal->getType())->getElementType()) |
| 4345 | ThrowException("Second operand of insertelement must be " |
| 4346 | "packed element type!"); |
| 4347 | if (yyvsp[0].ValueVal->getType() != Type::UIntTy) |
| 4348 | ThrowException("Third operand of insertelement must be uint!"); |
| 4349 | yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4350 | ;} |
| 4351 | break; |
| 4352 | |
| 4353 | case 215: |
| 4354 | #line 2217 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4355 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4356 | const Type *Ty = yyvsp[0].PHIList->front().first->getType(); |
| 4357 | if (!Ty->isFirstClassType()) |
| 4358 | ThrowException("PHI node operands must be of first class type!"); |
| 4359 | yyval.InstVal = new PHINode(Ty); |
| 4360 | ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size()); |
| 4361 | while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) { |
| 4362 | if (yyvsp[0].PHIList->front().first->getType() != Ty) |
| 4363 | ThrowException("All elements of a PHI node must be of the same type!"); |
| 4364 | cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second); |
| 4365 | yyvsp[0].PHIList->pop_front(); |
| 4366 | } |
| 4367 | delete yyvsp[0].PHIList; // Free the list... |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4368 | ;} |
| 4369 | break; |
| 4370 | |
| 4371 | case 216: |
| 4372 | #line 2231 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4373 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4374 | const PointerType *PFTy; |
| 4375 | const FunctionType *Ty; |
| 4376 | |
| 4377 | if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) || |
| 4378 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4379 | // Pull out the types of all of the arguments... |
| 4380 | std::vector<const Type*> ParamTypes; |
| 4381 | if (yyvsp[-1].ValueList) { |
| 4382 | for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end(); |
| 4383 | I != E; ++I) |
| 4384 | ParamTypes.push_back((*I)->getType()); |
| 4385 | } |
| 4386 | |
| 4387 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 4388 | if (isVarArg) ParamTypes.pop_back(); |
| 4389 | |
| 4390 | if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy) |
| 4391 | ThrowException("LLVM functions cannot return aggregate types!"); |
| 4392 | |
| 4393 | Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg); |
| 4394 | PFTy = PointerType::get(Ty); |
| 4395 | } |
| 4396 | |
| 4397 | Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling... |
| 4398 | |
| 4399 | // Create the call node... |
| 4400 | if (!yyvsp[-1].ValueList) { // Has no arguments? |
| 4401 | // Make sure no arguments is a good thing! |
| 4402 | if (Ty->getNumParams() != 0) |
| 4403 | ThrowException("No arguments passed to a function that " |
| 4404 | "expects arguments!"); |
| 4405 | |
| 4406 | yyval.InstVal = new CallInst(V, std::vector<Value*>()); |
| 4407 | } else { // Has arguments? |
| 4408 | // Loop through FunctionType's arguments and ensure they are specified |
| 4409 | // correctly! |
| 4410 | // |
| 4411 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4412 | FunctionType::param_iterator E = Ty->param_end(); |
| 4413 | std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end(); |
| 4414 | |
| 4415 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 4416 | if ((*ArgI)->getType() != *I) |
| 4417 | ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" + |
| 4418 | (*I)->getDescription() + "'!"); |
| 4419 | |
| 4420 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
| 4421 | ThrowException("Invalid number of parameters detected!"); |
| 4422 | |
| 4423 | yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList); |
| 4424 | } |
| 4425 | cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal); |
| 4426 | cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal); |
| 4427 | delete yyvsp[-4].TypeVal; |
| 4428 | delete yyvsp[-1].ValueList; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4429 | ;} |
| 4430 | break; |
| 4431 | |
| 4432 | case 217: |
| 4433 | #line 2288 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4434 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4435 | yyval.InstVal = yyvsp[0].InstVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4436 | ;} |
| 4437 | break; |
| 4438 | |
| 4439 | case 218: |
| 4440 | #line 2294 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4441 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4442 | yyval.ValueList = yyvsp[0].ValueList; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4443 | ;} |
| 4444 | break; |
| 4445 | |
| 4446 | case 219: |
| 4447 | #line 2296 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4448 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4449 | yyval.ValueList = new std::vector<Value*>(); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4450 | ;} |
| 4451 | break; |
| 4452 | |
| 4453 | case 220: |
| 4454 | #line 2300 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4455 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4456 | yyval.BoolVal = true; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4457 | ;} |
| 4458 | break; |
| 4459 | |
| 4460 | case 221: |
| 4461 | #line 2303 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4462 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4463 | yyval.BoolVal = false; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4464 | ;} |
| 4465 | break; |
| 4466 | |
| 4467 | case 222: |
| 4468 | #line 2309 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4469 | { |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 4470 | yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4471 | delete yyvsp[-1].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4472 | ;} |
| 4473 | break; |
| 4474 | |
| 4475 | case 223: |
| 4476 | #line 2313 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4477 | { |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 4478 | yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); |
| 4479 | delete yyvsp[-4].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4480 | ;} |
| 4481 | break; |
| 4482 | |
| 4483 | case 224: |
| 4484 | #line 2317 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4485 | { |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 4486 | yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal); |
| 4487 | delete yyvsp[-1].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4488 | ;} |
| 4489 | break; |
| 4490 | |
| 4491 | case 225: |
| 4492 | #line 2321 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4493 | { |
Chris Lattner | 86c352b | 2005-11-06 06:34:34 +0000 | [diff] [blame] | 4494 | yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal), yyvsp[0].UIntVal); |
| 4495 | delete yyvsp[-4].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4496 | ;} |
| 4497 | break; |
| 4498 | |
| 4499 | case 226: |
| 4500 | #line 2325 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4501 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4502 | if (!isa<PointerType>(yyvsp[0].ValueVal->getType())) |
| 4503 | ThrowException("Trying to free nonpointer type " + |
| 4504 | yyvsp[0].ValueVal->getType()->getDescription() + "!"); |
| 4505 | yyval.InstVal = new FreeInst(yyvsp[0].ValueVal); |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4506 | ;} |
| 4507 | break; |
| 4508 | |
| 4509 | case 227: |
| 4510 | #line 2332 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4511 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4512 | if (!isa<PointerType>(yyvsp[-1].TypeVal->get())) |
| 4513 | ThrowException("Can't load from nonpointer type: " + |
| 4514 | (*yyvsp[-1].TypeVal)->getDescription()); |
| 4515 | if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType()) |
| 4516 | ThrowException("Can't load from pointer of non-first-class type: " + |
| 4517 | (*yyvsp[-1].TypeVal)->getDescription()); |
| 4518 | yyval.InstVal = new LoadInst(getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), "", yyvsp[-3].BoolVal); |
| 4519 | delete yyvsp[-1].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4520 | ;} |
| 4521 | break; |
| 4522 | |
| 4523 | case 228: |
| 4524 | #line 2342 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4525 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4526 | const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get()); |
| 4527 | if (!PT) |
| 4528 | ThrowException("Can't store to a nonpointer type: " + |
| 4529 | (*yyvsp[-1].TypeVal)->getDescription()); |
| 4530 | const Type *ElTy = PT->getElementType(); |
| 4531 | if (ElTy != yyvsp[-3].ValueVal->getType()) |
| 4532 | ThrowException("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() + |
| 4533 | "' into space of type '" + ElTy->getDescription() + "'!"); |
| 4534 | |
| 4535 | yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal), yyvsp[-5].BoolVal); |
| 4536 | delete yyvsp[-1].TypeVal; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4537 | ;} |
| 4538 | break; |
| 4539 | |
| 4540 | case 229: |
| 4541 | #line 2355 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
| 4542 | { |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4543 | if (!isa<PointerType>(yyvsp[-2].TypeVal->get())) |
| 4544 | ThrowException("getelementptr insn requires pointer operand!"); |
| 4545 | |
| 4546 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct |
| 4547 | // indices to uint struct indices for compatibility. |
| 4548 | generic_gep_type_iterator<std::vector<Value*>::iterator> |
| 4549 | GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()), |
| 4550 | GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()); |
| 4551 | for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI) |
| 4552 | if (isa<StructType>(*GTI)) // Only change struct indices |
| 4553 | if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i])) |
| 4554 | if (CUI->getType() == Type::UByteTy) |
| 4555 | (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy); |
| 4556 | |
| 4557 | if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true)) |
| 4558 | ThrowException("Invalid getelementptr indices for type '" + |
| 4559 | (*yyvsp[-2].TypeVal)->getDescription()+ "'!"); |
| 4560 | yyval.InstVal = new GetElementPtrInst(getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal), *yyvsp[0].ValueList); |
| 4561 | delete yyvsp[-2].TypeVal; delete yyvsp[0].ValueList; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4562 | ;} |
| 4563 | break; |
| 4564 | |
| 4565 | |
| 4566 | } |
| 4567 | |
| 4568 | /* Line 1000 of yacc.c. */ |
| 4569 | #line 4570 "llvmAsmParser.tab.c" |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4570 | |
| 4571 | yyvsp -= yylen; |
| 4572 | yyssp -= yylen; |
| 4573 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4574 | |
| 4575 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4576 | |
| 4577 | *++yyvsp = yyval; |
| 4578 | |
| 4579 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4580 | /* Now `shift' the result of the reduction. Determine what state |
| 4581 | that goes to, based on the state we popped back to and the rule |
| 4582 | number reduced by. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4583 | |
| 4584 | yyn = yyr1[yyn]; |
| 4585 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4586 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 4587 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4588 | yystate = yytable[yystate]; |
| 4589 | else |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4590 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4591 | |
| 4592 | goto yynewstate; |
| 4593 | |
| 4594 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4595 | /*------------------------------------. |
| 4596 | | yyerrlab -- here on detecting error | |
| 4597 | `------------------------------------*/ |
| 4598 | yyerrlab: |
| 4599 | /* If not already recovering from an error, report this error. */ |
| 4600 | if (!yyerrstatus) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4601 | { |
| 4602 | ++yynerrs; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4603 | #if YYERROR_VERBOSE |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4604 | yyn = yypact[yystate]; |
| 4605 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4606 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4607 | { |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4608 | YYSIZE_T yysize = 0; |
| 4609 | int yytype = YYTRANSLATE (yychar); |
| 4610 | const char* yyprefix; |
| 4611 | char *yymsg; |
| 4612 | int yyx; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4613 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4614 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 4615 | YYCHECK. */ |
| 4616 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 4617 | |
| 4618 | /* Stay within bounds of both yycheck and yytname. */ |
| 4619 | int yychecklim = YYLAST - yyn; |
| 4620 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 4621 | int yycount = 0; |
| 4622 | |
| 4623 | yyprefix = ", expecting "; |
| 4624 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 4625 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 4626 | { |
| 4627 | yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); |
| 4628 | yycount += 1; |
| 4629 | if (yycount == 5) |
| 4630 | { |
| 4631 | yysize = 0; |
| 4632 | break; |
| 4633 | } |
| 4634 | } |
| 4635 | yysize += (sizeof ("syntax error, unexpected ") |
| 4636 | + yystrlen (yytname[yytype])); |
| 4637 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
| 4638 | if (yymsg != 0) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4639 | { |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4640 | char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); |
| 4641 | yyp = yystpcpy (yyp, yytname[yytype]); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4642 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4643 | if (yycount < 5) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4644 | { |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4645 | yyprefix = ", expecting "; |
| 4646 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 4647 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4648 | { |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4649 | yyp = yystpcpy (yyp, yyprefix); |
| 4650 | yyp = yystpcpy (yyp, yytname[yyx]); |
| 4651 | yyprefix = " or "; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4652 | } |
| 4653 | } |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4654 | yyerror (yymsg); |
| 4655 | YYSTACK_FREE (yymsg); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4656 | } |
| 4657 | else |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4658 | yyerror ("syntax error; also virtual memory exhausted"); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4659 | } |
| 4660 | else |
| 4661 | #endif /* YYERROR_VERBOSE */ |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4662 | yyerror ("syntax error"); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4663 | } |
| 4664 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4665 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4666 | |
| 4667 | if (yyerrstatus == 3) |
| 4668 | { |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4669 | /* If just tried and failed to reuse lookahead token after an |
| 4670 | error, discard it. */ |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4671 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4672 | if (yychar <= YYEOF) |
| 4673 | { |
| 4674 | /* If at end of input, pop the error token, |
| 4675 | then the rest of the stack, then return failure. */ |
| 4676 | if (yychar == YYEOF) |
| 4677 | for (;;) |
| 4678 | { |
| 4679 | YYPOPSTACK; |
| 4680 | if (yyssp == yyss) |
| 4681 | YYABORT; |
| 4682 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); |
| 4683 | yydestruct (yystos[*yyssp], yyvsp); |
| 4684 | } |
| 4685 | } |
| 4686 | else |
| 4687 | { |
| 4688 | YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); |
| 4689 | yydestruct (yytoken, &yylval); |
| 4690 | yychar = YYEMPTY; |
| 4691 | |
| 4692 | } |
| 4693 | } |
| 4694 | |
| 4695 | /* Else will try to reuse lookahead token after shifting the error |
| 4696 | token. */ |
| 4697 | goto yyerrlab1; |
| 4698 | |
| 4699 | |
| 4700 | /*---------------------------------------------------. |
| 4701 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 4702 | `---------------------------------------------------*/ |
| 4703 | yyerrorlab: |
| 4704 | |
| 4705 | #ifdef __GNUC__ |
| 4706 | /* Pacify GCC when the user code never invokes YYERROR and the label |
| 4707 | yyerrorlab therefore never appears in user code. */ |
| 4708 | if (0) |
| 4709 | goto yyerrorlab; |
| 4710 | #endif |
| 4711 | |
| 4712 | yyvsp -= yylen; |
| 4713 | yyssp -= yylen; |
| 4714 | yystate = *yyssp; |
| 4715 | goto yyerrlab1; |
| 4716 | |
| 4717 | |
| 4718 | /*-------------------------------------------------------------. |
| 4719 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 4720 | `-------------------------------------------------------------*/ |
| 4721 | yyerrlab1: |
| 4722 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 4723 | |
| 4724 | for (;;) |
| 4725 | { |
| 4726 | yyn = yypact[yystate]; |
| 4727 | if (yyn != YYPACT_NINF) |
| 4728 | { |
| 4729 | yyn += YYTERROR; |
| 4730 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 4731 | { |
| 4732 | yyn = yytable[yyn]; |
| 4733 | if (0 < yyn) |
| 4734 | break; |
| 4735 | } |
| 4736 | } |
| 4737 | |
| 4738 | /* Pop the current state because it cannot handle the error token. */ |
| 4739 | if (yyssp == yyss) |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4740 | YYABORT; |
| 4741 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4742 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); |
| 4743 | yydestruct (yystos[yystate], yyvsp); |
| 4744 | YYPOPSTACK; |
| 4745 | yystate = *yyssp; |
| 4746 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4747 | } |
| 4748 | |
| 4749 | if (yyn == YYFINAL) |
| 4750 | YYACCEPT; |
| 4751 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4752 | YYDPRINTF ((stderr, "Shifting error token, ")); |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4753 | |
| 4754 | *++yyvsp = yylval; |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4755 | |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4756 | |
| 4757 | yystate = yyn; |
| 4758 | goto yynewstate; |
| 4759 | |
Reid Spencer | b4f9a6f | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 4760 | |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4761 | /*-------------------------------------. |
| 4762 | | yyacceptlab -- YYACCEPT comes here. | |
| 4763 | `-------------------------------------*/ |
| 4764 | yyacceptlab: |
| 4765 | yyresult = 0; |
| 4766 | goto yyreturn; |
| 4767 | |
| 4768 | /*-----------------------------------. |
| 4769 | | yyabortlab -- YYABORT comes here. | |
| 4770 | `-----------------------------------*/ |
| 4771 | yyabortlab: |
| 4772 | yyresult = 1; |
| 4773 | goto yyreturn; |
| 4774 | |
| 4775 | #ifndef yyoverflow |
| 4776 | /*----------------------------------------------. |
| 4777 | | yyoverflowlab -- parser overflow comes here. | |
| 4778 | `----------------------------------------------*/ |
| 4779 | yyoverflowlab: |
| 4780 | yyerror ("parser stack overflow"); |
| 4781 | yyresult = 2; |
| 4782 | /* Fall through. */ |
Reid Spencer | b4f9a6f | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 4783 | #endif |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4784 | |
| 4785 | yyreturn: |
| 4786 | #ifndef yyoverflow |
| 4787 | if (yyss != yyssa) |
| 4788 | YYSTACK_FREE (yyss); |
| 4789 | #endif |
| 4790 | return yyresult; |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4791 | } |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4792 | |
| 4793 | |
| 4794 | #line 2378 "/proj/llvm/llvm2/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | dfb3fb4 | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4795 | |
| 4796 | int yyerror(const char *ErrorMsg) { |
| 4797 | std::string where |
| 4798 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 4799 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
| 4800 | std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading "; |
| 4801 | if (yychar == YYEMPTY || yychar == 0) |
| 4802 | errMsg += "end-of-file."; |
| 4803 | else |
| 4804 | errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'"; |
| 4805 | ThrowException(errMsg); |
| 4806 | return 0; |
| 4807 | } |
Reid Spencer | c8a9faf | 2006-01-19 01:21:04 +0000 | [diff] [blame^] | 4808 | |