Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1 | /* A Bison parser, made by GNU Bison 2.1. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3 | /* Skeleton parser for Yacc-like parsing with Bison, |
| 4 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +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. |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 10 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +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., 51 Franklin Street, Fifth Floor, |
| 19 | Boston, MA 02110-1301, 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 | /* Bison version. */ |
| 40 | #define YYBISON_VERSION "2.1" |
| 41 | |
| 42 | /* Skeleton name. */ |
| 43 | #define YYSKELETON_NAME "yacc.c" |
| 44 | |
| 45 | /* Pure parsers. */ |
| 46 | #define YYPURE 0 |
| 47 | |
| 48 | /* Using locations. */ |
| 49 | #define YYLSP_NEEDED 0 |
| 50 | |
| 51 | /* Substitute the variable and function names. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 52 | #define yyparse llvmAsmparse |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 53 | #define yylex llvmAsmlex |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 54 | #define yyerror llvmAsmerror |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 55 | #define yylval llvmAsmlval |
| 56 | #define yychar llvmAsmchar |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 57 | #define yydebug llvmAsmdebug |
| 58 | #define yynerrs llvmAsmnerrs |
| 59 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 60 | |
| 61 | /* Tokens. */ |
| 62 | #ifndef YYTOKENTYPE |
| 63 | # define YYTOKENTYPE |
| 64 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
| 65 | know about them. */ |
| 66 | enum yytokentype { |
| 67 | ESINT64VAL = 258, |
| 68 | EUINT64VAL = 259, |
| 69 | SINTVAL = 260, |
| 70 | UINTVAL = 261, |
| 71 | FPVAL = 262, |
| 72 | VOID = 263, |
| 73 | BOOL = 264, |
| 74 | SBYTE = 265, |
| 75 | UBYTE = 266, |
| 76 | SHORT = 267, |
| 77 | USHORT = 268, |
| 78 | INT = 269, |
| 79 | UINT = 270, |
| 80 | LONG = 271, |
| 81 | ULONG = 272, |
| 82 | FLOAT = 273, |
| 83 | DOUBLE = 274, |
| 84 | TYPE = 275, |
| 85 | LABEL = 276, |
| 86 | VAR_ID = 277, |
| 87 | LABELSTR = 278, |
| 88 | STRINGCONSTANT = 279, |
| 89 | IMPLEMENTATION = 280, |
| 90 | ZEROINITIALIZER = 281, |
| 91 | TRUETOK = 282, |
| 92 | FALSETOK = 283, |
| 93 | BEGINTOK = 284, |
| 94 | ENDTOK = 285, |
| 95 | DECLARE = 286, |
| 96 | GLOBAL = 287, |
| 97 | CONSTANT = 288, |
| 98 | SECTION = 289, |
| 99 | VOLATILE = 290, |
| 100 | TO = 291, |
| 101 | DOTDOTDOT = 292, |
| 102 | NULL_TOK = 293, |
| 103 | UNDEF = 294, |
| 104 | CONST = 295, |
| 105 | INTERNAL = 296, |
| 106 | LINKONCE = 297, |
| 107 | WEAK = 298, |
| 108 | APPENDING = 299, |
| 109 | DLLIMPORT = 300, |
| 110 | DLLEXPORT = 301, |
| 111 | EXTERN_WEAK = 302, |
| 112 | OPAQUE = 303, |
| 113 | NOT = 304, |
| 114 | EXTERNAL = 305, |
| 115 | TARGET = 306, |
| 116 | TRIPLE = 307, |
| 117 | ENDIAN = 308, |
| 118 | POINTERSIZE = 309, |
| 119 | LITTLE = 310, |
| 120 | BIG = 311, |
| 121 | ALIGN = 312, |
| 122 | DEPLIBS = 313, |
| 123 | CALL = 314, |
| 124 | TAIL = 315, |
| 125 | ASM_TOK = 316, |
| 126 | MODULE = 317, |
| 127 | SIDEEFFECT = 318, |
| 128 | CC_TOK = 319, |
| 129 | CCC_TOK = 320, |
| 130 | CSRETCC_TOK = 321, |
| 131 | FASTCC_TOK = 322, |
| 132 | COLDCC_TOK = 323, |
| 133 | X86_STDCALLCC_TOK = 324, |
| 134 | X86_FASTCALLCC_TOK = 325, |
| 135 | DATALAYOUT = 326, |
| 136 | RET = 327, |
| 137 | BR = 328, |
| 138 | SWITCH = 329, |
| 139 | INVOKE = 330, |
| 140 | UNWIND = 331, |
| 141 | UNREACHABLE = 332, |
| 142 | ADD = 333, |
| 143 | SUB = 334, |
| 144 | MUL = 335, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 145 | UDIV = 336, |
| 146 | SDIV = 337, |
| 147 | FDIV = 338, |
| 148 | REM = 339, |
| 149 | AND = 340, |
| 150 | OR = 341, |
| 151 | XOR = 342, |
| 152 | SETLE = 343, |
| 153 | SETGE = 344, |
| 154 | SETLT = 345, |
| 155 | SETGT = 346, |
| 156 | SETEQ = 347, |
| 157 | SETNE = 348, |
| 158 | MALLOC = 349, |
| 159 | ALLOCA = 350, |
| 160 | FREE = 351, |
| 161 | LOAD = 352, |
| 162 | STORE = 353, |
| 163 | GETELEMENTPTR = 354, |
| 164 | PHI_TOK = 355, |
| 165 | CAST = 356, |
| 166 | SELECT = 357, |
| 167 | SHL = 358, |
| 168 | SHR = 359, |
| 169 | VAARG = 360, |
| 170 | EXTRACTELEMENT = 361, |
| 171 | INSERTELEMENT = 362, |
| 172 | SHUFFLEVECTOR = 363, |
| 173 | VAARG_old = 364, |
| 174 | VANEXT_old = 365 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 175 | }; |
| 176 | #endif |
| 177 | /* Tokens. */ |
| 178 | #define ESINT64VAL 258 |
| 179 | #define EUINT64VAL 259 |
| 180 | #define SINTVAL 260 |
| 181 | #define UINTVAL 261 |
| 182 | #define FPVAL 262 |
| 183 | #define VOID 263 |
| 184 | #define BOOL 264 |
| 185 | #define SBYTE 265 |
| 186 | #define UBYTE 266 |
| 187 | #define SHORT 267 |
| 188 | #define USHORT 268 |
| 189 | #define INT 269 |
| 190 | #define UINT 270 |
| 191 | #define LONG 271 |
| 192 | #define ULONG 272 |
| 193 | #define FLOAT 273 |
| 194 | #define DOUBLE 274 |
| 195 | #define TYPE 275 |
| 196 | #define LABEL 276 |
| 197 | #define VAR_ID 277 |
| 198 | #define LABELSTR 278 |
| 199 | #define STRINGCONSTANT 279 |
| 200 | #define IMPLEMENTATION 280 |
| 201 | #define ZEROINITIALIZER 281 |
| 202 | #define TRUETOK 282 |
| 203 | #define FALSETOK 283 |
| 204 | #define BEGINTOK 284 |
| 205 | #define ENDTOK 285 |
| 206 | #define DECLARE 286 |
| 207 | #define GLOBAL 287 |
| 208 | #define CONSTANT 288 |
| 209 | #define SECTION 289 |
| 210 | #define VOLATILE 290 |
| 211 | #define TO 291 |
| 212 | #define DOTDOTDOT 292 |
| 213 | #define NULL_TOK 293 |
| 214 | #define UNDEF 294 |
| 215 | #define CONST 295 |
| 216 | #define INTERNAL 296 |
| 217 | #define LINKONCE 297 |
| 218 | #define WEAK 298 |
| 219 | #define APPENDING 299 |
| 220 | #define DLLIMPORT 300 |
| 221 | #define DLLEXPORT 301 |
| 222 | #define EXTERN_WEAK 302 |
| 223 | #define OPAQUE 303 |
| 224 | #define NOT 304 |
| 225 | #define EXTERNAL 305 |
| 226 | #define TARGET 306 |
| 227 | #define TRIPLE 307 |
| 228 | #define ENDIAN 308 |
| 229 | #define POINTERSIZE 309 |
| 230 | #define LITTLE 310 |
| 231 | #define BIG 311 |
| 232 | #define ALIGN 312 |
| 233 | #define DEPLIBS 313 |
| 234 | #define CALL 314 |
| 235 | #define TAIL 315 |
| 236 | #define ASM_TOK 316 |
| 237 | #define MODULE 317 |
| 238 | #define SIDEEFFECT 318 |
| 239 | #define CC_TOK 319 |
| 240 | #define CCC_TOK 320 |
| 241 | #define CSRETCC_TOK 321 |
| 242 | #define FASTCC_TOK 322 |
| 243 | #define COLDCC_TOK 323 |
| 244 | #define X86_STDCALLCC_TOK 324 |
| 245 | #define X86_FASTCALLCC_TOK 325 |
| 246 | #define DATALAYOUT 326 |
| 247 | #define RET 327 |
| 248 | #define BR 328 |
| 249 | #define SWITCH 329 |
| 250 | #define INVOKE 330 |
| 251 | #define UNWIND 331 |
| 252 | #define UNREACHABLE 332 |
| 253 | #define ADD 333 |
| 254 | #define SUB 334 |
| 255 | #define MUL 335 |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 256 | #define UDIV 336 |
| 257 | #define SDIV 337 |
| 258 | #define FDIV 338 |
| 259 | #define REM 339 |
| 260 | #define AND 340 |
| 261 | #define OR 341 |
| 262 | #define XOR 342 |
| 263 | #define SETLE 343 |
| 264 | #define SETGE 344 |
| 265 | #define SETLT 345 |
| 266 | #define SETGT 346 |
| 267 | #define SETEQ 347 |
| 268 | #define SETNE 348 |
| 269 | #define MALLOC 349 |
| 270 | #define ALLOCA 350 |
| 271 | #define FREE 351 |
| 272 | #define LOAD 352 |
| 273 | #define STORE 353 |
| 274 | #define GETELEMENTPTR 354 |
| 275 | #define PHI_TOK 355 |
| 276 | #define CAST 356 |
| 277 | #define SELECT 357 |
| 278 | #define SHL 358 |
| 279 | #define SHR 359 |
| 280 | #define VAARG 360 |
| 281 | #define EXTRACTELEMENT 361 |
| 282 | #define INSERTELEMENT 362 |
| 283 | #define SHUFFLEVECTOR 363 |
| 284 | #define VAARG_old 364 |
| 285 | #define VANEXT_old 365 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | /* Copy the first part of user declarations. */ |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 291 | #line 14 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 292 | |
| 293 | #include "ParserInternals.h" |
| 294 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 295 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 296 | #include "llvm/Instructions.h" |
| 297 | #include "llvm/Module.h" |
| 298 | #include "llvm/SymbolTable.h" |
Reid Spencer | 0b11820 | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 299 | #include "llvm/Assembly/AutoUpgrade.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 300 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
| 301 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 302 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 303 | #include <algorithm> |
| 304 | #include <iostream> |
| 305 | #include <list> |
| 306 | #include <utility> |
| 307 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 308 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 309 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 310 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 311 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 312 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 313 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 314 | // GenerateError are made from inside productions and they must simulate the |
| 315 | // previous exception behavior by exiting the production immediately. We have |
| 316 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 317 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 318 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 319 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 320 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 321 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 322 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 323 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 324 | int yylex(); // declaration" of xxx warnings. |
| 325 | int yyparse(); |
| 326 | |
| 327 | namespace llvm { |
| 328 | std::string CurFilename; |
| 329 | } |
| 330 | using namespace llvm; |
| 331 | |
| 332 | static Module *ParserResult; |
| 333 | |
| 334 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 335 | // relating to upreferences in the input stream. |
| 336 | // |
| 337 | //#define DEBUG_UPREFS 1 |
| 338 | #ifdef DEBUG_UPREFS |
| 339 | #define UR_OUT(X) std::cerr << X |
| 340 | #else |
| 341 | #define UR_OUT(X) |
| 342 | #endif |
| 343 | |
| 344 | #define YYERROR_VERBOSE 1 |
| 345 | |
| 346 | static bool ObsoleteVarArgs; |
| 347 | static bool NewVarArgs; |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 348 | static BasicBlock *CurBB; |
| 349 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 350 | |
| 351 | |
| 352 | // This contains info used when building the body of a function. It is |
| 353 | // destroyed when the function is completed. |
| 354 | // |
| 355 | typedef std::vector<Value *> ValueList; // Numbered defs |
| 356 | static void |
| 357 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 358 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 359 | |
| 360 | static struct PerModuleInfo { |
| 361 | Module *CurrentModule; |
| 362 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 363 | std::map<const Type *,ValueList> LateResolveValues; |
| 364 | std::vector<PATypeHolder> Types; |
| 365 | std::map<ValID, PATypeHolder> LateResolveTypes; |
| 366 | |
| 367 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 368 | /// how they were referenced and on which line of the input they came from so |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 369 | /// that we can resolve them later and print error messages as appropriate. |
| 370 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 371 | |
| 372 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 373 | // references to global values. Global values may be referenced before they |
| 374 | // are defined, and if so, the temporary object that they represent is held |
| 375 | // here. This is used for forward references of GlobalValues. |
| 376 | // |
| 377 | typedef std::map<std::pair<const PointerType *, |
| 378 | ValID>, GlobalValue*> GlobalRefsType; |
| 379 | GlobalRefsType GlobalRefs; |
| 380 | |
| 381 | void ModuleDone() { |
| 382 | // If we could not resolve some functions at function compilation time |
| 383 | // (calls to functions before they are defined), resolve them now... Types |
| 384 | // are resolved when the constant pool has been completely parsed. |
| 385 | // |
| 386 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 387 | if (TriggerError) |
| 388 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 389 | |
| 390 | // Check to make sure that all global value forward references have been |
| 391 | // resolved! |
| 392 | // |
| 393 | if (!GlobalRefs.empty()) { |
| 394 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 395 | |
| 396 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 397 | I != E; ++I) { |
| 398 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 399 | I->first.second.getName() + "\n"; |
| 400 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 401 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 402 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 403 | } |
| 404 | |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 405 | // Look for intrinsic functions and CallInst that need to be upgraded |
Chris Lattner | d5efe84 | 2006-04-08 01:18:56 +0000 | [diff] [blame] | 406 | for (Module::iterator FI = CurrentModule->begin(), |
| 407 | FE = CurrentModule->end(); FI != FE; ) |
Chris Lattner | c2c6038 | 2006-03-04 07:53:41 +0000 | [diff] [blame] | 408 | UpgradeCallsToIntrinsic(FI++); |
Reid Spencer | 0b11820 | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 409 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 410 | Values.clear(); // Clear out function local definitions |
| 411 | Types.clear(); |
| 412 | CurrentModule = 0; |
| 413 | } |
| 414 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 415 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 416 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 417 | // If not, just return null. |
| 418 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 419 | // Check to see if there is a forward reference to this global variable... |
| 420 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 421 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 422 | GlobalValue *Ret = 0; |
| 423 | if (I != GlobalRefs.end()) { |
| 424 | Ret = I->second; |
| 425 | GlobalRefs.erase(I); |
| 426 | } |
| 427 | return Ret; |
| 428 | } |
| 429 | } CurModule; |
| 430 | |
| 431 | static struct PerFunctionInfo { |
| 432 | Function *CurrentFunction; // Pointer to current function being created |
| 433 | |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 434 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 435 | std::map<const Type*, ValueList> LateResolveValues; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 436 | bool isDeclare; // Is this function a forward declararation? |
| 437 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 438 | |
| 439 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 440 | /// track of them here. |
| 441 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 442 | std::vector<BasicBlock*> NumberedBlocks; |
| 443 | unsigned NextBBNum; |
| 444 | |
| 445 | inline PerFunctionInfo() { |
| 446 | CurrentFunction = 0; |
| 447 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 448 | Linkage = GlobalValue::ExternalLinkage; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | inline void FunctionStart(Function *M) { |
| 452 | CurrentFunction = M; |
| 453 | NextBBNum = 0; |
| 454 | } |
| 455 | |
| 456 | void FunctionDone() { |
| 457 | NumberedBlocks.clear(); |
| 458 | |
| 459 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 460 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 461 | GenerateError("Undefined reference to label " + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 462 | BBForwardRefs.begin()->first->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 463 | return; |
| 464 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 465 | |
| 466 | // Resolve all forward references now. |
| 467 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 468 | |
| 469 | Values.clear(); // Clear out function local definitions |
| 470 | CurrentFunction = 0; |
| 471 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 472 | Linkage = GlobalValue::ExternalLinkage; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 473 | } |
| 474 | } CurFun; // Info for the current function... |
| 475 | |
| 476 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 477 | |
| 478 | |
| 479 | //===----------------------------------------------------------------------===// |
| 480 | // Code to handle definitions of all the types |
| 481 | //===----------------------------------------------------------------------===// |
| 482 | |
| 483 | static int InsertValue(Value *V, |
| 484 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 485 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 486 | |
| 487 | // Yes, insert the value into the value table... |
| 488 | ValueList &List = ValueTab[V->getType()]; |
| 489 | List.push_back(V); |
| 490 | return List.size()-1; |
| 491 | } |
| 492 | |
| 493 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 494 | switch (D.Type) { |
| 495 | case ValID::NumberVal: // Is it a numbered definition? |
| 496 | // Module constants occupy the lowest numbered slots... |
| 497 | if ((unsigned)D.Num < CurModule.Types.size()) |
| 498 | return CurModule.Types[(unsigned)D.Num]; |
| 499 | break; |
| 500 | case ValID::NameVal: // Is it a named definition? |
| 501 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 502 | D.destroy(); // Free old strdup'd memory... |
| 503 | return N; |
| 504 | } |
| 505 | break; |
| 506 | default: |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 507 | GenerateError("Internal parser error: Invalid symbol type reference!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 508 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | // If we reached here, we referenced either a symbol that we don't know about |
| 512 | // or an id number that hasn't been read yet. We may be referencing something |
| 513 | // forward, so just create an entry to be resolved later and get to it... |
| 514 | // |
| 515 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 516 | |
| 517 | |
| 518 | if (inFunctionScope()) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 519 | if (D.Type == ValID::NameVal) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 520 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 521 | return 0; |
| 522 | } else { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 523 | GenerateError("Reference to an undefined type: #" + itostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 524 | return 0; |
| 525 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
| 529 | if (I != CurModule.LateResolveTypes.end()) |
| 530 | return I->second; |
| 531 | |
| 532 | Type *Typ = OpaqueType::get(); |
| 533 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 534 | return Typ; |
| 535 | } |
| 536 | |
| 537 | static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) { |
| 538 | SymbolTable &SymTab = |
| 539 | inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() : |
| 540 | CurModule.CurrentModule->getSymbolTable(); |
| 541 | return SymTab.lookup(Ty, Name); |
| 542 | } |
| 543 | |
| 544 | // getValNonImprovising - Look up the value specified by the provided type and |
| 545 | // the provided ValID. If the value exists and has already been defined, return |
| 546 | // it. Otherwise return null. |
| 547 | // |
| 548 | static Value *getValNonImprovising(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 549 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 550 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 551 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 552 | return 0; |
| 553 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 554 | |
| 555 | switch (D.Type) { |
| 556 | case ValID::NumberVal: { // Is it a numbered definition? |
| 557 | unsigned Num = (unsigned)D.Num; |
| 558 | |
| 559 | // Module constants occupy the lowest numbered slots... |
| 560 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
| 561 | if (VI != CurModule.Values.end()) { |
| 562 | if (Num < VI->second.size()) |
| 563 | return VI->second[Num]; |
| 564 | Num -= VI->second.size(); |
| 565 | } |
| 566 | |
| 567 | // Make sure that our type is within bounds |
| 568 | VI = CurFun.Values.find(Ty); |
| 569 | if (VI == CurFun.Values.end()) return 0; |
| 570 | |
| 571 | // Check that the number is within bounds... |
| 572 | if (VI->second.size() <= Num) return 0; |
| 573 | |
| 574 | return VI->second[Num]; |
| 575 | } |
| 576 | |
| 577 | case ValID::NameVal: { // Is it a named definition? |
| 578 | Value *N = lookupInSymbolTable(Ty, std::string(D.Name)); |
| 579 | if (N == 0) return 0; |
| 580 | |
| 581 | D.destroy(); // Free old strdup'd memory... |
| 582 | return N; |
| 583 | } |
| 584 | |
| 585 | // Check to make sure that "Ty" is an integral type, and that our |
| 586 | // value will fit into the specified type... |
| 587 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 588 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 589 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 590 | itostr(D.ConstPool64) + "' is invalid for type '" + |
| 591 | Ty->getDescription() + "'!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 592 | return 0; |
| 593 | } |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 594 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 595 | |
| 596 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 597 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 598 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 599 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 600 | "' is invalid or out of range!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 601 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 602 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 603 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 604 | } |
| 605 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 606 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 610 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 611 | GenerateError("FP constant invalid for type!!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 612 | return 0; |
| 613 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 614 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 615 | |
| 616 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 617 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 618 | GenerateError("Cannot create a a non pointer null!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 619 | return 0; |
| 620 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 621 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 622 | |
| 623 | case ValID::ConstUndefVal: // Is it an undef value? |
| 624 | return UndefValue::get(Ty); |
| 625 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 626 | case ValID::ConstZeroVal: // Is it a zero value? |
| 627 | return Constant::getNullValue(Ty); |
| 628 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 629 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 630 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 631 | GenerateError("Constant expression type different from required type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 632 | return 0; |
| 633 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 634 | return D.ConstantValue; |
| 635 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 636 | case ValID::InlineAsmVal: { // Inline asm expression |
| 637 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 638 | const FunctionType *FTy = |
| 639 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 640 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 641 | GenerateError("Invalid type for asm constraint string!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 642 | return 0; |
| 643 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 644 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 645 | D.IAD->HasSideEffects); |
| 646 | D.destroy(); // Free InlineAsmDescriptor. |
| 647 | return IA; |
| 648 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 649 | default: |
| 650 | assert(0 && "Unhandled case!"); |
| 651 | return 0; |
| 652 | } // End of switch |
| 653 | |
| 654 | assert(0 && "Unhandled case!"); |
| 655 | return 0; |
| 656 | } |
| 657 | |
| 658 | // getVal - This function is identical to getValNonImprovising, except that if a |
| 659 | // value is not already defined, it "improvises" by creating a placeholder var |
| 660 | // that looks and acts just like the requested variable. When the value is |
| 661 | // defined later, all uses of the placeholder variable are replaced with the |
| 662 | // real thing. |
| 663 | // |
| 664 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 665 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 666 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 667 | return 0; |
| 668 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 669 | |
| 670 | // See if the value has already been defined. |
| 671 | Value *V = getValNonImprovising(Ty, ID); |
| 672 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 673 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 674 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 675 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 676 | GenerateError("Invalid use of a composite type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 677 | return 0; |
| 678 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 679 | |
| 680 | // If we reached here, we referenced either a symbol that we don't know about |
| 681 | // or an id number that hasn't been read yet. We may be referencing something |
| 682 | // forward, so just create an entry to be resolved later and get to it... |
| 683 | // |
| 684 | V = new Argument(Ty); |
| 685 | |
| 686 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 687 | // to recycle these things?? |
| 688 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 689 | llvmAsmlineno))); |
| 690 | |
| 691 | if (inFunctionScope()) |
| 692 | InsertValue(V, CurFun.LateResolveValues); |
| 693 | else |
| 694 | InsertValue(V, CurModule.LateResolveValues); |
| 695 | return V; |
| 696 | } |
| 697 | |
| 698 | /// getBBVal - This is used for two purposes: |
| 699 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 700 | /// defined. |
| 701 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 702 | /// or may not be a forward reference. |
| 703 | /// |
| 704 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
| 705 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 706 | |
| 707 | std::string Name; |
| 708 | BasicBlock *BB = 0; |
| 709 | switch (ID.Type) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 710 | default: |
| 711 | GenerateError("Illegal label reference " + ID.getName()); |
| 712 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 713 | case ValID::NumberVal: // Is it a numbered definition? |
| 714 | if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) |
| 715 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 716 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 717 | break; |
| 718 | case ValID::NameVal: // Is it a named definition? |
| 719 | Name = ID.Name; |
| 720 | if (Value *N = CurFun.CurrentFunction-> |
| 721 | getSymbolTable().lookup(Type::LabelTy, Name)) |
| 722 | BB = cast<BasicBlock>(N); |
| 723 | break; |
| 724 | } |
| 725 | |
| 726 | // See if the block has already been defined. |
| 727 | if (BB) { |
| 728 | // If this is the definition of the block, make sure the existing value was |
| 729 | // just a forward reference. If it was a forward reference, there will be |
| 730 | // an entry for it in the PlaceHolderInfo map. |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 731 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 732 | // The existing value was a definition, not a forward reference. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 733 | GenerateError("Redefinition of label " + ID.getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 734 | return 0; |
| 735 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 736 | |
| 737 | ID.destroy(); // Free strdup'd memory. |
| 738 | return BB; |
| 739 | } |
| 740 | |
| 741 | // Otherwise this block has not been seen before. |
| 742 | BB = new BasicBlock("", CurFun.CurrentFunction); |
| 743 | if (ID.Type == ValID::NameVal) { |
| 744 | BB->setName(ID.Name); |
| 745 | } else { |
| 746 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 747 | } |
| 748 | |
| 749 | // If this is not a definition, keep track of it so we can use it as a forward |
| 750 | // reference. |
| 751 | if (!isDefinition) { |
| 752 | // Remember where this forward reference came from. |
| 753 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno); |
| 754 | } else { |
| 755 | // The forward declaration could have been inserted anywhere in the |
| 756 | // function: insert it into the correct place now. |
| 757 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 758 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 759 | } |
| 760 | ID.destroy(); |
| 761 | return BB; |
| 762 | } |
| 763 | |
| 764 | |
| 765 | //===----------------------------------------------------------------------===// |
| 766 | // Code to handle forward references in instructions |
| 767 | //===----------------------------------------------------------------------===// |
| 768 | // |
| 769 | // This code handles the late binding needed with statements that reference |
| 770 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 771 | // a loop body. |
| 772 | // |
| 773 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 774 | // and back patchs after we are done. |
| 775 | // |
| 776 | |
| 777 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 778 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 779 | // defs now... |
| 780 | // |
| 781 | static void |
| 782 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 783 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
| 784 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 785 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 786 | E = LateResolvers.end(); LRI != E; ++LRI) { |
| 787 | ValueList &List = LRI->second; |
| 788 | while (!List.empty()) { |
| 789 | Value *V = List.back(); |
| 790 | List.pop_back(); |
| 791 | |
| 792 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 793 | CurModule.PlaceHolderInfo.find(V); |
| 794 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
| 795 | |
| 796 | ValID &DID = PHI->second.first; |
| 797 | |
| 798 | Value *TheRealValue = getValNonImprovising(LRI->first, DID); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 799 | if (TriggerError) |
| 800 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 801 | if (TheRealValue) { |
| 802 | V->replaceAllUsesWith(TheRealValue); |
| 803 | delete V; |
| 804 | CurModule.PlaceHolderInfo.erase(PHI); |
| 805 | } else if (FutureLateResolvers) { |
| 806 | // Functions have their unresolved items forwarded to the module late |
| 807 | // resolver table |
| 808 | InsertValue(V, *FutureLateResolvers); |
| 809 | } else { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 810 | if (DID.Type == ValID::NameVal) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 811 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 812 | "' of type '" + V->getType()->getDescription() + "'", |
| 813 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 814 | return; |
| 815 | } else { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 816 | GenerateError("Reference to an invalid definition: #" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 817 | itostr(DID.Num) + " of type '" + |
| 818 | V->getType()->getDescription() + "'", |
| 819 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 820 | return; |
| 821 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 822 | } |
| 823 | } |
| 824 | } |
| 825 | |
| 826 | LateResolvers.clear(); |
| 827 | } |
| 828 | |
| 829 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 830 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 831 | // refering to the number can be resolved. Do this now. |
| 832 | // |
| 833 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 834 | ValID D; |
| 835 | if (Name) D = ValID::create(Name); |
| 836 | else D = ValID::create((int)CurModule.Types.size()); |
| 837 | |
| 838 | std::map<ValID, PATypeHolder>::iterator I = |
| 839 | CurModule.LateResolveTypes.find(D); |
| 840 | if (I != CurModule.LateResolveTypes.end()) { |
| 841 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
| 842 | CurModule.LateResolveTypes.erase(I); |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | // setValueName - Set the specified value to the name given. The name may be |
| 847 | // null potentially, in which case this is a noop. The string passed in is |
| 848 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 849 | // |
| 850 | static void setValueName(Value *V, char *NameStr) { |
| 851 | if (NameStr) { |
| 852 | std::string Name(NameStr); // Copy string |
| 853 | free(NameStr); // Free old string |
| 854 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 855 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 856 | GenerateError("Can't assign name '" + Name+"' to value with void type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 857 | return; |
| 858 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 859 | |
| 860 | assert(inFunctionScope() && "Must be in function scope!"); |
| 861 | SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable(); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 862 | if (ST.lookup(V->getType(), Name)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 863 | GenerateError("Redefinition of value named '" + Name + "' in the '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 864 | V->getType()->getDescription() + "' type plane!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 865 | return; |
| 866 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 867 | |
| 868 | // Set the name. |
| 869 | V->setName(Name); |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 874 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 875 | static GlobalVariable * |
| 876 | ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, |
| 877 | bool isConstantGlobal, const Type *Ty, |
| 878 | Constant *Initializer) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 879 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 880 | GenerateError("Cannot declare global vars of function type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 881 | return 0; |
| 882 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 883 | |
| 884 | const PointerType *PTy = PointerType::get(Ty); |
| 885 | |
| 886 | std::string Name; |
| 887 | if (NameStr) { |
| 888 | Name = NameStr; // Copy string |
| 889 | free(NameStr); // Free old string |
| 890 | } |
| 891 | |
| 892 | // See if this global value was forward referenced. If so, recycle the |
| 893 | // object. |
| 894 | ValID ID; |
| 895 | if (!Name.empty()) { |
| 896 | ID = ValID::create((char*)Name.c_str()); |
| 897 | } else { |
| 898 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
| 899 | } |
| 900 | |
| 901 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 902 | // Move the global to the end of the list, from whereever it was |
| 903 | // previously inserted. |
| 904 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 905 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 906 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 907 | GV->setInitializer(Initializer); |
| 908 | GV->setLinkage(Linkage); |
| 909 | GV->setConstant(isConstantGlobal); |
| 910 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 911 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 912 | } |
| 913 | |
| 914 | // If this global has a name, check to see if there is already a definition |
| 915 | // of this global in the module. If so, merge as appropriate. Note that |
| 916 | // this is really just a hack around problems in the CFE. :( |
| 917 | if (!Name.empty()) { |
| 918 | // We are a simple redefinition of a value, check to see if it is defined |
| 919 | // the same as the old one. |
| 920 | if (GlobalVariable *EGV = |
| 921 | CurModule.CurrentModule->getGlobalVariable(Name, Ty)) { |
| 922 | // We are allowed to redefine a global variable in two circumstances: |
| 923 | // 1. If at least one of the globals is uninitialized or |
| 924 | // 2. If both initializers have the same value. |
| 925 | // |
| 926 | if (!EGV->hasInitializer() || !Initializer || |
| 927 | EGV->getInitializer() == Initializer) { |
| 928 | |
| 929 | // Make sure the existing global version gets the initializer! Make |
| 930 | // sure that it also gets marked const if the new version is. |
| 931 | if (Initializer && !EGV->hasInitializer()) |
| 932 | EGV->setInitializer(Initializer); |
| 933 | if (isConstantGlobal) |
| 934 | EGV->setConstant(true); |
| 935 | EGV->setLinkage(Linkage); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 936 | return EGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 937 | } |
| 938 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 939 | GenerateError("Redefinition of global variable named '" + Name + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 940 | "' in the '" + Ty->getDescription() + "' type plane!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 941 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 942 | } |
| 943 | } |
| 944 | |
| 945 | // Otherwise there is no existing GV to use, create one now. |
| 946 | GlobalVariable *GV = |
| 947 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 948 | CurModule.CurrentModule); |
| 949 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 950 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 951 | } |
| 952 | |
| 953 | // setTypeName - Set the specified type to the name given. The name may be |
| 954 | // null potentially, in which case this is a noop. The string passed in is |
| 955 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 956 | // |
| 957 | // This function returns true if the type has already been defined, but is |
| 958 | // allowed to be redefined in the specified context. If the name is a new name |
| 959 | // for the type plane, it is inserted and false is returned. |
| 960 | static bool setTypeName(const Type *T, char *NameStr) { |
| 961 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
| 962 | if (NameStr == 0) return false; |
| 963 | |
| 964 | std::string Name(NameStr); // Copy string |
| 965 | free(NameStr); // Free old string |
| 966 | |
| 967 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 968 | if (T == Type::VoidTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 969 | GenerateError("Can't assign name '" + Name + "' to the void type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 970 | return false; |
| 971 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 972 | |
| 973 | // Set the type name, checking for conflicts as we do so. |
| 974 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 975 | |
| 976 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 977 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 978 | assert(Existing && "Conflict but no matching type?"); |
| 979 | |
| 980 | // There is only one case where this is allowed: when we are refining an |
| 981 | // opaque type. In this case, Existing will be an opaque type. |
| 982 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 983 | // We ARE replacing an opaque type! |
| 984 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 985 | return true; |
| 986 | } |
| 987 | |
| 988 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 989 | // the redefinition is identical to the original. This will be so if |
| 990 | // Existing and T point to the same Type object. In this one case we |
| 991 | // allow the equivalent redefinition. |
| 992 | if (Existing == T) return true; // Yes, it's equal. |
| 993 | |
| 994 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 995 | GenerateError("Redefinition of type named '" + Name + "' in the '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 996 | T->getDescription() + "' type plane!"); |
| 997 | } |
| 998 | |
| 999 | return false; |
| 1000 | } |
| 1001 | |
| 1002 | //===----------------------------------------------------------------------===// |
| 1003 | // Code for handling upreferences in type names... |
| 1004 | // |
| 1005 | |
| 1006 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1007 | // |
| 1008 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1009 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1010 | E) != Ty->subtype_end(); |
| 1011 | } |
| 1012 | |
| 1013 | namespace { |
| 1014 | struct UpRefRecord { |
| 1015 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1016 | // this type is resolved. |
| 1017 | unsigned NestingLevel; |
| 1018 | |
| 1019 | // LastContainedTy - This is the type at the current binding level for the |
| 1020 | // type. Every time we reduce the nesting level, this gets updated. |
| 1021 | const Type *LastContainedTy; |
| 1022 | |
| 1023 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1024 | // represented with. |
| 1025 | OpaqueType *UpRefTy; |
| 1026 | |
| 1027 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 1028 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 1029 | }; |
| 1030 | } |
| 1031 | |
| 1032 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1033 | static std::vector<UpRefRecord> UpRefs; |
| 1034 | |
| 1035 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1036 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1037 | /// currently active types. For each type, if the up reference is contained in |
| 1038 | /// the newly completed type, we decrement the level count. When the level |
| 1039 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1040 | /// thus we can complete the cycle. |
| 1041 | /// |
| 1042 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 1043 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1044 | // nothing to resolve here. |
| 1045 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1046 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1047 | PATypeHolder Ty(ty); |
| 1048 | UR_OUT("Type '" << Ty->getDescription() << |
| 1049 | "' newly formed. Resolving upreferences.\n" << |
| 1050 | UpRefs.size() << " upreferences active!\n"); |
| 1051 | |
| 1052 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1053 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1054 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1055 | // this variable. |
| 1056 | OpaqueType *TypeToResolve = 0; |
| 1057 | |
| 1058 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1059 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1060 | << UpRefs[i].second->getDescription() << ") = " |
| 1061 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1062 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1063 | // Decrement level of upreference |
| 1064 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1065 | UpRefs[i].LastContainedTy = Ty; |
| 1066 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1067 | if (Level == 0) { // Upreference should be resolved! |
| 1068 | if (!TypeToResolve) { |
| 1069 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1070 | } else { |
| 1071 | UR_OUT(" * Resolving upreference for " |
| 1072 | << UpRefs[i].second->getDescription() << "\n"; |
| 1073 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1074 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1075 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1076 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1077 | } |
| 1078 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1079 | --i; // Do not skip the next element... |
| 1080 | } |
| 1081 | } |
| 1082 | } |
| 1083 | |
| 1084 | if (TypeToResolve) { |
| 1085 | UR_OUT(" * Resolving upreference for " |
| 1086 | << UpRefs[i].second->getDescription() << "\n"; |
| 1087 | std::string OldName = TypeToResolve->getDescription()); |
| 1088 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1089 | } |
| 1090 | |
| 1091 | return Ty; |
| 1092 | } |
| 1093 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1094 | /// This function is used to obtain the correct opcode for an instruction when |
| 1095 | /// an obsolete opcode is encountered. The OI parameter (OpcodeInfo) has both |
| 1096 | /// an opcode and an "obsolete" flag. These are generated by the lexer and |
| 1097 | /// the "obsolete" member will be true when the lexer encounters the token for |
| 1098 | /// an obsolete opcode. For example, "div" was replaced by [usf]div but we need |
| 1099 | /// to maintain backwards compatibility for asm files that still have the "div" |
| 1100 | /// instruction. This function handles converting div -> [usf]div appropriately. |
| 1101 | /// @brief Convert obsolete opcodes to new values |
| 1102 | static void |
| 1103 | sanitizeOpCode(OpcodeInfo<Instruction::BinaryOps> &OI, const PATypeHolder& PATy) |
| 1104 | { |
| 1105 | // If its not obsolete, don't do anything |
| 1106 | if (!OI.obsolete) |
| 1107 | return; |
| 1108 | |
| 1109 | // If its a packed type we want to use the element type |
| 1110 | const Type* Ty = PATy; |
| 1111 | if (const PackedType* PTy = dyn_cast<PackedType>(Ty)) |
| 1112 | Ty = PTy->getElementType(); |
| 1113 | |
| 1114 | // Depending on the opcode .. |
| 1115 | switch (OI.opcode) { |
| 1116 | default: |
| 1117 | GenerateError("Invalid Obsolete OpCode"); |
| 1118 | break; |
| 1119 | case Instruction::UDiv: |
| 1120 | // Handle cases where the opcode needs to change |
| 1121 | if (Ty->isFloatingPoint()) |
| 1122 | OI.opcode = Instruction::FDiv; |
| 1123 | else if (Ty->isSigned()) |
| 1124 | OI.opcode = Instruction::SDiv; |
| 1125 | break; |
| 1126 | } |
| 1127 | // Its not obsolete any more, we fixed it. |
| 1128 | OI.obsolete = false; |
| 1129 | } |
| 1130 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1131 | |
| 1132 | // common code from the two 'RunVMAsmParser' functions |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1133 | static Module* RunParser(Module * M) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1134 | |
| 1135 | llvmAsmlineno = 1; // Reset the current line number... |
| 1136 | ObsoleteVarArgs = false; |
| 1137 | NewVarArgs = false; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1138 | CurModule.CurrentModule = M; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 1139 | |
| 1140 | // Check to make sure the parser succeeded |
| 1141 | if (yyparse()) { |
| 1142 | if (ParserResult) |
| 1143 | delete ParserResult; |
| 1144 | return 0; |
| 1145 | } |
| 1146 | |
| 1147 | // Check to make sure that parsing produced a result |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1148 | if (!ParserResult) |
| 1149 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1150 | |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 1151 | // Reset ParserResult variable while saving its value for the result. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1152 | Module *Result = ParserResult; |
| 1153 | ParserResult = 0; |
| 1154 | |
| 1155 | //Not all functions use vaarg, so make a second check for ObsoleteVarArgs |
| 1156 | { |
| 1157 | Function* F; |
| 1158 | if ((F = Result->getNamedFunction("llvm.va_start")) |
| 1159 | && F->getFunctionType()->getNumParams() == 0) |
| 1160 | ObsoleteVarArgs = true; |
| 1161 | if((F = Result->getNamedFunction("llvm.va_copy")) |
| 1162 | && F->getFunctionType()->getNumParams() == 1) |
| 1163 | ObsoleteVarArgs = true; |
| 1164 | } |
| 1165 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1166 | if (ObsoleteVarArgs && NewVarArgs) { |
| 1167 | GenerateError( |
| 1168 | "This file is corrupt: it uses both new and old style varargs"); |
| 1169 | return 0; |
| 1170 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1171 | |
| 1172 | if(ObsoleteVarArgs) { |
| 1173 | if(Function* F = Result->getNamedFunction("llvm.va_start")) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1174 | if (F->arg_size() != 0) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1175 | GenerateError("Obsolete va_start takes 0 argument!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1176 | return 0; |
| 1177 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1178 | |
| 1179 | //foo = va_start() |
| 1180 | // -> |
| 1181 | //bar = alloca typeof(foo) |
| 1182 | //va_start(bar) |
| 1183 | //foo = load bar |
| 1184 | |
| 1185 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1186 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 1187 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1188 | Function* NF = Result->getOrInsertFunction("llvm.va_start", |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 1189 | RetTy, ArgTyPtr, (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1190 | |
| 1191 | while (!F->use_empty()) { |
| 1192 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1193 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); |
| 1194 | new CallInst(NF, bar, "", CI); |
| 1195 | Value* foo = new LoadInst(bar, "vastart.fix.2", CI); |
| 1196 | CI->replaceAllUsesWith(foo); |
| 1197 | CI->getParent()->getInstList().erase(CI); |
| 1198 | } |
| 1199 | Result->getFunctionList().erase(F); |
| 1200 | } |
| 1201 | |
| 1202 | if(Function* F = Result->getNamedFunction("llvm.va_end")) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1203 | if(F->arg_size() != 1) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1204 | GenerateError("Obsolete va_end takes 1 argument!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1205 | return 0; |
| 1206 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1207 | |
| 1208 | //vaend foo |
| 1209 | // -> |
| 1210 | //bar = alloca 1 of typeof(foo) |
| 1211 | //vaend bar |
| 1212 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1213 | const Type* ArgTy = F->getFunctionType()->getParamType(0); |
| 1214 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1215 | Function* NF = Result->getOrInsertFunction("llvm.va_end", |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 1216 | RetTy, ArgTyPtr, (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1217 | |
| 1218 | while (!F->use_empty()) { |
| 1219 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1220 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); |
| 1221 | new StoreInst(CI->getOperand(1), bar, CI); |
| 1222 | new CallInst(NF, bar, "", CI); |
| 1223 | CI->getParent()->getInstList().erase(CI); |
| 1224 | } |
| 1225 | Result->getFunctionList().erase(F); |
| 1226 | } |
| 1227 | |
| 1228 | if(Function* F = Result->getNamedFunction("llvm.va_copy")) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1229 | if(F->arg_size() != 1) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1230 | GenerateError("Obsolete va_copy takes 1 argument!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1231 | return 0; |
| 1232 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1233 | //foo = vacopy(bar) |
| 1234 | // -> |
| 1235 | //a = alloca 1 of typeof(foo) |
| 1236 | //b = alloca 1 of typeof(foo) |
| 1237 | //store bar -> b |
| 1238 | //vacopy(a, b) |
| 1239 | //foo = load a |
| 1240 | |
| 1241 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1242 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 1243 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1244 | Function* NF = Result->getOrInsertFunction("llvm.va_copy", |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 1245 | RetTy, ArgTyPtr, ArgTyPtr, |
| 1246 | (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1247 | |
| 1248 | while (!F->use_empty()) { |
| 1249 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1250 | AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI); |
| 1251 | AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI); |
| 1252 | new StoreInst(CI->getOperand(1), b, CI); |
| 1253 | new CallInst(NF, a, b, "", CI); |
| 1254 | Value* foo = new LoadInst(a, "vacopy.fix.3", CI); |
| 1255 | CI->replaceAllUsesWith(foo); |
| 1256 | CI->getParent()->getInstList().erase(CI); |
| 1257 | } |
| 1258 | Result->getFunctionList().erase(F); |
| 1259 | } |
| 1260 | } |
| 1261 | |
| 1262 | return Result; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1263 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1264 | |
| 1265 | //===----------------------------------------------------------------------===// |
| 1266 | // RunVMAsmParser - Define an interface to this parser |
| 1267 | //===----------------------------------------------------------------------===// |
| 1268 | // |
| 1269 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1270 | set_scan_file(F); |
| 1271 | |
| 1272 | CurFilename = Filename; |
| 1273 | return RunParser(new Module(CurFilename)); |
| 1274 | } |
| 1275 | |
| 1276 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1277 | set_scan_string(AsmString); |
| 1278 | |
| 1279 | CurFilename = "from_memory"; |
| 1280 | if (M == NULL) { |
| 1281 | return RunParser(new Module (CurFilename)); |
| 1282 | } else { |
| 1283 | return RunParser(M); |
| 1284 | } |
| 1285 | } |
| 1286 | |
| 1287 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1288 | |
| 1289 | /* Enabling traces. */ |
| 1290 | #ifndef YYDEBUG |
| 1291 | # define YYDEBUG 0 |
| 1292 | #endif |
| 1293 | |
| 1294 | /* Enabling verbose error messages. */ |
| 1295 | #ifdef YYERROR_VERBOSE |
| 1296 | # undef YYERROR_VERBOSE |
| 1297 | # define YYERROR_VERBOSE 1 |
| 1298 | #else |
| 1299 | # define YYERROR_VERBOSE 0 |
| 1300 | #endif |
| 1301 | |
| 1302 | /* Enabling the token table. */ |
| 1303 | #ifndef YYTOKEN_TABLE |
| 1304 | # define YYTOKEN_TABLE 0 |
| 1305 | #endif |
| 1306 | |
| 1307 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1308 | #line 1011 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1309 | typedef union YYSTYPE { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1310 | llvm::Module *ModuleVal; |
| 1311 | llvm::Function *FunctionVal; |
| 1312 | std::pair<llvm::PATypeHolder*, char*> *ArgVal; |
| 1313 | llvm::BasicBlock *BasicBlockVal; |
| 1314 | llvm::TerminatorInst *TermInstVal; |
| 1315 | llvm::Instruction *InstVal; |
| 1316 | llvm::Constant *ConstVal; |
| 1317 | |
| 1318 | const llvm::Type *PrimType; |
| 1319 | llvm::PATypeHolder *TypeVal; |
| 1320 | llvm::Value *ValueVal; |
| 1321 | |
| 1322 | std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList; |
| 1323 | std::vector<llvm::Value*> *ValueList; |
| 1324 | std::list<llvm::PATypeHolder> *TypeList; |
| 1325 | // Represent the RHS of PHI node |
| 1326 | std::list<std::pair<llvm::Value*, |
| 1327 | llvm::BasicBlock*> > *PHIList; |
| 1328 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
| 1329 | std::vector<llvm::Constant*> *ConstVector; |
| 1330 | |
| 1331 | llvm::GlobalValue::LinkageTypes Linkage; |
| 1332 | int64_t SInt64Val; |
| 1333 | uint64_t UInt64Val; |
| 1334 | int SIntVal; |
| 1335 | unsigned UIntVal; |
| 1336 | double FPVal; |
| 1337 | bool BoolVal; |
| 1338 | |
| 1339 | char *StrVal; // This memory is strdup'd! |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1340 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1341 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1342 | BinaryOpInfo BinaryOpVal; |
| 1343 | TermOpInfo TermOpVal; |
| 1344 | MemOpInfo MemOpVal; |
| 1345 | OtherOpInfo OtherOpVal; |
| 1346 | llvm::Module::Endianness Endianness; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1347 | } YYSTYPE; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1348 | /* Line 196 of yacc.c. */ |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1349 | #line 1350 "llvmAsmParser.tab.c" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1350 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 1351 | # define YYSTYPE_IS_DECLARED 1 |
| 1352 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1353 | #endif |
| 1354 | |
| 1355 | |
| 1356 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1357 | /* Copy the second part of user declarations. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1358 | |
| 1359 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1360 | /* Line 219 of yacc.c. */ |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1361 | #line 1362 "llvmAsmParser.tab.c" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1362 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1363 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
| 1364 | # define YYSIZE_T __SIZE_TYPE__ |
| 1365 | #endif |
| 1366 | #if ! defined (YYSIZE_T) && defined (size_t) |
| 1367 | # define YYSIZE_T size_t |
| 1368 | #endif |
| 1369 | #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) |
| 1370 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 1371 | # define YYSIZE_T size_t |
| 1372 | #endif |
| 1373 | #if ! defined (YYSIZE_T) |
| 1374 | # define YYSIZE_T unsigned int |
| 1375 | #endif |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 1376 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1377 | #ifndef YY_ |
| 1378 | # if YYENABLE_NLS |
| 1379 | # if ENABLE_NLS |
| 1380 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 1381 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
| 1382 | # endif |
| 1383 | # endif |
| 1384 | # ifndef YY_ |
| 1385 | # define YY_(msgid) msgid |
| 1386 | # endif |
| 1387 | #endif |
| 1388 | |
| 1389 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
| 1390 | |
| 1391 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 1392 | |
| 1393 | # ifdef YYSTACK_USE_ALLOCA |
| 1394 | # if YYSTACK_USE_ALLOCA |
| 1395 | # ifdef __GNUC__ |
| 1396 | # define YYSTACK_ALLOC __builtin_alloca |
| 1397 | # else |
| 1398 | # define YYSTACK_ALLOC alloca |
| 1399 | # if defined (__STDC__) || defined (__cplusplus) |
| 1400 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 1401 | # define YYINCLUDED_STDLIB_H |
| 1402 | # endif |
| 1403 | # endif |
| 1404 | # endif |
| 1405 | # endif |
| 1406 | |
| 1407 | # ifdef YYSTACK_ALLOC |
| 1408 | /* Pacify GCC's `empty if-body' warning. */ |
| 1409 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
| 1410 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1411 | /* The OS might guarantee only one guard page at the bottom of the stack, |
| 1412 | and a page size can be as small as 4096 bytes. So we cannot safely |
| 1413 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
| 1414 | to allow for a few compiler-allocated temporary stack slots. */ |
| 1415 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ |
| 1416 | # endif |
| 1417 | # else |
| 1418 | # define YYSTACK_ALLOC YYMALLOC |
| 1419 | # define YYSTACK_FREE YYFREE |
| 1420 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1421 | # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) |
| 1422 | # endif |
| 1423 | # ifdef __cplusplus |
| 1424 | extern "C" { |
| 1425 | # endif |
| 1426 | # ifndef YYMALLOC |
| 1427 | # define YYMALLOC malloc |
| 1428 | # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 1429 | && (defined (__STDC__) || defined (__cplusplus))) |
| 1430 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 1431 | # endif |
| 1432 | # endif |
| 1433 | # ifndef YYFREE |
| 1434 | # define YYFREE free |
| 1435 | # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 1436 | && (defined (__STDC__) || defined (__cplusplus))) |
| 1437 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 1438 | # endif |
| 1439 | # endif |
| 1440 | # ifdef __cplusplus |
| 1441 | } |
| 1442 | # endif |
| 1443 | # endif |
| 1444 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
| 1445 | |
| 1446 | |
| 1447 | #if (! defined (yyoverflow) \ |
| 1448 | && (! defined (__cplusplus) \ |
| 1449 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
| 1450 | |
| 1451 | /* A type that is properly aligned for any stack member. */ |
| 1452 | union yyalloc |
| 1453 | { |
| 1454 | short int yyss; |
| 1455 | YYSTYPE yyvs; |
| 1456 | }; |
| 1457 | |
| 1458 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 1459 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 1460 | |
| 1461 | /* The size of an array large to enough to hold all stacks, each with |
| 1462 | N elements. */ |
| 1463 | # define YYSTACK_BYTES(N) \ |
| 1464 | ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ |
| 1465 | + YYSTACK_GAP_MAXIMUM) |
| 1466 | |
| 1467 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 1468 | not overlap. */ |
| 1469 | # ifndef YYCOPY |
| 1470 | # if defined (__GNUC__) && 1 < __GNUC__ |
| 1471 | # define YYCOPY(To, From, Count) \ |
| 1472 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 1473 | # else |
| 1474 | # define YYCOPY(To, From, Count) \ |
| 1475 | do \ |
| 1476 | { \ |
| 1477 | YYSIZE_T yyi; \ |
| 1478 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 1479 | (To)[yyi] = (From)[yyi]; \ |
| 1480 | } \ |
| 1481 | while (0) |
| 1482 | # endif |
| 1483 | # endif |
| 1484 | |
| 1485 | /* Relocate STACK from its old location to the new one. The |
| 1486 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 1487 | elements in the stack, and YYPTR gives the new location of the |
| 1488 | stack. Advance YYPTR to a properly aligned location for the next |
| 1489 | stack. */ |
| 1490 | # define YYSTACK_RELOCATE(Stack) \ |
| 1491 | do \ |
| 1492 | { \ |
| 1493 | YYSIZE_T yynewbytes; \ |
| 1494 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 1495 | Stack = &yyptr->Stack; \ |
| 1496 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 1497 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 1498 | } \ |
| 1499 | while (0) |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 1500 | |
| 1501 | #endif |
| 1502 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1503 | #if defined (__STDC__) || defined (__cplusplus) |
| 1504 | typedef signed char yysigned_char; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1505 | #else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1506 | typedef short int yysigned_char; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1507 | #endif |
| 1508 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1509 | /* YYFINAL -- State number of the termination state. */ |
| 1510 | #define YYFINAL 4 |
| 1511 | /* YYLAST -- Last index in YYTABLE. */ |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1512 | #define YYLAST 1288 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1513 | |
| 1514 | /* YYNTOKENS -- Number of terminals. */ |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1515 | #define YYNTOKENS 125 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1516 | /* YYNNTS -- Number of nonterminals. */ |
| 1517 | #define YYNNTS 75 |
| 1518 | /* YYNRULES -- Number of rules. */ |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1519 | #define YYNRULES 254 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1520 | /* YYNRULES -- Number of states. */ |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1521 | #define YYNSTATES 519 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1522 | |
| 1523 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 1524 | #define YYUNDEFTOK 2 |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1525 | #define YYMAXUTOK 365 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1526 | |
| 1527 | #define YYTRANSLATE(YYX) \ |
| 1528 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 1529 | |
| 1530 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 1531 | static const unsigned char yytranslate[] = |
| 1532 | { |
| 1533 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1534 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1535 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1536 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1537 | 114, 115, 123, 2, 112, 2, 2, 2, 2, 2, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1538 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1539 | 119, 111, 120, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1540 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1541 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1542 | 2, 116, 113, 118, 2, 2, 2, 2, 2, 124, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1543 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1544 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1545 | 117, 2, 2, 121, 2, 122, 2, 2, 2, 2, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1546 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1547 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1548 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1549 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1550 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1551 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1552 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1553 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1554 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1555 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1556 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1557 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1558 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 1559 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 1560 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 1561 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 1562 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 1563 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 1564 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 1565 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 1566 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 1567 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1568 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1569 | 105, 106, 107, 108, 109, 110 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1570 | }; |
| 1571 | |
| 1572 | #if YYDEBUG |
| 1573 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 1574 | YYRHS. */ |
| 1575 | static const unsigned short int yyprhs[] = |
| 1576 | { |
| 1577 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 1578 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 1579 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1580 | 59, 61, 63, 65, 67, 69, 71, 74, 75, 77, |
| 1581 | 79, 81, 83, 85, 87, 89, 90, 91, 93, 95, |
| 1582 | 97, 99, 101, 103, 106, 107, 110, 111, 115, 118, |
| 1583 | 119, 121, 122, 126, 128, 131, 133, 135, 137, 139, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1584 | 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1585 | 161, 163, 165, 167, 169, 171, 173, 176, 181, 187, |
| 1586 | 193, 197, 200, 203, 205, 209, 211, 215, 217, 218, |
| 1587 | 223, 227, 231, 236, 241, 245, 248, 251, 254, 257, |
| 1588 | 260, 263, 266, 269, 272, 275, 282, 288, 297, 304, |
| 1589 | 311, 318, 325, 332, 341, 350, 354, 356, 358, 360, |
| 1590 | 362, 365, 368, 373, 376, 378, 383, 386, 391, 392, |
| 1591 | 400, 401, 409, 410, 418, 419, 427, 431, 436, 437, |
| 1592 | 439, 441, 443, 447, 451, 455, 459, 463, 467, 469, |
| 1593 | 470, 472, 474, 476, 477, 480, 484, 486, 488, 492, |
| 1594 | 494, 495, 504, 506, 508, 512, 514, 516, 519, 520, |
| 1595 | 522, 524, 525, 530, 531, 533, 535, 537, 539, 541, |
| 1596 | 543, 545, 547, 549, 553, 555, 561, 563, 565, 567, |
| 1597 | 569, 572, 575, 578, 582, 585, 586, 588, 591, 594, |
| 1598 | 598, 608, 618, 627, 641, 643, 645, 652, 658, 661, |
| 1599 | 668, 676, 678, 682, 684, 685, 688, 690, 696, 702, |
| 1600 | 708, 711, 716, 721, 728, 733, 738, 743, 748, 755, |
| 1601 | 762, 765, 773, 775, 778, 779, 781, 782, 786, 793, |
| 1602 | 797, 804, 807, 812, 819 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1603 | }; |
| 1604 | |
| 1605 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 1606 | static const short int yyrhs[] = |
| 1607 | { |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1608 | 156, 0, -1, 5, -1, 6, -1, 3, -1, 4, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1609 | -1, 78, -1, 79, -1, 80, -1, 81, -1, 82, |
| 1610 | -1, 83, -1, 84, -1, 85, -1, 86, -1, 87, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1611 | -1, 88, -1, 89, -1, 90, -1, 91, -1, 92, |
| 1612 | -1, 93, -1, 103, -1, 104, -1, 16, -1, 14, |
| 1613 | -1, 12, -1, 10, -1, 17, -1, 15, -1, 13, |
| 1614 | -1, 11, -1, 132, -1, 133, -1, 18, -1, 19, |
| 1615 | -1, 168, 111, -1, -1, 41, -1, 42, -1, 43, |
| 1616 | -1, 44, -1, 45, -1, 46, -1, 47, -1, -1, |
| 1617 | -1, 65, -1, 66, -1, 67, -1, 68, -1, 69, |
| 1618 | -1, 70, -1, 64, 4, -1, -1, 57, 4, -1, |
| 1619 | -1, 112, 57, 4, -1, 34, 24, -1, -1, 141, |
| 1620 | -1, -1, 112, 144, 143, -1, 141, -1, 57, 4, |
| 1621 | -1, 147, -1, 8, -1, 149, -1, 8, -1, 149, |
| 1622 | -1, 9, -1, 10, -1, 11, -1, 12, -1, 13, |
| 1623 | -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, |
| 1624 | -1, 19, -1, 20, -1, 21, -1, 48, -1, 148, |
| 1625 | -1, 183, -1, 113, 4, -1, 146, 114, 151, 115, |
| 1626 | -1, 116, 4, 117, 149, 118, -1, 119, 4, 117, |
| 1627 | 149, 120, -1, 121, 150, 122, -1, 121, 122, -1, |
| 1628 | 149, 123, -1, 149, -1, 150, 112, 149, -1, 150, |
| 1629 | -1, 150, 112, 37, -1, 37, -1, -1, 147, 116, |
| 1630 | 154, 118, -1, 147, 116, 118, -1, 147, 124, 24, |
| 1631 | -1, 147, 119, 154, 120, -1, 147, 121, 154, 122, |
| 1632 | -1, 147, 121, 122, -1, 147, 38, -1, 147, 39, |
| 1633 | -1, 147, 183, -1, 147, 153, -1, 147, 26, -1, |
| 1634 | 132, 127, -1, 133, 4, -1, 9, 27, -1, 9, |
| 1635 | 28, -1, 135, 7, -1, 101, 114, 152, 36, 147, |
| 1636 | 115, -1, 99, 114, 152, 197, 115, -1, 102, 114, |
| 1637 | 152, 112, 152, 112, 152, 115, -1, 128, 114, 152, |
| 1638 | 112, 152, 115, -1, 129, 114, 152, 112, 152, 115, |
| 1639 | -1, 130, 114, 152, 112, 152, 115, -1, 131, 114, |
| 1640 | 152, 112, 152, 115, -1, 106, 114, 152, 112, 152, |
| 1641 | 115, -1, 107, 114, 152, 112, 152, 112, 152, 115, |
| 1642 | -1, 108, 114, 152, 112, 152, 112, 152, 115, -1, |
| 1643 | 154, 112, 152, -1, 152, -1, 32, -1, 33, -1, |
| 1644 | 157, -1, 157, 177, -1, 157, 179, -1, 157, 62, |
| 1645 | 61, 163, -1, 157, 25, -1, 158, -1, 158, 136, |
| 1646 | 20, 145, -1, 158, 179, -1, 158, 62, 61, 163, |
| 1647 | -1, -1, 158, 136, 137, 155, 152, 159, 143, -1, |
| 1648 | -1, 158, 136, 50, 155, 147, 160, 143, -1, -1, |
| 1649 | 158, 136, 45, 155, 147, 161, 143, -1, -1, 158, |
| 1650 | 136, 47, 155, 147, 162, 143, -1, 158, 51, 165, |
| 1651 | -1, 158, 58, 111, 166, -1, -1, 24, -1, 56, |
| 1652 | -1, 55, -1, 53, 111, 164, -1, 54, 111, 4, |
| 1653 | -1, 52, 111, 24, -1, 71, 111, 24, -1, 116, |
| 1654 | 167, 118, -1, 167, 112, 24, -1, 24, -1, -1, |
| 1655 | 22, -1, 24, -1, 168, -1, -1, 147, 169, -1, |
| 1656 | 171, 112, 170, -1, 170, -1, 171, -1, 171, 112, |
| 1657 | 37, -1, 37, -1, -1, 138, 145, 168, 114, 172, |
| 1658 | 115, 142, 139, -1, 29, -1, 121, -1, 137, 173, |
| 1659 | 174, -1, 30, -1, 122, -1, 186, 176, -1, -1, |
| 1660 | 45, -1, 47, -1, -1, 31, 180, 178, 173, -1, |
| 1661 | -1, 63, -1, 3, -1, 4, -1, 7, -1, 27, |
| 1662 | -1, 28, -1, 38, -1, 39, -1, 26, -1, 119, |
| 1663 | 154, 120, -1, 153, -1, 61, 181, 24, 112, 24, |
| 1664 | -1, 126, -1, 168, -1, 183, -1, 182, -1, 147, |
| 1665 | 184, -1, 186, 187, -1, 175, 187, -1, 188, 136, |
| 1666 | 189, -1, 188, 191, -1, -1, 23, -1, 72, 185, |
| 1667 | -1, 72, 8, -1, 73, 21, 184, -1, 73, 9, |
| 1668 | 184, 112, 21, 184, 112, 21, 184, -1, 74, 134, |
| 1669 | 184, 112, 21, 184, 116, 190, 118, -1, 74, 134, |
| 1670 | 184, 112, 21, 184, 116, 118, -1, 75, 138, 145, |
| 1671 | 184, 114, 194, 115, 36, 21, 184, 76, 21, 184, |
| 1672 | -1, 76, -1, 77, -1, 190, 134, 182, 112, 21, |
| 1673 | 184, -1, 134, 182, 112, 21, 184, -1, 136, 196, |
| 1674 | -1, 147, 116, 184, 112, 184, 118, -1, 192, 112, |
| 1675 | 116, 184, 112, 184, 118, -1, 185, -1, 193, 112, |
| 1676 | 185, -1, 193, -1, -1, 60, 59, -1, 59, -1, |
| 1677 | 128, 147, 184, 112, 184, -1, 129, 147, 184, 112, |
| 1678 | 184, -1, 130, 147, 184, 112, 184, -1, 49, 185, |
| 1679 | -1, 131, 185, 112, 185, -1, 101, 185, 36, 147, |
| 1680 | -1, 102, 185, 112, 185, 112, 185, -1, 105, 185, |
| 1681 | 112, 147, -1, 109, 185, 112, 147, -1, 110, 185, |
| 1682 | 112, 147, -1, 106, 185, 112, 185, -1, 107, 185, |
| 1683 | 112, 185, 112, 185, -1, 108, 185, 112, 185, 112, |
| 1684 | 185, -1, 100, 192, -1, 195, 138, 145, 184, 114, |
| 1685 | 194, 115, -1, 199, -1, 112, 193, -1, -1, 35, |
| 1686 | -1, -1, 94, 147, 140, -1, 94, 147, 112, 15, |
| 1687 | 184, 140, -1, 95, 147, 140, -1, 95, 147, 112, |
| 1688 | 15, 184, 140, -1, 96, 185, -1, 198, 97, 147, |
| 1689 | 184, -1, 198, 98, 185, 112, 147, 184, -1, 99, |
| 1690 | 147, 184, 197, -1 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1691 | }; |
| 1692 | |
| 1693 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 1694 | static const unsigned short int yyrline[] = |
| 1695 | { |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1696 | 0, 1134, 1134, 1135, 1143, 1144, 1154, 1154, 1154, 1154, |
| 1697 | 1154, 1154, 1154, 1155, 1155, 1155, 1156, 1156, 1156, 1156, |
| 1698 | 1156, 1156, 1158, 1158, 1162, 1162, 1162, 1162, 1163, 1163, |
| 1699 | 1163, 1163, 1164, 1164, 1165, 1165, 1168, 1172, 1177, 1178, |
| 1700 | 1179, 1180, 1181, 1182, 1183, 1184, 1186, 1187, 1188, 1189, |
| 1701 | 1190, 1191, 1192, 1193, 1202, 1203, 1209, 1210, 1218, 1226, |
| 1702 | 1227, 1232, 1233, 1234, 1239, 1253, 1253, 1254, 1254, 1256, |
| 1703 | 1266, 1266, 1266, 1266, 1266, 1266, 1266, 1267, 1267, 1267, |
| 1704 | 1267, 1267, 1267, 1268, 1272, 1276, 1284, 1292, 1305, 1310, |
| 1705 | 1322, 1332, 1336, 1347, 1352, 1358, 1359, 1363, 1367, 1378, |
| 1706 | 1404, 1418, 1448, 1474, 1495, 1508, 1518, 1523, 1584, 1591, |
| 1707 | 1600, 1606, 1612, 1616, 1620, 1628, 1639, 1671, 1679, 1706, |
| 1708 | 1717, 1723, 1731, 1737, 1743, 1752, 1756, 1764, 1764, 1774, |
| 1709 | 1782, 1787, 1791, 1795, 1799, 1814, 1836, 1839, 1842, 1842, |
| 1710 | 1850, 1850, 1858, 1858, 1866, 1866, 1875, 1878, 1881, 1885, |
| 1711 | 1898, 1899, 1901, 1905, 1914, 1918, 1923, 1925, 1930, 1935, |
| 1712 | 1944, 1944, 1945, 1945, 1947, 1954, 1960, 1967, 1971, 1977, |
| 1713 | 1982, 1987, 2082, 2082, 2084, 2092, 2092, 2094, 2099, 2100, |
| 1714 | 2101, 2103, 2103, 2113, 2117, 2122, 2126, 2130, 2134, 2138, |
| 1715 | 2142, 2146, 2150, 2154, 2179, 2183, 2197, 2201, 2207, 2207, |
| 1716 | 2213, 2218, 2222, 2231, 2242, 2247, 2259, 2272, 2276, 2280, |
| 1717 | 2285, 2294, 2313, 2322, 2378, 2382, 2389, 2400, 2413, 2422, |
| 1718 | 2431, 2441, 2445, 2452, 2452, 2454, 2458, 2463, 2482, 2497, |
| 1719 | 2511, 2524, 2532, 2540, 2548, 2554, 2574, 2597, 2603, 2609, |
| 1720 | 2615, 2630, 2689, 2696, 2699, 2704, 2708, 2715, 2720, 2726, |
| 1721 | 2731, 2737, 2745, 2757, 2772 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1722 | }; |
| 1723 | #endif |
| 1724 | |
| 1725 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
| 1726 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 1727 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 1728 | static const char *const yytname[] = |
| 1729 | { |
| 1730 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", |
| 1731 | "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT", |
| 1732 | "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL", |
| 1733 | "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION", |
| 1734 | "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", |
| 1735 | "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", |
| 1736 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", |
| 1737 | "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 1738 | "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", |
| 1739 | "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", |
| 1740 | "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", |
| 1741 | "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", |
| 1742 | "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1743 | "MUL", "UDIV", "SDIV", "FDIV", "REM", "AND", "OR", "XOR", "SETLE", |
| 1744 | "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "MALLOC", "ALLOCA", "FREE", |
| 1745 | "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", "CAST", "SELECT", "SHL", |
| 1746 | "SHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", |
| 1747 | "VAARG_old", "VANEXT_old", "'='", "','", "'\\\\'", "'('", "')'", "'['", |
| 1748 | "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", |
| 1749 | "INTVAL", "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", |
| 1750 | "ShiftOps", "SIntType", "UIntType", "IntType", "FPType", "OptAssign", |
| 1751 | "OptLinkage", "OptCallingConv", "OptAlign", "OptCAlign", "SectionString", |
| 1752 | "OptSection", "GlobalVarAttributes", "GlobalVarAttribute", "TypesV", |
| 1753 | "UpRTypesV", "Types", "PrimType", "UpRTypes", "TypeListI", |
| 1754 | "ArgTypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType", |
| 1755 | "Module", "FunctionList", "ConstPool", "@1", "@2", "@3", "@4", |
| 1756 | "AsmBlock", "BigOrLittle", "TargetDefinition", "LibrariesDefinition", |
| 1757 | "LibList", "Name", "OptName", "ArgVal", "ArgListH", "ArgList", |
| 1758 | "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", "Function", |
| 1759 | "FnDeclareLinkage", "FunctionProto", "@5", "OptSideEffect", |
| 1760 | "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal", |
| 1761 | "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst", |
| 1762 | "JumpTable", "Inst", "PHIList", "ValueRefList", "ValueRefListE", |
| 1763 | "OptTailCall", "InstVal", "IndexList", "OptVolatile", "MemoryInst", 0 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1764 | }; |
| 1765 | #endif |
| 1766 | |
| 1767 | # ifdef YYPRINT |
| 1768 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 1769 | token YYLEX-NUM. */ |
| 1770 | static const unsigned short int yytoknum[] = |
| 1771 | { |
| 1772 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 1773 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 1774 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 1775 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 1776 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 1777 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 1778 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 1779 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 1780 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 1781 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1782 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
| 1783 | 365, 61, 44, 92, 40, 41, 91, 120, 93, 60, |
| 1784 | 62, 123, 125, 42, 99 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1785 | }; |
| 1786 | # endif |
| 1787 | |
| 1788 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 1789 | static const unsigned char yyr1[] = |
| 1790 | { |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1791 | 0, 125, 126, 126, 127, 127, 128, 128, 128, 128, |
| 1792 | 128, 128, 128, 129, 129, 129, 130, 130, 130, 130, |
| 1793 | 130, 130, 131, 131, 132, 132, 132, 132, 133, 133, |
| 1794 | 133, 133, 134, 134, 135, 135, 136, 136, 137, 137, |
| 1795 | 137, 137, 137, 137, 137, 137, 138, 138, 138, 138, |
| 1796 | 138, 138, 138, 138, 139, 139, 140, 140, 141, 142, |
| 1797 | 142, 143, 143, 144, 144, 145, 145, 146, 146, 147, |
| 1798 | 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, |
| 1799 | 148, 148, 148, 149, 149, 149, 149, 149, 149, 149, |
| 1800 | 149, 149, 149, 150, 150, 151, 151, 151, 151, 152, |
| 1801 | 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
| 1802 | 152, 152, 152, 152, 152, 153, 153, 153, 153, 153, |
| 1803 | 153, 153, 153, 153, 153, 154, 154, 155, 155, 156, |
| 1804 | 157, 157, 157, 157, 157, 158, 158, 158, 159, 158, |
| 1805 | 160, 158, 161, 158, 162, 158, 158, 158, 158, 163, |
| 1806 | 164, 164, 165, 165, 165, 165, 166, 167, 167, 167, |
| 1807 | 168, 168, 169, 169, 170, 171, 171, 172, 172, 172, |
| 1808 | 172, 173, 174, 174, 175, 176, 176, 177, 178, 178, |
| 1809 | 178, 180, 179, 181, 181, 182, 182, 182, 182, 182, |
| 1810 | 182, 182, 182, 182, 182, 182, 183, 183, 184, 184, |
| 1811 | 185, 186, 186, 187, 188, 188, 188, 189, 189, 189, |
| 1812 | 189, 189, 189, 189, 189, 189, 190, 190, 191, 192, |
| 1813 | 192, 193, 193, 194, 194, 195, 195, 196, 196, 196, |
| 1814 | 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, |
| 1815 | 196, 196, 196, 197, 197, 198, 198, 199, 199, 199, |
| 1816 | 199, 199, 199, 199, 199 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1817 | }; |
| 1818 | |
| 1819 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 1820 | static const unsigned char yyr2[] = |
| 1821 | { |
| 1822 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1823 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1824 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1825 | 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, |
| 1826 | 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, |
| 1827 | 1, 1, 1, 2, 0, 2, 0, 3, 2, 0, |
| 1828 | 1, 0, 3, 1, 2, 1, 1, 1, 1, 1, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1829 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1830 | 1, 1, 1, 1, 1, 1, 2, 4, 5, 5, |
| 1831 | 3, 2, 2, 1, 3, 1, 3, 1, 0, 4, |
| 1832 | 3, 3, 4, 4, 3, 2, 2, 2, 2, 2, |
| 1833 | 2, 2, 2, 2, 2, 6, 5, 8, 6, 6, |
| 1834 | 6, 6, 6, 8, 8, 3, 1, 1, 1, 1, |
| 1835 | 2, 2, 4, 2, 1, 4, 2, 4, 0, 7, |
| 1836 | 0, 7, 0, 7, 0, 7, 3, 4, 0, 1, |
| 1837 | 1, 1, 3, 3, 3, 3, 3, 3, 1, 0, |
| 1838 | 1, 1, 1, 0, 2, 3, 1, 1, 3, 1, |
| 1839 | 0, 8, 1, 1, 3, 1, 1, 2, 0, 1, |
| 1840 | 1, 0, 4, 0, 1, 1, 1, 1, 1, 1, |
| 1841 | 1, 1, 1, 3, 1, 5, 1, 1, 1, 1, |
| 1842 | 2, 2, 2, 3, 2, 0, 1, 2, 2, 3, |
| 1843 | 9, 9, 8, 13, 1, 1, 6, 5, 2, 6, |
| 1844 | 7, 1, 3, 1, 0, 2, 1, 5, 5, 5, |
| 1845 | 2, 4, 4, 6, 4, 4, 4, 4, 6, 6, |
| 1846 | 2, 7, 1, 2, 0, 1, 0, 3, 6, 3, |
| 1847 | 6, 2, 4, 6, 4 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1848 | }; |
| 1849 | |
| 1850 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 1851 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 1852 | means the default is an error. */ |
| 1853 | static const unsigned char yydefact[] = |
| 1854 | { |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1855 | 148, 0, 45, 134, 1, 133, 181, 38, 39, 40, |
| 1856 | 41, 42, 43, 44, 0, 46, 205, 130, 131, 205, |
| 1857 | 160, 161, 0, 0, 0, 45, 0, 136, 178, 0, |
| 1858 | 0, 47, 48, 49, 50, 51, 52, 0, 0, 206, |
| 1859 | 202, 37, 175, 176, 177, 201, 0, 0, 0, 0, |
| 1860 | 146, 0, 0, 0, 0, 0, 0, 0, 36, 179, |
| 1861 | 180, 46, 149, 132, 53, 2, 3, 66, 70, 71, |
| 1862 | 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, |
| 1863 | 82, 83, 0, 0, 0, 0, 196, 0, 0, 65, |
| 1864 | 84, 69, 197, 85, 172, 173, 174, 246, 204, 0, |
| 1865 | 0, 0, 0, 159, 147, 137, 135, 127, 128, 0, |
| 1866 | 0, 0, 0, 182, 86, 0, 0, 68, 91, 93, |
| 1867 | 0, 0, 98, 92, 245, 0, 226, 0, 0, 0, |
| 1868 | 0, 46, 214, 215, 6, 7, 8, 9, 10, 11, |
| 1869 | 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, |
| 1870 | 0, 0, 0, 0, 0, 0, 0, 22, 23, 0, |
| 1871 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 203, |
| 1872 | 46, 218, 0, 242, 154, 151, 150, 152, 153, 155, |
| 1873 | 158, 0, 142, 144, 140, 70, 71, 72, 73, 74, |
| 1874 | 75, 76, 77, 78, 79, 80, 0, 0, 0, 0, |
| 1875 | 138, 0, 0, 0, 90, 170, 97, 95, 0, 0, |
| 1876 | 230, 225, 208, 207, 0, 0, 27, 31, 26, 30, |
| 1877 | 25, 29, 24, 28, 32, 33, 0, 0, 56, 56, |
| 1878 | 251, 0, 0, 240, 0, 0, 0, 0, 0, 0, |
| 1879 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1880 | 156, 61, 61, 61, 112, 113, 4, 5, 110, 111, |
| 1881 | 114, 109, 105, 106, 0, 0, 0, 0, 0, 0, |
| 1882 | 0, 0, 0, 0, 0, 0, 0, 0, 108, 107, |
| 1883 | 61, 67, 67, 94, 169, 163, 166, 167, 0, 0, |
| 1884 | 87, 185, 186, 187, 192, 188, 189, 190, 191, 183, |
| 1885 | 0, 194, 199, 198, 200, 0, 209, 0, 0, 0, |
| 1886 | 247, 0, 249, 244, 0, 0, 0, 0, 0, 0, |
| 1887 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1888 | 0, 157, 0, 143, 145, 141, 0, 0, 0, 0, |
| 1889 | 0, 0, 100, 126, 0, 0, 104, 0, 101, 0, |
| 1890 | 0, 0, 0, 139, 88, 89, 162, 164, 0, 59, |
| 1891 | 96, 184, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1892 | 0, 254, 0, 0, 232, 0, 234, 237, 0, 0, |
| 1893 | 235, 236, 0, 0, 0, 231, 0, 252, 0, 0, |
| 1894 | 0, 63, 61, 244, 0, 0, 0, 0, 0, 0, |
| 1895 | 99, 102, 103, 0, 0, 0, 0, 168, 165, 60, |
| 1896 | 54, 0, 193, 0, 0, 224, 56, 57, 56, 221, |
| 1897 | 243, 0, 0, 0, 0, 0, 227, 228, 229, 224, |
| 1898 | 0, 58, 64, 62, 0, 0, 0, 0, 0, 0, |
| 1899 | 125, 0, 0, 0, 0, 0, 171, 0, 0, 0, |
| 1900 | 223, 0, 0, 248, 250, 0, 0, 0, 233, 238, |
| 1901 | 239, 0, 253, 116, 0, 0, 0, 0, 0, 0, |
| 1902 | 0, 0, 0, 55, 195, 0, 0, 0, 222, 219, |
| 1903 | 0, 241, 115, 0, 122, 0, 0, 118, 119, 120, |
| 1904 | 121, 0, 212, 0, 0, 0, 220, 0, 0, 0, |
| 1905 | 210, 0, 211, 0, 0, 117, 123, 124, 0, 0, |
| 1906 | 0, 0, 0, 0, 217, 0, 0, 216, 213 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1907 | }; |
| 1908 | |
| 1909 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 1910 | static const short int yydefgoto[] = |
| 1911 | { |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1912 | -1, 86, 258, 274, 275, 276, 277, 196, 197, 226, |
| 1913 | 198, 25, 15, 37, 446, 310, 391, 410, 333, 392, |
| 1914 | 87, 88, 199, 90, 91, 120, 208, 343, 301, 344, |
| 1915 | 109, 1, 2, 3, 280, 253, 251, 252, 63, 177, |
| 1916 | 50, 104, 181, 92, 357, 286, 287, 288, 38, 96, |
| 1917 | 16, 44, 17, 61, 18, 28, 362, 302, 93, 304, |
| 1918 | 419, 19, 40, 41, 169, 494, 98, 233, 450, 451, |
| 1919 | 170, 171, 371, 172, 173 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1920 | }; |
| 1921 | |
| 1922 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 1923 | STATE-NUM. */ |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1924 | #define YYPACT_NINF -463 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1925 | static const short int yypact[] = |
| 1926 | { |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1927 | -463, 42, 182, 621, -463, -463, -463, -463, -463, -463, |
| 1928 | -463, -463, -463, -463, -15, 347, 64, -463, -463, -12, |
| 1929 | -463, -463, 15, 1, 33, 360, 10, -463, 89, 114, |
| 1930 | 140, -463, -463, -463, -463, -463, -463, 1005, -1, -463, |
| 1931 | -463, 115, -463, -463, -463, -463, 40, 56, 67, 68, |
| 1932 | -463, 59, 114, 1005, 51, 51, 51, 51, -463, -463, |
| 1933 | -463, 347, -463, -463, -463, -463, -463, 66, -463, -463, |
| 1934 | -463, -463, -463, -463, -463, -463, -463, -463, -463, -463, |
| 1935 | -463, -463, 172, 177, 180, 489, -463, 115, 74, -463, |
| 1936 | -463, -97, -463, -463, -463, -463, -463, 1178, -463, 165, |
| 1937 | -17, 188, 170, 171, -463, -463, -463, -463, -463, 1046, |
| 1938 | 1046, 1046, 1087, -463, -463, 80, 81, -463, -463, -97, |
| 1939 | -91, 85, 838, -463, -463, 1046, -463, 142, 1128, 6, |
| 1940 | 248, 347, -463, -463, -463, -463, -463, -463, -463, -463, |
| 1941 | -463, -463, -463, -463, -463, -463, -463, -463, -463, -463, |
| 1942 | 1046, 1046, 1046, 1046, 1046, 1046, 1046, -463, -463, 1046, |
| 1943 | 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -463, |
| 1944 | 347, -463, 35, -463, -463, -463, -463, -463, -463, -463, |
| 1945 | -463, -48, -463, -463, -463, 113, 146, 198, 150, 200, |
| 1946 | 152, 213, 167, 214, 212, 223, 169, 216, 224, 443, |
| 1947 | -463, 1046, 1046, 1046, -463, 879, -463, 109, 117, 620, |
| 1948 | -463, -463, 66, -463, 620, 620, -463, -463, -463, -463, |
| 1949 | -463, -463, -463, -463, -463, -463, 620, 1005, 128, 129, |
| 1950 | -463, 620, 126, 131, 209, 134, 141, 143, 144, 154, |
| 1951 | 156, 157, 620, 620, 620, 158, 1005, 1046, 1046, 228, |
| 1952 | -463, 161, 161, 161, -463, -463, -463, -463, -463, -463, |
| 1953 | -463, -463, -463, -463, 160, 164, 175, 178, 181, 184, |
| 1954 | 87, 1087, 574, 230, 185, 186, 187, 189, -463, -463, |
| 1955 | 161, -33, -101, -97, -463, 115, -463, 163, 176, 923, |
| 1956 | -463, -463, -463, -463, -463, -463, -463, -463, -463, 231, |
| 1957 | 1087, -463, -463, -463, -463, 190, -463, 195, 620, -9, |
| 1958 | -463, -8, -463, 196, 620, 193, 1046, 1046, 1046, 1046, |
| 1959 | 1046, 1046, 1046, 1046, 199, 201, 202, 1046, 620, 620, |
| 1960 | 203, -463, -22, -463, -463, -463, 1087, 1087, 1087, 1087, |
| 1961 | 1087, 1087, -463, -463, -47, -79, -463, -82, -463, 1087, |
| 1962 | 1087, 1087, 1087, -463, -463, -463, -463, -463, 964, 262, |
| 1963 | -463, -463, 293, -75, 301, 302, 210, 620, 324, 620, |
| 1964 | 1046, -463, 217, 620, -463, 218, -463, -463, 219, 220, |
| 1965 | -463, -463, 620, 620, 620, -463, 229, -463, 1046, 314, |
| 1966 | 340, -463, 161, 196, 309, 234, 237, 240, 241, 1087, |
| 1967 | -463, -463, -463, 242, 243, 246, 247, -463, -463, -463, |
| 1968 | 303, 249, -463, 620, 620, 1046, 250, -463, 250, -463, |
| 1969 | 251, 620, 255, 1046, 1046, 1046, -463, -463, -463, 1046, |
| 1970 | 620, -463, -463, -463, 253, 1046, 1087, 1087, 1087, 1087, |
| 1971 | -463, 1087, 1087, 1087, 1087, 365, -463, 348, 259, 258, |
| 1972 | 251, 260, 320, -463, -463, 1046, 261, 620, -463, -463, |
| 1973 | -463, 267, -463, -463, 270, 277, 278, 282, 283, 281, |
| 1974 | 284, 294, 304, -463, -463, 376, 65, 372, -463, -463, |
| 1975 | 305, -463, -463, 1087, -463, 1087, 1087, -463, -463, -463, |
| 1976 | -463, 620, -463, 726, 149, 399, -463, 306, 307, 310, |
| 1977 | -463, 312, -463, 726, 620, -463, -463, -463, 405, 315, |
| 1978 | 352, 620, 409, 411, -463, 620, 620, -463, -463 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1979 | }; |
| 1980 | |
| 1981 | /* YYPGOTO[NTERM-NUM]. */ |
| 1982 | static const short int yypgoto[] = |
| 1983 | { |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1984 | -463, -463, -463, 336, 339, 341, 342, -129, -128, -462, |
| 1985 | -463, 396, 415, -118, -463, -225, 82, -463, -244, -463, |
| 1986 | -50, -463, -37, -463, -56, 321, -463, -102, 252, -247, |
| 1987 | 5, -463, -463, -463, -463, -463, -463, -463, 390, -463, |
| 1988 | -463, -463, -463, 2, -463, 92, -463, -463, 391, -463, |
| 1989 | -463, -463, -463, -463, 450, -463, -463, -459, -57, 62, |
| 1990 | -105, -463, 436, -463, -463, -463, -463, -463, 86, 28, |
| 1991 | -463, -463, 69, -463, -463 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1992 | }; |
| 1993 | |
| 1994 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 1995 | positive, shift that token. If negative, reduce the rule which |
| 1996 | number is the opposite. If zero, do what YYDEFACT says. |
| 1997 | If YYTABLE_NINF, syntax error. */ |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 1998 | #define YYTABLE_NINF -130 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1999 | static const short int yytable[] = |
| 2000 | { |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2001 | 89, 224, 225, 106, 312, 26, 367, 369, 334, 335, |
| 2002 | 200, 39, 389, 227, 493, 214, 89, -67, 42, 355, |
| 2003 | 210, 203, 123, 213, 345, 347, 123, 215, 94, 119, |
| 2004 | 399, 204, 503, 399, 501, 390, 353, 399, 175, 176, |
| 2005 | 402, 401, 4, 26, 509, 412, 29, 230, 368, 368, |
| 2006 | 234, 235, 246, 363, 236, 237, 238, 239, 240, 241, |
| 2007 | 110, 111, 112, 245, 249, 399, 119, 46, 47, 48, |
| 2008 | 250, 400, 182, 183, 184, 216, 217, 218, 219, 220, |
| 2009 | 221, 222, 223, 107, 108, 354, 49, 39, 209, 121, |
| 2010 | 123, 209, 65, 66, 52, 117, 185, 186, 187, 188, |
| 2011 | 189, 190, 191, 192, 193, 194, 195, 79, 80, 20, |
| 2012 | 43, 21, 51, 228, 229, 209, 231, 232, 209, 209, |
| 2013 | 95, 58, 209, 209, 209, 209, 209, 209, 242, 243, |
| 2014 | 244, 209, 247, 248, 59, 81, 60, 20, 62, 21, |
| 2015 | 254, 255, 279, 330, 64, 281, 282, 283, 433, -27, |
| 2016 | -27, 99, 303, -26, -26, -25, -25, 303, 303, 216, |
| 2017 | 217, 218, 219, 220, 221, 222, 223, 100, 285, 303, |
| 2018 | -24, -24, 256, 257, 303, 103, 114, 308, 101, 102, |
| 2019 | -68, 115, -129, 492, 116, 303, 303, 303, 122, 174, |
| 2020 | 89, 453, 178, 454, 179, 180, 328, 201, 202, 205, |
| 2021 | 82, 211, -31, 83, -30, 342, 84, 5, 85, 89, |
| 2022 | 329, 209, 375, 6, 377, 378, 379, -29, -28, -34, |
| 2023 | 259, 289, 385, 7, 8, 9, 10, 11, 12, 13, |
| 2024 | -35, 260, 290, 283, 393, 394, 395, 396, 397, 398, |
| 2025 | 309, 311, 314, 315, 14, 316, 317, 403, 404, 405, |
| 2026 | 406, 303, 331, 318, 348, 319, 320, 303, 216, 217, |
| 2027 | 218, 219, 220, 221, 222, 223, 321, 502, 322, 323, |
| 2028 | 327, 303, 303, 332, 336, 358, 305, 306, 337, 374, |
| 2029 | 209, 376, 209, 209, 209, 380, 381, 356, 307, 338, |
| 2030 | 209, 359, 339, 313, 361, 340, 389, 440, 341, 349, |
| 2031 | 350, 351, 364, 352, 324, 325, 326, 365, 370, 373, |
| 2032 | 303, 382, 303, 383, 384, 388, 303, 411, 458, 459, |
| 2033 | 460, 285, 413, 414, 415, 303, 303, 303, 417, 421, |
| 2034 | 423, 424, 425, 209, 465, 466, 467, 468, 431, 469, |
| 2035 | 470, 471, 472, 429, 432, 435, 436, 224, 225, 437, |
| 2036 | 478, 430, 438, 439, 441, 442, 303, 303, 443, 444, |
| 2037 | 445, 447, 452, 455, 303, 224, 225, 457, 463, 473, |
| 2038 | 366, 475, 474, 303, 476, 477, 372, 368, 209, 479, |
| 2039 | 53, 497, 481, 498, 499, 482, 209, 209, 209, 483, |
| 2040 | 386, 387, 209, 484, 485, 486, 487, 491, 464, 488, |
| 2041 | 303, 7, 8, 9, 10, 54, 12, 55, 495, 489, |
| 2042 | 56, 30, 31, 32, 33, 34, 35, 36, 209, 490, |
| 2043 | 504, 505, 506, 496, 508, 507, 511, 512, 513, 416, |
| 2044 | 515, 418, 516, 165, 303, 422, 166, 97, 167, 168, |
| 2045 | 57, 409, 105, 207, 426, 427, 428, 303, 65, 66, |
| 2046 | 408, 278, 113, 27, 303, 45, 420, 461, 303, 303, |
| 2047 | 0, 0, 434, 0, 0, 20, 0, 21, 0, 261, |
| 2048 | 0, 0, 0, 0, 0, 448, 449, 0, 0, 0, |
| 2049 | 0, 262, 263, 456, 0, 0, 0, 0, 0, 0, |
| 2050 | 0, 0, 462, 0, 65, 66, 0, 117, 68, 69, |
| 2051 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 2052 | 80, 20, 0, 21, 0, 0, 0, 0, 0, 480, |
| 2053 | 0, 134, 135, 136, 137, 138, 139, 140, 141, 142, |
| 2054 | 143, 144, 145, 146, 147, 148, 149, 81, 0, 0, |
| 2055 | 0, 0, 264, 0, 265, 266, 157, 158, 0, 267, |
| 2056 | 268, 269, 0, 500, 0, 0, 0, 0, 0, 270, |
| 2057 | 0, 0, 271, 0, 272, 0, 510, 273, 0, 0, |
| 2058 | 0, 0, 0, 514, 0, 0, 0, 517, 518, 65, |
| 2059 | 66, 0, 117, 185, 186, 187, 188, 189, 190, 191, |
| 2060 | 192, 193, 194, 195, 79, 80, 20, 0, 21, 0, |
| 2061 | 0, 0, 82, 0, 0, 83, 0, 0, 84, 0, |
| 2062 | 85, 118, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2063 | 0, 0, 81, 291, 292, 65, 66, 293, 0, 0, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2064 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2065 | 0, -37, 20, 20, 21, 21, 294, 295, 296, 0, |
| 2066 | 0, 0, 6, -37, -37, 0, 0, 0, 297, 298, |
| 2067 | 0, 0, -37, -37, -37, -37, -37, -37, -37, 0, |
| 2068 | 0, -37, 22, 0, 0, 0, 0, 0, 0, 23, |
| 2069 | 0, 299, 0, 24, 0, 0, 0, 82, 0, 0, |
| 2070 | 83, 0, 0, 84, 0, 85, 346, 0, 134, 135, |
| 2071 | 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, |
| 2072 | 146, 147, 148, 149, 0, 0, 0, 0, 0, 264, |
| 2073 | 0, 265, 266, 157, 158, 0, 267, 268, 269, 291, |
| 2074 | 292, 0, 0, 293, 0, 0, 0, 0, 0, 300, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2075 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2076 | 0, 0, 294, 295, 296, 0, 0, 0, 0, 0, |
| 2077 | 0, 0, 0, 0, 297, 298, 0, 0, 0, 0, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2078 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2079 | 0, 0, 0, 0, 0, 0, 0, 299, 0, 0, |
| 2080 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2081 | 0, 0, 0, 0, 134, 135, 136, 137, 138, 139, |
| 2082 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, |
| 2083 | 0, 0, 0, 0, 0, 264, 0, 265, 266, 157, |
| 2084 | 158, 0, 267, 268, 269, 0, 0, 0, 0, 0, |
| 2085 | 0, 0, 0, 65, 66, 300, 117, 68, 69, 70, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2086 | 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2087 | 20, 0, 21, 0, 0, 0, 0, 0, 0, 0, |
| 2088 | 0, 0, 0, 0, 0, 206, 0, 0, 0, 0, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2089 | 0, 0, 0, 0, 65, 66, 81, 117, 68, 69, |
| 2090 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2091 | 80, 20, 0, 21, 0, 0, 0, 0, 0, 0, |
| 2092 | 0, 0, 0, 0, 0, 0, 284, 0, 0, 0, |
| 2093 | 0, 0, 0, 0, 0, 0, 0, 81, 65, 66, |
| 2094 | 0, 117, 68, 69, 70, 71, 72, 73, 74, 75, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2095 | 76, 77, 78, 79, 80, 20, 0, 21, 0, 0, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2096 | 0, 82, 0, 0, 83, 0, 0, 84, 0, 85, |
| 2097 | 360, 0, 0, 0, 0, 0, 0, 0, 0, 65, |
| 2098 | 66, 81, 117, 68, 69, 70, 71, 72, 73, 74, |
| 2099 | 75, 76, 77, 78, 79, 80, 20, 0, 21, 0, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2100 | 0, 0, 82, 0, 0, 83, 0, 0, 84, 0, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2101 | 85, 407, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2102 | 65, 66, 81, 67, 68, 69, 70, 71, 72, 73, |
| 2103 | 74, 75, 76, 77, 78, 79, 80, 20, 0, 21, |
| 2104 | 0, 0, 0, 0, 0, 0, 82, 0, 0, 83, |
| 2105 | 0, 0, 84, 0, 85, 0, 0, 0, 0, 0, |
| 2106 | 0, 65, 66, 81, 117, 68, 69, 70, 71, 72, |
| 2107 | 73, 74, 75, 76, 77, 78, 79, 80, 20, 0, |
| 2108 | 21, 0, 0, 0, 0, 0, 0, 82, 0, 0, |
| 2109 | 83, 0, 0, 84, 0, 85, 0, 0, 0, 0, |
| 2110 | 0, 0, 65, 66, 81, 117, 185, 186, 187, 188, |
| 2111 | 189, 190, 191, 192, 193, 194, 195, 79, 80, 20, |
| 2112 | 0, 21, 0, 0, 0, 0, 0, 0, 82, 0, |
| 2113 | 0, 83, 0, 0, 84, 0, 85, 0, 0, 0, |
| 2114 | 0, 0, 0, 65, 66, 81, 212, 68, 69, 70, |
| 2115 | 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 2116 | 20, 0, 21, 0, 0, 0, 0, 0, 0, 82, |
| 2117 | 0, 0, 83, 0, 0, 84, 0, 85, 0, 0, |
| 2118 | 0, 0, 0, 0, 0, 0, 81, 0, 0, 0, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2119 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2120 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2121 | 82, 0, 0, 83, 0, 0, 84, 0, 85, 0, |
| 2122 | 0, 0, 0, 124, 0, 0, 0, 0, 0, 0, |
| 2123 | 0, 0, 0, 0, 0, 0, 0, 125, 0, 0, |
| 2124 | 0, 0, 0, 0, 0, 0, 0, 126, 127, 0, |
| 2125 | 0, 82, 0, 0, 83, 0, 0, 84, 0, 85, |
| 2126 | 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, |
| 2127 | 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, |
| 2128 | 148, 149, 150, 151, 152, 0, 0, 153, 154, 155, |
| 2129 | 156, 157, 158, 159, 160, 161, 162, 163, 164 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2130 | }; |
| 2131 | |
| 2132 | static const short int yycheck[] = |
| 2133 | { |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2134 | 37, 130, 130, 53, 229, 3, 15, 15, 252, 253, |
| 2135 | 112, 23, 34, 131, 476, 9, 53, 114, 30, 120, |
| 2136 | 125, 112, 123, 128, 271, 272, 123, 21, 29, 85, |
| 2137 | 112, 122, 494, 112, 493, 57, 280, 112, 55, 56, |
| 2138 | 122, 120, 0, 41, 503, 120, 61, 152, 57, 57, |
| 2139 | 155, 156, 170, 300, 159, 160, 161, 162, 163, 164, |
| 2140 | 55, 56, 57, 168, 112, 112, 122, 52, 53, 54, |
| 2141 | 118, 118, 109, 110, 111, 10, 11, 12, 13, 14, |
| 2142 | 15, 16, 17, 32, 33, 118, 71, 23, 125, 87, |
| 2143 | 123, 128, 5, 6, 61, 8, 9, 10, 11, 12, |
| 2144 | 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, |
| 2145 | 122, 24, 111, 150, 151, 152, 153, 154, 155, 156, |
| 2146 | 121, 111, 159, 160, 161, 162, 163, 164, 165, 166, |
| 2147 | 167, 168, 97, 98, 45, 48, 47, 22, 24, 24, |
| 2148 | 27, 28, 199, 248, 4, 201, 202, 203, 392, 3, |
| 2149 | 4, 111, 209, 3, 4, 3, 4, 214, 215, 10, |
| 2150 | 11, 12, 13, 14, 15, 16, 17, 111, 205, 226, |
| 2151 | 3, 4, 3, 4, 231, 116, 4, 227, 111, 111, |
| 2152 | 114, 4, 0, 118, 4, 242, 243, 244, 114, 24, |
| 2153 | 227, 416, 4, 418, 24, 24, 246, 117, 117, 114, |
| 2154 | 113, 59, 4, 116, 4, 118, 119, 25, 121, 246, |
| 2155 | 247, 248, 317, 31, 319, 320, 321, 4, 4, 7, |
| 2156 | 4, 112, 327, 41, 42, 43, 44, 45, 46, 47, |
| 2157 | 7, 7, 115, 289, 336, 337, 338, 339, 340, 341, |
| 2158 | 112, 112, 116, 112, 62, 36, 112, 349, 350, 351, |
| 2159 | 352, 308, 24, 112, 24, 112, 112, 314, 10, 11, |
| 2160 | 12, 13, 14, 15, 16, 17, 112, 118, 112, 112, |
| 2161 | 112, 328, 329, 112, 114, 112, 214, 215, 114, 316, |
| 2162 | 317, 318, 319, 320, 321, 322, 323, 285, 226, 114, |
| 2163 | 327, 115, 114, 231, 63, 114, 34, 399, 114, 114, |
| 2164 | 114, 114, 112, 114, 242, 243, 244, 112, 112, 116, |
| 2165 | 367, 112, 369, 112, 112, 112, 373, 24, 423, 424, |
| 2166 | 425, 358, 21, 21, 114, 382, 383, 384, 4, 112, |
| 2167 | 112, 112, 112, 370, 436, 437, 438, 439, 24, 441, |
| 2168 | 442, 443, 444, 114, 4, 36, 112, 476, 476, 112, |
| 2169 | 455, 388, 112, 112, 112, 112, 413, 414, 112, 112, |
| 2170 | 57, 112, 112, 112, 421, 494, 494, 112, 115, 4, |
| 2171 | 308, 112, 24, 430, 116, 115, 314, 57, 415, 118, |
| 2172 | 20, 483, 115, 485, 486, 115, 423, 424, 425, 112, |
| 2173 | 328, 329, 429, 115, 112, 112, 115, 21, 435, 115, |
| 2174 | 457, 41, 42, 43, 44, 45, 46, 47, 36, 115, |
| 2175 | 50, 64, 65, 66, 67, 68, 69, 70, 455, 115, |
| 2176 | 21, 115, 115, 118, 112, 115, 21, 112, 76, 367, |
| 2177 | 21, 369, 21, 97, 491, 373, 97, 41, 97, 97, |
| 2178 | 25, 359, 52, 122, 382, 383, 384, 504, 5, 6, |
| 2179 | 358, 199, 61, 3, 511, 19, 370, 429, 515, 516, |
| 2180 | -1, -1, 393, -1, -1, 22, -1, 24, -1, 26, |
| 2181 | -1, -1, -1, -1, -1, 413, 414, -1, -1, -1, |
| 2182 | -1, 38, 39, 421, -1, -1, -1, -1, -1, -1, |
| 2183 | -1, -1, 430, -1, 5, 6, -1, 8, 9, 10, |
| 2184 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 2185 | 21, 22, -1, 24, -1, -1, -1, -1, -1, 457, |
| 2186 | -1, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 2187 | 87, 88, 89, 90, 91, 92, 93, 48, -1, -1, |
| 2188 | -1, -1, 99, -1, 101, 102, 103, 104, -1, 106, |
| 2189 | 107, 108, -1, 491, -1, -1, -1, -1, -1, 116, |
| 2190 | -1, -1, 119, -1, 121, -1, 504, 124, -1, -1, |
| 2191 | -1, -1, -1, 511, -1, -1, -1, 515, 516, 5, |
| 2192 | 6, -1, 8, 9, 10, 11, 12, 13, 14, 15, |
| 2193 | 16, 17, 18, 19, 20, 21, 22, -1, 24, -1, |
| 2194 | -1, -1, 113, -1, -1, 116, -1, -1, 119, -1, |
| 2195 | 121, 122, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2196 | -1, -1, 48, 3, 4, 5, 6, 7, -1, -1, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2197 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2198 | -1, 20, 22, 22, 24, 24, 26, 27, 28, -1, |
| 2199 | -1, -1, 31, 32, 33, -1, -1, -1, 38, 39, |
| 2200 | -1, -1, 41, 42, 43, 44, 45, 46, 47, -1, |
| 2201 | -1, 50, 51, -1, -1, -1, -1, -1, -1, 58, |
| 2202 | -1, 61, -1, 62, -1, -1, -1, 113, -1, -1, |
| 2203 | 116, -1, -1, 119, -1, 121, 122, -1, 78, 79, |
| 2204 | 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, |
| 2205 | 90, 91, 92, 93, -1, -1, -1, -1, -1, 99, |
| 2206 | -1, 101, 102, 103, 104, -1, 106, 107, 108, 3, |
| 2207 | 4, -1, -1, 7, -1, -1, -1, -1, -1, 119, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2208 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2209 | -1, -1, 26, 27, 28, -1, -1, -1, -1, -1, |
| 2210 | -1, -1, -1, -1, 38, 39, -1, -1, -1, -1, |
| 2211 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2212 | -1, -1, -1, -1, -1, -1, -1, 61, -1, -1, |
| 2213 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2214 | -1, -1, -1, -1, 78, 79, 80, 81, 82, 83, |
| 2215 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 2216 | -1, -1, -1, -1, -1, 99, -1, 101, 102, 103, |
| 2217 | 104, -1, 106, 107, 108, -1, -1, -1, -1, -1, |
| 2218 | -1, -1, -1, 5, 6, 119, 8, 9, 10, 11, |
| 2219 | 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, |
| 2220 | 22, -1, 24, -1, -1, -1, -1, -1, -1, -1, |
| 2221 | -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, |
| 2222 | -1, -1, -1, -1, 5, 6, 48, 8, 9, 10, |
| 2223 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 2224 | 21, 22, -1, 24, -1, -1, -1, -1, -1, -1, |
| 2225 | -1, -1, -1, -1, -1, -1, 37, -1, -1, -1, |
| 2226 | -1, -1, -1, -1, -1, -1, -1, 48, 5, 6, |
| 2227 | -1, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2228 | 17, 18, 19, 20, 21, 22, -1, 24, -1, -1, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2229 | -1, 113, -1, -1, 116, -1, -1, 119, -1, 121, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2230 | 37, -1, -1, -1, -1, -1, -1, -1, -1, 5, |
| 2231 | 6, 48, 8, 9, 10, 11, 12, 13, 14, 15, |
| 2232 | 16, 17, 18, 19, 20, 21, 22, -1, 24, -1, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2233 | -1, -1, 113, -1, -1, 116, -1, -1, 119, -1, |
| 2234 | 121, 37, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2235 | 5, 6, 48, 8, 9, 10, 11, 12, 13, 14, |
| 2236 | 15, 16, 17, 18, 19, 20, 21, 22, -1, 24, |
| 2237 | -1, -1, -1, -1, -1, -1, 113, -1, -1, 116, |
| 2238 | -1, -1, 119, -1, 121, -1, -1, -1, -1, -1, |
| 2239 | -1, 5, 6, 48, 8, 9, 10, 11, 12, 13, |
| 2240 | 14, 15, 16, 17, 18, 19, 20, 21, 22, -1, |
| 2241 | 24, -1, -1, -1, -1, -1, -1, 113, -1, -1, |
| 2242 | 116, -1, -1, 119, -1, 121, -1, -1, -1, -1, |
| 2243 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
| 2244 | 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, |
| 2245 | -1, 24, -1, -1, -1, -1, -1, -1, 113, -1, |
| 2246 | -1, 116, -1, -1, 119, -1, 121, -1, -1, -1, |
| 2247 | -1, -1, -1, 5, 6, 48, 8, 9, 10, 11, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2248 | 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2249 | 22, -1, 24, -1, -1, -1, -1, -1, -1, 113, |
| 2250 | -1, -1, 116, -1, -1, 119, -1, 121, -1, -1, |
| 2251 | -1, -1, -1, -1, -1, -1, 48, -1, -1, -1, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2252 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2253 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2254 | 113, -1, -1, 116, -1, -1, 119, -1, 121, -1, |
| 2255 | -1, -1, -1, 35, -1, -1, -1, -1, -1, -1, |
| 2256 | -1, -1, -1, -1, -1, -1, -1, 49, -1, -1, |
| 2257 | -1, -1, -1, -1, -1, -1, -1, 59, 60, -1, |
| 2258 | -1, 113, -1, -1, 116, -1, -1, 119, -1, 121, |
| 2259 | 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, |
| 2260 | 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, |
| 2261 | 92, 93, 94, 95, 96, -1, -1, 99, 100, 101, |
| 2262 | 102, 103, 104, 105, 106, 107, 108, 109, 110 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2263 | }; |
| 2264 | |
| 2265 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 2266 | symbol of state STATE-NUM. */ |
| 2267 | static const unsigned char yystos[] = |
| 2268 | { |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2269 | 0, 156, 157, 158, 0, 25, 31, 41, 42, 43, |
| 2270 | 44, 45, 46, 47, 62, 137, 175, 177, 179, 186, |
| 2271 | 22, 24, 51, 58, 62, 136, 168, 179, 180, 61, |
| 2272 | 64, 65, 66, 67, 68, 69, 70, 138, 173, 23, |
| 2273 | 187, 188, 30, 122, 176, 187, 52, 53, 54, 71, |
| 2274 | 165, 111, 61, 20, 45, 47, 50, 137, 111, 45, |
| 2275 | 47, 178, 24, 163, 4, 5, 6, 8, 9, 10, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2276 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2277 | 21, 48, 113, 116, 119, 121, 126, 145, 146, 147, |
| 2278 | 148, 149, 168, 183, 29, 121, 174, 136, 191, 111, |
| 2279 | 111, 111, 111, 116, 166, 163, 145, 32, 33, 155, |
| 2280 | 155, 155, 155, 173, 4, 4, 4, 8, 122, 149, |
| 2281 | 150, 168, 114, 123, 35, 49, 59, 60, 72, 73, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2282 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 2283 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2284 | 94, 95, 96, 99, 100, 101, 102, 103, 104, 105, |
| 2285 | 106, 107, 108, 109, 110, 128, 129, 130, 131, 189, |
| 2286 | 195, 196, 198, 199, 24, 55, 56, 164, 4, 24, |
| 2287 | 24, 167, 147, 147, 147, 9, 10, 11, 12, 13, |
| 2288 | 14, 15, 16, 17, 18, 19, 132, 133, 135, 147, |
| 2289 | 152, 117, 117, 112, 122, 114, 37, 150, 151, 147, |
| 2290 | 185, 59, 8, 185, 9, 21, 10, 11, 12, 13, |
| 2291 | 14, 15, 16, 17, 132, 133, 134, 138, 147, 147, |
| 2292 | 185, 147, 147, 192, 185, 185, 185, 185, 185, 185, |
| 2293 | 185, 185, 147, 147, 147, 185, 138, 97, 98, 112, |
| 2294 | 118, 161, 162, 160, 27, 28, 3, 4, 127, 4, |
| 2295 | 7, 26, 38, 39, 99, 101, 102, 106, 107, 108, |
| 2296 | 116, 119, 121, 124, 128, 129, 130, 131, 153, 183, |
| 2297 | 159, 149, 149, 149, 37, 147, 170, 171, 172, 112, |
| 2298 | 115, 3, 4, 7, 26, 27, 28, 38, 39, 61, |
| 2299 | 119, 153, 182, 183, 184, 184, 184, 184, 145, 112, |
| 2300 | 140, 112, 140, 184, 116, 112, 36, 112, 112, 112, |
| 2301 | 112, 112, 112, 112, 184, 184, 184, 112, 145, 147, |
| 2302 | 185, 24, 112, 143, 143, 143, 114, 114, 114, 114, |
| 2303 | 114, 114, 118, 152, 154, 154, 122, 154, 24, 114, |
| 2304 | 114, 114, 114, 143, 118, 120, 168, 169, 112, 115, |
| 2305 | 37, 63, 181, 154, 112, 112, 184, 15, 57, 15, |
| 2306 | 112, 197, 184, 116, 147, 185, 147, 185, 185, 185, |
| 2307 | 147, 147, 112, 112, 112, 185, 184, 184, 112, 34, |
| 2308 | 57, 141, 144, 152, 152, 152, 152, 152, 152, 112, |
| 2309 | 118, 120, 122, 152, 152, 152, 152, 37, 170, 141, |
| 2310 | 142, 24, 120, 21, 21, 114, 184, 4, 184, 185, |
| 2311 | 193, 112, 184, 112, 112, 112, 184, 184, 184, 114, |
| 2312 | 147, 24, 4, 143, 197, 36, 112, 112, 112, 112, |
| 2313 | 152, 112, 112, 112, 112, 57, 139, 112, 184, 184, |
| 2314 | 193, 194, 112, 140, 140, 112, 184, 112, 185, 185, |
| 2315 | 185, 194, 184, 115, 147, 152, 152, 152, 152, 152, |
| 2316 | 152, 152, 152, 4, 24, 112, 116, 115, 185, 118, |
| 2317 | 184, 115, 115, 112, 115, 112, 112, 115, 115, 115, |
| 2318 | 115, 21, 118, 134, 190, 36, 118, 152, 152, 152, |
| 2319 | 184, 182, 118, 134, 21, 115, 115, 115, 112, 182, |
| 2320 | 184, 21, 112, 76, 184, 21, 21, 184, 184 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2321 | }; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2322 | |
| 2323 | #define yyerrok (yyerrstatus = 0) |
| 2324 | #define yyclearin (yychar = YYEMPTY) |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2325 | #define YYEMPTY (-2) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2326 | #define YYEOF 0 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2327 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2328 | #define YYACCEPT goto yyacceptlab |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2329 | #define YYABORT goto yyabortlab |
| 2330 | #define YYERROR goto yyerrorlab |
| 2331 | |
| 2332 | |
| 2333 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 2334 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2335 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2336 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2337 | #define YYFAIL goto yyerrlab |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2338 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2339 | #define YYRECOVERING() (!!yyerrstatus) |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2340 | |
| 2341 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2342 | do \ |
| 2343 | if (yychar == YYEMPTY && yylen == 1) \ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2344 | { \ |
| 2345 | yychar = (Token); \ |
| 2346 | yylval = (Value); \ |
| 2347 | yytoken = YYTRANSLATE (yychar); \ |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2348 | YYPOPSTACK; \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2349 | goto yybackup; \ |
| 2350 | } \ |
| 2351 | else \ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2352 | { \ |
| 2353 | yyerror (YY_("syntax error: cannot back up")); \ |
| 2354 | YYERROR; \ |
| 2355 | } \ |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2356 | while (0) |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2357 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2358 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2359 | #define YYTERROR 1 |
| 2360 | #define YYERRCODE 256 |
| 2361 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2362 | |
| 2363 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
| 2364 | If N is 0, then set CURRENT to the empty location which ends |
| 2365 | the previous symbol: RHS[0] (always defined). */ |
| 2366 | |
| 2367 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| 2368 | #ifndef YYLLOC_DEFAULT |
| 2369 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 2370 | do \ |
| 2371 | if (N) \ |
| 2372 | { \ |
| 2373 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
| 2374 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
| 2375 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
| 2376 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
| 2377 | } \ |
| 2378 | else \ |
| 2379 | { \ |
| 2380 | (Current).first_line = (Current).last_line = \ |
| 2381 | YYRHSLOC (Rhs, 0).last_line; \ |
| 2382 | (Current).first_column = (Current).last_column = \ |
| 2383 | YYRHSLOC (Rhs, 0).last_column; \ |
| 2384 | } \ |
| 2385 | while (0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2386 | #endif |
| 2387 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2388 | |
| 2389 | /* YY_LOCATION_PRINT -- Print the location on the stream. |
| 2390 | This macro was not mandated originally: define only if we know |
| 2391 | we won't break user code: when these are the locations we know. */ |
| 2392 | |
| 2393 | #ifndef YY_LOCATION_PRINT |
| 2394 | # if YYLTYPE_IS_TRIVIAL |
| 2395 | # define YY_LOCATION_PRINT(File, Loc) \ |
| 2396 | fprintf (File, "%d.%d-%d.%d", \ |
| 2397 | (Loc).first_line, (Loc).first_column, \ |
| 2398 | (Loc).last_line, (Loc).last_column) |
| 2399 | # else |
| 2400 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 2401 | # endif |
| 2402 | #endif |
| 2403 | |
| 2404 | |
| 2405 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 2406 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2407 | #ifdef YYLEX_PARAM |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2408 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2409 | #else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2410 | # define YYLEX yylex () |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2411 | #endif |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2412 | |
| 2413 | /* Enable debugging if requested. */ |
| 2414 | #if YYDEBUG |
| 2415 | |
| 2416 | # ifndef YYFPRINTF |
| 2417 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 2418 | # define YYFPRINTF fprintf |
| 2419 | # endif |
| 2420 | |
| 2421 | # define YYDPRINTF(Args) \ |
| 2422 | do { \ |
| 2423 | if (yydebug) \ |
| 2424 | YYFPRINTF Args; \ |
| 2425 | } while (0) |
| 2426 | |
| 2427 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 2428 | do { \ |
| 2429 | if (yydebug) \ |
| 2430 | { \ |
| 2431 | YYFPRINTF (stderr, "%s ", Title); \ |
| 2432 | yysymprint (stderr, \ |
| 2433 | Type, Value); \ |
| 2434 | YYFPRINTF (stderr, "\n"); \ |
| 2435 | } \ |
| 2436 | } while (0) |
| 2437 | |
| 2438 | /*------------------------------------------------------------------. |
| 2439 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 2440 | | TOP (included). | |
| 2441 | `------------------------------------------------------------------*/ |
| 2442 | |
| 2443 | #if defined (__STDC__) || defined (__cplusplus) |
| 2444 | static void |
| 2445 | yy_stack_print (short int *bottom, short int *top) |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2446 | #else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2447 | static void |
| 2448 | yy_stack_print (bottom, top) |
| 2449 | short int *bottom; |
| 2450 | short int *top; |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2451 | #endif |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2452 | { |
| 2453 | YYFPRINTF (stderr, "Stack now"); |
| 2454 | for (/* Nothing. */; bottom <= top; ++bottom) |
| 2455 | YYFPRINTF (stderr, " %d", *bottom); |
| 2456 | YYFPRINTF (stderr, "\n"); |
| 2457 | } |
| 2458 | |
| 2459 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 2460 | do { \ |
| 2461 | if (yydebug) \ |
| 2462 | yy_stack_print ((Bottom), (Top)); \ |
| 2463 | } while (0) |
| 2464 | |
| 2465 | |
| 2466 | /*------------------------------------------------. |
| 2467 | | Report that the YYRULE is going to be reduced. | |
| 2468 | `------------------------------------------------*/ |
| 2469 | |
| 2470 | #if defined (__STDC__) || defined (__cplusplus) |
| 2471 | static void |
| 2472 | yy_reduce_print (int yyrule) |
| 2473 | #else |
| 2474 | static void |
| 2475 | yy_reduce_print (yyrule) |
| 2476 | int yyrule; |
Chris Lattner | 59c85e9 | 2006-10-15 23:27:25 +0000 | [diff] [blame] | 2477 | #endif |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2478 | { |
| 2479 | int yyi; |
| 2480 | unsigned long int yylno = yyrline[yyrule]; |
| 2481 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", |
| 2482 | yyrule - 1, yylno); |
| 2483 | /* Print the symbols being reduced, and their result. */ |
| 2484 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
| 2485 | YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); |
| 2486 | YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); |
| 2487 | } |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 2488 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2489 | # define YY_REDUCE_PRINT(Rule) \ |
| 2490 | do { \ |
| 2491 | if (yydebug) \ |
| 2492 | yy_reduce_print (Rule); \ |
| 2493 | } while (0) |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 2494 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2495 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 2496 | multiple parsers can coexist. */ |
| 2497 | int yydebug; |
| 2498 | #else /* !YYDEBUG */ |
| 2499 | # define YYDPRINTF(Args) |
| 2500 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
| 2501 | # define YY_STACK_PRINT(Bottom, Top) |
| 2502 | # define YY_REDUCE_PRINT(Rule) |
| 2503 | #endif /* !YYDEBUG */ |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 2504 | |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 2505 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2506 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2507 | #ifndef YYINITDEPTH |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2508 | # define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2509 | #endif |
| 2510 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2511 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 2512 | if the built-in stack extension method is used). |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2513 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2514 | Do not make this value too large; the results are undefined if |
| 2515 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
| 2516 | evaluated with infinite-precision integer arithmetic. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2517 | |
| 2518 | #ifndef YYMAXDEPTH |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2519 | # define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2520 | #endif |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2521 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2522 | |
| 2523 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2524 | #if YYERROR_VERBOSE |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2525 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2526 | # ifndef yystrlen |
| 2527 | # if defined (__GLIBC__) && defined (_STRING_H) |
| 2528 | # define yystrlen strlen |
| 2529 | # else |
| 2530 | /* Return the length of YYSTR. */ |
| 2531 | static YYSIZE_T |
| 2532 | # if defined (__STDC__) || defined (__cplusplus) |
| 2533 | yystrlen (const char *yystr) |
| 2534 | # else |
| 2535 | yystrlen (yystr) |
| 2536 | const char *yystr; |
| 2537 | # endif |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2538 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2539 | const char *yys = yystr; |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2540 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2541 | while (*yys++ != '\0') |
| 2542 | continue; |
| 2543 | |
| 2544 | return yys - yystr - 1; |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2545 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2546 | # endif |
| 2547 | # endif |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2548 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2549 | # ifndef yystpcpy |
| 2550 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
| 2551 | # define yystpcpy stpcpy |
| 2552 | # else |
| 2553 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 2554 | YYDEST. */ |
| 2555 | static char * |
| 2556 | # if defined (__STDC__) || defined (__cplusplus) |
| 2557 | yystpcpy (char *yydest, const char *yysrc) |
| 2558 | # else |
| 2559 | yystpcpy (yydest, yysrc) |
| 2560 | char *yydest; |
| 2561 | const char *yysrc; |
| 2562 | # endif |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2563 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2564 | char *yyd = yydest; |
| 2565 | const char *yys = yysrc; |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2566 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2567 | while ((*yyd++ = *yys++) != '\0') |
| 2568 | continue; |
| 2569 | |
| 2570 | return yyd - 1; |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2571 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2572 | # endif |
| 2573 | # endif |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2574 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2575 | # ifndef yytnamerr |
| 2576 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
| 2577 | quotes and backslashes, so that it's suitable for yyerror. The |
| 2578 | heuristic is that double-quoting is unnecessary unless the string |
| 2579 | contains an apostrophe, a comma, or backslash (other than |
| 2580 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
| 2581 | null, do not copy; instead, return the length of what the result |
| 2582 | would have been. */ |
| 2583 | static YYSIZE_T |
| 2584 | yytnamerr (char *yyres, const char *yystr) |
| 2585 | { |
| 2586 | if (*yystr == '"') |
| 2587 | { |
| 2588 | size_t yyn = 0; |
| 2589 | char const *yyp = yystr; |
| 2590 | |
| 2591 | for (;;) |
| 2592 | switch (*++yyp) |
| 2593 | { |
| 2594 | case '\'': |
| 2595 | case ',': |
| 2596 | goto do_not_strip_quotes; |
| 2597 | |
| 2598 | case '\\': |
| 2599 | if (*++yyp != '\\') |
| 2600 | goto do_not_strip_quotes; |
| 2601 | /* Fall through. */ |
| 2602 | default: |
| 2603 | if (yyres) |
| 2604 | yyres[yyn] = *yyp; |
| 2605 | yyn++; |
| 2606 | break; |
| 2607 | |
| 2608 | case '"': |
| 2609 | if (yyres) |
| 2610 | yyres[yyn] = '\0'; |
| 2611 | return yyn; |
| 2612 | } |
| 2613 | do_not_strip_quotes: ; |
| 2614 | } |
| 2615 | |
| 2616 | if (! yyres) |
| 2617 | return yystrlen (yystr); |
| 2618 | |
| 2619 | return yystpcpy (yyres, yystr) - yyres; |
| 2620 | } |
| 2621 | # endif |
| 2622 | |
| 2623 | #endif /* YYERROR_VERBOSE */ |
| 2624 | |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 2625 | |
| 2626 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2627 | #if YYDEBUG |
| 2628 | /*--------------------------------. |
| 2629 | | Print this symbol on YYOUTPUT. | |
| 2630 | `--------------------------------*/ |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 2631 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2632 | #if defined (__STDC__) || defined (__cplusplus) |
| 2633 | static void |
| 2634 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2635 | #else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2636 | static void |
| 2637 | yysymprint (yyoutput, yytype, yyvaluep) |
| 2638 | FILE *yyoutput; |
| 2639 | int yytype; |
| 2640 | YYSTYPE *yyvaluep; |
| 2641 | #endif |
| 2642 | { |
| 2643 | /* Pacify ``unused variable'' warnings. */ |
| 2644 | (void) yyvaluep; |
| 2645 | |
| 2646 | if (yytype < YYNTOKENS) |
| 2647 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 2648 | else |
| 2649 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 2650 | |
| 2651 | |
| 2652 | # ifdef YYPRINT |
| 2653 | if (yytype < YYNTOKENS) |
| 2654 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 2655 | # endif |
| 2656 | switch (yytype) |
| 2657 | { |
| 2658 | default: |
| 2659 | break; |
| 2660 | } |
| 2661 | YYFPRINTF (yyoutput, ")"); |
| 2662 | } |
| 2663 | |
| 2664 | #endif /* ! YYDEBUG */ |
| 2665 | /*-----------------------------------------------. |
| 2666 | | Release the memory associated to this symbol. | |
| 2667 | `-----------------------------------------------*/ |
| 2668 | |
| 2669 | #if defined (__STDC__) || defined (__cplusplus) |
| 2670 | static void |
| 2671 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
| 2672 | #else |
| 2673 | static void |
| 2674 | yydestruct (yymsg, yytype, yyvaluep) |
| 2675 | const char *yymsg; |
| 2676 | int yytype; |
| 2677 | YYSTYPE *yyvaluep; |
| 2678 | #endif |
| 2679 | { |
| 2680 | /* Pacify ``unused variable'' warnings. */ |
| 2681 | (void) yyvaluep; |
| 2682 | |
| 2683 | if (!yymsg) |
| 2684 | yymsg = "Deleting"; |
| 2685 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 2686 | |
| 2687 | switch (yytype) |
| 2688 | { |
| 2689 | |
| 2690 | default: |
| 2691 | break; |
| 2692 | } |
| 2693 | } |
| 2694 | |
| 2695 | |
| 2696 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 2697 | |
| 2698 | #ifdef YYPARSE_PARAM |
| 2699 | # if defined (__STDC__) || defined (__cplusplus) |
| 2700 | int yyparse (void *YYPARSE_PARAM); |
| 2701 | # else |
| 2702 | int yyparse (); |
| 2703 | # endif |
| 2704 | #else /* ! YYPARSE_PARAM */ |
| 2705 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 2706 | int yyparse (void); |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2707 | #else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2708 | int yyparse (); |
| 2709 | #endif |
| 2710 | #endif /* ! YYPARSE_PARAM */ |
| 2711 | |
| 2712 | |
| 2713 | |
| 2714 | /* The look-ahead symbol. */ |
| 2715 | int yychar; |
| 2716 | |
| 2717 | /* The semantic value of the look-ahead symbol. */ |
| 2718 | YYSTYPE yylval; |
| 2719 | |
| 2720 | /* Number of syntax errors so far. */ |
| 2721 | int yynerrs; |
| 2722 | |
| 2723 | |
| 2724 | |
| 2725 | /*----------. |
| 2726 | | yyparse. | |
| 2727 | `----------*/ |
| 2728 | |
| 2729 | #ifdef YYPARSE_PARAM |
| 2730 | # if defined (__STDC__) || defined (__cplusplus) |
| 2731 | int yyparse (void *YYPARSE_PARAM) |
| 2732 | # else |
| 2733 | int yyparse (YYPARSE_PARAM) |
| 2734 | void *YYPARSE_PARAM; |
| 2735 | # endif |
| 2736 | #else /* ! YYPARSE_PARAM */ |
| 2737 | #if defined (__STDC__) || defined (__cplusplus) |
| 2738 | int |
| 2739 | yyparse (void) |
| 2740 | #else |
| 2741 | int |
| 2742 | yyparse () |
| 2743 | |
| 2744 | #endif |
| 2745 | #endif |
| 2746 | { |
| 2747 | |
| 2748 | int yystate; |
| 2749 | int yyn; |
| 2750 | int yyresult; |
| 2751 | /* Number of tokens to shift before error messages enabled. */ |
| 2752 | int yyerrstatus; |
| 2753 | /* Look-ahead token as an internal (translated) token number. */ |
| 2754 | int yytoken = 0; |
| 2755 | |
| 2756 | /* Three stacks and their tools: |
| 2757 | `yyss': related to states, |
| 2758 | `yyvs': related to semantic values, |
| 2759 | `yyls': related to locations. |
| 2760 | |
| 2761 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 2762 | to reallocate them elsewhere. */ |
| 2763 | |
| 2764 | /* The state stack. */ |
| 2765 | short int yyssa[YYINITDEPTH]; |
| 2766 | short int *yyss = yyssa; |
| 2767 | short int *yyssp; |
| 2768 | |
| 2769 | /* The semantic value stack. */ |
| 2770 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 2771 | YYSTYPE *yyvs = yyvsa; |
| 2772 | YYSTYPE *yyvsp; |
| 2773 | |
| 2774 | |
| 2775 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2776 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2777 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2778 | YYSIZE_T yystacksize = YYINITDEPTH; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2779 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2780 | /* The variables used to return semantic value and location from the |
| 2781 | action routines. */ |
| 2782 | YYSTYPE yyval; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2783 | |
| 2784 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2785 | /* When reducing, the number of symbols on the RHS of the reduced |
| 2786 | rule. */ |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2787 | int yylen; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2788 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2789 | YYDPRINTF ((stderr, "Starting parse\n")); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2790 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2791 | yystate = 0; |
| 2792 | yyerrstatus = 0; |
| 2793 | yynerrs = 0; |
| 2794 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2795 | |
| 2796 | /* Initialize stack pointers. |
| 2797 | Waste one element of value and location stack |
| 2798 | so that they stay on the same level as the state stack. |
| 2799 | The wasted elements are never initialized. */ |
| 2800 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2801 | yyssp = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2802 | yyvsp = yyvs; |
| 2803 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2804 | goto yysetstate; |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2805 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2806 | /*------------------------------------------------------------. |
| 2807 | | yynewstate -- Push a new state, which is found in yystate. | |
| 2808 | `------------------------------------------------------------*/ |
| 2809 | yynewstate: |
| 2810 | /* In all cases, when you get here, the value and location stacks |
| 2811 | have just been pushed. so pushing a state here evens the stacks. |
| 2812 | */ |
| 2813 | yyssp++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2814 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2815 | yysetstate: |
| 2816 | *yyssp = yystate; |
| 2817 | |
| 2818 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2819 | { |
| 2820 | /* Get the current used size of the three stacks, in elements. */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2821 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2822 | |
| 2823 | #ifdef yyoverflow |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2824 | { |
| 2825 | /* Give user a chance to reallocate the stack. Use copies of |
| 2826 | these so that the &'s don't force the real ones into |
| 2827 | memory. */ |
| 2828 | YYSTYPE *yyvs1 = yyvs; |
| 2829 | short int *yyss1 = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2830 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2831 | |
| 2832 | /* Each stack pointer address is followed by the size of the |
| 2833 | data in use in that stack, in bytes. This used to be a |
| 2834 | conditional around just the two extra args, but that might |
| 2835 | be undefined if yyoverflow is a macro. */ |
| 2836 | yyoverflow (YY_("memory exhausted"), |
| 2837 | &yyss1, yysize * sizeof (*yyssp), |
| 2838 | &yyvs1, yysize * sizeof (*yyvsp), |
| 2839 | |
| 2840 | &yystacksize); |
| 2841 | |
| 2842 | yyss = yyss1; |
| 2843 | yyvs = yyvs1; |
| 2844 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2845 | #else /* no yyoverflow */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2846 | # ifndef YYSTACK_RELOCATE |
| 2847 | goto yyexhaustedlab; |
| 2848 | # else |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2849 | /* Extend the stack our own way. */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2850 | if (YYMAXDEPTH <= yystacksize) |
| 2851 | goto yyexhaustedlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2852 | yystacksize *= 2; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2853 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2854 | yystacksize = YYMAXDEPTH; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2855 | |
| 2856 | { |
| 2857 | short int *yyss1 = yyss; |
| 2858 | union yyalloc *yyptr = |
| 2859 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 2860 | if (! yyptr) |
| 2861 | goto yyexhaustedlab; |
| 2862 | YYSTACK_RELOCATE (yyss); |
| 2863 | YYSTACK_RELOCATE (yyvs); |
| 2864 | |
| 2865 | # undef YYSTACK_RELOCATE |
| 2866 | if (yyss1 != yyssa) |
| 2867 | YYSTACK_FREE (yyss1); |
| 2868 | } |
| 2869 | # endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2870 | #endif /* no yyoverflow */ |
| 2871 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2872 | yyssp = yyss + yysize - 1; |
| 2873 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2874 | |
| 2875 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2876 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 2877 | (unsigned long int) yystacksize)); |
| 2878 | |
| 2879 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2880 | YYABORT; |
| 2881 | } |
| 2882 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2883 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2884 | |
| 2885 | goto yybackup; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2886 | |
| 2887 | /*-----------. |
| 2888 | | yybackup. | |
| 2889 | `-----------*/ |
| 2890 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2891 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2892 | /* Do appropriate processing given the current state. */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2893 | /* Read a look-ahead token if we need one and don't already have one. */ |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2894 | /* yyresume: */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2895 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2896 | /* First try to decide what to do without reference to look-ahead token. */ |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2897 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2898 | yyn = yypact[yystate]; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2899 | if (yyn == YYPACT_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2900 | goto yydefault; |
| 2901 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2902 | /* Not known => get a look-ahead token if don't already have one. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2903 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2904 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2905 | if (yychar == YYEMPTY) |
| 2906 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2907 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2908 | yychar = YYLEX; |
| 2909 | } |
| 2910 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2911 | if (yychar <= YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2912 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2913 | yychar = yytoken = YYEOF; |
| 2914 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2915 | } |
| 2916 | else |
| 2917 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2918 | yytoken = YYTRANSLATE (yychar); |
| 2919 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2920 | } |
| 2921 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2922 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 2923 | detect an error, take that action. */ |
| 2924 | yyn += yytoken; |
| 2925 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2926 | goto yydefault; |
| 2927 | yyn = yytable[yyn]; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2928 | if (yyn <= 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2929 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2930 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2931 | goto yyerrlab; |
| 2932 | yyn = -yyn; |
| 2933 | goto yyreduce; |
| 2934 | } |
| 2935 | |
| 2936 | if (yyn == YYFINAL) |
| 2937 | YYACCEPT; |
| 2938 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2939 | /* Shift the look-ahead token. */ |
| 2940 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2941 | |
| 2942 | /* Discard the token being shifted unless it is eof. */ |
| 2943 | if (yychar != YYEOF) |
| 2944 | yychar = YYEMPTY; |
| 2945 | |
| 2946 | *++yyvsp = yylval; |
| 2947 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2948 | |
| 2949 | /* Count tokens shifted since error; after three, turn off error |
| 2950 | status. */ |
| 2951 | if (yyerrstatus) |
| 2952 | yyerrstatus--; |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 2953 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2954 | yystate = yyn; |
| 2955 | goto yynewstate; |
| 2956 | |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2957 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2958 | /*-----------------------------------------------------------. |
| 2959 | | yydefault -- do the default action for the current state. | |
| 2960 | `-----------------------------------------------------------*/ |
| 2961 | yydefault: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2962 | yyn = yydefact[yystate]; |
| 2963 | if (yyn == 0) |
| 2964 | goto yyerrlab; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2965 | goto yyreduce; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2966 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2967 | |
| 2968 | /*-----------------------------. |
| 2969 | | yyreduce -- Do a reduction. | |
| 2970 | `-----------------------------*/ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2971 | yyreduce: |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2972 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2973 | yylen = yyr2[yyn]; |
| 2974 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2975 | /* If YYLEN is nonzero, implement the default value of the action: |
| 2976 | `$$ = $1'. |
| 2977 | |
| 2978 | Otherwise, the following line sets YYVAL to garbage. |
| 2979 | This behavior is undocumented and Bison |
| 2980 | users should not rely upon it. Assigning to YYVAL |
| 2981 | unconditionally makes the parser a bit smaller, and it avoids a |
| 2982 | GCC warning that YYVAL may be used uninitialized. */ |
| 2983 | yyval = yyvsp[1-yylen]; |
| 2984 | |
| 2985 | |
| 2986 | YY_REDUCE_PRINT (yyn); |
| 2987 | switch (yyn) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2988 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2989 | case 3: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 2990 | #line 1135 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2991 | { |
| 2992 | if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range! |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 2993 | GEN_ERROR("Value too large for type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2994 | (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 2995 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2996 | ;} |
| 2997 | break; |
| 2998 | |
| 2999 | case 5: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3000 | #line 1144 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3001 | { |
| 3002 | if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range! |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3003 | GEN_ERROR("Value too large for type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3004 | (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3005 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3006 | ;} |
| 3007 | break; |
| 3008 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3009 | case 36: |
| 3010 | #line 1168 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3011 | { |
| 3012 | (yyval.StrVal) = (yyvsp[-1].StrVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3013 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3014 | ;} |
| 3015 | break; |
| 3016 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3017 | case 37: |
| 3018 | #line 1172 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3019 | { |
| 3020 | (yyval.StrVal) = 0; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3021 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3022 | ;} |
| 3023 | break; |
| 3024 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3025 | case 38: |
| 3026 | #line 1177 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3027 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3028 | break; |
| 3029 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3030 | case 39: |
| 3031 | #line 1178 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3032 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 3033 | break; |
| 3034 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3035 | case 40: |
| 3036 | #line 1179 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3037 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3038 | break; |
| 3039 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3040 | case 41: |
| 3041 | #line 1180 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3042 | { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} |
| 3043 | break; |
| 3044 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3045 | case 42: |
| 3046 | #line 1181 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3047 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 3048 | break; |
| 3049 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3050 | case 43: |
| 3051 | #line 1182 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3052 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 3053 | break; |
| 3054 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3055 | case 44: |
| 3056 | #line 1183 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3057 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 3058 | break; |
| 3059 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3060 | case 45: |
| 3061 | #line 1184 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3062 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3063 | break; |
| 3064 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3065 | case 46: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3066 | #line 1186 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3067 | { (yyval.UIntVal) = CallingConv::C; ;} |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3068 | break; |
| 3069 | |
| 3070 | case 47: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3071 | #line 1187 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3072 | { (yyval.UIntVal) = CallingConv::C; ;} |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3073 | break; |
| 3074 | |
| 3075 | case 48: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3076 | #line 1188 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3077 | { (yyval.UIntVal) = CallingConv::CSRet; ;} |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3078 | break; |
| 3079 | |
| 3080 | case 49: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3081 | #line 1189 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3082 | { (yyval.UIntVal) = CallingConv::Fast; ;} |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3083 | break; |
| 3084 | |
| 3085 | case 50: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3086 | #line 1190 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3087 | { (yyval.UIntVal) = CallingConv::Cold; ;} |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3088 | break; |
| 3089 | |
| 3090 | case 51: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3091 | #line 1191 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3092 | { (yyval.UIntVal) = CallingConv::X86_StdCall; ;} |
| 3093 | break; |
| 3094 | |
| 3095 | case 52: |
| 3096 | #line 1192 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3097 | { (yyval.UIntVal) = CallingConv::X86_FastCall; ;} |
| 3098 | break; |
| 3099 | |
| 3100 | case 53: |
| 3101 | #line 1193 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3102 | { |
| 3103 | if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3104 | GEN_ERROR("Calling conv too large!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3105 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3106 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3107 | ;} |
| 3108 | break; |
| 3109 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3110 | case 54: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3111 | #line 1202 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3112 | { (yyval.UIntVal) = 0; ;} |
| 3113 | break; |
| 3114 | |
| 3115 | case 55: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3116 | #line 1203 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3117 | { |
| 3118 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 3119 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3120 | GEN_ERROR("Alignment must be a power of two!"); |
| 3121 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3122 | ;} |
| 3123 | break; |
| 3124 | |
| 3125 | case 56: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3126 | #line 1209 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3127 | { (yyval.UIntVal) = 0; ;} |
| 3128 | break; |
| 3129 | |
| 3130 | case 57: |
| 3131 | #line 1210 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3132 | { |
| 3133 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 3134 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
| 3135 | GEN_ERROR("Alignment must be a power of two!"); |
| 3136 | CHECK_FOR_ERROR |
| 3137 | ;} |
| 3138 | break; |
| 3139 | |
| 3140 | case 58: |
| 3141 | #line 1218 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3142 | { |
| 3143 | for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) |
| 3144 | if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3145 | GEN_ERROR("Invalid character in section name!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3146 | (yyval.StrVal) = (yyvsp[0].StrVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3147 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3148 | ;} |
| 3149 | break; |
| 3150 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3151 | case 59: |
| 3152 | #line 1226 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3153 | { (yyval.StrVal) = 0; ;} |
| 3154 | break; |
| 3155 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3156 | case 60: |
| 3157 | #line 1227 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3158 | { (yyval.StrVal) = (yyvsp[0].StrVal); ;} |
| 3159 | break; |
| 3160 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3161 | case 61: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3162 | #line 1232 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3163 | {;} |
| 3164 | break; |
| 3165 | |
| 3166 | case 62: |
| 3167 | #line 1233 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3168 | {;} |
| 3169 | break; |
| 3170 | |
| 3171 | case 63: |
| 3172 | #line 1234 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3173 | { |
| 3174 | CurGV->setSection((yyvsp[0].StrVal)); |
| 3175 | free((yyvsp[0].StrVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3176 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3177 | ;} |
| 3178 | break; |
| 3179 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3180 | case 64: |
| 3181 | #line 1239 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3182 | { |
| 3183 | if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3184 | GEN_ERROR("Alignment must be a power of two!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3185 | CurGV->setAlignment((yyvsp[0].UInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3186 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3187 | ;} |
| 3188 | break; |
| 3189 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3190 | case 66: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3191 | #line 1253 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3192 | { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;} |
| 3193 | break; |
| 3194 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3195 | case 68: |
| 3196 | #line 1254 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3197 | { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;} |
| 3198 | break; |
| 3199 | |
| 3200 | case 69: |
| 3201 | #line 1256 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3202 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3203 | if (!UpRefs.empty()) |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3204 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 3205 | (yyval.TypeVal) = (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3206 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3207 | ;} |
| 3208 | break; |
| 3209 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3210 | case 83: |
| 3211 | #line 1268 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3212 | { |
| 3213 | (yyval.TypeVal) = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3214 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3215 | ;} |
| 3216 | break; |
| 3217 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3218 | case 84: |
| 3219 | #line 1272 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3220 | { |
| 3221 | (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3222 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3223 | ;} |
| 3224 | break; |
| 3225 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3226 | case 85: |
| 3227 | #line 1276 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3228 | { // Named types are also simple types... |
| 3229 | const Type* tmp = getTypeVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3230 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3231 | (yyval.TypeVal) = new PATypeHolder(tmp); |
| 3232 | ;} |
| 3233 | break; |
| 3234 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3235 | case 86: |
| 3236 | #line 1284 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3237 | { // Type UpReference |
| 3238 | if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3239 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3240 | UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector... |
| 3241 | (yyval.TypeVal) = new PATypeHolder(OT); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3242 | UR_OUT("New Upreference!\n"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3243 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3244 | ;} |
| 3245 | break; |
| 3246 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3247 | case 87: |
| 3248 | #line 1292 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3249 | { // Function derived type? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3250 | std::vector<const Type*> Params; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3251 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(), |
| 3252 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3253 | Params.push_back(*I); |
| 3254 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3255 | if (isVarArg) Params.pop_back(); |
| 3256 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3257 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[-3].TypeVal),Params,isVarArg))); |
| 3258 | delete (yyvsp[-1].TypeList); // Delete the argument list |
| 3259 | delete (yyvsp[-3].TypeVal); // Delete the return type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3260 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3261 | ;} |
| 3262 | break; |
| 3263 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3264 | case 88: |
| 3265 | #line 1305 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3266 | { // Sized array type? |
| 3267 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); |
| 3268 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3269 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3270 | ;} |
| 3271 | break; |
| 3272 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3273 | case 89: |
| 3274 | #line 1310 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3275 | { // Packed array type? |
| 3276 | const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get(); |
| 3277 | if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3278 | GEN_ERROR("Unsigned result not equal to signed result"); |
Chris Lattner | 9547d7f | 2005-11-10 01:42:43 +0000 | [diff] [blame] | 3279 | if (!ElemTy->isPrimitiveType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3280 | GEN_ERROR("Elemental type of a PackedType must be primitive"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3281 | if (!isPowerOf2_32((yyvsp[-3].UInt64Val))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3282 | GEN_ERROR("Vector length should be a power of 2!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3283 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); |
| 3284 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3285 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3286 | ;} |
| 3287 | break; |
| 3288 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3289 | case 90: |
| 3290 | #line 1322 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3291 | { // Structure type? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3292 | std::vector<const Type*> Elements; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3293 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(), |
| 3294 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3295 | Elements.push_back(*I); |
| 3296 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3297 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 3298 | delete (yyvsp[-1].TypeList); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3299 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3300 | ;} |
| 3301 | break; |
| 3302 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3303 | case 91: |
| 3304 | #line 1332 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3305 | { // Empty structure type? |
| 3306 | (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3307 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3308 | ;} |
| 3309 | break; |
| 3310 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3311 | case 92: |
| 3312 | #line 1336 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3313 | { // Pointer type? |
| 3314 | if (*(yyvsp[-1].TypeVal) == Type::LabelTy) |
Chris Lattner | 59c85e9 | 2006-10-15 23:27:25 +0000 | [diff] [blame] | 3315 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3316 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal)))); |
| 3317 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3318 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3319 | ;} |
| 3320 | break; |
| 3321 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3322 | case 93: |
| 3323 | #line 1347 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3324 | { |
| 3325 | (yyval.TypeList) = new std::list<PATypeHolder>(); |
| 3326 | (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3327 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3328 | ;} |
| 3329 | break; |
| 3330 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3331 | case 94: |
| 3332 | #line 1352 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3333 | { |
| 3334 | ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3335 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3336 | ;} |
| 3337 | break; |
| 3338 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3339 | case 96: |
| 3340 | #line 1359 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3341 | { |
| 3342 | ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3343 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3344 | ;} |
| 3345 | break; |
| 3346 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3347 | case 97: |
| 3348 | #line 1363 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3349 | { |
| 3350 | ((yyval.TypeList) = new std::list<PATypeHolder>())->push_back(Type::VoidTy); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3351 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3352 | ;} |
| 3353 | break; |
| 3354 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3355 | case 98: |
| 3356 | #line 1367 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3357 | { |
| 3358 | (yyval.TypeList) = new std::list<PATypeHolder>(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3359 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3360 | ;} |
| 3361 | break; |
| 3362 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3363 | case 99: |
| 3364 | #line 1378 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3365 | { // Nonempty unsized arr |
| 3366 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3367 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3368 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3369 | (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3370 | const Type *ETy = ATy->getElementType(); |
| 3371 | int NumElements = ATy->getNumElements(); |
| 3372 | |
| 3373 | // Verify that we have the correct size... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3374 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3375 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3376 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3377 | itostr(NumElements) + "!"); |
| 3378 | |
| 3379 | // Verify all elements are correct type! |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3380 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 3381 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3382 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3383 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3384 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3385 | } |
| 3386 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3387 | (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector)); |
| 3388 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3389 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3390 | ;} |
| 3391 | break; |
| 3392 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3393 | case 100: |
| 3394 | #line 1404 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3395 | { |
| 3396 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3397 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3398 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3399 | (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3400 | |
| 3401 | int NumElements = ATy->getNumElements(); |
| 3402 | if (NumElements != -1 && NumElements != 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3403 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3404 | " arguments, but has size of " + itostr(NumElements) +"!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3405 | (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3406 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3407 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3408 | ;} |
| 3409 | break; |
| 3410 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3411 | case 101: |
| 3412 | #line 1418 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3413 | { |
| 3414 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3415 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3416 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3417 | (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3418 | |
| 3419 | int NumElements = ATy->getNumElements(); |
| 3420 | const Type *ETy = ATy->getElementType(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3421 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 3422 | if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3423 | GEN_ERROR("Can't build string constant of size " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3424 | itostr((int)(EndStr-(yyvsp[0].StrVal))) + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3425 | " when array has size " + itostr(NumElements) + "!"); |
| 3426 | std::vector<Constant*> Vals; |
| 3427 | if (ETy == Type::SByteTy) { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3428 | for (signed char *C = (signed char *)(yyvsp[0].StrVal); C != (signed char *)EndStr; ++C) |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 3429 | Vals.push_back(ConstantInt::get(ETy, *C)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3430 | } else if (ETy == Type::UByteTy) { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3431 | for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3432 | C != (unsigned char*)EndStr; ++C) |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 3433 | Vals.push_back(ConstantInt::get(ETy, *C)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3434 | } else { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3435 | free((yyvsp[0].StrVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3436 | GEN_ERROR("Cannot build string arrays of non byte sized elements!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3437 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3438 | free((yyvsp[0].StrVal)); |
| 3439 | (yyval.ConstVal) = ConstantArray::get(ATy, Vals); |
| 3440 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3441 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3442 | ;} |
| 3443 | break; |
| 3444 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3445 | case 102: |
| 3446 | #line 1448 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3447 | { // Nonempty unsized arr |
| 3448 | const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3449 | if (PTy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3450 | GEN_ERROR("Cannot make packed constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3451 | (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3452 | const Type *ETy = PTy->getElementType(); |
| 3453 | int NumElements = PTy->getNumElements(); |
| 3454 | |
| 3455 | // Verify that we have the correct size... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3456 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3457 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3458 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3459 | itostr(NumElements) + "!"); |
| 3460 | |
| 3461 | // Verify all elements are correct type! |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3462 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 3463 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3464 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3465 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3466 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3467 | } |
| 3468 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3469 | (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector)); |
| 3470 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3471 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3472 | ;} |
| 3473 | break; |
| 3474 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3475 | case 103: |
| 3476 | #line 1474 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3477 | { |
| 3478 | const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get()); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3479 | if (STy == 0) |
| 3480 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3481 | (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3482 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3483 | if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3484 | GEN_ERROR("Illegal number of initializers for structure type!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3485 | |
| 3486 | // Check to ensure that constants are compatible with the type initializer! |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3487 | for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) |
| 3488 | if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3489 | GEN_ERROR("Expected type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3490 | STy->getElementType(i)->getDescription() + |
| 3491 | "' for element #" + utostr(i) + |
| 3492 | " of structure initializer!"); |
| 3493 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3494 | (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector)); |
| 3495 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3496 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3497 | ;} |
| 3498 | break; |
| 3499 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3500 | case 104: |
| 3501 | #line 1495 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3502 | { |
| 3503 | const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3504 | if (STy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3505 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3506 | (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3507 | |
| 3508 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3509 | GEN_ERROR("Illegal number of initializers for structure type!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3510 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3511 | (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3512 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3513 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3514 | ;} |
| 3515 | break; |
| 3516 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3517 | case 105: |
| 3518 | #line 1508 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3519 | { |
| 3520 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3521 | if (PTy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3522 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3523 | (*(yyvsp[-1].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3524 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3525 | (yyval.ConstVal) = ConstantPointerNull::get(PTy); |
| 3526 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3527 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3528 | ;} |
| 3529 | break; |
| 3530 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3531 | case 106: |
| 3532 | #line 1518 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3533 | { |
| 3534 | (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get()); |
| 3535 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3536 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3537 | ;} |
| 3538 | break; |
| 3539 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3540 | case 107: |
| 3541 | #line 1523 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3542 | { |
| 3543 | const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3544 | if (Ty == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3545 | GEN_ERROR("Global const reference must be a pointer type!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3546 | |
| 3547 | // ConstExprs can exist in the body of a function, thus creating |
| 3548 | // GlobalValues whenever they refer to a variable. Because we are in |
| 3549 | // the context of a function, getValNonImprovising will search the functions |
| 3550 | // symbol table instead of the module symbol table for the global symbol, |
| 3551 | // which throws things all off. To get around this, we just tell |
| 3552 | // getValNonImprovising that we are at global scope here. |
| 3553 | // |
| 3554 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3555 | CurFun.CurrentFunction = 0; |
| 3556 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3557 | Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3558 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3559 | |
| 3560 | CurFun.CurrentFunction = SavedCurFn; |
| 3561 | |
| 3562 | // If this is an initializer for a constant pointer, which is referencing a |
| 3563 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3564 | // in the future with the right type of variable. |
| 3565 | // |
| 3566 | if (V == 0) { |
| 3567 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
| 3568 | const PointerType *PT = cast<PointerType>(Ty); |
| 3569 | |
| 3570 | // First check to see if the forward references value is already created! |
| 3571 | PerModuleInfo::GlobalRefsType::iterator I = |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3572 | CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal))); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3573 | |
| 3574 | if (I != CurModule.GlobalRefs.end()) { |
| 3575 | V = I->second; // Placeholder already exists, use it... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3576 | (yyvsp[0].ValIDVal).destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3577 | } else { |
| 3578 | std::string Name; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3579 | if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3580 | |
| 3581 | // Create the forward referenced global. |
| 3582 | GlobalValue *GV; |
| 3583 | if (const FunctionType *FTy = |
| 3584 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 3585 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 3586 | CurModule.CurrentModule); |
| 3587 | } else { |
| 3588 | GV = new GlobalVariable(PT->getElementType(), false, |
| 3589 | GlobalValue::ExternalLinkage, 0, |
| 3590 | Name, CurModule.CurrentModule); |
| 3591 | } |
| 3592 | |
| 3593 | // Keep track of the fact that we have a forward ref to recycle it |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3594 | CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3595 | V = GV; |
| 3596 | } |
| 3597 | } |
| 3598 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3599 | (yyval.ConstVal) = cast<GlobalValue>(V); |
| 3600 | delete (yyvsp[-1].TypeVal); // Free the type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3601 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3602 | ;} |
| 3603 | break; |
| 3604 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3605 | case 108: |
| 3606 | #line 1584 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3607 | { |
| 3608 | if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3609 | GEN_ERROR("Mismatched types for constant expression!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3610 | (yyval.ConstVal) = (yyvsp[0].ConstVal); |
| 3611 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3612 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3613 | ;} |
| 3614 | break; |
| 3615 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3616 | case 109: |
| 3617 | #line 1591 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3618 | { |
| 3619 | const Type *Ty = (yyvsp[-1].TypeVal)->get(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3620 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3621 | GEN_ERROR("Cannot create a null initialized value of this type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3622 | (yyval.ConstVal) = Constant::getNullValue(Ty); |
| 3623 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3624 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3625 | ;} |
| 3626 | break; |
| 3627 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3628 | case 110: |
| 3629 | #line 1600 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3630 | { // integral constants |
| 3631 | if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3632 | GEN_ERROR("Constant value doesn't fit in type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3633 | (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3634 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3635 | ;} |
| 3636 | break; |
| 3637 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3638 | case 111: |
| 3639 | #line 1606 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3640 | { // integral constants |
| 3641 | if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3642 | GEN_ERROR("Constant value doesn't fit in type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3643 | (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3644 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3645 | ;} |
| 3646 | break; |
| 3647 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3648 | case 112: |
| 3649 | #line 1612 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3650 | { // Boolean constants |
| 3651 | (yyval.ConstVal) = ConstantBool::getTrue(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3652 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3653 | ;} |
| 3654 | break; |
| 3655 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3656 | case 113: |
| 3657 | #line 1616 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3658 | { // Boolean constants |
| 3659 | (yyval.ConstVal) = ConstantBool::getFalse(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3660 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3661 | ;} |
| 3662 | break; |
| 3663 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3664 | case 114: |
| 3665 | #line 1620 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3666 | { // Float & Double constants |
| 3667 | if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3668 | GEN_ERROR("Floating point constant invalid for type!!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3669 | (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3670 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3671 | ;} |
| 3672 | break; |
| 3673 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3674 | case 115: |
| 3675 | #line 1628 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3676 | { |
| 3677 | if (!(yyvsp[-3].ConstVal)->getType()->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3678 | GEN_ERROR("cast constant expression from a non-primitive type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3679 | (yyvsp[-3].ConstVal)->getType()->getDescription() + "'!"); |
| 3680 | if (!(yyvsp[-1].TypeVal)->get()->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3681 | GEN_ERROR("cast constant expression to a non-primitive type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3682 | (yyvsp[-1].TypeVal)->get()->getDescription() + "'!"); |
| 3683 | (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get()); |
| 3684 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3685 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3686 | ;} |
| 3687 | break; |
| 3688 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3689 | case 116: |
| 3690 | #line 1639 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3691 | { |
| 3692 | if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3693 | GEN_ERROR("GetElementPtr requires a pointer operand!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3694 | |
| 3695 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct |
| 3696 | // indices to uint struct indices for compatibility. |
| 3697 | generic_gep_type_iterator<std::vector<Value*>::iterator> |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3698 | GTI = gep_type_begin((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()), |
| 3699 | GTE = gep_type_end((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()); |
| 3700 | for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3701 | if (isa<StructType>(*GTI)) // Only change struct indices |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3702 | if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[-1].ValueList))[i])) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3703 | if (CUI->getType() == Type::UByteTy) |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3704 | (*(yyvsp[-1].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3705 | |
| 3706 | const Type *IdxTy = |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3707 | GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3708 | if (!IdxTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3709 | GEN_ERROR("Index list invalid for constant getelementptr!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3710 | |
| 3711 | std::vector<Constant*> IdxVec; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3712 | for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i) |
| 3713 | if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i])) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3714 | IdxVec.push_back(C); |
| 3715 | else |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3716 | GEN_ERROR("Indices to constant getelementptr must be constants!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3717 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3718 | delete (yyvsp[-1].ValueList); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3719 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3720 | (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3721 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3722 | ;} |
| 3723 | break; |
| 3724 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3725 | case 117: |
| 3726 | #line 1671 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3727 | { |
| 3728 | if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3729 | GEN_ERROR("Select condition must be of boolean type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3730 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3731 | GEN_ERROR("Select operand types must match!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3732 | (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3733 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3734 | ;} |
| 3735 | break; |
| 3736 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3737 | case 118: |
| 3738 | #line 1679 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3739 | { |
| 3740 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3741 | GEN_ERROR("Binary operator types must match!"); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3742 | // First, make sure we're dealing with the right opcode by upgrading from |
| 3743 | // obsolete versions. |
| 3744 | sanitizeOpCode((yyvsp[-5].BinaryOpVal),(yyvsp[-3].ConstVal)->getType()); |
| 3745 | CHECK_FOR_ERROR; |
| 3746 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3747 | // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. |
| 3748 | // To retain backward compatibility with these early compilers, we emit a |
| 3749 | // cast to the appropriate integer type automatically if we are in the |
| 3750 | // broken case. See PR424 for more information. |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3751 | if (!isa<PointerType>((yyvsp[-3].ConstVal)->getType())) { |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3752 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3753 | } else { |
| 3754 | const Type *IntPtrTy = 0; |
| 3755 | switch (CurModule.CurrentModule->getPointerSize()) { |
| 3756 | case Module::Pointer32: IntPtrTy = Type::IntTy; break; |
| 3757 | case Module::Pointer64: IntPtrTy = Type::LongTy; break; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3758 | default: GEN_ERROR("invalid pointer binary constant expr!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3759 | } |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3760 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, ConstantExpr::getCast((yyvsp[-3].ConstVal), IntPtrTy), |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3761 | ConstantExpr::getCast((yyvsp[-1].ConstVal), IntPtrTy)); |
| 3762 | (yyval.ConstVal) = ConstantExpr::getCast((yyval.ConstVal), (yyvsp[-3].ConstVal)->getType()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3763 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3764 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3765 | ;} |
| 3766 | break; |
| 3767 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3768 | case 119: |
| 3769 | #line 1706 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3770 | { |
| 3771 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3772 | GEN_ERROR("Logical operator types must match!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3773 | if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) { |
| 3774 | if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) || |
| 3775 | !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3776 | GEN_ERROR("Logical operator requires integral operands!"); |
Chris Lattner | 524a131 | 2005-12-21 18:31:50 +0000 | [diff] [blame] | 3777 | } |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3778 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3779 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3780 | ;} |
| 3781 | break; |
| 3782 | |
| 3783 | case 120: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3784 | #line 1717 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3785 | { |
| 3786 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
| 3787 | GEN_ERROR("setcc operand types must match!"); |
| 3788 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
| 3789 | CHECK_FOR_ERROR |
| 3790 | ;} |
| 3791 | break; |
| 3792 | |
| 3793 | case 121: |
| 3794 | #line 1723 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3795 | { |
| 3796 | if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy) |
| 3797 | GEN_ERROR("Shift count for shift constant must be unsigned byte!"); |
| 3798 | if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) |
| 3799 | GEN_ERROR("Shift constant expression requires integer operand!"); |
| 3800 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
| 3801 | CHECK_FOR_ERROR |
| 3802 | ;} |
| 3803 | break; |
| 3804 | |
| 3805 | case 122: |
| 3806 | #line 1731 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3807 | { |
| 3808 | if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3809 | GEN_ERROR("Invalid extractelement operands!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3810 | (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3811 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3812 | ;} |
| 3813 | break; |
| 3814 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3815 | case 123: |
| 3816 | #line 1737 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3817 | { |
| 3818 | if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3819 | GEN_ERROR("Invalid insertelement operands!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3820 | (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3821 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3822 | ;} |
| 3823 | break; |
| 3824 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3825 | case 124: |
| 3826 | #line 1743 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3827 | { |
| 3828 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3829 | GEN_ERROR("Invalid shufflevector operands!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3830 | (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3831 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3832 | ;} |
| 3833 | break; |
| 3834 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3835 | case 125: |
| 3836 | #line 1752 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3837 | { |
| 3838 | ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3839 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3840 | ;} |
| 3841 | break; |
| 3842 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3843 | case 126: |
| 3844 | #line 1756 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3845 | { |
| 3846 | (yyval.ConstVector) = new std::vector<Constant*>(); |
| 3847 | (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3848 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3849 | ;} |
| 3850 | break; |
| 3851 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3852 | case 127: |
| 3853 | #line 1764 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3854 | { (yyval.BoolVal) = false; ;} |
| 3855 | break; |
| 3856 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3857 | case 128: |
| 3858 | #line 1764 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3859 | { (yyval.BoolVal) = true; ;} |
| 3860 | break; |
| 3861 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3862 | case 129: |
| 3863 | #line 1774 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3864 | { |
| 3865 | (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3866 | CurModule.ModuleDone(); |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 3867 | CHECK_FOR_ERROR; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3868 | ;} |
| 3869 | break; |
| 3870 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3871 | case 130: |
| 3872 | #line 1782 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3873 | { |
| 3874 | (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3875 | CurFun.FunctionDone(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3876 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3877 | ;} |
| 3878 | break; |
| 3879 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3880 | case 131: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3881 | #line 1787 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3882 | { |
| 3883 | (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); |
Anton Korobeynikov | bcb9770 | 2006-09-17 20:25:45 +0000 | [diff] [blame] | 3884 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3885 | ;} |
| 3886 | break; |
| 3887 | |
| 3888 | case 132: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3889 | #line 1791 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3890 | { |
| 3891 | (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); |
| 3892 | CHECK_FOR_ERROR |
| 3893 | ;} |
| 3894 | break; |
| 3895 | |
| 3896 | case 133: |
| 3897 | #line 1795 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3898 | { |
| 3899 | (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); |
| 3900 | CHECK_FOR_ERROR |
| 3901 | ;} |
| 3902 | break; |
| 3903 | |
| 3904 | case 134: |
| 3905 | #line 1799 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3906 | { |
| 3907 | (yyval.ModuleVal) = CurModule.CurrentModule; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3908 | // Emit an error if there are any unresolved types left. |
| 3909 | if (!CurModule.LateResolveTypes.empty()) { |
| 3910 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3911 | if (DID.Type == ValID::NameVal) { |
| 3912 | GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'"); |
| 3913 | } else { |
| 3914 | GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num)); |
| 3915 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3916 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3917 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3918 | ;} |
| 3919 | break; |
| 3920 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3921 | case 135: |
| 3922 | #line 1814 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3923 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3924 | // Eagerly resolve types. This is not an optimization, this is a |
| 3925 | // requirement that is due to the fact that we could have this: |
| 3926 | // |
| 3927 | // %list = type { %list * } |
| 3928 | // %list = type { %list * } ; repeated type decl |
| 3929 | // |
| 3930 | // If types are not resolved eagerly, then the two types will not be |
| 3931 | // determined to be the same type! |
| 3932 | // |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3933 | ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3934 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3935 | if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3936 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3937 | // If this is a named type that is not a redefinition, add it to the slot |
| 3938 | // table. |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3939 | CurModule.Types.push_back(*(yyvsp[0].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3940 | } |
| 3941 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3942 | delete (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3943 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3944 | ;} |
| 3945 | break; |
| 3946 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3947 | case 136: |
| 3948 | #line 1836 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3949 | { // Function prototypes can be in const pool |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3950 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3951 | ;} |
| 3952 | break; |
| 3953 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3954 | case 137: |
| 3955 | #line 1839 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3956 | { // Asm blocks can be in the const pool |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3957 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3958 | ;} |
| 3959 | break; |
| 3960 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3961 | case 138: |
| 3962 | #line 1842 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3963 | { |
| 3964 | if ((yyvsp[0].ConstVal) == 0) |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3965 | GEN_ERROR("Global value initializer is not a constant!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3966 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3967 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3968 | ;} |
| 3969 | break; |
| 3970 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3971 | case 139: |
| 3972 | #line 1847 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3973 | { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3974 | CurGV = 0; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3975 | ;} |
| 3976 | break; |
| 3977 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3978 | case 140: |
| 3979 | #line 1850 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3980 | { |
| 3981 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3982 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3983 | delete (yyvsp[0].TypeVal); |
| 3984 | ;} |
| 3985 | break; |
| 3986 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3987 | case 141: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3988 | #line 1854 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3989 | { |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 3990 | CurGV = 0; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3991 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3992 | ;} |
| 3993 | break; |
| 3994 | |
| 3995 | case 142: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 3996 | #line 1858 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 3997 | { |
| 3998 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); |
| 3999 | CHECK_FOR_ERROR |
| 4000 | delete (yyvsp[0].TypeVal); |
| 4001 | ;} |
| 4002 | break; |
| 4003 | |
| 4004 | case 143: |
| 4005 | #line 1862 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4006 | { |
| 4007 | CurGV = 0; |
| 4008 | CHECK_FOR_ERROR |
| 4009 | ;} |
| 4010 | break; |
| 4011 | |
| 4012 | case 144: |
| 4013 | #line 1866 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4014 | { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4015 | CurGV = |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4016 | ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4017 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4018 | delete (yyvsp[0].TypeVal); |
| 4019 | ;} |
| 4020 | break; |
| 4021 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4022 | case 145: |
| 4023 | #line 1871 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4024 | { |
Anton Korobeynikov | bcb9770 | 2006-09-17 20:25:45 +0000 | [diff] [blame] | 4025 | CurGV = 0; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4026 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4027 | ;} |
| 4028 | break; |
| 4029 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4030 | case 146: |
| 4031 | #line 1875 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4032 | { |
Anton Korobeynikov | bcb9770 | 2006-09-17 20:25:45 +0000 | [diff] [blame] | 4033 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4034 | ;} |
| 4035 | break; |
| 4036 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4037 | case 147: |
| 4038 | #line 1878 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4039 | { |
Anton Korobeynikov | bcb9770 | 2006-09-17 20:25:45 +0000 | [diff] [blame] | 4040 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4041 | ;} |
| 4042 | break; |
| 4043 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4044 | case 148: |
| 4045 | #line 1881 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4046 | { |
| 4047 | ;} |
| 4048 | break; |
| 4049 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4050 | case 149: |
| 4051 | #line 1885 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4052 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4053 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4054 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4055 | std::string NewAsm((yyvsp[0].StrVal), EndStr); |
| 4056 | free((yyvsp[0].StrVal)); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4057 | |
| 4058 | if (AsmSoFar.empty()) |
| 4059 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 4060 | else |
| 4061 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4062 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4063 | ;} |
| 4064 | break; |
| 4065 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4066 | case 150: |
| 4067 | #line 1898 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4068 | { (yyval.Endianness) = Module::BigEndian; ;} |
| 4069 | break; |
| 4070 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4071 | case 151: |
| 4072 | #line 1899 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4073 | { (yyval.Endianness) = Module::LittleEndian; ;} |
| 4074 | break; |
| 4075 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4076 | case 152: |
| 4077 | #line 1901 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4078 | { |
| 4079 | CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4080 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4081 | ;} |
| 4082 | break; |
| 4083 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4084 | case 153: |
| 4085 | #line 1905 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4086 | { |
| 4087 | if ((yyvsp[0].UInt64Val) == 32) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4088 | CurModule.CurrentModule->setPointerSize(Module::Pointer32); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4089 | else if ((yyvsp[0].UInt64Val) == 64) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4090 | CurModule.CurrentModule->setPointerSize(Module::Pointer64); |
| 4091 | else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4092 | GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4093 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4094 | ;} |
| 4095 | break; |
| 4096 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4097 | case 154: |
| 4098 | #line 1914 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4099 | { |
| 4100 | CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); |
| 4101 | free((yyvsp[0].StrVal)); |
| 4102 | ;} |
| 4103 | break; |
| 4104 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4105 | case 155: |
| 4106 | #line 1918 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4107 | { |
| 4108 | CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); |
| 4109 | free((yyvsp[0].StrVal)); |
| 4110 | ;} |
| 4111 | break; |
| 4112 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4113 | case 157: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4114 | #line 1925 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4115 | { |
| 4116 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 4117 | free((yyvsp[0].StrVal)); |
| 4118 | CHECK_FOR_ERROR |
| 4119 | ;} |
| 4120 | break; |
| 4121 | |
| 4122 | case 158: |
| 4123 | #line 1930 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4124 | { |
| 4125 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 4126 | free((yyvsp[0].StrVal)); |
| 4127 | CHECK_FOR_ERROR |
| 4128 | ;} |
| 4129 | break; |
| 4130 | |
| 4131 | case 159: |
| 4132 | #line 1935 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4133 | { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4134 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4135 | ;} |
| 4136 | break; |
| 4137 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4138 | case 163: |
| 4139 | #line 1945 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4140 | { (yyval.StrVal) = 0; ;} |
| 4141 | break; |
| 4142 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4143 | case 164: |
| 4144 | #line 1947 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4145 | { |
| 4146 | if (*(yyvsp[-1].TypeVal) == Type::VoidTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4147 | GEN_ERROR("void typed arguments are invalid!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4148 | (yyval.ArgVal) = new std::pair<PATypeHolder*, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4149 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4150 | ;} |
| 4151 | break; |
| 4152 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4153 | case 165: |
| 4154 | #line 1954 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4155 | { |
| 4156 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
| 4157 | (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal)); |
| 4158 | delete (yyvsp[0].ArgVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4159 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4160 | ;} |
| 4161 | break; |
| 4162 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4163 | case 166: |
| 4164 | #line 1960 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4165 | { |
| 4166 | (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >(); |
| 4167 | (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); |
| 4168 | delete (yyvsp[0].ArgVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4169 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4170 | ;} |
| 4171 | break; |
| 4172 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4173 | case 167: |
| 4174 | #line 1967 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4175 | { |
| 4176 | (yyval.ArgList) = (yyvsp[0].ArgList); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4177 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4178 | ;} |
| 4179 | break; |
| 4180 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4181 | case 168: |
| 4182 | #line 1971 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4183 | { |
| 4184 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
| 4185 | (yyval.ArgList)->push_back(std::pair<PATypeHolder*, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4186 | char*>(new PATypeHolder(Type::VoidTy), 0)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4187 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4188 | ;} |
| 4189 | break; |
| 4190 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4191 | case 169: |
| 4192 | #line 1977 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4193 | { |
| 4194 | (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >(); |
| 4195 | (yyval.ArgList)->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4196 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4197 | ;} |
| 4198 | break; |
| 4199 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4200 | case 170: |
| 4201 | #line 1982 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4202 | { |
| 4203 | (yyval.ArgList) = 0; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4204 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4205 | ;} |
| 4206 | break; |
| 4207 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4208 | case 171: |
| 4209 | #line 1988 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4210 | { |
| 4211 | UnEscapeLexed((yyvsp[-5].StrVal)); |
| 4212 | std::string FunctionName((yyvsp[-5].StrVal)); |
| 4213 | free((yyvsp[-5].StrVal)); // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4214 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4215 | if (!(*(yyvsp[-6].TypeVal))->isFirstClassType() && *(yyvsp[-6].TypeVal) != Type::VoidTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4216 | GEN_ERROR("LLVM functions cannot return aggregate types!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4217 | |
| 4218 | std::vector<const Type*> ParamTypeList; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4219 | if ((yyvsp[-3].ArgList)) { // If there are arguments... |
| 4220 | for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin(); |
| 4221 | I != (yyvsp[-3].ArgList)->end(); ++I) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4222 | ParamTypeList.push_back(I->first->get()); |
| 4223 | } |
| 4224 | |
| 4225 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 4226 | if (isVarArg) ParamTypeList.pop_back(); |
| 4227 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4228 | const FunctionType *FT = FunctionType::get(*(yyvsp[-6].TypeVal), ParamTypeList, isVarArg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4229 | const PointerType *PFT = PointerType::get(FT); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4230 | delete (yyvsp[-6].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4231 | |
| 4232 | ValID ID; |
| 4233 | if (!FunctionName.empty()) { |
| 4234 | ID = ValID::create((char*)FunctionName.c_str()); |
| 4235 | } else { |
| 4236 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
| 4237 | } |
| 4238 | |
| 4239 | Function *Fn = 0; |
| 4240 | // See if this function was forward referenced. If so, recycle the object. |
| 4241 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 4242 | // Move the function to the end of the list, from whereever it was |
| 4243 | // previously inserted. |
| 4244 | Fn = cast<Function>(FWRef); |
| 4245 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 4246 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 4247 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
| 4248 | (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) { |
| 4249 | // If this is the case, either we need to be a forward decl, or it needs |
| 4250 | // to be. |
| 4251 | if (!CurFun.isDeclare && !Fn->isExternal()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4252 | GEN_ERROR("Redefinition of function '" + FunctionName + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4253 | |
| 4254 | // Make sure to strip off any argument names so we can't get conflicts. |
| 4255 | if (Fn->isExternal()) |
| 4256 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 4257 | AI != AE; ++AI) |
| 4258 | AI->setName(""); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4259 | } else { // Not already defined? |
| 4260 | Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, |
| 4261 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4262 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4263 | InsertValue(Fn, CurModule.Values); |
| 4264 | } |
| 4265 | |
| 4266 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4267 | |
| 4268 | if (CurFun.isDeclare) { |
| 4269 | // If we have declaration, always overwrite linkage. This will allow us to |
| 4270 | // correctly handle cases, when pointer to function is passed as argument to |
| 4271 | // another function. |
| 4272 | Fn->setLinkage(CurFun.Linkage); |
| 4273 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4274 | Fn->setCallingConv((yyvsp[-7].UIntVal)); |
| 4275 | Fn->setAlignment((yyvsp[0].UIntVal)); |
| 4276 | if ((yyvsp[-1].StrVal)) { |
| 4277 | Fn->setSection((yyvsp[-1].StrVal)); |
| 4278 | free((yyvsp[-1].StrVal)); |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 4279 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4280 | |
| 4281 | // Add all of the arguments we parsed to the function... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4282 | if ((yyvsp[-3].ArgList)) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4283 | if (isVarArg) { // Nuke the last entry |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4284 | assert((yyvsp[-3].ArgList)->back().first->get() == Type::VoidTy && (yyvsp[-3].ArgList)->back().second == 0&& |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4285 | "Not a varargs marker!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4286 | delete (yyvsp[-3].ArgList)->back().first; |
| 4287 | (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4288 | } |
| 4289 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4290 | for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin(); |
| 4291 | I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4292 | delete I->first; // Delete the typeholder... |
| 4293 | |
| 4294 | setValueName(ArgIt, I->second); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4295 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4296 | InsertValue(ArgIt); |
| 4297 | } |
| 4298 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4299 | delete (yyvsp[-3].ArgList); // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4300 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4301 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4302 | ;} |
| 4303 | break; |
| 4304 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4305 | case 174: |
| 4306 | #line 2084 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4307 | { |
| 4308 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4309 | |
| 4310 | // Make sure that we keep track of the linkage type even if there was a |
| 4311 | // previous "declare". |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4312 | (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage)); |
| 4313 | ;} |
| 4314 | break; |
| 4315 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4316 | case 177: |
| 4317 | #line 2094 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4318 | { |
| 4319 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4320 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4321 | ;} |
| 4322 | break; |
| 4323 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4324 | case 179: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4325 | #line 2100 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4326 | { CurFun.Linkage = GlobalValue::DLLImportLinkage ;} |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4327 | break; |
| 4328 | |
| 4329 | case 180: |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4330 | #line 2101 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4331 | { CurFun.Linkage = GlobalValue::DLLImportLinkage ;} |
| 4332 | break; |
| 4333 | |
| 4334 | case 181: |
| 4335 | #line 2103 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
| 4336 | { CurFun.isDeclare = true; ;} |
| 4337 | break; |
| 4338 | |
| 4339 | case 182: |
| 4340 | #line 2103 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4341 | { |
| 4342 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4343 | CurFun.FunctionDone(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4344 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4345 | ;} |
| 4346 | break; |
| 4347 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4348 | case 183: |
| 4349 | #line 2113 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4350 | { |
| 4351 | (yyval.BoolVal) = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4352 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4353 | ;} |
| 4354 | break; |
| 4355 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4356 | case 184: |
| 4357 | #line 2117 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4358 | { |
| 4359 | (yyval.BoolVal) = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4360 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4361 | ;} |
| 4362 | break; |
| 4363 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4364 | case 185: |
| 4365 | #line 2122 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4366 | { // A reference to a direct constant |
| 4367 | (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4368 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4369 | ;} |
| 4370 | break; |
| 4371 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4372 | case 186: |
| 4373 | #line 2126 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4374 | { |
| 4375 | (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4376 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4377 | ;} |
| 4378 | break; |
| 4379 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4380 | case 187: |
| 4381 | #line 2130 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4382 | { // Perhaps it's an FP constant? |
| 4383 | (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4384 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4385 | ;} |
| 4386 | break; |
| 4387 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4388 | case 188: |
| 4389 | #line 2134 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4390 | { |
| 4391 | (yyval.ValIDVal) = ValID::create(ConstantBool::getTrue()); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4392 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4393 | ;} |
| 4394 | break; |
| 4395 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4396 | case 189: |
| 4397 | #line 2138 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4398 | { |
| 4399 | (yyval.ValIDVal) = ValID::create(ConstantBool::getFalse()); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4400 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4401 | ;} |
| 4402 | break; |
| 4403 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4404 | case 190: |
| 4405 | #line 2142 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4406 | { |
| 4407 | (yyval.ValIDVal) = ValID::createNull(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4408 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4409 | ;} |
| 4410 | break; |
| 4411 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4412 | case 191: |
| 4413 | #line 2146 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4414 | { |
| 4415 | (yyval.ValIDVal) = ValID::createUndef(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4416 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4417 | ;} |
| 4418 | break; |
| 4419 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4420 | case 192: |
| 4421 | #line 2150 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4422 | { // A vector zero constant. |
| 4423 | (yyval.ValIDVal) = ValID::createZeroInit(); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4424 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4425 | ;} |
| 4426 | break; |
| 4427 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4428 | case 193: |
| 4429 | #line 2154 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4430 | { // Nonempty unsized packed vector |
| 4431 | const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType(); |
| 4432 | int NumElements = (yyvsp[-1].ConstVector)->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4433 | |
| 4434 | PackedType* pt = PackedType::get(ETy, NumElements); |
| 4435 | PATypeHolder* PTy = new PATypeHolder( |
| 4436 | HandleUpRefs( |
| 4437 | PackedType::get( |
| 4438 | ETy, |
| 4439 | NumElements) |
| 4440 | ) |
| 4441 | ); |
| 4442 | |
| 4443 | // Verify all elements are correct type! |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4444 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 4445 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4446 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4447 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4448 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4449 | } |
| 4450 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4451 | (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector))); |
| 4452 | delete PTy; delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4453 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4454 | ;} |
| 4455 | break; |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 4456 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4457 | case 194: |
| 4458 | #line 2179 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4459 | { |
| 4460 | (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal)); |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 4461 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4462 | ;} |
| 4463 | break; |
| 4464 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4465 | case 195: |
| 4466 | #line 2183 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4467 | { |
| 4468 | char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); |
| 4469 | std::string AsmStr = std::string((yyvsp[-2].StrVal), End); |
| 4470 | End = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4471 | std::string Constraints = std::string((yyvsp[0].StrVal), End); |
| 4472 | (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal)); |
| 4473 | free((yyvsp[-2].StrVal)); |
| 4474 | free((yyvsp[0].StrVal)); |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 4475 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4476 | ;} |
| 4477 | break; |
| 4478 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4479 | case 196: |
| 4480 | #line 2197 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4481 | { // Is it an integer reference...? |
| 4482 | (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); |
| 4483 | CHECK_FOR_ERROR |
| 4484 | ;} |
| 4485 | break; |
| 4486 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4487 | case 197: |
| 4488 | #line 2201 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4489 | { // Is it a named reference...? |
| 4490 | (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); |
| 4491 | CHECK_FOR_ERROR |
| 4492 | ;} |
| 4493 | break; |
| 4494 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4495 | case 200: |
| 4496 | #line 2213 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4497 | { |
| 4498 | (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal); |
| 4499 | CHECK_FOR_ERROR |
| 4500 | ;} |
| 4501 | break; |
| 4502 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4503 | case 201: |
| 4504 | #line 2218 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4505 | { |
| 4506 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 4507 | CHECK_FOR_ERROR |
| 4508 | ;} |
| 4509 | break; |
| 4510 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4511 | case 202: |
| 4512 | #line 2222 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4513 | { // Do not allow functions with 0 basic blocks |
| 4514 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 4515 | CHECK_FOR_ERROR |
| 4516 | ;} |
| 4517 | break; |
| 4518 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4519 | case 203: |
| 4520 | #line 2231 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4521 | { |
| 4522 | setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal)); |
| 4523 | CHECK_FOR_ERROR |
| 4524 | InsertValue((yyvsp[0].TermInstVal)); |
| 4525 | |
| 4526 | (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal)); |
| 4527 | InsertValue((yyvsp[-2].BasicBlockVal)); |
| 4528 | (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal); |
| 4529 | CHECK_FOR_ERROR |
| 4530 | ;} |
| 4531 | break; |
| 4532 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4533 | case 204: |
| 4534 | #line 2242 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4535 | { |
| 4536 | (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal)); |
| 4537 | (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); |
| 4538 | CHECK_FOR_ERROR |
| 4539 | ;} |
| 4540 | break; |
| 4541 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4542 | case 205: |
| 4543 | #line 2247 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4544 | { |
| 4545 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4546 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4547 | |
| 4548 | // Make sure to move the basic block to the correct location in the |
| 4549 | // function, instead of leaving it inserted wherever it was first |
| 4550 | // referenced. |
| 4551 | Function::BasicBlockListType &BBL = |
| 4552 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4553 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4554 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4555 | ;} |
| 4556 | break; |
| 4557 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4558 | case 206: |
| 4559 | #line 2259 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4560 | { |
| 4561 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4562 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4563 | |
| 4564 | // Make sure to move the basic block to the correct location in the |
| 4565 | // function, instead of leaving it inserted wherever it was first |
| 4566 | // referenced. |
| 4567 | Function::BasicBlockListType &BBL = |
| 4568 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4569 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4570 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4571 | ;} |
| 4572 | break; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4573 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4574 | case 207: |
| 4575 | #line 2272 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4576 | { // Return with a result... |
| 4577 | (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal)); |
| 4578 | CHECK_FOR_ERROR |
| 4579 | ;} |
| 4580 | break; |
| 4581 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4582 | case 208: |
| 4583 | #line 2276 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4584 | { // Return with no result... |
| 4585 | (yyval.TermInstVal) = new ReturnInst(); |
| 4586 | CHECK_FOR_ERROR |
| 4587 | ;} |
| 4588 | break; |
| 4589 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4590 | case 209: |
| 4591 | #line 2280 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4592 | { // Unconditional Branch... |
| 4593 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
| 4594 | CHECK_FOR_ERROR |
| 4595 | (yyval.TermInstVal) = new BranchInst(tmpBB); |
| 4596 | ;} |
| 4597 | break; |
| 4598 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4599 | case 210: |
| 4600 | #line 2285 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4601 | { |
| 4602 | BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); |
| 4603 | CHECK_FOR_ERROR |
| 4604 | BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal)); |
| 4605 | CHECK_FOR_ERROR |
| 4606 | Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal)); |
| 4607 | CHECK_FOR_ERROR |
| 4608 | (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4609 | ;} |
| 4610 | break; |
| 4611 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4612 | case 211: |
| 4613 | #line 2294 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4614 | { |
| 4615 | Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal)); |
| 4616 | CHECK_FOR_ERROR |
| 4617 | BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal)); |
| 4618 | CHECK_FOR_ERROR |
| 4619 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size()); |
| 4620 | (yyval.TermInstVal) = S; |
| 4621 | |
| 4622 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(), |
| 4623 | E = (yyvsp[-1].JumpTable)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4624 | for (; I != E; ++I) { |
| 4625 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4626 | S->addCase(CI, I->second); |
| 4627 | else |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4628 | GEN_ERROR("Switch case is constant, but not a simple integer!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4629 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4630 | delete (yyvsp[-1].JumpTable); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4631 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4632 | ;} |
| 4633 | break; |
| 4634 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4635 | case 212: |
| 4636 | #line 2313 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4637 | { |
| 4638 | Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4639 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4640 | BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4641 | CHECK_FOR_ERROR |
| 4642 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4643 | (yyval.TermInstVal) = S; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4644 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4645 | ;} |
| 4646 | break; |
| 4647 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4648 | case 213: |
| 4649 | #line 2323 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4650 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4651 | const PointerType *PFTy; |
| 4652 | const FunctionType *Ty; |
| 4653 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4654 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal)->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4655 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4656 | // Pull out the types of all of the arguments... |
| 4657 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4658 | if ((yyvsp[-7].ValueList)) { |
| 4659 | for (std::vector<Value*>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4660 | I != E; ++I) |
| 4661 | ParamTypes.push_back((*I)->getType()); |
| 4662 | } |
| 4663 | |
| 4664 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 4665 | if (isVarArg) ParamTypes.pop_back(); |
| 4666 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4667 | Ty = FunctionType::get((yyvsp[-10].TypeVal)->get(), ParamTypes, isVarArg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4668 | PFTy = PointerType::get(Ty); |
| 4669 | } |
| 4670 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4671 | Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4672 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4673 | BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4674 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4675 | BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4676 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4677 | |
| 4678 | // Create the call node... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4679 | if (!(yyvsp[-7].ValueList)) { // Has no arguments? |
| 4680 | (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4681 | } else { // Has arguments? |
| 4682 | // Loop through FunctionType's arguments and ensure they are specified |
| 4683 | // correctly! |
| 4684 | // |
| 4685 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4686 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4687 | std::vector<Value*>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4688 | |
| 4689 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 4690 | if ((*ArgI)->getType() != *I) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4691 | GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4692 | (*I)->getDescription() + "'!"); |
| 4693 | |
| 4694 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4695 | GEN_ERROR("Invalid number of parameters detected!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4696 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4697 | (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4698 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4699 | cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4700 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4701 | delete (yyvsp[-10].TypeVal); |
| 4702 | delete (yyvsp[-7].ValueList); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4703 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4704 | ;} |
| 4705 | break; |
| 4706 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4707 | case 214: |
| 4708 | #line 2378 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4709 | { |
| 4710 | (yyval.TermInstVal) = new UnwindInst(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4711 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4712 | ;} |
| 4713 | break; |
| 4714 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4715 | case 215: |
| 4716 | #line 2382 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4717 | { |
| 4718 | (yyval.TermInstVal) = new UnreachableInst(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4719 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4720 | ;} |
| 4721 | break; |
| 4722 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4723 | case 216: |
| 4724 | #line 2389 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4725 | { |
| 4726 | (yyval.JumpTable) = (yyvsp[-5].JumpTable); |
| 4727 | Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4728 | CHECK_FOR_ERROR |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4729 | if (V == 0) |
| 4730 | GEN_ERROR("May only switch on a constant pool value!"); |
| 4731 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4732 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4733 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4734 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 4735 | ;} |
| 4736 | break; |
| 4737 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4738 | case 217: |
| 4739 | #line 2400 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4740 | { |
| 4741 | (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 4742 | Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4743 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4744 | |
| 4745 | if (V == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4746 | GEN_ERROR("May only switch on a constant pool value!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4747 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4748 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4749 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4750 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 4751 | ;} |
| 4752 | break; |
| 4753 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4754 | case 218: |
| 4755 | #line 2413 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4756 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4757 | // Is this definition named?? if so, assign the name... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4758 | setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4759 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4760 | InsertValue((yyvsp[0].InstVal)); |
| 4761 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4762 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4763 | ;} |
| 4764 | break; |
| 4765 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4766 | case 219: |
| 4767 | #line 2422 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4768 | { // Used for PHI nodes |
| 4769 | (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 4770 | Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4771 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4772 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4773 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4774 | (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4775 | delete (yyvsp[-5].TypeVal); |
| 4776 | ;} |
| 4777 | break; |
| 4778 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4779 | case 220: |
| 4780 | #line 2431 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4781 | { |
| 4782 | (yyval.PHIList) = (yyvsp[-6].PHIList); |
| 4783 | Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4784 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4785 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4786 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4787 | (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4788 | ;} |
| 4789 | break; |
| 4790 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4791 | case 221: |
| 4792 | #line 2441 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4793 | { // Used for call statements, and memory insts... |
| 4794 | (yyval.ValueList) = new std::vector<Value*>(); |
| 4795 | (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); |
| 4796 | ;} |
| 4797 | break; |
| 4798 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4799 | case 222: |
| 4800 | #line 2445 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4801 | { |
| 4802 | (yyval.ValueList) = (yyvsp[-2].ValueList); |
| 4803 | (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4804 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4805 | ;} |
| 4806 | break; |
| 4807 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4808 | case 224: |
| 4809 | #line 2452 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4810 | { (yyval.ValueList) = 0; ;} |
| 4811 | break; |
| 4812 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4813 | case 225: |
| 4814 | #line 2454 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4815 | { |
| 4816 | (yyval.BoolVal) = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4817 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4818 | ;} |
| 4819 | break; |
| 4820 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4821 | case 226: |
| 4822 | #line 2458 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4823 | { |
| 4824 | (yyval.BoolVal) = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4825 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4826 | ;} |
| 4827 | break; |
| 4828 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4829 | case 227: |
| 4830 | #line 2463 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4831 | { |
| 4832 | if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() && |
| 4833 | !isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4834 | GEN_ERROR( |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4835 | "Arithmetic operator requires integer, FP, or packed operands!"); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4836 | if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) && (yyvsp[-4].BinaryOpVal).opcode == Instruction::Rem) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4837 | GEN_ERROR("Rem not supported on packed types!"); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4838 | // Upgrade the opcode from obsolete versions before we do anything with it. |
| 4839 | sanitizeOpCode((yyvsp[-4].BinaryOpVal),*(yyvsp[-3].TypeVal)); |
| 4840 | CHECK_FOR_ERROR; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4841 | Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4842 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4843 | Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4844 | CHECK_FOR_ERROR |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4845 | (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, val1, val2); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4846 | if ((yyval.InstVal) == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4847 | GEN_ERROR("binary operator returned null!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4848 | delete (yyvsp[-3].TypeVal); |
| 4849 | ;} |
| 4850 | break; |
| 4851 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4852 | case 228: |
| 4853 | #line 2482 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4854 | { |
| 4855 | if (!(*(yyvsp[-3].TypeVal))->isIntegral()) { |
| 4856 | if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) || |
| 4857 | !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4858 | GEN_ERROR("Logical operator requires integral operands!"); |
Chris Lattner | 524a131 | 2005-12-21 18:31:50 +0000 | [diff] [blame] | 4859 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4860 | Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4861 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4862 | Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4863 | CHECK_FOR_ERROR |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4864 | (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4865 | if ((yyval.InstVal) == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4866 | GEN_ERROR("binary operator returned null!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4867 | delete (yyvsp[-3].TypeVal); |
| 4868 | ;} |
| 4869 | break; |
| 4870 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4871 | case 229: |
| 4872 | #line 2497 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4873 | { |
| 4874 | if(isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4875 | GEN_ERROR( |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4876 | "PackedTypes currently not supported in setcc instructions!"); |
| 4877 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4878 | Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4879 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4880 | Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4881 | CHECK_FOR_ERROR |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4882 | (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4883 | if ((yyval.InstVal) == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4884 | GEN_ERROR("binary operator returned null!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4885 | delete (yyvsp[-3].TypeVal); |
| 4886 | ;} |
| 4887 | break; |
| 4888 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4889 | case 230: |
| 4890 | #line 2511 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4891 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4892 | std::cerr << "WARNING: Use of eliminated 'not' instruction:" |
| 4893 | << " Replacing with 'xor'.\n"; |
| 4894 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4895 | Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4896 | if (Ones == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4897 | GEN_ERROR("Expected integral type for not instruction!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4898 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4899 | (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones); |
| 4900 | if ((yyval.InstVal) == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4901 | GEN_ERROR("Could not create a xor instruction!"); |
| 4902 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4903 | ;} |
| 4904 | break; |
| 4905 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4906 | case 231: |
| 4907 | #line 2524 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4908 | { |
| 4909 | if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4910 | GEN_ERROR("Shift amount must be ubyte!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4911 | if (!(yyvsp[-2].ValueVal)->getType()->isInteger()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4912 | GEN_ERROR("Shift constant expression requires integer operand!"); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4913 | (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal).opcode, (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4914 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4915 | ;} |
| 4916 | break; |
| 4917 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4918 | case 232: |
| 4919 | #line 2532 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4920 | { |
| 4921 | if (!(yyvsp[0].TypeVal)->get()->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4922 | GEN_ERROR("cast instruction to a non-primitive type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4923 | (yyvsp[0].TypeVal)->get()->getDescription() + "'!"); |
| 4924 | (yyval.InstVal) = new CastInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal)); |
| 4925 | delete (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4926 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4927 | ;} |
| 4928 | break; |
| 4929 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4930 | case 233: |
| 4931 | #line 2540 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4932 | { |
| 4933 | if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4934 | GEN_ERROR("select condition must be boolean!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4935 | if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4936 | GEN_ERROR("select value types should match!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4937 | (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4938 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4939 | ;} |
| 4940 | break; |
| 4941 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4942 | case 234: |
| 4943 | #line 2548 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4944 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4945 | NewVarArgs = true; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4946 | (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal)); |
| 4947 | delete (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4948 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4949 | ;} |
| 4950 | break; |
| 4951 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4952 | case 235: |
| 4953 | #line 2554 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4954 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4955 | ObsoleteVarArgs = true; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4956 | const Type* ArgTy = (yyvsp[-2].ValueVal)->getType(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4957 | Function* NF = CurModule.CurrentModule-> |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 4958 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4959 | |
| 4960 | //b = vaarg a, t -> |
| 4961 | //foo = alloca 1 of t |
| 4962 | //bar = vacopy a |
| 4963 | //store bar -> foo |
| 4964 | //b = vaarg foo, t |
| 4965 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); |
| 4966 | CurBB->getInstList().push_back(foo); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4967 | CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4968 | CurBB->getInstList().push_back(bar); |
| 4969 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4970 | (yyval.InstVal) = new VAArgInst(foo, *(yyvsp[0].TypeVal)); |
| 4971 | delete (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4972 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4973 | ;} |
| 4974 | break; |
| 4975 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 4976 | case 236: |
| 4977 | #line 2574 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4978 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4979 | ObsoleteVarArgs = true; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4980 | const Type* ArgTy = (yyvsp[-2].ValueVal)->getType(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4981 | Function* NF = CurModule.CurrentModule-> |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 4982 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4983 | |
| 4984 | //b = vanext a, t -> |
| 4985 | //foo = alloca 1 of t |
| 4986 | //bar = vacopy a |
| 4987 | //store bar -> foo |
| 4988 | //tmp = vaarg foo, t |
| 4989 | //b = load foo |
| 4990 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); |
| 4991 | CurBB->getInstList().push_back(foo); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4992 | CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4993 | CurBB->getInstList().push_back(bar); |
| 4994 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4995 | Instruction* tmp = new VAArgInst(foo, *(yyvsp[0].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4996 | CurBB->getInstList().push_back(tmp); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4997 | (yyval.InstVal) = new LoadInst(foo); |
| 4998 | delete (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4999 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5000 | ;} |
| 5001 | break; |
| 5002 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5003 | case 237: |
| 5004 | #line 2597 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5005 | { |
| 5006 | if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5007 | GEN_ERROR("Invalid extractelement operands!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5008 | (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5009 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5010 | ;} |
| 5011 | break; |
| 5012 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5013 | case 238: |
| 5014 | #line 2603 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5015 | { |
| 5016 | if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5017 | GEN_ERROR("Invalid insertelement operands!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5018 | (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5019 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5020 | ;} |
| 5021 | break; |
| 5022 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5023 | case 239: |
| 5024 | #line 2609 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5025 | { |
| 5026 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5027 | GEN_ERROR("Invalid shufflevector operands!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5028 | (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5029 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5030 | ;} |
| 5031 | break; |
| 5032 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5033 | case 240: |
| 5034 | #line 2615 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5035 | { |
| 5036 | const Type *Ty = (yyvsp[0].PHIList)->front().first->getType(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5037 | if (!Ty->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5038 | GEN_ERROR("PHI node operands must be of first class type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5039 | (yyval.InstVal) = new PHINode(Ty); |
| 5040 | ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size()); |
| 5041 | while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) { |
| 5042 | if ((yyvsp[0].PHIList)->front().first->getType() != Ty) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5043 | GEN_ERROR("All elements of a PHI node must be of the same type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5044 | cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second); |
| 5045 | (yyvsp[0].PHIList)->pop_front(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5046 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5047 | delete (yyvsp[0].PHIList); // Free the list... |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5048 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5049 | ;} |
| 5050 | break; |
| 5051 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5052 | case 241: |
| 5053 | #line 2630 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5054 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5055 | const PointerType *PFTy; |
| 5056 | const FunctionType *Ty; |
| 5057 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5058 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal)->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5059 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5060 | // Pull out the types of all of the arguments... |
| 5061 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5062 | if ((yyvsp[-1].ValueList)) { |
| 5063 | for (std::vector<Value*>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5064 | I != E; ++I) |
| 5065 | ParamTypes.push_back((*I)->getType()); |
| 5066 | } |
| 5067 | |
| 5068 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 5069 | if (isVarArg) ParamTypes.pop_back(); |
| 5070 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5071 | if (!(*(yyvsp[-4].TypeVal))->isFirstClassType() && *(yyvsp[-4].TypeVal) != Type::VoidTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5072 | GEN_ERROR("LLVM functions cannot return aggregate types!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5073 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5074 | Ty = FunctionType::get((yyvsp[-4].TypeVal)->get(), ParamTypes, isVarArg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5075 | PFTy = PointerType::get(Ty); |
| 5076 | } |
| 5077 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5078 | Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); // Get the function we're calling... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5079 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5080 | |
| 5081 | // Create the call node... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5082 | if (!(yyvsp[-1].ValueList)) { // Has no arguments? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5083 | // Make sure no arguments is a good thing! |
| 5084 | if (Ty->getNumParams() != 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5085 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5086 | "expects arguments!"); |
| 5087 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5088 | (yyval.InstVal) = new CallInst(V, std::vector<Value*>()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5089 | } else { // Has arguments? |
| 5090 | // Loop through FunctionType's arguments and ensure they are specified |
| 5091 | // correctly! |
| 5092 | // |
| 5093 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5094 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5095 | std::vector<Value*>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5096 | |
| 5097 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 5098 | if ((*ArgI)->getType() != *I) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5099 | GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5100 | (*I)->getDescription() + "'!"); |
| 5101 | |
| 5102 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5103 | GEN_ERROR("Invalid number of parameters detected!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5104 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5105 | (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5106 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5107 | cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal)); |
| 5108 | cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal)); |
| 5109 | delete (yyvsp[-4].TypeVal); |
| 5110 | delete (yyvsp[-1].ValueList); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5111 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5112 | ;} |
| 5113 | break; |
| 5114 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5115 | case 242: |
| 5116 | #line 2689 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5117 | { |
| 5118 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5119 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5120 | ;} |
| 5121 | break; |
| 5122 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5123 | case 243: |
| 5124 | #line 2696 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5125 | { |
| 5126 | (yyval.ValueList) = (yyvsp[0].ValueList); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5127 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5128 | ;} |
| 5129 | break; |
| 5130 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5131 | case 244: |
| 5132 | #line 2699 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5133 | { |
| 5134 | (yyval.ValueList) = new std::vector<Value*>(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5135 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5136 | ;} |
| 5137 | break; |
| 5138 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5139 | case 245: |
| 5140 | #line 2704 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5141 | { |
| 5142 | (yyval.BoolVal) = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5143 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5144 | ;} |
| 5145 | break; |
| 5146 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5147 | case 246: |
| 5148 | #line 2708 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5149 | { |
| 5150 | (yyval.BoolVal) = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5151 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5152 | ;} |
| 5153 | break; |
| 5154 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5155 | case 247: |
| 5156 | #line 2715 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5157 | { |
| 5158 | (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); |
| 5159 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5160 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5161 | ;} |
| 5162 | break; |
| 5163 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5164 | case 248: |
| 5165 | #line 2720 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5166 | { |
| 5167 | Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5168 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5169 | (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); |
| 5170 | delete (yyvsp[-4].TypeVal); |
| 5171 | ;} |
| 5172 | break; |
| 5173 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5174 | case 249: |
| 5175 | #line 2726 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5176 | { |
| 5177 | (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); |
| 5178 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5179 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5180 | ;} |
| 5181 | break; |
| 5182 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5183 | case 250: |
| 5184 | #line 2731 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5185 | { |
| 5186 | Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5187 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5188 | (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); |
| 5189 | delete (yyvsp[-4].TypeVal); |
| 5190 | ;} |
| 5191 | break; |
| 5192 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5193 | case 251: |
| 5194 | #line 2737 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5195 | { |
| 5196 | if (!isa<PointerType>((yyvsp[0].ValueVal)->getType())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5197 | GEN_ERROR("Trying to free nonpointer type " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5198 | (yyvsp[0].ValueVal)->getType()->getDescription() + "!"); |
| 5199 | (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5200 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5201 | ;} |
| 5202 | break; |
| 5203 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5204 | case 252: |
| 5205 | #line 2745 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5206 | { |
| 5207 | if (!isa<PointerType>((yyvsp[-1].TypeVal)->get())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5208 | GEN_ERROR("Can't load from nonpointer type: " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5209 | (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5210 | if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5211 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5212 | (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5213 | Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5214 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5215 | (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal)); |
| 5216 | delete (yyvsp[-1].TypeVal); |
| 5217 | ;} |
| 5218 | break; |
| 5219 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5220 | case 253: |
| 5221 | #line 2757 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5222 | { |
| 5223 | const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5224 | if (!PT) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5225 | GEN_ERROR("Can't store to a nonpointer type: " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5226 | (*(yyvsp[-1].TypeVal))->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5227 | const Type *ElTy = PT->getElementType(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5228 | if (ElTy != (yyvsp[-3].ValueVal)->getType()) |
| 5229 | GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5230 | "' into space of type '" + ElTy->getDescription() + "'!"); |
| 5231 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5232 | Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5233 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5234 | (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal)); |
| 5235 | delete (yyvsp[-1].TypeVal); |
| 5236 | ;} |
| 5237 | break; |
| 5238 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5239 | case 254: |
| 5240 | #line 2772 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5241 | { |
| 5242 | if (!isa<PointerType>((yyvsp[-2].TypeVal)->get())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5243 | GEN_ERROR("getelementptr insn requires pointer operand!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5244 | |
| 5245 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct |
| 5246 | // indices to uint struct indices for compatibility. |
| 5247 | generic_gep_type_iterator<std::vector<Value*>::iterator> |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5248 | GTI = gep_type_begin((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()), |
| 5249 | GTE = gep_type_end((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()); |
| 5250 | for (unsigned i = 0, e = (yyvsp[0].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5251 | if (isa<StructType>(*GTI)) // Only change struct indices |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5252 | if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[0].ValueList))[i])) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5253 | if (CUI->getType() == Type::UByteTy) |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5254 | (*(yyvsp[0].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5255 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5256 | if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5257 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5258 | (*(yyvsp[-2].TypeVal))->getDescription()+ "'!"); |
| 5259 | Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5260 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5261 | (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList)); |
| 5262 | delete (yyvsp[-2].TypeVal); |
| 5263 | delete (yyvsp[0].ValueList); |
| 5264 | ;} |
| 5265 | break; |
| 5266 | |
| 5267 | |
| 5268 | default: break; |
| 5269 | } |
| 5270 | |
| 5271 | /* Line 1126 of yacc.c. */ |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5272 | #line 5273 "llvmAsmParser.tab.c" |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5273 | |
| 5274 | yyvsp -= yylen; |
| 5275 | yyssp -= yylen; |
| 5276 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5277 | |
| 5278 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5279 | |
| 5280 | *++yyvsp = yyval; |
| 5281 | |
| 5282 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5283 | /* Now `shift' the result of the reduction. Determine what state |
| 5284 | that goes to, based on the state we popped back to and the rule |
| 5285 | number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5286 | |
| 5287 | yyn = yyr1[yyn]; |
| 5288 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5289 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 5290 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5291 | yystate = yytable[yystate]; |
| 5292 | else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5293 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5294 | |
| 5295 | goto yynewstate; |
| 5296 | |
| 5297 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5298 | /*------------------------------------. |
| 5299 | | yyerrlab -- here on detecting error | |
| 5300 | `------------------------------------*/ |
| 5301 | yyerrlab: |
| 5302 | /* If not already recovering from an error, report this error. */ |
| 5303 | if (!yyerrstatus) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5304 | { |
| 5305 | ++yynerrs; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5306 | #if YYERROR_VERBOSE |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5307 | yyn = yypact[yystate]; |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 5308 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5309 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5310 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5311 | int yytype = YYTRANSLATE (yychar); |
| 5312 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); |
| 5313 | YYSIZE_T yysize = yysize0; |
| 5314 | YYSIZE_T yysize1; |
| 5315 | int yysize_overflow = 0; |
| 5316 | char *yymsg = 0; |
| 5317 | # define YYERROR_VERBOSE_ARGS_MAXIMUM 5 |
| 5318 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 5319 | int yyx; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5320 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5321 | #if 0 |
| 5322 | /* This is so xgettext sees the translatable formats that are |
| 5323 | constructed on the fly. */ |
| 5324 | YY_("syntax error, unexpected %s"); |
| 5325 | YY_("syntax error, unexpected %s, expecting %s"); |
| 5326 | YY_("syntax error, unexpected %s, expecting %s or %s"); |
| 5327 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); |
| 5328 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); |
| 5329 | #endif |
| 5330 | char *yyfmt; |
| 5331 | char const *yyf; |
| 5332 | static char const yyunexpected[] = "syntax error, unexpected %s"; |
| 5333 | static char const yyexpecting[] = ", expecting %s"; |
| 5334 | static char const yyor[] = " or %s"; |
| 5335 | char yyformat[sizeof yyunexpected |
| 5336 | + sizeof yyexpecting - 1 |
| 5337 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) |
| 5338 | * (sizeof yyor - 1))]; |
| 5339 | char const *yyprefix = yyexpecting; |
| 5340 | |
| 5341 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 5342 | YYCHECK. */ |
| 5343 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 5344 | |
| 5345 | /* Stay within bounds of both yycheck and yytname. */ |
| 5346 | int yychecklim = YYLAST - yyn; |
| 5347 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 5348 | int yycount = 1; |
| 5349 | |
| 5350 | yyarg[0] = yytname[yytype]; |
| 5351 | yyfmt = yystpcpy (yyformat, yyunexpected); |
| 5352 | |
| 5353 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 5354 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 5355 | { |
| 5356 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 5357 | { |
| 5358 | yycount = 1; |
| 5359 | yysize = yysize0; |
| 5360 | yyformat[sizeof yyunexpected - 1] = '\0'; |
| 5361 | break; |
| 5362 | } |
| 5363 | yyarg[yycount++] = yytname[yyx]; |
| 5364 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); |
| 5365 | yysize_overflow |= yysize1 < yysize; |
| 5366 | yysize = yysize1; |
| 5367 | yyfmt = yystpcpy (yyfmt, yyprefix); |
| 5368 | yyprefix = yyor; |
| 5369 | } |
| 5370 | |
| 5371 | yyf = YY_(yyformat); |
| 5372 | yysize1 = yysize + yystrlen (yyf); |
| 5373 | yysize_overflow |= yysize1 < yysize; |
| 5374 | yysize = yysize1; |
| 5375 | |
| 5376 | if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) |
| 5377 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
| 5378 | if (yymsg) |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5379 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5380 | /* Avoid sprintf, as that infringes on the user's name space. |
| 5381 | Don't have undefined behavior even if the translation |
| 5382 | produced a string with the wrong number of "%s"s. */ |
| 5383 | char *yyp = yymsg; |
| 5384 | int yyi = 0; |
| 5385 | while ((*yyp = *yyf)) |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5386 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5387 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) |
| 5388 | { |
| 5389 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
| 5390 | yyf += 2; |
| 5391 | } |
| 5392 | else |
| 5393 | { |
| 5394 | yyp++; |
| 5395 | yyf++; |
| 5396 | } |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5397 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5398 | yyerror (yymsg); |
| 5399 | YYSTACK_FREE (yymsg); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5400 | } |
| 5401 | else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5402 | { |
| 5403 | yyerror (YY_("syntax error")); |
| 5404 | goto yyexhaustedlab; |
| 5405 | } |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5406 | } |
| 5407 | else |
| 5408 | #endif /* YYERROR_VERBOSE */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5409 | yyerror (YY_("syntax error")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5410 | } |
| 5411 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5412 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5413 | |
| 5414 | if (yyerrstatus == 3) |
| 5415 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5416 | /* If just tried and failed to reuse look-ahead token after an |
| 5417 | error, discard it. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5418 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5419 | if (yychar <= YYEOF) |
| 5420 | { |
| 5421 | /* Return failure if at end of input. */ |
| 5422 | if (yychar == YYEOF) |
| 5423 | YYABORT; |
| 5424 | } |
| 5425 | else |
| 5426 | { |
| 5427 | yydestruct ("Error: discarding", yytoken, &yylval); |
| 5428 | yychar = YYEMPTY; |
| 5429 | } |
| 5430 | } |
| 5431 | |
| 5432 | /* Else will try to reuse look-ahead token after shifting the error |
| 5433 | token. */ |
| 5434 | goto yyerrlab1; |
| 5435 | |
| 5436 | |
| 5437 | /*---------------------------------------------------. |
| 5438 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 5439 | `---------------------------------------------------*/ |
| 5440 | yyerrorlab: |
| 5441 | |
| 5442 | /* Pacify compilers like GCC when the user code never invokes |
| 5443 | YYERROR and the label yyerrorlab therefore never appears in user |
| 5444 | code. */ |
| 5445 | if (0) |
| 5446 | goto yyerrorlab; |
| 5447 | |
| 5448 | yyvsp -= yylen; |
| 5449 | yyssp -= yylen; |
| 5450 | yystate = *yyssp; |
| 5451 | goto yyerrlab1; |
| 5452 | |
| 5453 | |
| 5454 | /*-------------------------------------------------------------. |
| 5455 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 5456 | `-------------------------------------------------------------*/ |
| 5457 | yyerrlab1: |
| 5458 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 5459 | |
| 5460 | for (;;) |
| 5461 | { |
| 5462 | yyn = yypact[yystate]; |
| 5463 | if (yyn != YYPACT_NINF) |
| 5464 | { |
| 5465 | yyn += YYTERROR; |
| 5466 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 5467 | { |
| 5468 | yyn = yytable[yyn]; |
| 5469 | if (0 < yyn) |
| 5470 | break; |
| 5471 | } |
| 5472 | } |
| 5473 | |
| 5474 | /* Pop the current state because it cannot handle the error token. */ |
| 5475 | if (yyssp == yyss) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5476 | YYABORT; |
| 5477 | |
Chris Lattner | 8335e84 | 2006-01-23 23:05:42 +0000 | [diff] [blame] | 5478 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5479 | yydestruct ("Error: popping", yystos[yystate], yyvsp); |
| 5480 | YYPOPSTACK; |
| 5481 | yystate = *yyssp; |
| 5482 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5483 | } |
| 5484 | |
| 5485 | if (yyn == YYFINAL) |
| 5486 | YYACCEPT; |
| 5487 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5488 | *++yyvsp = yylval; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5489 | |
| 5490 | |
| 5491 | /* Shift the error token. */ |
| 5492 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5493 | |
| 5494 | yystate = yyn; |
| 5495 | goto yynewstate; |
| 5496 | |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 5497 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5498 | /*-------------------------------------. |
| 5499 | | yyacceptlab -- YYACCEPT comes here. | |
| 5500 | `-------------------------------------*/ |
| 5501 | yyacceptlab: |
| 5502 | yyresult = 0; |
| 5503 | goto yyreturn; |
| 5504 | |
| 5505 | /*-----------------------------------. |
| 5506 | | yyabortlab -- YYABORT comes here. | |
| 5507 | `-----------------------------------*/ |
| 5508 | yyabortlab: |
| 5509 | yyresult = 1; |
| 5510 | goto yyreturn; |
| 5511 | |
| 5512 | #ifndef yyoverflow |
| 5513 | /*-------------------------------------------------. |
| 5514 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 5515 | `-------------------------------------------------*/ |
| 5516 | yyexhaustedlab: |
| 5517 | yyerror (YY_("memory exhausted")); |
| 5518 | yyresult = 2; |
| 5519 | /* Fall through. */ |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 5520 | #endif |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5521 | |
| 5522 | yyreturn: |
| 5523 | if (yychar != YYEOF && yychar != YYEMPTY) |
| 5524 | yydestruct ("Cleanup: discarding lookahead", |
| 5525 | yytoken, &yylval); |
| 5526 | while (yyssp != yyss) |
| 5527 | { |
| 5528 | yydestruct ("Cleanup: popping", |
| 5529 | yystos[*yyssp], yyvsp); |
| 5530 | YYPOPSTACK; |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 5531 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5532 | #ifndef yyoverflow |
| 5533 | if (yyss != yyssa) |
| 5534 | YYSTACK_FREE (yyss); |
| 5535 | #endif |
| 5536 | return yyresult; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5537 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5538 | |
| 5539 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame^] | 5540 | #line 2798 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5541 | |
| 5542 | |
| 5543 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 5544 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 5545 | // TODO: column number in exception |
| 5546 | if (TheParseError) |
| 5547 | TheParseError->setError(CurFilename, message, LineNo); |
| 5548 | TriggerError = 1; |
| 5549 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5550 | |
| 5551 | int yyerror(const char *ErrorMsg) { |
| 5552 | std::string where |
| 5553 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 5554 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
| 5555 | std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading "; |
| 5556 | if (yychar == YYEMPTY || yychar == 0) |
| 5557 | errMsg += "end-of-file."; |
| 5558 | else |
| 5559 | errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5560 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5561 | return 0; |
| 5562 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5563 | |