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, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 148 | UREM = 339, |
| 149 | SREM = 340, |
| 150 | FREM = 341, |
| 151 | AND = 342, |
| 152 | OR = 343, |
| 153 | XOR = 344, |
| 154 | SETLE = 345, |
| 155 | SETGE = 346, |
| 156 | SETLT = 347, |
| 157 | SETGT = 348, |
| 158 | SETEQ = 349, |
| 159 | SETNE = 350, |
| 160 | MALLOC = 351, |
| 161 | ALLOCA = 352, |
| 162 | FREE = 353, |
| 163 | LOAD = 354, |
| 164 | STORE = 355, |
| 165 | GETELEMENTPTR = 356, |
| 166 | PHI_TOK = 357, |
| 167 | CAST = 358, |
| 168 | SELECT = 359, |
| 169 | SHL = 360, |
| 170 | SHR = 361, |
| 171 | VAARG = 362, |
| 172 | EXTRACTELEMENT = 363, |
| 173 | INSERTELEMENT = 364, |
| 174 | SHUFFLEVECTOR = 365, |
| 175 | VAARG_old = 366, |
| 176 | VANEXT_old = 367 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 177 | }; |
| 178 | #endif |
| 179 | /* Tokens. */ |
| 180 | #define ESINT64VAL 258 |
| 181 | #define EUINT64VAL 259 |
| 182 | #define SINTVAL 260 |
| 183 | #define UINTVAL 261 |
| 184 | #define FPVAL 262 |
| 185 | #define VOID 263 |
| 186 | #define BOOL 264 |
| 187 | #define SBYTE 265 |
| 188 | #define UBYTE 266 |
| 189 | #define SHORT 267 |
| 190 | #define USHORT 268 |
| 191 | #define INT 269 |
| 192 | #define UINT 270 |
| 193 | #define LONG 271 |
| 194 | #define ULONG 272 |
| 195 | #define FLOAT 273 |
| 196 | #define DOUBLE 274 |
| 197 | #define TYPE 275 |
| 198 | #define LABEL 276 |
| 199 | #define VAR_ID 277 |
| 200 | #define LABELSTR 278 |
| 201 | #define STRINGCONSTANT 279 |
| 202 | #define IMPLEMENTATION 280 |
| 203 | #define ZEROINITIALIZER 281 |
| 204 | #define TRUETOK 282 |
| 205 | #define FALSETOK 283 |
| 206 | #define BEGINTOK 284 |
| 207 | #define ENDTOK 285 |
| 208 | #define DECLARE 286 |
| 209 | #define GLOBAL 287 |
| 210 | #define CONSTANT 288 |
| 211 | #define SECTION 289 |
| 212 | #define VOLATILE 290 |
| 213 | #define TO 291 |
| 214 | #define DOTDOTDOT 292 |
| 215 | #define NULL_TOK 293 |
| 216 | #define UNDEF 294 |
| 217 | #define CONST 295 |
| 218 | #define INTERNAL 296 |
| 219 | #define LINKONCE 297 |
| 220 | #define WEAK 298 |
| 221 | #define APPENDING 299 |
| 222 | #define DLLIMPORT 300 |
| 223 | #define DLLEXPORT 301 |
| 224 | #define EXTERN_WEAK 302 |
| 225 | #define OPAQUE 303 |
| 226 | #define NOT 304 |
| 227 | #define EXTERNAL 305 |
| 228 | #define TARGET 306 |
| 229 | #define TRIPLE 307 |
| 230 | #define ENDIAN 308 |
| 231 | #define POINTERSIZE 309 |
| 232 | #define LITTLE 310 |
| 233 | #define BIG 311 |
| 234 | #define ALIGN 312 |
| 235 | #define DEPLIBS 313 |
| 236 | #define CALL 314 |
| 237 | #define TAIL 315 |
| 238 | #define ASM_TOK 316 |
| 239 | #define MODULE 317 |
| 240 | #define SIDEEFFECT 318 |
| 241 | #define CC_TOK 319 |
| 242 | #define CCC_TOK 320 |
| 243 | #define CSRETCC_TOK 321 |
| 244 | #define FASTCC_TOK 322 |
| 245 | #define COLDCC_TOK 323 |
| 246 | #define X86_STDCALLCC_TOK 324 |
| 247 | #define X86_FASTCALLCC_TOK 325 |
| 248 | #define DATALAYOUT 326 |
| 249 | #define RET 327 |
| 250 | #define BR 328 |
| 251 | #define SWITCH 329 |
| 252 | #define INVOKE 330 |
| 253 | #define UNWIND 331 |
| 254 | #define UNREACHABLE 332 |
| 255 | #define ADD 333 |
| 256 | #define SUB 334 |
| 257 | #define MUL 335 |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 258 | #define UDIV 336 |
| 259 | #define SDIV 337 |
| 260 | #define FDIV 338 |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 261 | #define UREM 339 |
| 262 | #define SREM 340 |
| 263 | #define FREM 341 |
| 264 | #define AND 342 |
| 265 | #define OR 343 |
| 266 | #define XOR 344 |
| 267 | #define SETLE 345 |
| 268 | #define SETGE 346 |
| 269 | #define SETLT 347 |
| 270 | #define SETGT 348 |
| 271 | #define SETEQ 349 |
| 272 | #define SETNE 350 |
| 273 | #define MALLOC 351 |
| 274 | #define ALLOCA 352 |
| 275 | #define FREE 353 |
| 276 | #define LOAD 354 |
| 277 | #define STORE 355 |
| 278 | #define GETELEMENTPTR 356 |
| 279 | #define PHI_TOK 357 |
| 280 | #define CAST 358 |
| 281 | #define SELECT 359 |
| 282 | #define SHL 360 |
| 283 | #define SHR 361 |
| 284 | #define VAARG 362 |
| 285 | #define EXTRACTELEMENT 363 |
| 286 | #define INSERTELEMENT 364 |
| 287 | #define SHUFFLEVECTOR 365 |
| 288 | #define VAARG_old 366 |
| 289 | #define VANEXT_old 367 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | /* Copy the first part of user declarations. */ |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 295 | #line 14 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 296 | |
| 297 | #include "ParserInternals.h" |
| 298 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 299 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 300 | #include "llvm/Instructions.h" |
| 301 | #include "llvm/Module.h" |
| 302 | #include "llvm/SymbolTable.h" |
Reid Spencer | 0b11820 | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 303 | #include "llvm/Assembly/AutoUpgrade.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 304 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
| 305 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 306 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 307 | #include <algorithm> |
| 308 | #include <iostream> |
| 309 | #include <list> |
| 310 | #include <utility> |
| 311 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 312 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 313 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 314 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 315 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 316 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 317 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 318 | // GenerateError are made from inside productions and they must simulate the |
| 319 | // previous exception behavior by exiting the production immediately. We have |
| 320 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 321 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 322 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 323 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 324 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 325 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 326 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 327 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 328 | int yylex(); // declaration" of xxx warnings. |
| 329 | int yyparse(); |
| 330 | |
| 331 | namespace llvm { |
| 332 | std::string CurFilename; |
| 333 | } |
| 334 | using namespace llvm; |
| 335 | |
| 336 | static Module *ParserResult; |
| 337 | |
| 338 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 339 | // relating to upreferences in the input stream. |
| 340 | // |
| 341 | //#define DEBUG_UPREFS 1 |
| 342 | #ifdef DEBUG_UPREFS |
| 343 | #define UR_OUT(X) std::cerr << X |
| 344 | #else |
| 345 | #define UR_OUT(X) |
| 346 | #endif |
| 347 | |
| 348 | #define YYERROR_VERBOSE 1 |
| 349 | |
| 350 | static bool ObsoleteVarArgs; |
| 351 | static bool NewVarArgs; |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 352 | static BasicBlock *CurBB; |
| 353 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 354 | |
| 355 | |
| 356 | // This contains info used when building the body of a function. It is |
| 357 | // destroyed when the function is completed. |
| 358 | // |
| 359 | typedef std::vector<Value *> ValueList; // Numbered defs |
| 360 | static void |
| 361 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 362 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 363 | |
| 364 | static struct PerModuleInfo { |
| 365 | Module *CurrentModule; |
| 366 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 367 | std::map<const Type *,ValueList> LateResolveValues; |
| 368 | std::vector<PATypeHolder> Types; |
| 369 | std::map<ValID, PATypeHolder> LateResolveTypes; |
| 370 | |
| 371 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 372 | /// 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] | 373 | /// that we can resolve them later and print error messages as appropriate. |
| 374 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 375 | |
| 376 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 377 | // references to global values. Global values may be referenced before they |
| 378 | // are defined, and if so, the temporary object that they represent is held |
| 379 | // here. This is used for forward references of GlobalValues. |
| 380 | // |
| 381 | typedef std::map<std::pair<const PointerType *, |
| 382 | ValID>, GlobalValue*> GlobalRefsType; |
| 383 | GlobalRefsType GlobalRefs; |
| 384 | |
| 385 | void ModuleDone() { |
| 386 | // If we could not resolve some functions at function compilation time |
| 387 | // (calls to functions before they are defined), resolve them now... Types |
| 388 | // are resolved when the constant pool has been completely parsed. |
| 389 | // |
| 390 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 391 | if (TriggerError) |
| 392 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 393 | |
| 394 | // Check to make sure that all global value forward references have been |
| 395 | // resolved! |
| 396 | // |
| 397 | if (!GlobalRefs.empty()) { |
| 398 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 399 | |
| 400 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 401 | I != E; ++I) { |
| 402 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 403 | I->first.second.getName() + "\n"; |
| 404 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 405 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 406 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 407 | } |
| 408 | |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 409 | // Look for intrinsic functions and CallInst that need to be upgraded |
Chris Lattner | d5efe84 | 2006-04-08 01:18:56 +0000 | [diff] [blame] | 410 | for (Module::iterator FI = CurrentModule->begin(), |
| 411 | FE = CurrentModule->end(); FI != FE; ) |
Chris Lattner | c2c6038 | 2006-03-04 07:53:41 +0000 | [diff] [blame] | 412 | UpgradeCallsToIntrinsic(FI++); |
Reid Spencer | 0b11820 | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 413 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 414 | Values.clear(); // Clear out function local definitions |
| 415 | Types.clear(); |
| 416 | CurrentModule = 0; |
| 417 | } |
| 418 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 419 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 420 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 421 | // If not, just return null. |
| 422 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 423 | // Check to see if there is a forward reference to this global variable... |
| 424 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 425 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 426 | GlobalValue *Ret = 0; |
| 427 | if (I != GlobalRefs.end()) { |
| 428 | Ret = I->second; |
| 429 | GlobalRefs.erase(I); |
| 430 | } |
| 431 | return Ret; |
| 432 | } |
| 433 | } CurModule; |
| 434 | |
| 435 | static struct PerFunctionInfo { |
| 436 | Function *CurrentFunction; // Pointer to current function being created |
| 437 | |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 438 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 439 | std::map<const Type*, ValueList> LateResolveValues; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 440 | bool isDeclare; // Is this function a forward declararation? |
| 441 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 442 | |
| 443 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 444 | /// track of them here. |
| 445 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 446 | std::vector<BasicBlock*> NumberedBlocks; |
| 447 | unsigned NextBBNum; |
| 448 | |
| 449 | inline PerFunctionInfo() { |
| 450 | CurrentFunction = 0; |
| 451 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 452 | Linkage = GlobalValue::ExternalLinkage; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | inline void FunctionStart(Function *M) { |
| 456 | CurrentFunction = M; |
| 457 | NextBBNum = 0; |
| 458 | } |
| 459 | |
| 460 | void FunctionDone() { |
| 461 | NumberedBlocks.clear(); |
| 462 | |
| 463 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 464 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 465 | GenerateError("Undefined reference to label " + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 466 | BBForwardRefs.begin()->first->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 467 | return; |
| 468 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 469 | |
| 470 | // Resolve all forward references now. |
| 471 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 472 | |
| 473 | Values.clear(); // Clear out function local definitions |
| 474 | CurrentFunction = 0; |
| 475 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 476 | Linkage = GlobalValue::ExternalLinkage; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 477 | } |
| 478 | } CurFun; // Info for the current function... |
| 479 | |
| 480 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 481 | |
| 482 | |
| 483 | //===----------------------------------------------------------------------===// |
| 484 | // Code to handle definitions of all the types |
| 485 | //===----------------------------------------------------------------------===// |
| 486 | |
| 487 | static int InsertValue(Value *V, |
| 488 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 489 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 490 | |
| 491 | // Yes, insert the value into the value table... |
| 492 | ValueList &List = ValueTab[V->getType()]; |
| 493 | List.push_back(V); |
| 494 | return List.size()-1; |
| 495 | } |
| 496 | |
| 497 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 498 | switch (D.Type) { |
| 499 | case ValID::NumberVal: // Is it a numbered definition? |
| 500 | // Module constants occupy the lowest numbered slots... |
| 501 | if ((unsigned)D.Num < CurModule.Types.size()) |
| 502 | return CurModule.Types[(unsigned)D.Num]; |
| 503 | break; |
| 504 | case ValID::NameVal: // Is it a named definition? |
| 505 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 506 | D.destroy(); // Free old strdup'd memory... |
| 507 | return N; |
| 508 | } |
| 509 | break; |
| 510 | default: |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 511 | GenerateError("Internal parser error: Invalid symbol type reference!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 512 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | // If we reached here, we referenced either a symbol that we don't know about |
| 516 | // or an id number that hasn't been read yet. We may be referencing something |
| 517 | // forward, so just create an entry to be resolved later and get to it... |
| 518 | // |
| 519 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 520 | |
| 521 | |
| 522 | if (inFunctionScope()) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 523 | if (D.Type == ValID::NameVal) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 524 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 525 | return 0; |
| 526 | } else { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 527 | GenerateError("Reference to an undefined type: #" + itostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 528 | return 0; |
| 529 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
| 533 | if (I != CurModule.LateResolveTypes.end()) |
| 534 | return I->second; |
| 535 | |
| 536 | Type *Typ = OpaqueType::get(); |
| 537 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 538 | return Typ; |
| 539 | } |
| 540 | |
| 541 | static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) { |
| 542 | SymbolTable &SymTab = |
| 543 | inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() : |
| 544 | CurModule.CurrentModule->getSymbolTable(); |
| 545 | return SymTab.lookup(Ty, Name); |
| 546 | } |
| 547 | |
| 548 | // getValNonImprovising - Look up the value specified by the provided type and |
| 549 | // the provided ValID. If the value exists and has already been defined, return |
| 550 | // it. Otherwise return null. |
| 551 | // |
| 552 | static Value *getValNonImprovising(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 553 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 554 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 555 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 556 | return 0; |
| 557 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 558 | |
| 559 | switch (D.Type) { |
| 560 | case ValID::NumberVal: { // Is it a numbered definition? |
| 561 | unsigned Num = (unsigned)D.Num; |
| 562 | |
| 563 | // Module constants occupy the lowest numbered slots... |
| 564 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
| 565 | if (VI != CurModule.Values.end()) { |
| 566 | if (Num < VI->second.size()) |
| 567 | return VI->second[Num]; |
| 568 | Num -= VI->second.size(); |
| 569 | } |
| 570 | |
| 571 | // Make sure that our type is within bounds |
| 572 | VI = CurFun.Values.find(Ty); |
| 573 | if (VI == CurFun.Values.end()) return 0; |
| 574 | |
| 575 | // Check that the number is within bounds... |
| 576 | if (VI->second.size() <= Num) return 0; |
| 577 | |
| 578 | return VI->second[Num]; |
| 579 | } |
| 580 | |
| 581 | case ValID::NameVal: { // Is it a named definition? |
| 582 | Value *N = lookupInSymbolTable(Ty, std::string(D.Name)); |
| 583 | if (N == 0) return 0; |
| 584 | |
| 585 | D.destroy(); // Free old strdup'd memory... |
| 586 | return N; |
| 587 | } |
| 588 | |
| 589 | // Check to make sure that "Ty" is an integral type, and that our |
| 590 | // value will fit into the specified type... |
| 591 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 592 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 593 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 594 | itostr(D.ConstPool64) + "' is invalid for type '" + |
| 595 | Ty->getDescription() + "'!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 596 | return 0; |
| 597 | } |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 598 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 599 | |
| 600 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 601 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 602 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 603 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 604 | "' is invalid or out of range!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 605 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 606 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 607 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 608 | } |
| 609 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 610 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 611 | } |
| 612 | |
| 613 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 614 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 615 | GenerateError("FP constant invalid for type!!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 616 | return 0; |
| 617 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 618 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 619 | |
| 620 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 621 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 622 | GenerateError("Cannot create a a non pointer null!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 623 | return 0; |
| 624 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 625 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 626 | |
| 627 | case ValID::ConstUndefVal: // Is it an undef value? |
| 628 | return UndefValue::get(Ty); |
| 629 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 630 | case ValID::ConstZeroVal: // Is it a zero value? |
| 631 | return Constant::getNullValue(Ty); |
| 632 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 633 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 634 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 635 | GenerateError("Constant expression type different from required type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 636 | return 0; |
| 637 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 638 | return D.ConstantValue; |
| 639 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 640 | case ValID::InlineAsmVal: { // Inline asm expression |
| 641 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 642 | const FunctionType *FTy = |
| 643 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 644 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 645 | GenerateError("Invalid type for asm constraint string!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 646 | return 0; |
| 647 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 648 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 649 | D.IAD->HasSideEffects); |
| 650 | D.destroy(); // Free InlineAsmDescriptor. |
| 651 | return IA; |
| 652 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 653 | default: |
| 654 | assert(0 && "Unhandled case!"); |
| 655 | return 0; |
| 656 | } // End of switch |
| 657 | |
| 658 | assert(0 && "Unhandled case!"); |
| 659 | return 0; |
| 660 | } |
| 661 | |
| 662 | // getVal - This function is identical to getValNonImprovising, except that if a |
| 663 | // value is not already defined, it "improvises" by creating a placeholder var |
| 664 | // that looks and acts just like the requested variable. When the value is |
| 665 | // defined later, all uses of the placeholder variable are replaced with the |
| 666 | // real thing. |
| 667 | // |
| 668 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 669 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 670 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 671 | return 0; |
| 672 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 673 | |
| 674 | // See if the value has already been defined. |
| 675 | Value *V = getValNonImprovising(Ty, ID); |
| 676 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 677 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 678 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 679 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 680 | GenerateError("Invalid use of a composite type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 681 | return 0; |
| 682 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 683 | |
| 684 | // If we reached here, we referenced either a symbol that we don't know about |
| 685 | // or an id number that hasn't been read yet. We may be referencing something |
| 686 | // forward, so just create an entry to be resolved later and get to it... |
| 687 | // |
| 688 | V = new Argument(Ty); |
| 689 | |
| 690 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 691 | // to recycle these things?? |
| 692 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 693 | llvmAsmlineno))); |
| 694 | |
| 695 | if (inFunctionScope()) |
| 696 | InsertValue(V, CurFun.LateResolveValues); |
| 697 | else |
| 698 | InsertValue(V, CurModule.LateResolveValues); |
| 699 | return V; |
| 700 | } |
| 701 | |
| 702 | /// getBBVal - This is used for two purposes: |
| 703 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 704 | /// defined. |
| 705 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 706 | /// or may not be a forward reference. |
| 707 | /// |
| 708 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
| 709 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 710 | |
| 711 | std::string Name; |
| 712 | BasicBlock *BB = 0; |
| 713 | switch (ID.Type) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 714 | default: |
| 715 | GenerateError("Illegal label reference " + ID.getName()); |
| 716 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 717 | case ValID::NumberVal: // Is it a numbered definition? |
| 718 | if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) |
| 719 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 720 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 721 | break; |
| 722 | case ValID::NameVal: // Is it a named definition? |
| 723 | Name = ID.Name; |
| 724 | if (Value *N = CurFun.CurrentFunction-> |
| 725 | getSymbolTable().lookup(Type::LabelTy, Name)) |
| 726 | BB = cast<BasicBlock>(N); |
| 727 | break; |
| 728 | } |
| 729 | |
| 730 | // See if the block has already been defined. |
| 731 | if (BB) { |
| 732 | // If this is the definition of the block, make sure the existing value was |
| 733 | // just a forward reference. If it was a forward reference, there will be |
| 734 | // an entry for it in the PlaceHolderInfo map. |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 735 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 736 | // The existing value was a definition, not a forward reference. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 737 | GenerateError("Redefinition of label " + ID.getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 738 | return 0; |
| 739 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 740 | |
| 741 | ID.destroy(); // Free strdup'd memory. |
| 742 | return BB; |
| 743 | } |
| 744 | |
| 745 | // Otherwise this block has not been seen before. |
| 746 | BB = new BasicBlock("", CurFun.CurrentFunction); |
| 747 | if (ID.Type == ValID::NameVal) { |
| 748 | BB->setName(ID.Name); |
| 749 | } else { |
| 750 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 751 | } |
| 752 | |
| 753 | // If this is not a definition, keep track of it so we can use it as a forward |
| 754 | // reference. |
| 755 | if (!isDefinition) { |
| 756 | // Remember where this forward reference came from. |
| 757 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno); |
| 758 | } else { |
| 759 | // The forward declaration could have been inserted anywhere in the |
| 760 | // function: insert it into the correct place now. |
| 761 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 762 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 763 | } |
| 764 | ID.destroy(); |
| 765 | return BB; |
| 766 | } |
| 767 | |
| 768 | |
| 769 | //===----------------------------------------------------------------------===// |
| 770 | // Code to handle forward references in instructions |
| 771 | //===----------------------------------------------------------------------===// |
| 772 | // |
| 773 | // This code handles the late binding needed with statements that reference |
| 774 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 775 | // a loop body. |
| 776 | // |
| 777 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 778 | // and back patchs after we are done. |
| 779 | // |
| 780 | |
| 781 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 782 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 783 | // defs now... |
| 784 | // |
| 785 | static void |
| 786 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 787 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
| 788 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 789 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 790 | E = LateResolvers.end(); LRI != E; ++LRI) { |
| 791 | ValueList &List = LRI->second; |
| 792 | while (!List.empty()) { |
| 793 | Value *V = List.back(); |
| 794 | List.pop_back(); |
| 795 | |
| 796 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 797 | CurModule.PlaceHolderInfo.find(V); |
| 798 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
| 799 | |
| 800 | ValID &DID = PHI->second.first; |
| 801 | |
| 802 | Value *TheRealValue = getValNonImprovising(LRI->first, DID); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 803 | if (TriggerError) |
| 804 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 805 | if (TheRealValue) { |
| 806 | V->replaceAllUsesWith(TheRealValue); |
| 807 | delete V; |
| 808 | CurModule.PlaceHolderInfo.erase(PHI); |
| 809 | } else if (FutureLateResolvers) { |
| 810 | // Functions have their unresolved items forwarded to the module late |
| 811 | // resolver table |
| 812 | InsertValue(V, *FutureLateResolvers); |
| 813 | } else { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 814 | if (DID.Type == ValID::NameVal) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 815 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 816 | "' of type '" + V->getType()->getDescription() + "'", |
| 817 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 818 | return; |
| 819 | } else { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 820 | GenerateError("Reference to an invalid definition: #" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 821 | itostr(DID.Num) + " of type '" + |
| 822 | V->getType()->getDescription() + "'", |
| 823 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 824 | return; |
| 825 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 826 | } |
| 827 | } |
| 828 | } |
| 829 | |
| 830 | LateResolvers.clear(); |
| 831 | } |
| 832 | |
| 833 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 834 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 835 | // refering to the number can be resolved. Do this now. |
| 836 | // |
| 837 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 838 | ValID D; |
| 839 | if (Name) D = ValID::create(Name); |
| 840 | else D = ValID::create((int)CurModule.Types.size()); |
| 841 | |
| 842 | std::map<ValID, PATypeHolder>::iterator I = |
| 843 | CurModule.LateResolveTypes.find(D); |
| 844 | if (I != CurModule.LateResolveTypes.end()) { |
| 845 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
| 846 | CurModule.LateResolveTypes.erase(I); |
| 847 | } |
| 848 | } |
| 849 | |
| 850 | // setValueName - Set the specified value to the name given. The name may be |
| 851 | // null potentially, in which case this is a noop. The string passed in is |
| 852 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 853 | // |
| 854 | static void setValueName(Value *V, char *NameStr) { |
| 855 | if (NameStr) { |
| 856 | std::string Name(NameStr); // Copy string |
| 857 | free(NameStr); // Free old string |
| 858 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 859 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 860 | GenerateError("Can't assign name '" + Name+"' to value with void type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 861 | return; |
| 862 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 863 | |
| 864 | assert(inFunctionScope() && "Must be in function scope!"); |
| 865 | SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable(); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 866 | if (ST.lookup(V->getType(), Name)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 867 | GenerateError("Redefinition of value named '" + Name + "' in the '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 868 | V->getType()->getDescription() + "' type plane!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 869 | return; |
| 870 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 871 | |
| 872 | // Set the name. |
| 873 | V->setName(Name); |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 878 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 879 | static GlobalVariable * |
| 880 | ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, |
| 881 | bool isConstantGlobal, const Type *Ty, |
| 882 | Constant *Initializer) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 883 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 884 | GenerateError("Cannot declare global vars of function type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 885 | return 0; |
| 886 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 887 | |
| 888 | const PointerType *PTy = PointerType::get(Ty); |
| 889 | |
| 890 | std::string Name; |
| 891 | if (NameStr) { |
| 892 | Name = NameStr; // Copy string |
| 893 | free(NameStr); // Free old string |
| 894 | } |
| 895 | |
| 896 | // See if this global value was forward referenced. If so, recycle the |
| 897 | // object. |
| 898 | ValID ID; |
| 899 | if (!Name.empty()) { |
| 900 | ID = ValID::create((char*)Name.c_str()); |
| 901 | } else { |
| 902 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
| 903 | } |
| 904 | |
| 905 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 906 | // Move the global to the end of the list, from whereever it was |
| 907 | // previously inserted. |
| 908 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 909 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 910 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 911 | GV->setInitializer(Initializer); |
| 912 | GV->setLinkage(Linkage); |
| 913 | GV->setConstant(isConstantGlobal); |
| 914 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 915 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 916 | } |
| 917 | |
| 918 | // If this global has a name, check to see if there is already a definition |
| 919 | // of this global in the module. If so, merge as appropriate. Note that |
| 920 | // this is really just a hack around problems in the CFE. :( |
| 921 | if (!Name.empty()) { |
| 922 | // We are a simple redefinition of a value, check to see if it is defined |
| 923 | // the same as the old one. |
| 924 | if (GlobalVariable *EGV = |
| 925 | CurModule.CurrentModule->getGlobalVariable(Name, Ty)) { |
| 926 | // We are allowed to redefine a global variable in two circumstances: |
| 927 | // 1. If at least one of the globals is uninitialized or |
| 928 | // 2. If both initializers have the same value. |
| 929 | // |
| 930 | if (!EGV->hasInitializer() || !Initializer || |
| 931 | EGV->getInitializer() == Initializer) { |
| 932 | |
| 933 | // Make sure the existing global version gets the initializer! Make |
| 934 | // sure that it also gets marked const if the new version is. |
| 935 | if (Initializer && !EGV->hasInitializer()) |
| 936 | EGV->setInitializer(Initializer); |
| 937 | if (isConstantGlobal) |
| 938 | EGV->setConstant(true); |
| 939 | EGV->setLinkage(Linkage); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 940 | return EGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 941 | } |
| 942 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 943 | GenerateError("Redefinition of global variable named '" + Name + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 944 | "' in the '" + Ty->getDescription() + "' type plane!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 945 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 946 | } |
| 947 | } |
| 948 | |
| 949 | // Otherwise there is no existing GV to use, create one now. |
| 950 | GlobalVariable *GV = |
| 951 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 952 | CurModule.CurrentModule); |
| 953 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 954 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 955 | } |
| 956 | |
| 957 | // setTypeName - Set the specified type to the name given. The name may be |
| 958 | // null potentially, in which case this is a noop. The string passed in is |
| 959 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 960 | // |
| 961 | // This function returns true if the type has already been defined, but is |
| 962 | // allowed to be redefined in the specified context. If the name is a new name |
| 963 | // for the type plane, it is inserted and false is returned. |
| 964 | static bool setTypeName(const Type *T, char *NameStr) { |
| 965 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
| 966 | if (NameStr == 0) return false; |
| 967 | |
| 968 | std::string Name(NameStr); // Copy string |
| 969 | free(NameStr); // Free old string |
| 970 | |
| 971 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 972 | if (T == Type::VoidTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 973 | GenerateError("Can't assign name '" + Name + "' to the void type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 974 | return false; |
| 975 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 976 | |
| 977 | // Set the type name, checking for conflicts as we do so. |
| 978 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 979 | |
| 980 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 981 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 982 | assert(Existing && "Conflict but no matching type?"); |
| 983 | |
| 984 | // There is only one case where this is allowed: when we are refining an |
| 985 | // opaque type. In this case, Existing will be an opaque type. |
| 986 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 987 | // We ARE replacing an opaque type! |
| 988 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 989 | return true; |
| 990 | } |
| 991 | |
| 992 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 993 | // the redefinition is identical to the original. This will be so if |
| 994 | // Existing and T point to the same Type object. In this one case we |
| 995 | // allow the equivalent redefinition. |
| 996 | if (Existing == T) return true; // Yes, it's equal. |
| 997 | |
| 998 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 999 | GenerateError("Redefinition of type named '" + Name + "' in the '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1000 | T->getDescription() + "' type plane!"); |
| 1001 | } |
| 1002 | |
| 1003 | return false; |
| 1004 | } |
| 1005 | |
| 1006 | //===----------------------------------------------------------------------===// |
| 1007 | // Code for handling upreferences in type names... |
| 1008 | // |
| 1009 | |
| 1010 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1011 | // |
| 1012 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1013 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1014 | E) != Ty->subtype_end(); |
| 1015 | } |
| 1016 | |
| 1017 | namespace { |
| 1018 | struct UpRefRecord { |
| 1019 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1020 | // this type is resolved. |
| 1021 | unsigned NestingLevel; |
| 1022 | |
| 1023 | // LastContainedTy - This is the type at the current binding level for the |
| 1024 | // type. Every time we reduce the nesting level, this gets updated. |
| 1025 | const Type *LastContainedTy; |
| 1026 | |
| 1027 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1028 | // represented with. |
| 1029 | OpaqueType *UpRefTy; |
| 1030 | |
| 1031 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 1032 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 1033 | }; |
| 1034 | } |
| 1035 | |
| 1036 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1037 | static std::vector<UpRefRecord> UpRefs; |
| 1038 | |
| 1039 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1040 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1041 | /// currently active types. For each type, if the up reference is contained in |
| 1042 | /// the newly completed type, we decrement the level count. When the level |
| 1043 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1044 | /// thus we can complete the cycle. |
| 1045 | /// |
| 1046 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 1047 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1048 | // nothing to resolve here. |
| 1049 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1050 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1051 | PATypeHolder Ty(ty); |
| 1052 | UR_OUT("Type '" << Ty->getDescription() << |
| 1053 | "' newly formed. Resolving upreferences.\n" << |
| 1054 | UpRefs.size() << " upreferences active!\n"); |
| 1055 | |
| 1056 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1057 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1058 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1059 | // this variable. |
| 1060 | OpaqueType *TypeToResolve = 0; |
| 1061 | |
| 1062 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1063 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1064 | << UpRefs[i].second->getDescription() << ") = " |
| 1065 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1066 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1067 | // Decrement level of upreference |
| 1068 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1069 | UpRefs[i].LastContainedTy = Ty; |
| 1070 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1071 | if (Level == 0) { // Upreference should be resolved! |
| 1072 | if (!TypeToResolve) { |
| 1073 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1074 | } else { |
| 1075 | UR_OUT(" * Resolving upreference for " |
| 1076 | << UpRefs[i].second->getDescription() << "\n"; |
| 1077 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1078 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1079 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1080 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1081 | } |
| 1082 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1083 | --i; // Do not skip the next element... |
| 1084 | } |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | if (TypeToResolve) { |
| 1089 | UR_OUT(" * Resolving upreference for " |
| 1090 | << UpRefs[i].second->getDescription() << "\n"; |
| 1091 | std::string OldName = TypeToResolve->getDescription()); |
| 1092 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1093 | } |
| 1094 | |
| 1095 | return Ty; |
| 1096 | } |
| 1097 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1098 | /// This function is used to obtain the correct opcode for an instruction when |
| 1099 | /// an obsolete opcode is encountered. The OI parameter (OpcodeInfo) has both |
| 1100 | /// an opcode and an "obsolete" flag. These are generated by the lexer and |
| 1101 | /// the "obsolete" member will be true when the lexer encounters the token for |
| 1102 | /// an obsolete opcode. For example, "div" was replaced by [usf]div but we need |
| 1103 | /// to maintain backwards compatibility for asm files that still have the "div" |
| 1104 | /// instruction. This function handles converting div -> [usf]div appropriately. |
| 1105 | /// @brief Convert obsolete opcodes to new values |
| 1106 | static void |
| 1107 | sanitizeOpCode(OpcodeInfo<Instruction::BinaryOps> &OI, const PATypeHolder& PATy) |
| 1108 | { |
| 1109 | // If its not obsolete, don't do anything |
| 1110 | if (!OI.obsolete) |
| 1111 | return; |
| 1112 | |
| 1113 | // If its a packed type we want to use the element type |
| 1114 | const Type* Ty = PATy; |
| 1115 | if (const PackedType* PTy = dyn_cast<PackedType>(Ty)) |
| 1116 | Ty = PTy->getElementType(); |
| 1117 | |
| 1118 | // Depending on the opcode .. |
| 1119 | switch (OI.opcode) { |
| 1120 | default: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1121 | GenerateError("Invalid obsolete opCode (check Lexer.l)"); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1122 | break; |
| 1123 | case Instruction::UDiv: |
| 1124 | // Handle cases where the opcode needs to change |
| 1125 | if (Ty->isFloatingPoint()) |
| 1126 | OI.opcode = Instruction::FDiv; |
| 1127 | else if (Ty->isSigned()) |
| 1128 | OI.opcode = Instruction::SDiv; |
| 1129 | break; |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1130 | case Instruction::URem: |
| 1131 | if (Ty->isFloatingPoint()) |
| 1132 | OI.opcode = Instruction::FRem; |
| 1133 | else if (Ty->isSigned()) |
| 1134 | OI.opcode = Instruction::SRem; |
| 1135 | break; |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1136 | } |
| 1137 | // Its not obsolete any more, we fixed it. |
| 1138 | OI.obsolete = false; |
| 1139 | } |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1140 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1141 | // common code from the two 'RunVMAsmParser' functions |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1142 | static Module* RunParser(Module * M) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1143 | |
| 1144 | llvmAsmlineno = 1; // Reset the current line number... |
| 1145 | ObsoleteVarArgs = false; |
| 1146 | NewVarArgs = false; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1147 | CurModule.CurrentModule = M; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 1148 | |
| 1149 | // Check to make sure the parser succeeded |
| 1150 | if (yyparse()) { |
| 1151 | if (ParserResult) |
| 1152 | delete ParserResult; |
| 1153 | return 0; |
| 1154 | } |
| 1155 | |
| 1156 | // Check to make sure that parsing produced a result |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1157 | if (!ParserResult) |
| 1158 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1159 | |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 1160 | // Reset ParserResult variable while saving its value for the result. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1161 | Module *Result = ParserResult; |
| 1162 | ParserResult = 0; |
| 1163 | |
| 1164 | //Not all functions use vaarg, so make a second check for ObsoleteVarArgs |
| 1165 | { |
| 1166 | Function* F; |
| 1167 | if ((F = Result->getNamedFunction("llvm.va_start")) |
| 1168 | && F->getFunctionType()->getNumParams() == 0) |
| 1169 | ObsoleteVarArgs = true; |
| 1170 | if((F = Result->getNamedFunction("llvm.va_copy")) |
| 1171 | && F->getFunctionType()->getNumParams() == 1) |
| 1172 | ObsoleteVarArgs = true; |
| 1173 | } |
| 1174 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1175 | if (ObsoleteVarArgs && NewVarArgs) { |
| 1176 | GenerateError( |
| 1177 | "This file is corrupt: it uses both new and old style varargs"); |
| 1178 | return 0; |
| 1179 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1180 | |
| 1181 | if(ObsoleteVarArgs) { |
| 1182 | if(Function* F = Result->getNamedFunction("llvm.va_start")) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1183 | if (F->arg_size() != 0) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1184 | GenerateError("Obsolete va_start takes 0 argument!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1185 | return 0; |
| 1186 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1187 | |
| 1188 | //foo = va_start() |
| 1189 | // -> |
| 1190 | //bar = alloca typeof(foo) |
| 1191 | //va_start(bar) |
| 1192 | //foo = load bar |
| 1193 | |
| 1194 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1195 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 1196 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1197 | Function* NF = Result->getOrInsertFunction("llvm.va_start", |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 1198 | RetTy, ArgTyPtr, (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1199 | |
| 1200 | while (!F->use_empty()) { |
| 1201 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1202 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); |
| 1203 | new CallInst(NF, bar, "", CI); |
| 1204 | Value* foo = new LoadInst(bar, "vastart.fix.2", CI); |
| 1205 | CI->replaceAllUsesWith(foo); |
| 1206 | CI->getParent()->getInstList().erase(CI); |
| 1207 | } |
| 1208 | Result->getFunctionList().erase(F); |
| 1209 | } |
| 1210 | |
| 1211 | if(Function* F = Result->getNamedFunction("llvm.va_end")) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1212 | if(F->arg_size() != 1) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1213 | GenerateError("Obsolete va_end takes 1 argument!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1214 | return 0; |
| 1215 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1216 | |
| 1217 | //vaend foo |
| 1218 | // -> |
| 1219 | //bar = alloca 1 of typeof(foo) |
| 1220 | //vaend bar |
| 1221 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1222 | const Type* ArgTy = F->getFunctionType()->getParamType(0); |
| 1223 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1224 | Function* NF = Result->getOrInsertFunction("llvm.va_end", |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 1225 | RetTy, ArgTyPtr, (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1226 | |
| 1227 | while (!F->use_empty()) { |
| 1228 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1229 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); |
| 1230 | new StoreInst(CI->getOperand(1), bar, CI); |
| 1231 | new CallInst(NF, bar, "", CI); |
| 1232 | CI->getParent()->getInstList().erase(CI); |
| 1233 | } |
| 1234 | Result->getFunctionList().erase(F); |
| 1235 | } |
| 1236 | |
| 1237 | if(Function* F = Result->getNamedFunction("llvm.va_copy")) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1238 | if(F->arg_size() != 1) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1239 | GenerateError("Obsolete va_copy takes 1 argument!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1240 | return 0; |
| 1241 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1242 | //foo = vacopy(bar) |
| 1243 | // -> |
| 1244 | //a = alloca 1 of typeof(foo) |
| 1245 | //b = alloca 1 of typeof(foo) |
| 1246 | //store bar -> b |
| 1247 | //vacopy(a, b) |
| 1248 | //foo = load a |
| 1249 | |
| 1250 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1251 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 1252 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1253 | Function* NF = Result->getOrInsertFunction("llvm.va_copy", |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 1254 | RetTy, ArgTyPtr, ArgTyPtr, |
| 1255 | (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1256 | |
| 1257 | while (!F->use_empty()) { |
| 1258 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1259 | AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI); |
| 1260 | AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI); |
| 1261 | new StoreInst(CI->getOperand(1), b, CI); |
| 1262 | new CallInst(NF, a, b, "", CI); |
| 1263 | Value* foo = new LoadInst(a, "vacopy.fix.3", CI); |
| 1264 | CI->replaceAllUsesWith(foo); |
| 1265 | CI->getParent()->getInstList().erase(CI); |
| 1266 | } |
| 1267 | Result->getFunctionList().erase(F); |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | return Result; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1272 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1273 | |
| 1274 | //===----------------------------------------------------------------------===// |
| 1275 | // RunVMAsmParser - Define an interface to this parser |
| 1276 | //===----------------------------------------------------------------------===// |
| 1277 | // |
| 1278 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1279 | set_scan_file(F); |
| 1280 | |
| 1281 | CurFilename = Filename; |
| 1282 | return RunParser(new Module(CurFilename)); |
| 1283 | } |
| 1284 | |
| 1285 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1286 | set_scan_string(AsmString); |
| 1287 | |
| 1288 | CurFilename = "from_memory"; |
| 1289 | if (M == NULL) { |
| 1290 | return RunParser(new Module (CurFilename)); |
| 1291 | } else { |
| 1292 | return RunParser(M); |
| 1293 | } |
| 1294 | } |
| 1295 | |
| 1296 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1297 | |
| 1298 | /* Enabling traces. */ |
| 1299 | #ifndef YYDEBUG |
| 1300 | # define YYDEBUG 0 |
| 1301 | #endif |
| 1302 | |
| 1303 | /* Enabling verbose error messages. */ |
| 1304 | #ifdef YYERROR_VERBOSE |
| 1305 | # undef YYERROR_VERBOSE |
| 1306 | # define YYERROR_VERBOSE 1 |
| 1307 | #else |
| 1308 | # define YYERROR_VERBOSE 0 |
| 1309 | #endif |
| 1310 | |
| 1311 | /* Enabling the token table. */ |
| 1312 | #ifndef YYTOKEN_TABLE |
| 1313 | # define YYTOKEN_TABLE 0 |
| 1314 | #endif |
| 1315 | |
| 1316 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1317 | #line 1016 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1318 | typedef union YYSTYPE { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1319 | llvm::Module *ModuleVal; |
| 1320 | llvm::Function *FunctionVal; |
| 1321 | std::pair<llvm::PATypeHolder*, char*> *ArgVal; |
| 1322 | llvm::BasicBlock *BasicBlockVal; |
| 1323 | llvm::TerminatorInst *TermInstVal; |
| 1324 | llvm::Instruction *InstVal; |
| 1325 | llvm::Constant *ConstVal; |
| 1326 | |
| 1327 | const llvm::Type *PrimType; |
| 1328 | llvm::PATypeHolder *TypeVal; |
| 1329 | llvm::Value *ValueVal; |
| 1330 | |
| 1331 | std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList; |
| 1332 | std::vector<llvm::Value*> *ValueList; |
| 1333 | std::list<llvm::PATypeHolder> *TypeList; |
| 1334 | // Represent the RHS of PHI node |
| 1335 | std::list<std::pair<llvm::Value*, |
| 1336 | llvm::BasicBlock*> > *PHIList; |
| 1337 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
| 1338 | std::vector<llvm::Constant*> *ConstVector; |
| 1339 | |
| 1340 | llvm::GlobalValue::LinkageTypes Linkage; |
| 1341 | int64_t SInt64Val; |
| 1342 | uint64_t UInt64Val; |
| 1343 | int SIntVal; |
| 1344 | unsigned UIntVal; |
| 1345 | double FPVal; |
| 1346 | bool BoolVal; |
| 1347 | |
| 1348 | char *StrVal; // This memory is strdup'd! |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1349 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1350 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1351 | BinaryOpInfo BinaryOpVal; |
| 1352 | TermOpInfo TermOpVal; |
| 1353 | MemOpInfo MemOpVal; |
| 1354 | OtherOpInfo OtherOpVal; |
| 1355 | llvm::Module::Endianness Endianness; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1356 | } YYSTYPE; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1357 | /* Line 196 of yacc.c. */ |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1358 | #line 1359 "llvmAsmParser.tab.c" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1359 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 1360 | # define YYSTYPE_IS_DECLARED 1 |
| 1361 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1362 | #endif |
| 1363 | |
| 1364 | |
| 1365 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1366 | /* Copy the second part of user declarations. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1367 | |
| 1368 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1369 | /* Line 219 of yacc.c. */ |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1370 | #line 1371 "llvmAsmParser.tab.c" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1371 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1372 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
| 1373 | # define YYSIZE_T __SIZE_TYPE__ |
| 1374 | #endif |
| 1375 | #if ! defined (YYSIZE_T) && defined (size_t) |
| 1376 | # define YYSIZE_T size_t |
| 1377 | #endif |
| 1378 | #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) |
| 1379 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 1380 | # define YYSIZE_T size_t |
| 1381 | #endif |
| 1382 | #if ! defined (YYSIZE_T) |
| 1383 | # define YYSIZE_T unsigned int |
| 1384 | #endif |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 1385 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1386 | #ifndef YY_ |
| 1387 | # if YYENABLE_NLS |
| 1388 | # if ENABLE_NLS |
| 1389 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 1390 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
| 1391 | # endif |
| 1392 | # endif |
| 1393 | # ifndef YY_ |
| 1394 | # define YY_(msgid) msgid |
| 1395 | # endif |
| 1396 | #endif |
| 1397 | |
| 1398 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
| 1399 | |
| 1400 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 1401 | |
| 1402 | # ifdef YYSTACK_USE_ALLOCA |
| 1403 | # if YYSTACK_USE_ALLOCA |
| 1404 | # ifdef __GNUC__ |
| 1405 | # define YYSTACK_ALLOC __builtin_alloca |
| 1406 | # else |
| 1407 | # define YYSTACK_ALLOC alloca |
| 1408 | # if defined (__STDC__) || defined (__cplusplus) |
| 1409 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 1410 | # define YYINCLUDED_STDLIB_H |
| 1411 | # endif |
| 1412 | # endif |
| 1413 | # endif |
| 1414 | # endif |
| 1415 | |
| 1416 | # ifdef YYSTACK_ALLOC |
| 1417 | /* Pacify GCC's `empty if-body' warning. */ |
| 1418 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
| 1419 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1420 | /* The OS might guarantee only one guard page at the bottom of the stack, |
| 1421 | and a page size can be as small as 4096 bytes. So we cannot safely |
| 1422 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
| 1423 | to allow for a few compiler-allocated temporary stack slots. */ |
| 1424 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ |
| 1425 | # endif |
| 1426 | # else |
| 1427 | # define YYSTACK_ALLOC YYMALLOC |
| 1428 | # define YYSTACK_FREE YYFREE |
| 1429 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1430 | # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) |
| 1431 | # endif |
| 1432 | # ifdef __cplusplus |
| 1433 | extern "C" { |
| 1434 | # endif |
| 1435 | # ifndef YYMALLOC |
| 1436 | # define YYMALLOC malloc |
| 1437 | # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 1438 | && (defined (__STDC__) || defined (__cplusplus))) |
| 1439 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 1440 | # endif |
| 1441 | # endif |
| 1442 | # ifndef YYFREE |
| 1443 | # define YYFREE free |
| 1444 | # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 1445 | && (defined (__STDC__) || defined (__cplusplus))) |
| 1446 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 1447 | # endif |
| 1448 | # endif |
| 1449 | # ifdef __cplusplus |
| 1450 | } |
| 1451 | # endif |
| 1452 | # endif |
| 1453 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
| 1454 | |
| 1455 | |
| 1456 | #if (! defined (yyoverflow) \ |
| 1457 | && (! defined (__cplusplus) \ |
| 1458 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
| 1459 | |
| 1460 | /* A type that is properly aligned for any stack member. */ |
| 1461 | union yyalloc |
| 1462 | { |
| 1463 | short int yyss; |
| 1464 | YYSTYPE yyvs; |
| 1465 | }; |
| 1466 | |
| 1467 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 1468 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 1469 | |
| 1470 | /* The size of an array large to enough to hold all stacks, each with |
| 1471 | N elements. */ |
| 1472 | # define YYSTACK_BYTES(N) \ |
| 1473 | ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ |
| 1474 | + YYSTACK_GAP_MAXIMUM) |
| 1475 | |
| 1476 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 1477 | not overlap. */ |
| 1478 | # ifndef YYCOPY |
| 1479 | # if defined (__GNUC__) && 1 < __GNUC__ |
| 1480 | # define YYCOPY(To, From, Count) \ |
| 1481 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 1482 | # else |
| 1483 | # define YYCOPY(To, From, Count) \ |
| 1484 | do \ |
| 1485 | { \ |
| 1486 | YYSIZE_T yyi; \ |
| 1487 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 1488 | (To)[yyi] = (From)[yyi]; \ |
| 1489 | } \ |
| 1490 | while (0) |
| 1491 | # endif |
| 1492 | # endif |
| 1493 | |
| 1494 | /* Relocate STACK from its old location to the new one. The |
| 1495 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 1496 | elements in the stack, and YYPTR gives the new location of the |
| 1497 | stack. Advance YYPTR to a properly aligned location for the next |
| 1498 | stack. */ |
| 1499 | # define YYSTACK_RELOCATE(Stack) \ |
| 1500 | do \ |
| 1501 | { \ |
| 1502 | YYSIZE_T yynewbytes; \ |
| 1503 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 1504 | Stack = &yyptr->Stack; \ |
| 1505 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 1506 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 1507 | } \ |
| 1508 | while (0) |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 1509 | |
| 1510 | #endif |
| 1511 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1512 | #if defined (__STDC__) || defined (__cplusplus) |
| 1513 | typedef signed char yysigned_char; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1514 | #else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1515 | typedef short int yysigned_char; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1516 | #endif |
| 1517 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1518 | /* YYFINAL -- State number of the termination state. */ |
| 1519 | #define YYFINAL 4 |
| 1520 | /* YYLAST -- Last index in YYTABLE. */ |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1521 | #define YYLAST 1357 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1522 | |
| 1523 | /* YYNTOKENS -- Number of terminals. */ |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1524 | #define YYNTOKENS 127 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1525 | /* YYNNTS -- Number of nonterminals. */ |
| 1526 | #define YYNNTS 75 |
| 1527 | /* YYNRULES -- Number of rules. */ |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1528 | #define YYNRULES 256 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1529 | /* YYNRULES -- Number of states. */ |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1530 | #define YYNSTATES 521 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1531 | |
| 1532 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 1533 | #define YYUNDEFTOK 2 |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1534 | #define YYMAXUTOK 367 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1535 | |
| 1536 | #define YYTRANSLATE(YYX) \ |
| 1537 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 1538 | |
| 1539 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 1540 | static const unsigned char yytranslate[] = |
| 1541 | { |
| 1542 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1543 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1544 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1545 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1546 | 116, 117, 125, 2, 114, 2, 2, 2, 2, 2, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1547 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1548 | 121, 113, 122, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1549 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1550 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1551 | 2, 118, 115, 120, 2, 2, 2, 2, 2, 126, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1552 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1553 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1554 | 119, 2, 2, 123, 2, 124, 2, 2, 2, 2, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 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, 2, 2, 2, 2, |
| 1559 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1560 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1561 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1562 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1563 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1564 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1565 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1566 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1567 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 1568 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 1569 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 1570 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 1571 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 1572 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 1573 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 1574 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 1575 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 1576 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1577 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1578 | 105, 106, 107, 108, 109, 110, 111, 112 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1579 | }; |
| 1580 | |
| 1581 | #if YYDEBUG |
| 1582 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 1583 | YYRHS. */ |
| 1584 | static const unsigned short int yyprhs[] = |
| 1585 | { |
| 1586 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 1587 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 1588 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1589 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 78, |
| 1590 | 79, 81, 83, 85, 87, 89, 91, 93, 94, 95, |
| 1591 | 97, 99, 101, 103, 105, 107, 110, 111, 114, 115, |
| 1592 | 119, 122, 123, 125, 126, 130, 132, 135, 137, 139, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1593 | 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1594 | 161, 163, 165, 167, 169, 171, 173, 175, 177, 180, |
| 1595 | 185, 191, 197, 201, 204, 207, 209, 213, 215, 219, |
| 1596 | 221, 222, 227, 231, 235, 240, 245, 249, 252, 255, |
| 1597 | 258, 261, 264, 267, 270, 273, 276, 279, 286, 292, |
| 1598 | 301, 308, 315, 322, 329, 336, 345, 354, 358, 360, |
| 1599 | 362, 364, 366, 369, 372, 377, 380, 382, 387, 390, |
| 1600 | 395, 396, 404, 405, 413, 414, 422, 423, 431, 435, |
| 1601 | 440, 441, 443, 445, 447, 451, 455, 459, 463, 467, |
| 1602 | 471, 473, 474, 476, 478, 480, 481, 484, 488, 490, |
| 1603 | 492, 496, 498, 499, 508, 510, 512, 516, 518, 520, |
| 1604 | 523, 524, 526, 528, 529, 534, 535, 537, 539, 541, |
| 1605 | 543, 545, 547, 549, 551, 553, 557, 559, 565, 567, |
| 1606 | 569, 571, 573, 576, 579, 582, 586, 589, 590, 592, |
| 1607 | 595, 598, 602, 612, 622, 631, 645, 647, 649, 656, |
| 1608 | 662, 665, 672, 680, 682, 686, 688, 689, 692, 694, |
| 1609 | 700, 706, 712, 715, 720, 725, 732, 737, 742, 747, |
| 1610 | 752, 759, 766, 769, 777, 779, 782, 783, 785, 786, |
| 1611 | 790, 797, 801, 808, 811, 816, 823 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1612 | }; |
| 1613 | |
| 1614 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 1615 | static const short int yyrhs[] = |
| 1616 | { |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1617 | 158, 0, -1, 5, -1, 6, -1, 3, -1, 4, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1618 | -1, 78, -1, 79, -1, 80, -1, 81, -1, 82, |
| 1619 | -1, 83, -1, 84, -1, 85, -1, 86, -1, 87, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1620 | -1, 88, -1, 89, -1, 90, -1, 91, -1, 92, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1621 | -1, 93, -1, 94, -1, 95, -1, 105, -1, 106, |
| 1622 | -1, 16, -1, 14, -1, 12, -1, 10, -1, 17, |
| 1623 | -1, 15, -1, 13, -1, 11, -1, 134, -1, 135, |
| 1624 | -1, 18, -1, 19, -1, 170, 113, -1, -1, 41, |
| 1625 | -1, 42, -1, 43, -1, 44, -1, 45, -1, 46, |
| 1626 | -1, 47, -1, -1, -1, 65, -1, 66, -1, 67, |
| 1627 | -1, 68, -1, 69, -1, 70, -1, 64, 4, -1, |
| 1628 | -1, 57, 4, -1, -1, 114, 57, 4, -1, 34, |
| 1629 | 24, -1, -1, 143, -1, -1, 114, 146, 145, -1, |
| 1630 | 143, -1, 57, 4, -1, 149, -1, 8, -1, 151, |
| 1631 | -1, 8, -1, 151, -1, 9, -1, 10, -1, 11, |
| 1632 | -1, 12, -1, 13, -1, 14, -1, 15, -1, 16, |
| 1633 | -1, 17, -1, 18, -1, 19, -1, 20, -1, 21, |
| 1634 | -1, 48, -1, 150, -1, 185, -1, 115, 4, -1, |
| 1635 | 148, 116, 153, 117, -1, 118, 4, 119, 151, 120, |
| 1636 | -1, 121, 4, 119, 151, 122, -1, 123, 152, 124, |
| 1637 | -1, 123, 124, -1, 151, 125, -1, 151, -1, 152, |
| 1638 | 114, 151, -1, 152, -1, 152, 114, 37, -1, 37, |
| 1639 | -1, -1, 149, 118, 156, 120, -1, 149, 118, 120, |
| 1640 | -1, 149, 126, 24, -1, 149, 121, 156, 122, -1, |
| 1641 | 149, 123, 156, 124, -1, 149, 123, 124, -1, 149, |
| 1642 | 38, -1, 149, 39, -1, 149, 185, -1, 149, 155, |
| 1643 | -1, 149, 26, -1, 134, 129, -1, 135, 4, -1, |
| 1644 | 9, 27, -1, 9, 28, -1, 137, 7, -1, 103, |
| 1645 | 116, 154, 36, 149, 117, -1, 101, 116, 154, 199, |
| 1646 | 117, -1, 104, 116, 154, 114, 154, 114, 154, 117, |
| 1647 | -1, 130, 116, 154, 114, 154, 117, -1, 131, 116, |
| 1648 | 154, 114, 154, 117, -1, 132, 116, 154, 114, 154, |
| 1649 | 117, -1, 133, 116, 154, 114, 154, 117, -1, 108, |
| 1650 | 116, 154, 114, 154, 117, -1, 109, 116, 154, 114, |
| 1651 | 154, 114, 154, 117, -1, 110, 116, 154, 114, 154, |
| 1652 | 114, 154, 117, -1, 156, 114, 154, -1, 154, -1, |
| 1653 | 32, -1, 33, -1, 159, -1, 159, 179, -1, 159, |
| 1654 | 181, -1, 159, 62, 61, 165, -1, 159, 25, -1, |
| 1655 | 160, -1, 160, 138, 20, 147, -1, 160, 181, -1, |
| 1656 | 160, 62, 61, 165, -1, -1, 160, 138, 139, 157, |
| 1657 | 154, 161, 145, -1, -1, 160, 138, 50, 157, 149, |
| 1658 | 162, 145, -1, -1, 160, 138, 45, 157, 149, 163, |
| 1659 | 145, -1, -1, 160, 138, 47, 157, 149, 164, 145, |
| 1660 | -1, 160, 51, 167, -1, 160, 58, 113, 168, -1, |
| 1661 | -1, 24, -1, 56, -1, 55, -1, 53, 113, 166, |
| 1662 | -1, 54, 113, 4, -1, 52, 113, 24, -1, 71, |
| 1663 | 113, 24, -1, 118, 169, 120, -1, 169, 114, 24, |
| 1664 | -1, 24, -1, -1, 22, -1, 24, -1, 170, -1, |
| 1665 | -1, 149, 171, -1, 173, 114, 172, -1, 172, -1, |
| 1666 | 173, -1, 173, 114, 37, -1, 37, -1, -1, 140, |
| 1667 | 147, 170, 116, 174, 117, 144, 141, -1, 29, -1, |
| 1668 | 123, -1, 139, 175, 176, -1, 30, -1, 124, -1, |
| 1669 | 188, 178, -1, -1, 45, -1, 47, -1, -1, 31, |
| 1670 | 182, 180, 175, -1, -1, 63, -1, 3, -1, 4, |
| 1671 | -1, 7, -1, 27, -1, 28, -1, 38, -1, 39, |
| 1672 | -1, 26, -1, 121, 156, 122, -1, 155, -1, 61, |
| 1673 | 183, 24, 114, 24, -1, 128, -1, 170, -1, 185, |
| 1674 | -1, 184, -1, 149, 186, -1, 188, 189, -1, 177, |
| 1675 | 189, -1, 190, 138, 191, -1, 190, 193, -1, -1, |
| 1676 | 23, -1, 72, 187, -1, 72, 8, -1, 73, 21, |
| 1677 | 186, -1, 73, 9, 186, 114, 21, 186, 114, 21, |
| 1678 | 186, -1, 74, 136, 186, 114, 21, 186, 118, 192, |
| 1679 | 120, -1, 74, 136, 186, 114, 21, 186, 118, 120, |
| 1680 | -1, 75, 140, 147, 186, 116, 196, 117, 36, 21, |
| 1681 | 186, 76, 21, 186, -1, 76, -1, 77, -1, 192, |
| 1682 | 136, 184, 114, 21, 186, -1, 136, 184, 114, 21, |
| 1683 | 186, -1, 138, 198, -1, 149, 118, 186, 114, 186, |
| 1684 | 120, -1, 194, 114, 118, 186, 114, 186, 120, -1, |
| 1685 | 187, -1, 195, 114, 187, -1, 195, -1, -1, 60, |
| 1686 | 59, -1, 59, -1, 130, 149, 186, 114, 186, -1, |
| 1687 | 131, 149, 186, 114, 186, -1, 132, 149, 186, 114, |
| 1688 | 186, -1, 49, 187, -1, 133, 187, 114, 187, -1, |
| 1689 | 103, 187, 36, 149, -1, 104, 187, 114, 187, 114, |
| 1690 | 187, -1, 107, 187, 114, 149, -1, 111, 187, 114, |
| 1691 | 149, -1, 112, 187, 114, 149, -1, 108, 187, 114, |
| 1692 | 187, -1, 109, 187, 114, 187, 114, 187, -1, 110, |
| 1693 | 187, 114, 187, 114, 187, -1, 102, 194, -1, 197, |
| 1694 | 140, 147, 186, 116, 196, 117, -1, 201, -1, 114, |
| 1695 | 195, -1, -1, 35, -1, -1, 96, 149, 142, -1, |
| 1696 | 96, 149, 114, 15, 186, 142, -1, 97, 149, 142, |
| 1697 | -1, 97, 149, 114, 15, 186, 142, -1, 98, 187, |
| 1698 | -1, 200, 99, 149, 186, -1, 200, 100, 187, 114, |
| 1699 | 149, 186, -1, 101, 149, 186, 199, -1 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1700 | }; |
| 1701 | |
| 1702 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 1703 | static const unsigned short int yyrline[] = |
| 1704 | { |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1705 | 0, 1139, 1139, 1140, 1148, 1149, 1159, 1159, 1159, 1159, |
| 1706 | 1159, 1159, 1159, 1159, 1159, 1160, 1160, 1160, 1161, 1161, |
| 1707 | 1161, 1161, 1161, 1161, 1163, 1163, 1167, 1167, 1167, 1167, |
| 1708 | 1168, 1168, 1168, 1168, 1169, 1169, 1170, 1170, 1173, 1177, |
| 1709 | 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1191, 1192, |
| 1710 | 1193, 1194, 1195, 1196, 1197, 1198, 1207, 1208, 1214, 1215, |
| 1711 | 1223, 1231, 1232, 1237, 1238, 1239, 1244, 1258, 1258, 1259, |
| 1712 | 1259, 1261, 1271, 1271, 1271, 1271, 1271, 1271, 1271, 1272, |
| 1713 | 1272, 1272, 1272, 1272, 1272, 1273, 1277, 1281, 1289, 1297, |
| 1714 | 1310, 1315, 1327, 1337, 1341, 1352, 1357, 1363, 1364, 1368, |
| 1715 | 1372, 1383, 1409, 1423, 1453, 1479, 1500, 1513, 1523, 1528, |
| 1716 | 1589, 1596, 1605, 1611, 1617, 1621, 1625, 1633, 1644, 1676, |
| 1717 | 1684, 1711, 1722, 1728, 1736, 1742, 1748, 1757, 1761, 1769, |
| 1718 | 1769, 1779, 1787, 1792, 1796, 1800, 1804, 1819, 1841, 1844, |
| 1719 | 1847, 1847, 1855, 1855, 1863, 1863, 1871, 1871, 1880, 1883, |
| 1720 | 1886, 1890, 1903, 1904, 1906, 1910, 1919, 1923, 1928, 1930, |
| 1721 | 1935, 1940, 1949, 1949, 1950, 1950, 1952, 1959, 1965, 1972, |
| 1722 | 1976, 1982, 1987, 1992, 2087, 2087, 2089, 2097, 2097, 2099, |
| 1723 | 2104, 2105, 2106, 2108, 2108, 2118, 2122, 2127, 2131, 2135, |
| 1724 | 2139, 2143, 2147, 2151, 2155, 2159, 2184, 2188, 2202, 2206, |
| 1725 | 2212, 2212, 2218, 2223, 2227, 2236, 2247, 2252, 2264, 2277, |
| 1726 | 2281, 2285, 2290, 2299, 2318, 2327, 2383, 2387, 2394, 2405, |
| 1727 | 2418, 2427, 2436, 2446, 2450, 2457, 2457, 2459, 2463, 2468, |
| 1728 | 2490, 2505, 2519, 2532, 2540, 2548, 2556, 2562, 2582, 2605, |
| 1729 | 2611, 2617, 2623, 2638, 2697, 2704, 2707, 2712, 2716, 2723, |
| 1730 | 2728, 2734, 2739, 2745, 2753, 2765, 2780 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1731 | }; |
| 1732 | #endif |
| 1733 | |
| 1734 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
| 1735 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 1736 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 1737 | static const char *const yytname[] = |
| 1738 | { |
| 1739 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", |
| 1740 | "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT", |
| 1741 | "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL", |
| 1742 | "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION", |
| 1743 | "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", |
| 1744 | "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", |
| 1745 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", |
| 1746 | "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 1747 | "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", |
| 1748 | "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", |
| 1749 | "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", |
| 1750 | "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", |
| 1751 | "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1752 | "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR", |
| 1753 | "XOR", "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "MALLOC", |
| 1754 | "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", "CAST", |
| 1755 | "SELECT", "SHL", "SHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", |
| 1756 | "SHUFFLEVECTOR", "VAARG_old", "VANEXT_old", "'='", "','", "'\\\\'", |
| 1757 | "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'*'", |
| 1758 | "'c'", "$accept", "INTVAL", "EINT64VAL", "ArithmeticOps", "LogicalOps", |
| 1759 | "SetCondOps", "ShiftOps", "SIntType", "UIntType", "IntType", "FPType", |
| 1760 | "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign", "OptCAlign", |
| 1761 | "SectionString", "OptSection", "GlobalVarAttributes", |
| 1762 | "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType", |
| 1763 | "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr", |
| 1764 | "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1", |
| 1765 | "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition", |
| 1766 | "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal", |
| 1767 | "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", |
| 1768 | "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5", |
| 1769 | "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef", |
| 1770 | "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList", |
| 1771 | "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ValueRefList", |
| 1772 | "ValueRefListE", "OptTailCall", "InstVal", "IndexList", "OptVolatile", |
| 1773 | "MemoryInst", 0 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1774 | }; |
| 1775 | #endif |
| 1776 | |
| 1777 | # ifdef YYPRINT |
| 1778 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 1779 | token YYLEX-NUM. */ |
| 1780 | static const unsigned short int yytoknum[] = |
| 1781 | { |
| 1782 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 1783 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 1784 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 1785 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 1786 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 1787 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 1788 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 1789 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 1790 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 1791 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1792 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1793 | 365, 366, 367, 61, 44, 92, 40, 41, 91, 120, |
| 1794 | 93, 60, 62, 123, 125, 42, 99 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1795 | }; |
| 1796 | # endif |
| 1797 | |
| 1798 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 1799 | static const unsigned char yyr1[] = |
| 1800 | { |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1801 | 0, 127, 128, 128, 129, 129, 130, 130, 130, 130, |
| 1802 | 130, 130, 130, 130, 130, 131, 131, 131, 132, 132, |
| 1803 | 132, 132, 132, 132, 133, 133, 134, 134, 134, 134, |
| 1804 | 135, 135, 135, 135, 136, 136, 137, 137, 138, 138, |
| 1805 | 139, 139, 139, 139, 139, 139, 139, 139, 140, 140, |
| 1806 | 140, 140, 140, 140, 140, 140, 141, 141, 142, 142, |
| 1807 | 143, 144, 144, 145, 145, 146, 146, 147, 147, 148, |
| 1808 | 148, 149, 150, 150, 150, 150, 150, 150, 150, 150, |
| 1809 | 150, 150, 150, 150, 150, 151, 151, 151, 151, 151, |
| 1810 | 151, 151, 151, 151, 151, 152, 152, 153, 153, 153, |
| 1811 | 153, 154, 154, 154, 154, 154, 154, 154, 154, 154, |
| 1812 | 154, 154, 154, 154, 154, 154, 154, 155, 155, 155, |
| 1813 | 155, 155, 155, 155, 155, 155, 155, 156, 156, 157, |
| 1814 | 157, 158, 159, 159, 159, 159, 159, 160, 160, 160, |
| 1815 | 161, 160, 162, 160, 163, 160, 164, 160, 160, 160, |
| 1816 | 160, 165, 166, 166, 167, 167, 167, 167, 168, 169, |
| 1817 | 169, 169, 170, 170, 171, 171, 172, 173, 173, 174, |
| 1818 | 174, 174, 174, 175, 176, 176, 177, 178, 178, 179, |
| 1819 | 180, 180, 180, 182, 181, 183, 183, 184, 184, 184, |
| 1820 | 184, 184, 184, 184, 184, 184, 184, 184, 185, 185, |
| 1821 | 186, 186, 187, 188, 188, 189, 190, 190, 190, 191, |
| 1822 | 191, 191, 191, 191, 191, 191, 191, 191, 192, 192, |
| 1823 | 193, 194, 194, 195, 195, 196, 196, 197, 197, 198, |
| 1824 | 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, |
| 1825 | 198, 198, 198, 198, 198, 199, 199, 200, 200, 201, |
| 1826 | 201, 201, 201, 201, 201, 201, 201 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1827 | }; |
| 1828 | |
| 1829 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 1830 | static const unsigned char yyr2[] = |
| 1831 | { |
| 1832 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1833 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1834 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1835 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, |
| 1836 | 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, |
| 1837 | 1, 1, 1, 1, 1, 2, 0, 2, 0, 3, |
| 1838 | 2, 0, 1, 0, 3, 1, 2, 1, 1, 1, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1839 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1840 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, |
| 1841 | 5, 5, 3, 2, 2, 1, 3, 1, 3, 1, |
| 1842 | 0, 4, 3, 3, 4, 4, 3, 2, 2, 2, |
| 1843 | 2, 2, 2, 2, 2, 2, 2, 6, 5, 8, |
| 1844 | 6, 6, 6, 6, 6, 8, 8, 3, 1, 1, |
| 1845 | 1, 1, 2, 2, 4, 2, 1, 4, 2, 4, |
| 1846 | 0, 7, 0, 7, 0, 7, 0, 7, 3, 4, |
| 1847 | 0, 1, 1, 1, 3, 3, 3, 3, 3, 3, |
| 1848 | 1, 0, 1, 1, 1, 0, 2, 3, 1, 1, |
| 1849 | 3, 1, 0, 8, 1, 1, 3, 1, 1, 2, |
| 1850 | 0, 1, 1, 0, 4, 0, 1, 1, 1, 1, |
| 1851 | 1, 1, 1, 1, 1, 3, 1, 5, 1, 1, |
| 1852 | 1, 1, 2, 2, 2, 3, 2, 0, 1, 2, |
| 1853 | 2, 3, 9, 9, 8, 13, 1, 1, 6, 5, |
| 1854 | 2, 6, 7, 1, 3, 1, 0, 2, 1, 5, |
| 1855 | 5, 5, 2, 4, 4, 6, 4, 4, 4, 4, |
| 1856 | 6, 6, 2, 7, 1, 2, 0, 1, 0, 3, |
| 1857 | 6, 3, 6, 2, 4, 6, 4 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1858 | }; |
| 1859 | |
| 1860 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 1861 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 1862 | means the default is an error. */ |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1863 | static const unsigned short int yydefact[] = |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1864 | { |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1865 | 150, 0, 47, 136, 1, 135, 183, 40, 41, 42, |
| 1866 | 43, 44, 45, 46, 0, 48, 207, 132, 133, 207, |
| 1867 | 162, 163, 0, 0, 0, 47, 0, 138, 180, 0, |
| 1868 | 0, 49, 50, 51, 52, 53, 54, 0, 0, 208, |
| 1869 | 204, 39, 177, 178, 179, 203, 0, 0, 0, 0, |
| 1870 | 148, 0, 0, 0, 0, 0, 0, 0, 38, 181, |
| 1871 | 182, 48, 151, 134, 55, 2, 3, 68, 72, 73, |
| 1872 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 1873 | 84, 85, 0, 0, 0, 0, 198, 0, 0, 67, |
| 1874 | 86, 71, 199, 87, 174, 175, 176, 248, 206, 0, |
| 1875 | 0, 0, 0, 161, 149, 139, 137, 129, 130, 0, |
| 1876 | 0, 0, 0, 184, 88, 0, 0, 70, 93, 95, |
| 1877 | 0, 0, 100, 94, 247, 0, 228, 0, 0, 0, |
| 1878 | 0, 48, 216, 217, 6, 7, 8, 9, 10, 11, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1879 | 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1880 | 22, 23, 0, 0, 0, 0, 0, 0, 0, 24, |
| 1881 | 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1882 | 0, 205, 48, 220, 0, 244, 156, 153, 152, 154, |
| 1883 | 155, 157, 160, 0, 144, 146, 142, 72, 73, 74, |
| 1884 | 75, 76, 77, 78, 79, 80, 81, 82, 0, 0, |
| 1885 | 0, 0, 140, 0, 0, 0, 92, 172, 99, 97, |
| 1886 | 0, 0, 232, 227, 210, 209, 0, 0, 29, 33, |
| 1887 | 28, 32, 27, 31, 26, 30, 34, 35, 0, 0, |
| 1888 | 58, 58, 253, 0, 0, 242, 0, 0, 0, 0, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1889 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1890 | 0, 0, 158, 63, 63, 63, 114, 115, 4, 5, |
| 1891 | 112, 113, 116, 111, 107, 108, 0, 0, 0, 0, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1892 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1893 | 110, 109, 63, 69, 69, 96, 171, 165, 168, 169, |
| 1894 | 0, 0, 89, 187, 188, 189, 194, 190, 191, 192, |
| 1895 | 193, 185, 0, 196, 201, 200, 202, 0, 211, 0, |
| 1896 | 0, 0, 249, 0, 251, 246, 0, 0, 0, 0, |
| 1897 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1898 | 0, 0, 0, 159, 0, 145, 147, 143, 0, 0, |
| 1899 | 0, 0, 0, 0, 102, 128, 0, 0, 106, 0, |
| 1900 | 103, 0, 0, 0, 0, 141, 90, 91, 164, 166, |
| 1901 | 0, 61, 98, 186, 0, 0, 0, 0, 0, 0, |
| 1902 | 0, 0, 0, 256, 0, 0, 234, 0, 236, 239, |
| 1903 | 0, 0, 237, 238, 0, 0, 0, 233, 0, 254, |
| 1904 | 0, 0, 0, 65, 63, 246, 0, 0, 0, 0, |
| 1905 | 0, 0, 101, 104, 105, 0, 0, 0, 0, 170, |
| 1906 | 167, 62, 56, 0, 195, 0, 0, 226, 58, 59, |
| 1907 | 58, 223, 245, 0, 0, 0, 0, 0, 229, 230, |
| 1908 | 231, 226, 0, 60, 66, 64, 0, 0, 0, 0, |
| 1909 | 0, 0, 127, 0, 0, 0, 0, 0, 173, 0, |
| 1910 | 0, 0, 225, 0, 0, 250, 252, 0, 0, 0, |
| 1911 | 235, 240, 241, 0, 255, 118, 0, 0, 0, 0, |
| 1912 | 0, 0, 0, 0, 0, 57, 197, 0, 0, 0, |
| 1913 | 224, 221, 0, 243, 117, 0, 124, 0, 0, 120, |
| 1914 | 121, 122, 123, 0, 214, 0, 0, 0, 222, 0, |
| 1915 | 0, 0, 212, 0, 213, 0, 0, 119, 125, 126, |
| 1916 | 0, 0, 0, 0, 0, 0, 219, 0, 0, 218, |
| 1917 | 215 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1918 | }; |
| 1919 | |
| 1920 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 1921 | static const short int yydefgoto[] = |
| 1922 | { |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1923 | -1, 86, 260, 276, 277, 278, 279, 198, 199, 228, |
| 1924 | 200, 25, 15, 37, 448, 312, 393, 412, 335, 394, |
| 1925 | 87, 88, 201, 90, 91, 120, 210, 345, 303, 346, |
| 1926 | 109, 1, 2, 3, 282, 255, 253, 254, 63, 179, |
| 1927 | 50, 104, 183, 92, 359, 288, 289, 290, 38, 96, |
| 1928 | 16, 44, 17, 61, 18, 28, 364, 304, 93, 306, |
| 1929 | 421, 19, 40, 41, 171, 496, 98, 235, 452, 453, |
| 1930 | 172, 173, 373, 174, 175 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1931 | }; |
| 1932 | |
| 1933 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 1934 | STATE-NUM. */ |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1935 | #define YYPACT_NINF -447 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1936 | static const short int yypact[] = |
| 1937 | { |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1938 | -447, 33, 122, 610, -447, -447, -447, -447, -447, -447, |
| 1939 | -447, -447, -447, -447, -13, 161, 47, -447, -447, -15, |
| 1940 | -447, -447, 15, 10, 91, -6, 48, -447, 19, 138, |
| 1941 | 168, -447, -447, -447, -447, -447, -447, 1070, -20, -447, |
| 1942 | -447, 70, -447, -447, -447, -447, 60, 61, 64, 67, |
| 1943 | -447, 63, 138, 1070, 106, 106, 106, 106, -447, -447, |
| 1944 | -447, 161, -447, -447, -447, -447, -447, 59, -447, -447, |
| 1945 | -447, -447, -447, -447, -447, -447, -447, -447, -447, -447, |
| 1946 | -447, -447, 174, 178, 179, 576, -447, 70, 74, -447, |
| 1947 | -447, -54, -447, -447, -447, -447, -447, 1245, -447, 162, |
| 1948 | -44, 190, 171, 172, -447, -447, -447, -447, -447, 1111, |
| 1949 | 1111, 1111, 1152, -447, -447, 78, 88, -447, -447, -54, |
| 1950 | -29, 92, 865, -447, -447, 1111, -447, 150, 1193, 75, |
| 1951 | 189, 161, -447, -447, -447, -447, -447, -447, -447, -447, |
| 1952 | -447, -447, -447, -447, -447, -447, -447, -447, -447, -447, |
| 1953 | -447, -447, 1111, 1111, 1111, 1111, 1111, 1111, 1111, -447, |
| 1954 | -447, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, |
| 1955 | 1111, -447, 161, -447, 8, -447, -447, -447, -447, -447, |
| 1956 | -447, -447, -447, -10, -447, -447, -447, 113, 139, 206, |
| 1957 | 145, 211, 147, 215, 152, 216, 214, 225, 154, 218, |
| 1958 | 226, 419, -447, 1111, 1111, 1111, -447, 906, -447, 120, |
| 1959 | 118, 643, -447, -447, 59, -447, 643, 643, -447, -447, |
| 1960 | -447, -447, -447, -447, -447, -447, -447, -447, 643, 1070, |
| 1961 | 128, 129, -447, 643, 126, 131, 210, 133, 134, 140, |
| 1962 | 141, 142, 143, 144, 643, 643, 643, 146, 1070, 1111, |
| 1963 | 1111, 237, -447, 148, 148, 148, -447, -447, -447, -447, |
| 1964 | -447, -447, -447, -447, -447, -447, 149, 151, 153, 155, |
| 1965 | 156, 159, 947, 1152, 596, 239, 160, 164, 175, 177, |
| 1966 | -447, -447, 148, -74, -23, -54, -447, 70, -447, 163, |
| 1967 | 180, 988, -447, -447, -447, -447, -447, -447, -447, -447, |
| 1968 | -447, 201, 1152, -447, -447, -447, -447, 182, -447, 184, |
| 1969 | 643, -2, -447, 6, -447, 186, 643, 176, 1111, 1111, |
| 1970 | 1111, 1111, 1111, 1111, 1111, 1111, 187, 188, 191, 1111, |
| 1971 | 643, 643, 195, -447, -12, -447, -447, -447, 1152, 1152, |
| 1972 | 1152, 1152, 1152, 1152, -447, -447, -9, -21, -447, -27, |
| 1973 | -447, 1152, 1152, 1152, 1152, -447, -447, -447, -447, -447, |
| 1974 | 1029, 232, -447, -447, 244, -16, 249, 282, 194, 643, |
| 1975 | 300, 643, 1111, -447, 197, 643, -447, 199, -447, -447, |
| 1976 | 202, 203, -447, -447, 643, 643, 643, -447, 208, -447, |
| 1977 | 1111, 291, 315, -447, 148, 186, 289, 212, 217, 219, |
| 1978 | 220, 1152, -447, -447, -447, 231, 233, 234, 240, -447, |
| 1979 | -447, -447, 273, 241, -447, 643, 643, 1111, 242, -447, |
| 1980 | 242, -447, 243, 643, 246, 1111, 1111, 1111, -447, -447, |
| 1981 | -447, 1111, 643, -447, -447, -447, 223, 1111, 1152, 1152, |
| 1982 | 1152, 1152, -447, 1152, 1152, 1152, 1152, 328, -447, 322, |
| 1983 | 247, 245, 243, 248, 294, -447, -447, 1111, 250, 643, |
| 1984 | -447, -447, -447, 252, -447, -447, 254, 259, 257, 262, |
| 1985 | 263, 264, 265, 267, 270, -447, -447, 341, 14, 343, |
| 1986 | -447, -447, 271, -447, -447, 1152, -447, 1152, 1152, -447, |
| 1987 | -447, -447, -447, 643, -447, 751, 65, 374, -447, 279, |
| 1988 | 280, 281, -447, 285, -447, 751, 643, -447, -447, -447, |
| 1989 | 380, 290, 288, 643, 382, 384, -447, 643, 643, -447, |
| 1990 | -447 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 1991 | }; |
| 1992 | |
| 1993 | /* YYPGOTO[NTERM-NUM]. */ |
| 1994 | static const short int yypgoto[] = |
| 1995 | { |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 1996 | -447, -447, -447, 309, 310, 311, 312, -129, -128, -446, |
| 1997 | -447, 369, 386, -89, -447, -227, 51, -447, -248, -447, |
| 1998 | -50, -447, -37, -447, -68, 292, -447, -102, 221, -255, |
| 1999 | 57, -447, -447, -447, -447, -447, -447, -447, 361, -447, |
| 2000 | -447, -447, -447, 2, -447, 55, -447, -447, 355, -447, |
| 2001 | -447, -447, -447, -447, 414, -447, -447, -405, -57, 62, |
| 2002 | -105, -447, 399, -447, -447, -447, -447, -447, 49, -8, |
| 2003 | -447, -447, 24, -447, -447 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2004 | }; |
| 2005 | |
| 2006 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 2007 | positive, shift that token. If negative, reduce the rule which |
| 2008 | number is the opposite. If zero, do what YYDEFACT says. |
| 2009 | If YYTABLE_NINF, syntax error. */ |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2010 | #define YYTABLE_NINF -132 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2011 | static const short int yytable[] = |
| 2012 | { |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2013 | 89, 226, 227, 106, 314, 26, 336, 337, 39, 94, |
| 2014 | 202, 177, 178, 369, 53, 42, 89, 119, 347, 349, |
| 2015 | 212, 371, 391, 215, 218, 219, 220, 221, 222, 223, |
| 2016 | 224, 225, 495, 4, 355, 7, 8, 9, 10, 54, |
| 2017 | 12, 55, 229, 26, 56, 392, 356, 365, 29, 232, |
| 2018 | 505, 123, 236, 237, 119, 370, 238, 239, 240, 241, |
| 2019 | 242, 243, -69, 370, 59, 247, 60, 46, 47, 48, |
| 2020 | 39, 123, 184, 185, 186, 218, 219, 220, 221, 222, |
| 2021 | 223, 224, 225, 248, 216, 205, 49, 401, 211, 121, |
| 2022 | 503, 211, 20, 401, 21, 206, 217, 404, 401, 357, |
| 2023 | 511, 403, 123, 95, 251, 401, 414, 249, 250, 43, |
| 2024 | 252, 402, 110, 111, 112, 230, 231, 211, 233, 234, |
| 2025 | 211, 211, -131, 51, 211, 211, 211, 211, 211, 211, |
| 2026 | 244, 245, 246, 211, 494, 283, 284, 285, 107, 108, |
| 2027 | 256, 257, -29, -29, 281, 332, 435, 5, -28, -28, |
| 2028 | -27, -27, 52, 6, 305, -26, -26, 258, 259, 305, |
| 2029 | 305, 58, 62, 7, 8, 9, 10, 11, 12, 13, |
| 2030 | 287, 305, 64, 99, 100, -70, 305, 101, 114, 310, |
| 2031 | 102, 103, 115, 116, 14, 504, 176, 305, 305, 305, |
| 2032 | 122, 455, 89, 456, 180, 181, 182, 203, 330, 218, |
| 2033 | 219, 220, 221, 222, 223, 224, 225, 204, 207, 213, |
| 2034 | -33, 89, 331, 211, 377, -32, 379, 380, 381, -31, |
| 2035 | -30, -36, 261, 285, 387, 30, 31, 32, 33, 34, |
| 2036 | 35, 36, -37, 262, 291, 292, 395, 396, 397, 398, |
| 2037 | 399, 400, 311, 313, 316, 317, 318, 319, 320, 405, |
| 2038 | 406, 407, 408, 305, 321, 322, 323, 324, 325, 305, |
| 2039 | 329, 333, 334, 350, 363, 338, 391, 339, 413, 340, |
| 2040 | 415, 341, 342, 305, 305, 343, 351, 360, 307, 308, |
| 2041 | 352, 376, 211, 378, 211, 211, 211, 382, 383, 358, |
| 2042 | 309, 353, 211, 354, 375, 315, 366, 361, 367, 442, |
| 2043 | 372, 384, 385, 416, 419, 386, 326, 327, 328, 390, |
| 2044 | 417, 423, 305, 425, 305, 433, 426, 427, 305, 434, |
| 2045 | 460, 461, 462, 287, 431, 437, 438, 305, 305, 305, |
| 2046 | 447, 439, 475, 440, 441, 211, 467, 468, 469, 470, |
| 2047 | 465, 471, 472, 473, 474, 443, 476, 444, 445, 226, |
| 2048 | 227, 370, 480, 432, 446, 449, 454, 457, 305, 305, |
| 2049 | 459, 477, 493, 478, 515, 479, 305, 226, 227, 483, |
| 2050 | 481, 484, 368, 485, 486, 305, 487, 488, 374, 497, |
| 2051 | 211, 489, 490, 499, 491, 500, 501, 492, 211, 211, |
| 2052 | 211, 498, 388, 389, 211, 506, 507, 508, 509, 510, |
| 2053 | 466, 513, 305, 517, 514, 518, 167, 168, 169, 170, |
| 2054 | 97, 57, 411, 105, 209, 410, 113, 27, 45, 436, |
| 2055 | 211, 422, 280, 463, 65, 66, 0, 0, 0, 0, |
| 2056 | 0, 418, 0, 420, 0, 0, 305, 424, 0, 0, |
| 2057 | 0, 20, 0, 21, 0, 263, 428, 429, 430, 305, |
| 2058 | 0, 0, 0, 0, 0, 0, 305, 264, 265, 0, |
| 2059 | 305, 305, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2060 | 0, 0, 0, 0, 0, 0, 0, 450, 451, 0, |
| 2061 | 0, 0, 0, 0, 0, 458, 0, 0, 0, 0, |
| 2062 | 0, 0, 0, 0, 464, 0, 0, 134, 135, 136, |
| 2063 | 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, |
| 2064 | 147, 148, 149, 150, 151, 0, 0, 0, 0, 0, |
| 2065 | 266, 482, 267, 268, 159, 160, 0, 269, 270, 271, |
| 2066 | 0, 0, 0, 0, 0, 0, 0, 272, 0, 0, |
| 2067 | 273, 0, 274, 0, 0, 275, 0, 0, 0, 0, |
| 2068 | 0, 0, 0, 0, 0, 502, 0, 0, 0, 0, |
| 2069 | 0, 0, 0, 0, 0, 0, 0, 0, 512, 0, |
| 2070 | 0, 0, 0, 0, 0, 516, 0, 0, 0, 519, |
| 2071 | 520, 65, 66, 0, 117, 68, 69, 70, 71, 72, |
| 2072 | 73, 74, 75, 76, 77, 78, 79, 80, 20, 0, |
| 2073 | 21, 65, 66, 0, 117, 187, 188, 189, 190, 191, |
| 2074 | 192, 193, 194, 195, 196, 197, 79, 80, 20, 0, |
| 2075 | 21, 0, 0, 0, 81, 0, 0, 0, 0, 0, |
| 2076 | -39, 0, 20, 0, 21, 0, 0, 0, 0, 0, |
| 2077 | 0, 6, -39, -39, 81, 0, 293, 294, 65, 66, |
| 2078 | 295, -39, -39, -39, -39, -39, -39, -39, 0, 0, |
| 2079 | -39, 22, 0, 0, 0, 20, 0, 21, 23, 296, |
| 2080 | 297, 298, 24, 0, 0, 0, 0, 0, 0, 0, |
| 2081 | 0, 299, 300, 0, 0, 0, 0, 0, 0, 0, |
| 2082 | 0, 82, 0, 0, 83, 0, 0, 84, 0, 85, |
| 2083 | 118, 0, 0, 0, 301, 0, 0, 0, 0, 0, |
| 2084 | 0, 82, 0, 0, 83, 0, 0, 84, 0, 85, |
| 2085 | 348, 134, 135, 136, 137, 138, 139, 140, 141, 142, |
| 2086 | 143, 144, 145, 146, 147, 148, 149, 150, 151, 0, |
| 2087 | 0, 0, 0, 0, 266, 0, 267, 268, 159, 160, |
| 2088 | 0, 269, 270, 271, 293, 294, 0, 0, 295, 0, |
| 2089 | 0, 0, 0, 0, 302, 0, 0, 0, 0, 0, |
| 2090 | 0, 0, 0, 0, 0, 0, 0, 296, 297, 298, |
| 2091 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 299, |
| 2092 | 300, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2093 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2094 | 0, 0, 301, 0, 0, 0, 0, 0, 0, 0, |
| 2095 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 134, |
| 2096 | 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, |
| 2097 | 145, 146, 147, 148, 149, 150, 151, 0, 0, 0, |
| 2098 | 0, 0, 266, 0, 267, 268, 159, 160, 0, 269, |
| 2099 | 270, 271, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2100 | 65, 66, 302, 117, 68, 69, 70, 71, 72, 73, |
| 2101 | 74, 75, 76, 77, 78, 79, 80, 20, 0, 21, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2102 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2103 | 0, 0, 208, 0, 0, 0, 0, 0, 0, 0, |
| 2104 | 0, 65, 66, 81, 117, 68, 69, 70, 71, 72, |
| 2105 | 73, 74, 75, 76, 77, 78, 79, 80, 20, 0, |
| 2106 | 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2107 | 0, 0, 0, 286, 0, 0, 0, 0, 0, 0, |
| 2108 | 0, 0, 65, 66, 81, 117, 187, 188, 189, 190, |
| 2109 | 191, 192, 193, 194, 195, 196, 197, 79, 80, 20, |
| 2110 | 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2111 | 82, 0, 0, 83, 0, 0, 84, 0, 85, 0, |
| 2112 | 0, 0, 0, 65, 66, 81, 117, 68, 69, 70, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2113 | 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2114 | 20, 0, 21, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2115 | 0, 82, 0, 0, 83, 362, 0, 84, 0, 85, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2116 | 0, 0, 0, 0, 65, 66, 81, 117, 68, 69, |
| 2117 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2118 | 80, 20, 0, 21, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2119 | 0, 0, 82, 0, 0, 83, 409, 344, 84, 0, |
| 2120 | 85, 0, 0, 0, 0, 65, 66, 81, 67, 68, |
| 2121 | 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 2122 | 79, 80, 20, 0, 21, 0, 0, 0, 0, 0, |
| 2123 | 0, 0, 0, 82, 0, 0, 83, 0, 0, 84, |
| 2124 | 0, 85, 0, 0, 0, 0, 65, 66, 81, 117, |
| 2125 | 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 2126 | 78, 79, 80, 20, 0, 21, 0, 0, 0, 0, |
| 2127 | 0, 0, 0, 0, 82, 0, 0, 83, 0, 0, |
| 2128 | 84, 0, 85, 0, 0, 0, 0, 65, 66, 81, |
| 2129 | 117, 187, 188, 189, 190, 191, 192, 193, 194, 195, |
| 2130 | 196, 197, 79, 80, 20, 0, 21, 0, 0, 0, |
| 2131 | 0, 0, 0, 0, 0, 82, 0, 0, 83, 0, |
| 2132 | 0, 84, 0, 85, 0, 0, 0, 0, 65, 66, |
| 2133 | 81, 214, 68, 69, 70, 71, 72, 73, 74, 75, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2134 | 76, 77, 78, 79, 80, 20, 0, 21, 0, 0, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2135 | 0, 0, 0, 0, 0, 0, 82, 0, 0, 83, |
| 2136 | 0, 0, 84, 0, 85, 0, 0, 0, 0, 0, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2137 | 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2138 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2139 | 0, 0, 0, 0, 0, 0, 0, 82, 0, 0, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2140 | 83, 0, 0, 84, 0, 85, 0, 0, 0, 0, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2141 | 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2142 | 0, 0, 0, 0, 125, 0, 0, 0, 0, 0, |
| 2143 | 0, 0, 0, 0, 126, 127, 0, 0, 82, 0, |
| 2144 | 0, 83, 0, 0, 84, 0, 85, 128, 129, 130, |
| 2145 | 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, |
| 2146 | 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, |
| 2147 | 151, 152, 153, 154, 0, 0, 155, 156, 157, 158, |
| 2148 | 159, 160, 161, 162, 163, 164, 165, 166 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2149 | }; |
| 2150 | |
| 2151 | static const short int yycheck[] = |
| 2152 | { |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2153 | 37, 130, 130, 53, 231, 3, 254, 255, 23, 29, |
| 2154 | 112, 55, 56, 15, 20, 30, 53, 85, 273, 274, |
| 2155 | 125, 15, 34, 128, 10, 11, 12, 13, 14, 15, |
| 2156 | 16, 17, 478, 0, 282, 41, 42, 43, 44, 45, |
| 2157 | 46, 47, 131, 41, 50, 57, 120, 302, 61, 154, |
| 2158 | 496, 125, 157, 158, 122, 57, 161, 162, 163, 164, |
| 2159 | 165, 166, 116, 57, 45, 170, 47, 52, 53, 54, |
| 2160 | 23, 125, 109, 110, 111, 10, 11, 12, 13, 14, |
| 2161 | 15, 16, 17, 172, 9, 114, 71, 114, 125, 87, |
| 2162 | 495, 128, 22, 114, 24, 124, 21, 124, 114, 122, |
| 2163 | 505, 122, 125, 123, 114, 114, 122, 99, 100, 124, |
| 2164 | 120, 120, 55, 56, 57, 152, 153, 154, 155, 156, |
| 2165 | 157, 158, 0, 113, 161, 162, 163, 164, 165, 166, |
| 2166 | 167, 168, 169, 170, 120, 203, 204, 205, 32, 33, |
| 2167 | 27, 28, 3, 4, 201, 250, 394, 25, 3, 4, |
| 2168 | 3, 4, 61, 31, 211, 3, 4, 3, 4, 216, |
| 2169 | 217, 113, 24, 41, 42, 43, 44, 45, 46, 47, |
| 2170 | 207, 228, 4, 113, 113, 116, 233, 113, 4, 229, |
| 2171 | 113, 118, 4, 4, 62, 120, 24, 244, 245, 246, |
| 2172 | 116, 418, 229, 420, 4, 24, 24, 119, 248, 10, |
| 2173 | 11, 12, 13, 14, 15, 16, 17, 119, 116, 59, |
| 2174 | 4, 248, 249, 250, 319, 4, 321, 322, 323, 4, |
| 2175 | 4, 7, 4, 291, 329, 64, 65, 66, 67, 68, |
| 2176 | 69, 70, 7, 7, 114, 117, 338, 339, 340, 341, |
| 2177 | 342, 343, 114, 114, 118, 114, 36, 114, 114, 351, |
| 2178 | 352, 353, 354, 310, 114, 114, 114, 114, 114, 316, |
| 2179 | 114, 24, 114, 24, 63, 116, 34, 116, 24, 116, |
| 2180 | 21, 116, 116, 330, 331, 116, 116, 114, 216, 217, |
| 2181 | 116, 318, 319, 320, 321, 322, 323, 324, 325, 287, |
| 2182 | 228, 116, 329, 116, 118, 233, 114, 117, 114, 401, |
| 2183 | 114, 114, 114, 21, 4, 114, 244, 245, 246, 114, |
| 2184 | 116, 114, 369, 114, 371, 24, 114, 114, 375, 4, |
| 2185 | 425, 426, 427, 360, 116, 36, 114, 384, 385, 386, |
| 2186 | 57, 114, 4, 114, 114, 372, 438, 439, 440, 441, |
| 2187 | 117, 443, 444, 445, 446, 114, 24, 114, 114, 478, |
| 2188 | 478, 57, 457, 390, 114, 114, 114, 114, 415, 416, |
| 2189 | 114, 114, 21, 118, 76, 117, 423, 496, 496, 117, |
| 2190 | 120, 117, 310, 114, 117, 432, 114, 114, 316, 36, |
| 2191 | 417, 117, 117, 485, 117, 487, 488, 117, 425, 426, |
| 2192 | 427, 120, 330, 331, 431, 21, 117, 117, 117, 114, |
| 2193 | 437, 21, 459, 21, 114, 21, 97, 97, 97, 97, |
| 2194 | 41, 25, 361, 52, 122, 360, 61, 3, 19, 395, |
| 2195 | 457, 372, 201, 431, 5, 6, -1, -1, -1, -1, |
| 2196 | -1, 369, -1, 371, -1, -1, 493, 375, -1, -1, |
| 2197 | -1, 22, -1, 24, -1, 26, 384, 385, 386, 506, |
| 2198 | -1, -1, -1, -1, -1, -1, 513, 38, 39, -1, |
| 2199 | 517, 518, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2200 | -1, -1, -1, -1, -1, -1, -1, 415, 416, -1, |
| 2201 | -1, -1, -1, -1, -1, 423, -1, -1, -1, -1, |
| 2202 | -1, -1, -1, -1, 432, -1, -1, 78, 79, 80, |
| 2203 | 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 2204 | 91, 92, 93, 94, 95, -1, -1, -1, -1, -1, |
| 2205 | 101, 459, 103, 104, 105, 106, -1, 108, 109, 110, |
| 2206 | -1, -1, -1, -1, -1, -1, -1, 118, -1, -1, |
| 2207 | 121, -1, 123, -1, -1, 126, -1, -1, -1, -1, |
| 2208 | -1, -1, -1, -1, -1, 493, -1, -1, -1, -1, |
| 2209 | -1, -1, -1, -1, -1, -1, -1, -1, 506, -1, |
| 2210 | -1, -1, -1, -1, -1, 513, -1, -1, -1, 517, |
| 2211 | 518, 5, 6, -1, 8, 9, 10, 11, 12, 13, |
| 2212 | 14, 15, 16, 17, 18, 19, 20, 21, 22, -1, |
| 2213 | 24, 5, 6, -1, 8, 9, 10, 11, 12, 13, |
| 2214 | 14, 15, 16, 17, 18, 19, 20, 21, 22, -1, |
| 2215 | 24, -1, -1, -1, 48, -1, -1, -1, -1, -1, |
| 2216 | 20, -1, 22, -1, 24, -1, -1, -1, -1, -1, |
| 2217 | -1, 31, 32, 33, 48, -1, 3, 4, 5, 6, |
| 2218 | 7, 41, 42, 43, 44, 45, 46, 47, -1, -1, |
| 2219 | 50, 51, -1, -1, -1, 22, -1, 24, 58, 26, |
| 2220 | 27, 28, 62, -1, -1, -1, -1, -1, -1, -1, |
| 2221 | -1, 38, 39, -1, -1, -1, -1, -1, -1, -1, |
| 2222 | -1, 115, -1, -1, 118, -1, -1, 121, -1, 123, |
| 2223 | 124, -1, -1, -1, 61, -1, -1, -1, -1, -1, |
| 2224 | -1, 115, -1, -1, 118, -1, -1, 121, -1, 123, |
| 2225 | 124, 78, 79, 80, 81, 82, 83, 84, 85, 86, |
| 2226 | 87, 88, 89, 90, 91, 92, 93, 94, 95, -1, |
| 2227 | -1, -1, -1, -1, 101, -1, 103, 104, 105, 106, |
| 2228 | -1, 108, 109, 110, 3, 4, -1, -1, 7, -1, |
| 2229 | -1, -1, -1, -1, 121, -1, -1, -1, -1, -1, |
| 2230 | -1, -1, -1, -1, -1, -1, -1, 26, 27, 28, |
| 2231 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 38, |
| 2232 | 39, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2233 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2234 | -1, -1, 61, -1, -1, -1, -1, -1, -1, -1, |
| 2235 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 78, |
| 2236 | 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, |
| 2237 | 89, 90, 91, 92, 93, 94, 95, -1, -1, -1, |
| 2238 | -1, -1, 101, -1, 103, 104, 105, 106, -1, 108, |
| 2239 | 109, 110, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2240 | 5, 6, 121, 8, 9, 10, 11, 12, 13, 14, |
| 2241 | 15, 16, 17, 18, 19, 20, 21, 22, -1, 24, |
| 2242 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2243 | -1, -1, 37, -1, -1, -1, -1, -1, -1, -1, |
| 2244 | -1, 5, 6, 48, 8, 9, 10, 11, 12, 13, |
| 2245 | 14, 15, 16, 17, 18, 19, 20, 21, 22, -1, |
| 2246 | 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2247 | -1, -1, -1, 37, -1, -1, -1, -1, -1, -1, |
| 2248 | -1, -1, 5, 6, 48, 8, 9, 10, 11, 12, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2249 | 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2250 | -1, 24, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2251 | 115, -1, -1, 118, -1, -1, 121, -1, 123, -1, |
| 2252 | -1, -1, -1, 5, 6, 48, 8, 9, 10, 11, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2253 | 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, |
| 2254 | 22, -1, 24, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2255 | -1, 115, -1, -1, 118, 37, -1, 121, -1, 123, |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 2256 | -1, -1, -1, -1, 5, 6, 48, 8, 9, 10, |
| 2257 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 2258 | 21, 22, -1, 24, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2259 | -1, -1, 115, -1, -1, 118, 37, 120, 121, -1, |
| 2260 | 123, -1, -1, -1, -1, 5, 6, 48, 8, 9, |
| 2261 | 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, |
| 2262 | 20, 21, 22, -1, 24, -1, -1, -1, -1, -1, |
| 2263 | -1, -1, -1, 115, -1, -1, 118, -1, -1, 121, |
| 2264 | -1, 123, -1, -1, -1, -1, 5, 6, 48, 8, |
| 2265 | 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |
| 2266 | 19, 20, 21, 22, -1, 24, -1, -1, -1, -1, |
| 2267 | -1, -1, -1, -1, 115, -1, -1, 118, -1, -1, |
| 2268 | 121, -1, 123, -1, -1, -1, -1, 5, 6, 48, |
| 2269 | 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
| 2270 | 18, 19, 20, 21, 22, -1, 24, -1, -1, -1, |
| 2271 | -1, -1, -1, -1, -1, 115, -1, -1, 118, -1, |
| 2272 | -1, 121, -1, 123, -1, -1, -1, -1, 5, 6, |
| 2273 | 48, 8, 9, 10, 11, 12, 13, 14, 15, 16, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2274 | 17, 18, 19, 20, 21, 22, -1, 24, -1, -1, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2275 | -1, -1, -1, -1, -1, -1, 115, -1, -1, 118, |
| 2276 | -1, -1, 121, -1, 123, -1, -1, -1, -1, -1, |
| 2277 | -1, 48, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2278 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2279 | -1, -1, -1, -1, -1, -1, -1, 115, -1, -1, |
| 2280 | 118, -1, -1, 121, -1, 123, -1, -1, -1, -1, |
| 2281 | 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2282 | -1, -1, -1, -1, 49, -1, -1, -1, -1, -1, |
| 2283 | -1, -1, -1, -1, 59, 60, -1, -1, 115, -1, |
| 2284 | -1, 118, -1, -1, 121, -1, 123, 72, 73, 74, |
| 2285 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 2286 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 2287 | 95, 96, 97, 98, -1, -1, 101, 102, 103, 104, |
| 2288 | 105, 106, 107, 108, 109, 110, 111, 112 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2289 | }; |
| 2290 | |
| 2291 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 2292 | symbol of state STATE-NUM. */ |
| 2293 | static const unsigned char yystos[] = |
| 2294 | { |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2295 | 0, 158, 159, 160, 0, 25, 31, 41, 42, 43, |
| 2296 | 44, 45, 46, 47, 62, 139, 177, 179, 181, 188, |
| 2297 | 22, 24, 51, 58, 62, 138, 170, 181, 182, 61, |
| 2298 | 64, 65, 66, 67, 68, 69, 70, 140, 175, 23, |
| 2299 | 189, 190, 30, 124, 178, 189, 52, 53, 54, 71, |
| 2300 | 167, 113, 61, 20, 45, 47, 50, 139, 113, 45, |
| 2301 | 47, 180, 24, 165, 4, 5, 6, 8, 9, 10, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2302 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2303 | 21, 48, 115, 118, 121, 123, 128, 147, 148, 149, |
| 2304 | 150, 151, 170, 185, 29, 123, 176, 138, 193, 113, |
| 2305 | 113, 113, 113, 118, 168, 165, 147, 32, 33, 157, |
| 2306 | 157, 157, 157, 175, 4, 4, 4, 8, 124, 151, |
| 2307 | 152, 170, 116, 125, 35, 49, 59, 60, 72, 73, |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2308 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 2309 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 2310 | 94, 95, 96, 97, 98, 101, 102, 103, 104, 105, |
| 2311 | 106, 107, 108, 109, 110, 111, 112, 130, 131, 132, |
| 2312 | 133, 191, 197, 198, 200, 201, 24, 55, 56, 166, |
| 2313 | 4, 24, 24, 169, 149, 149, 149, 9, 10, 11, |
| 2314 | 12, 13, 14, 15, 16, 17, 18, 19, 134, 135, |
| 2315 | 137, 149, 154, 119, 119, 114, 124, 116, 37, 152, |
| 2316 | 153, 149, 187, 59, 8, 187, 9, 21, 10, 11, |
| 2317 | 12, 13, 14, 15, 16, 17, 134, 135, 136, 140, |
| 2318 | 149, 149, 187, 149, 149, 194, 187, 187, 187, 187, |
| 2319 | 187, 187, 187, 187, 149, 149, 149, 187, 140, 99, |
| 2320 | 100, 114, 120, 163, 164, 162, 27, 28, 3, 4, |
| 2321 | 129, 4, 7, 26, 38, 39, 101, 103, 104, 108, |
| 2322 | 109, 110, 118, 121, 123, 126, 130, 131, 132, 133, |
| 2323 | 155, 185, 161, 151, 151, 151, 37, 149, 172, 173, |
| 2324 | 174, 114, 117, 3, 4, 7, 26, 27, 28, 38, |
| 2325 | 39, 61, 121, 155, 184, 185, 186, 186, 186, 186, |
| 2326 | 147, 114, 142, 114, 142, 186, 118, 114, 36, 114, |
| 2327 | 114, 114, 114, 114, 114, 114, 186, 186, 186, 114, |
| 2328 | 147, 149, 187, 24, 114, 145, 145, 145, 116, 116, |
| 2329 | 116, 116, 116, 116, 120, 154, 156, 156, 124, 156, |
| 2330 | 24, 116, 116, 116, 116, 145, 120, 122, 170, 171, |
| 2331 | 114, 117, 37, 63, 183, 156, 114, 114, 186, 15, |
| 2332 | 57, 15, 114, 199, 186, 118, 149, 187, 149, 187, |
| 2333 | 187, 187, 149, 149, 114, 114, 114, 187, 186, 186, |
| 2334 | 114, 34, 57, 143, 146, 154, 154, 154, 154, 154, |
| 2335 | 154, 114, 120, 122, 124, 154, 154, 154, 154, 37, |
| 2336 | 172, 143, 144, 24, 122, 21, 21, 116, 186, 4, |
| 2337 | 186, 187, 195, 114, 186, 114, 114, 114, 186, 186, |
| 2338 | 186, 116, 149, 24, 4, 145, 199, 36, 114, 114, |
| 2339 | 114, 114, 154, 114, 114, 114, 114, 57, 141, 114, |
| 2340 | 186, 186, 195, 196, 114, 142, 142, 114, 186, 114, |
| 2341 | 187, 187, 187, 196, 186, 117, 149, 154, 154, 154, |
| 2342 | 154, 154, 154, 154, 154, 4, 24, 114, 118, 117, |
| 2343 | 187, 120, 186, 117, 117, 114, 117, 114, 114, 117, |
| 2344 | 117, 117, 117, 21, 120, 136, 192, 36, 120, 154, |
| 2345 | 154, 154, 186, 184, 120, 136, 21, 117, 117, 117, |
| 2346 | 114, 184, 186, 21, 114, 76, 186, 21, 21, 186, |
| 2347 | 186 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2348 | }; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2349 | |
| 2350 | #define yyerrok (yyerrstatus = 0) |
| 2351 | #define yyclearin (yychar = YYEMPTY) |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2352 | #define YYEMPTY (-2) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2353 | #define YYEOF 0 |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2354 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2355 | #define YYACCEPT goto yyacceptlab |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2356 | #define YYABORT goto yyabortlab |
| 2357 | #define YYERROR goto yyerrorlab |
| 2358 | |
| 2359 | |
| 2360 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 2361 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2362 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2363 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2364 | #define YYFAIL goto yyerrlab |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2365 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2366 | #define YYRECOVERING() (!!yyerrstatus) |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2367 | |
| 2368 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2369 | do \ |
| 2370 | if (yychar == YYEMPTY && yylen == 1) \ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2371 | { \ |
| 2372 | yychar = (Token); \ |
| 2373 | yylval = (Value); \ |
| 2374 | yytoken = YYTRANSLATE (yychar); \ |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2375 | YYPOPSTACK; \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2376 | goto yybackup; \ |
| 2377 | } \ |
| 2378 | else \ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2379 | { \ |
| 2380 | yyerror (YY_("syntax error: cannot back up")); \ |
| 2381 | YYERROR; \ |
| 2382 | } \ |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2383 | while (0) |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2384 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2385 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2386 | #define YYTERROR 1 |
| 2387 | #define YYERRCODE 256 |
| 2388 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2389 | |
| 2390 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
| 2391 | If N is 0, then set CURRENT to the empty location which ends |
| 2392 | the previous symbol: RHS[0] (always defined). */ |
| 2393 | |
| 2394 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| 2395 | #ifndef YYLLOC_DEFAULT |
| 2396 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 2397 | do \ |
| 2398 | if (N) \ |
| 2399 | { \ |
| 2400 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
| 2401 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
| 2402 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
| 2403 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
| 2404 | } \ |
| 2405 | else \ |
| 2406 | { \ |
| 2407 | (Current).first_line = (Current).last_line = \ |
| 2408 | YYRHSLOC (Rhs, 0).last_line; \ |
| 2409 | (Current).first_column = (Current).last_column = \ |
| 2410 | YYRHSLOC (Rhs, 0).last_column; \ |
| 2411 | } \ |
| 2412 | while (0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2413 | #endif |
| 2414 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2415 | |
| 2416 | /* YY_LOCATION_PRINT -- Print the location on the stream. |
| 2417 | This macro was not mandated originally: define only if we know |
| 2418 | we won't break user code: when these are the locations we know. */ |
| 2419 | |
| 2420 | #ifndef YY_LOCATION_PRINT |
| 2421 | # if YYLTYPE_IS_TRIVIAL |
| 2422 | # define YY_LOCATION_PRINT(File, Loc) \ |
| 2423 | fprintf (File, "%d.%d-%d.%d", \ |
| 2424 | (Loc).first_line, (Loc).first_column, \ |
| 2425 | (Loc).last_line, (Loc).last_column) |
| 2426 | # else |
| 2427 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 2428 | # endif |
| 2429 | #endif |
| 2430 | |
| 2431 | |
| 2432 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 2433 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2434 | #ifdef YYLEX_PARAM |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2435 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2436 | #else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2437 | # define YYLEX yylex () |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2438 | #endif |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2439 | |
| 2440 | /* Enable debugging if requested. */ |
| 2441 | #if YYDEBUG |
| 2442 | |
| 2443 | # ifndef YYFPRINTF |
| 2444 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 2445 | # define YYFPRINTF fprintf |
| 2446 | # endif |
| 2447 | |
| 2448 | # define YYDPRINTF(Args) \ |
| 2449 | do { \ |
| 2450 | if (yydebug) \ |
| 2451 | YYFPRINTF Args; \ |
| 2452 | } while (0) |
| 2453 | |
| 2454 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 2455 | do { \ |
| 2456 | if (yydebug) \ |
| 2457 | { \ |
| 2458 | YYFPRINTF (stderr, "%s ", Title); \ |
| 2459 | yysymprint (stderr, \ |
| 2460 | Type, Value); \ |
| 2461 | YYFPRINTF (stderr, "\n"); \ |
| 2462 | } \ |
| 2463 | } while (0) |
| 2464 | |
| 2465 | /*------------------------------------------------------------------. |
| 2466 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 2467 | | TOP (included). | |
| 2468 | `------------------------------------------------------------------*/ |
| 2469 | |
| 2470 | #if defined (__STDC__) || defined (__cplusplus) |
| 2471 | static void |
| 2472 | yy_stack_print (short int *bottom, short int *top) |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2473 | #else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2474 | static void |
| 2475 | yy_stack_print (bottom, top) |
| 2476 | short int *bottom; |
| 2477 | short int *top; |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2478 | #endif |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2479 | { |
| 2480 | YYFPRINTF (stderr, "Stack now"); |
| 2481 | for (/* Nothing. */; bottom <= top; ++bottom) |
| 2482 | YYFPRINTF (stderr, " %d", *bottom); |
| 2483 | YYFPRINTF (stderr, "\n"); |
| 2484 | } |
| 2485 | |
| 2486 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 2487 | do { \ |
| 2488 | if (yydebug) \ |
| 2489 | yy_stack_print ((Bottom), (Top)); \ |
| 2490 | } while (0) |
| 2491 | |
| 2492 | |
| 2493 | /*------------------------------------------------. |
| 2494 | | Report that the YYRULE is going to be reduced. | |
| 2495 | `------------------------------------------------*/ |
| 2496 | |
| 2497 | #if defined (__STDC__) || defined (__cplusplus) |
| 2498 | static void |
| 2499 | yy_reduce_print (int yyrule) |
| 2500 | #else |
| 2501 | static void |
| 2502 | yy_reduce_print (yyrule) |
| 2503 | int yyrule; |
Chris Lattner | 59c85e9 | 2006-10-15 23:27:25 +0000 | [diff] [blame] | 2504 | #endif |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2505 | { |
| 2506 | int yyi; |
| 2507 | unsigned long int yylno = yyrline[yyrule]; |
| 2508 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", |
| 2509 | yyrule - 1, yylno); |
| 2510 | /* Print the symbols being reduced, and their result. */ |
| 2511 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
| 2512 | YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); |
| 2513 | YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); |
| 2514 | } |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 2515 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2516 | # define YY_REDUCE_PRINT(Rule) \ |
| 2517 | do { \ |
| 2518 | if (yydebug) \ |
| 2519 | yy_reduce_print (Rule); \ |
| 2520 | } while (0) |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 2521 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2522 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 2523 | multiple parsers can coexist. */ |
| 2524 | int yydebug; |
| 2525 | #else /* !YYDEBUG */ |
| 2526 | # define YYDPRINTF(Args) |
| 2527 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
| 2528 | # define YY_STACK_PRINT(Bottom, Top) |
| 2529 | # define YY_REDUCE_PRINT(Rule) |
| 2530 | #endif /* !YYDEBUG */ |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 2531 | |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 2532 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2533 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2534 | #ifndef YYINITDEPTH |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2535 | # define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2536 | #endif |
| 2537 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2538 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 2539 | if the built-in stack extension method is used). |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2540 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2541 | Do not make this value too large; the results are undefined if |
| 2542 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
| 2543 | evaluated with infinite-precision integer arithmetic. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2544 | |
| 2545 | #ifndef YYMAXDEPTH |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2546 | # define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2547 | #endif |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2548 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2549 | |
| 2550 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2551 | #if YYERROR_VERBOSE |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2552 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2553 | # ifndef yystrlen |
| 2554 | # if defined (__GLIBC__) && defined (_STRING_H) |
| 2555 | # define yystrlen strlen |
| 2556 | # else |
| 2557 | /* Return the length of YYSTR. */ |
| 2558 | static YYSIZE_T |
| 2559 | # if defined (__STDC__) || defined (__cplusplus) |
| 2560 | yystrlen (const char *yystr) |
| 2561 | # else |
| 2562 | yystrlen (yystr) |
| 2563 | const char *yystr; |
| 2564 | # endif |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2565 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2566 | const char *yys = yystr; |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2567 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2568 | while (*yys++ != '\0') |
| 2569 | continue; |
| 2570 | |
| 2571 | return yys - yystr - 1; |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2572 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2573 | # endif |
| 2574 | # endif |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2575 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2576 | # ifndef yystpcpy |
| 2577 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
| 2578 | # define yystpcpy stpcpy |
| 2579 | # else |
| 2580 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 2581 | YYDEST. */ |
| 2582 | static char * |
| 2583 | # if defined (__STDC__) || defined (__cplusplus) |
| 2584 | yystpcpy (char *yydest, const char *yysrc) |
| 2585 | # else |
| 2586 | yystpcpy (yydest, yysrc) |
| 2587 | char *yydest; |
| 2588 | const char *yysrc; |
| 2589 | # endif |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2590 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2591 | char *yyd = yydest; |
| 2592 | const char *yys = yysrc; |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2593 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2594 | while ((*yyd++ = *yys++) != '\0') |
| 2595 | continue; |
| 2596 | |
| 2597 | return yyd - 1; |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2598 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2599 | # endif |
| 2600 | # endif |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2601 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2602 | # ifndef yytnamerr |
| 2603 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
| 2604 | quotes and backslashes, so that it's suitable for yyerror. The |
| 2605 | heuristic is that double-quoting is unnecessary unless the string |
| 2606 | contains an apostrophe, a comma, or backslash (other than |
| 2607 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
| 2608 | null, do not copy; instead, return the length of what the result |
| 2609 | would have been. */ |
| 2610 | static YYSIZE_T |
| 2611 | yytnamerr (char *yyres, const char *yystr) |
| 2612 | { |
| 2613 | if (*yystr == '"') |
| 2614 | { |
| 2615 | size_t yyn = 0; |
| 2616 | char const *yyp = yystr; |
| 2617 | |
| 2618 | for (;;) |
| 2619 | switch (*++yyp) |
| 2620 | { |
| 2621 | case '\'': |
| 2622 | case ',': |
| 2623 | goto do_not_strip_quotes; |
| 2624 | |
| 2625 | case '\\': |
| 2626 | if (*++yyp != '\\') |
| 2627 | goto do_not_strip_quotes; |
| 2628 | /* Fall through. */ |
| 2629 | default: |
| 2630 | if (yyres) |
| 2631 | yyres[yyn] = *yyp; |
| 2632 | yyn++; |
| 2633 | break; |
| 2634 | |
| 2635 | case '"': |
| 2636 | if (yyres) |
| 2637 | yyres[yyn] = '\0'; |
| 2638 | return yyn; |
| 2639 | } |
| 2640 | do_not_strip_quotes: ; |
| 2641 | } |
| 2642 | |
| 2643 | if (! yyres) |
| 2644 | return yystrlen (yystr); |
| 2645 | |
| 2646 | return yystpcpy (yyres, yystr) - yyres; |
| 2647 | } |
| 2648 | # endif |
| 2649 | |
| 2650 | #endif /* YYERROR_VERBOSE */ |
| 2651 | |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 2652 | |
| 2653 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2654 | #if YYDEBUG |
| 2655 | /*--------------------------------. |
| 2656 | | Print this symbol on YYOUTPUT. | |
| 2657 | `--------------------------------*/ |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 2658 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2659 | #if defined (__STDC__) || defined (__cplusplus) |
| 2660 | static void |
| 2661 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2662 | #else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2663 | static void |
| 2664 | yysymprint (yyoutput, yytype, yyvaluep) |
| 2665 | FILE *yyoutput; |
| 2666 | int yytype; |
| 2667 | YYSTYPE *yyvaluep; |
| 2668 | #endif |
| 2669 | { |
| 2670 | /* Pacify ``unused variable'' warnings. */ |
| 2671 | (void) yyvaluep; |
| 2672 | |
| 2673 | if (yytype < YYNTOKENS) |
| 2674 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 2675 | else |
| 2676 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 2677 | |
| 2678 | |
| 2679 | # ifdef YYPRINT |
| 2680 | if (yytype < YYNTOKENS) |
| 2681 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 2682 | # endif |
| 2683 | switch (yytype) |
| 2684 | { |
| 2685 | default: |
| 2686 | break; |
| 2687 | } |
| 2688 | YYFPRINTF (yyoutput, ")"); |
| 2689 | } |
| 2690 | |
| 2691 | #endif /* ! YYDEBUG */ |
| 2692 | /*-----------------------------------------------. |
| 2693 | | Release the memory associated to this symbol. | |
| 2694 | `-----------------------------------------------*/ |
| 2695 | |
| 2696 | #if defined (__STDC__) || defined (__cplusplus) |
| 2697 | static void |
| 2698 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
| 2699 | #else |
| 2700 | static void |
| 2701 | yydestruct (yymsg, yytype, yyvaluep) |
| 2702 | const char *yymsg; |
| 2703 | int yytype; |
| 2704 | YYSTYPE *yyvaluep; |
| 2705 | #endif |
| 2706 | { |
| 2707 | /* Pacify ``unused variable'' warnings. */ |
| 2708 | (void) yyvaluep; |
| 2709 | |
| 2710 | if (!yymsg) |
| 2711 | yymsg = "Deleting"; |
| 2712 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 2713 | |
| 2714 | switch (yytype) |
| 2715 | { |
| 2716 | |
| 2717 | default: |
| 2718 | break; |
| 2719 | } |
| 2720 | } |
| 2721 | |
| 2722 | |
| 2723 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 2724 | |
| 2725 | #ifdef YYPARSE_PARAM |
| 2726 | # if defined (__STDC__) || defined (__cplusplus) |
| 2727 | int yyparse (void *YYPARSE_PARAM); |
| 2728 | # else |
| 2729 | int yyparse (); |
| 2730 | # endif |
| 2731 | #else /* ! YYPARSE_PARAM */ |
| 2732 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 2733 | int yyparse (void); |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2734 | #else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2735 | int yyparse (); |
| 2736 | #endif |
| 2737 | #endif /* ! YYPARSE_PARAM */ |
| 2738 | |
| 2739 | |
| 2740 | |
| 2741 | /* The look-ahead symbol. */ |
| 2742 | int yychar; |
| 2743 | |
| 2744 | /* The semantic value of the look-ahead symbol. */ |
| 2745 | YYSTYPE yylval; |
| 2746 | |
| 2747 | /* Number of syntax errors so far. */ |
| 2748 | int yynerrs; |
| 2749 | |
| 2750 | |
| 2751 | |
| 2752 | /*----------. |
| 2753 | | yyparse. | |
| 2754 | `----------*/ |
| 2755 | |
| 2756 | #ifdef YYPARSE_PARAM |
| 2757 | # if defined (__STDC__) || defined (__cplusplus) |
| 2758 | int yyparse (void *YYPARSE_PARAM) |
| 2759 | # else |
| 2760 | int yyparse (YYPARSE_PARAM) |
| 2761 | void *YYPARSE_PARAM; |
| 2762 | # endif |
| 2763 | #else /* ! YYPARSE_PARAM */ |
| 2764 | #if defined (__STDC__) || defined (__cplusplus) |
| 2765 | int |
| 2766 | yyparse (void) |
| 2767 | #else |
| 2768 | int |
| 2769 | yyparse () |
| 2770 | |
| 2771 | #endif |
| 2772 | #endif |
| 2773 | { |
| 2774 | |
| 2775 | int yystate; |
| 2776 | int yyn; |
| 2777 | int yyresult; |
| 2778 | /* Number of tokens to shift before error messages enabled. */ |
| 2779 | int yyerrstatus; |
| 2780 | /* Look-ahead token as an internal (translated) token number. */ |
| 2781 | int yytoken = 0; |
| 2782 | |
| 2783 | /* Three stacks and their tools: |
| 2784 | `yyss': related to states, |
| 2785 | `yyvs': related to semantic values, |
| 2786 | `yyls': related to locations. |
| 2787 | |
| 2788 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 2789 | to reallocate them elsewhere. */ |
| 2790 | |
| 2791 | /* The state stack. */ |
| 2792 | short int yyssa[YYINITDEPTH]; |
| 2793 | short int *yyss = yyssa; |
| 2794 | short int *yyssp; |
| 2795 | |
| 2796 | /* The semantic value stack. */ |
| 2797 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 2798 | YYSTYPE *yyvs = yyvsa; |
| 2799 | YYSTYPE *yyvsp; |
| 2800 | |
| 2801 | |
| 2802 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2803 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2804 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2805 | YYSIZE_T yystacksize = YYINITDEPTH; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2806 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2807 | /* The variables used to return semantic value and location from the |
| 2808 | action routines. */ |
| 2809 | YYSTYPE yyval; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2810 | |
| 2811 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2812 | /* When reducing, the number of symbols on the RHS of the reduced |
| 2813 | rule. */ |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2814 | int yylen; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2815 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2816 | YYDPRINTF ((stderr, "Starting parse\n")); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2817 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2818 | yystate = 0; |
| 2819 | yyerrstatus = 0; |
| 2820 | yynerrs = 0; |
| 2821 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2822 | |
| 2823 | /* Initialize stack pointers. |
| 2824 | Waste one element of value and location stack |
| 2825 | so that they stay on the same level as the state stack. |
| 2826 | The wasted elements are never initialized. */ |
| 2827 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2828 | yyssp = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2829 | yyvsp = yyvs; |
| 2830 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2831 | goto yysetstate; |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2832 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2833 | /*------------------------------------------------------------. |
| 2834 | | yynewstate -- Push a new state, which is found in yystate. | |
| 2835 | `------------------------------------------------------------*/ |
| 2836 | yynewstate: |
| 2837 | /* In all cases, when you get here, the value and location stacks |
| 2838 | have just been pushed. so pushing a state here evens the stacks. |
| 2839 | */ |
| 2840 | yyssp++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2841 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2842 | yysetstate: |
| 2843 | *yyssp = yystate; |
| 2844 | |
| 2845 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2846 | { |
| 2847 | /* Get the current used size of the three stacks, in elements. */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2848 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2849 | |
| 2850 | #ifdef yyoverflow |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2851 | { |
| 2852 | /* Give user a chance to reallocate the stack. Use copies of |
| 2853 | these so that the &'s don't force the real ones into |
| 2854 | memory. */ |
| 2855 | YYSTYPE *yyvs1 = yyvs; |
| 2856 | short int *yyss1 = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2857 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2858 | |
| 2859 | /* Each stack pointer address is followed by the size of the |
| 2860 | data in use in that stack, in bytes. This used to be a |
| 2861 | conditional around just the two extra args, but that might |
| 2862 | be undefined if yyoverflow is a macro. */ |
| 2863 | yyoverflow (YY_("memory exhausted"), |
| 2864 | &yyss1, yysize * sizeof (*yyssp), |
| 2865 | &yyvs1, yysize * sizeof (*yyvsp), |
| 2866 | |
| 2867 | &yystacksize); |
| 2868 | |
| 2869 | yyss = yyss1; |
| 2870 | yyvs = yyvs1; |
| 2871 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2872 | #else /* no yyoverflow */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2873 | # ifndef YYSTACK_RELOCATE |
| 2874 | goto yyexhaustedlab; |
| 2875 | # else |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2876 | /* Extend the stack our own way. */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2877 | if (YYMAXDEPTH <= yystacksize) |
| 2878 | goto yyexhaustedlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2879 | yystacksize *= 2; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2880 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2881 | yystacksize = YYMAXDEPTH; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2882 | |
| 2883 | { |
| 2884 | short int *yyss1 = yyss; |
| 2885 | union yyalloc *yyptr = |
| 2886 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 2887 | if (! yyptr) |
| 2888 | goto yyexhaustedlab; |
| 2889 | YYSTACK_RELOCATE (yyss); |
| 2890 | YYSTACK_RELOCATE (yyvs); |
| 2891 | |
| 2892 | # undef YYSTACK_RELOCATE |
| 2893 | if (yyss1 != yyssa) |
| 2894 | YYSTACK_FREE (yyss1); |
| 2895 | } |
| 2896 | # endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2897 | #endif /* no yyoverflow */ |
| 2898 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2899 | yyssp = yyss + yysize - 1; |
| 2900 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2901 | |
| 2902 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2903 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 2904 | (unsigned long int) yystacksize)); |
| 2905 | |
| 2906 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2907 | YYABORT; |
| 2908 | } |
| 2909 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2910 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2911 | |
| 2912 | goto yybackup; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2913 | |
| 2914 | /*-----------. |
| 2915 | | yybackup. | |
| 2916 | `-----------*/ |
| 2917 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2918 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2919 | /* Do appropriate processing given the current state. */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2920 | /* 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] | 2921 | /* yyresume: */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2922 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2923 | /* 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] | 2924 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2925 | yyn = yypact[yystate]; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2926 | if (yyn == YYPACT_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2927 | goto yydefault; |
| 2928 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2929 | /* 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] | 2930 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2931 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2932 | if (yychar == YYEMPTY) |
| 2933 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2934 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2935 | yychar = YYLEX; |
| 2936 | } |
| 2937 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2938 | if (yychar <= YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2939 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2940 | yychar = yytoken = YYEOF; |
| 2941 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2942 | } |
| 2943 | else |
| 2944 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2945 | yytoken = YYTRANSLATE (yychar); |
| 2946 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2947 | } |
| 2948 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2949 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 2950 | detect an error, take that action. */ |
| 2951 | yyn += yytoken; |
| 2952 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2953 | goto yydefault; |
| 2954 | yyn = yytable[yyn]; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2955 | if (yyn <= 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2956 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2957 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2958 | goto yyerrlab; |
| 2959 | yyn = -yyn; |
| 2960 | goto yyreduce; |
| 2961 | } |
| 2962 | |
| 2963 | if (yyn == YYFINAL) |
| 2964 | YYACCEPT; |
| 2965 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2966 | /* Shift the look-ahead token. */ |
| 2967 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2968 | |
| 2969 | /* Discard the token being shifted unless it is eof. */ |
| 2970 | if (yychar != YYEOF) |
| 2971 | yychar = YYEMPTY; |
| 2972 | |
| 2973 | *++yyvsp = yylval; |
| 2974 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2975 | |
| 2976 | /* Count tokens shifted since error; after three, turn off error |
| 2977 | status. */ |
| 2978 | if (yyerrstatus) |
| 2979 | yyerrstatus--; |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 2980 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2981 | yystate = yyn; |
| 2982 | goto yynewstate; |
| 2983 | |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2984 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2985 | /*-----------------------------------------------------------. |
| 2986 | | yydefault -- do the default action for the current state. | |
| 2987 | `-----------------------------------------------------------*/ |
| 2988 | yydefault: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2989 | yyn = yydefact[yystate]; |
| 2990 | if (yyn == 0) |
| 2991 | goto yyerrlab; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2992 | goto yyreduce; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2993 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2994 | |
| 2995 | /*-----------------------------. |
| 2996 | | yyreduce -- Do a reduction. | |
| 2997 | `-----------------------------*/ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2998 | yyreduce: |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2999 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3000 | yylen = yyr2[yyn]; |
| 3001 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3002 | /* If YYLEN is nonzero, implement the default value of the action: |
| 3003 | `$$ = $1'. |
| 3004 | |
| 3005 | Otherwise, the following line sets YYVAL to garbage. |
| 3006 | This behavior is undocumented and Bison |
| 3007 | users should not rely upon it. Assigning to YYVAL |
| 3008 | unconditionally makes the parser a bit smaller, and it avoids a |
| 3009 | GCC warning that YYVAL may be used uninitialized. */ |
| 3010 | yyval = yyvsp[1-yylen]; |
| 3011 | |
| 3012 | |
| 3013 | YY_REDUCE_PRINT (yyn); |
| 3014 | switch (yyn) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3015 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3016 | case 3: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3017 | #line 1140 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3018 | { |
| 3019 | if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range! |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3020 | GEN_ERROR("Value too large for type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3021 | (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3022 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3023 | ;} |
| 3024 | break; |
| 3025 | |
| 3026 | case 5: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3027 | #line 1149 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3028 | { |
| 3029 | if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range! |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3030 | GEN_ERROR("Value too large for type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3031 | (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3032 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3033 | ;} |
| 3034 | break; |
| 3035 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3036 | case 38: |
| 3037 | #line 1173 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3038 | { |
| 3039 | (yyval.StrVal) = (yyvsp[-1].StrVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3040 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3041 | ;} |
| 3042 | break; |
| 3043 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3044 | case 39: |
| 3045 | #line 1177 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3046 | { |
| 3047 | (yyval.StrVal) = 0; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3048 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3049 | ;} |
| 3050 | break; |
| 3051 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3052 | case 40: |
| 3053 | #line 1182 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3054 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3055 | break; |
| 3056 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3057 | case 41: |
| 3058 | #line 1183 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3059 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 3060 | break; |
| 3061 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3062 | case 42: |
| 3063 | #line 1184 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3064 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3065 | break; |
| 3066 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3067 | case 43: |
| 3068 | #line 1185 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3069 | { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} |
| 3070 | break; |
| 3071 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3072 | case 44: |
| 3073 | #line 1186 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3074 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 3075 | break; |
| 3076 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3077 | case 45: |
| 3078 | #line 1187 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3079 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 3080 | break; |
| 3081 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3082 | case 46: |
| 3083 | #line 1188 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3084 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 3085 | break; |
| 3086 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3087 | case 47: |
| 3088 | #line 1189 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3089 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3090 | break; |
| 3091 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3092 | case 48: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3093 | #line 1191 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3094 | { (yyval.UIntVal) = CallingConv::C; ;} |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3095 | break; |
| 3096 | |
| 3097 | case 49: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3098 | #line 1192 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3099 | { (yyval.UIntVal) = CallingConv::C; ;} |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3100 | break; |
| 3101 | |
| 3102 | case 50: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3103 | #line 1193 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3104 | { (yyval.UIntVal) = CallingConv::CSRet; ;} |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3105 | break; |
| 3106 | |
| 3107 | case 51: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3108 | #line 1194 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3109 | { (yyval.UIntVal) = CallingConv::Fast; ;} |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3110 | break; |
| 3111 | |
| 3112 | case 52: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3113 | #line 1195 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3114 | { (yyval.UIntVal) = CallingConv::Cold; ;} |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3115 | break; |
| 3116 | |
| 3117 | case 53: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3118 | #line 1196 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3119 | { (yyval.UIntVal) = CallingConv::X86_StdCall; ;} |
| 3120 | break; |
| 3121 | |
| 3122 | case 54: |
| 3123 | #line 1197 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3124 | { (yyval.UIntVal) = CallingConv::X86_FastCall; ;} |
| 3125 | break; |
| 3126 | |
| 3127 | case 55: |
| 3128 | #line 1198 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3129 | { |
| 3130 | if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3131 | GEN_ERROR("Calling conv too large!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3132 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3133 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3134 | ;} |
| 3135 | break; |
| 3136 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3137 | case 56: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3138 | #line 1207 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3139 | { (yyval.UIntVal) = 0; ;} |
| 3140 | break; |
| 3141 | |
| 3142 | case 57: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3143 | #line 1208 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3144 | { |
| 3145 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 3146 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
| 3147 | GEN_ERROR("Alignment must be a power of two!"); |
| 3148 | CHECK_FOR_ERROR |
| 3149 | ;} |
| 3150 | break; |
| 3151 | |
| 3152 | case 58: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3153 | #line 1214 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3154 | { (yyval.UIntVal) = 0; ;} |
| 3155 | break; |
| 3156 | |
| 3157 | case 59: |
| 3158 | #line 1215 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3159 | { |
| 3160 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 3161 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
| 3162 | GEN_ERROR("Alignment must be a power of two!"); |
| 3163 | CHECK_FOR_ERROR |
| 3164 | ;} |
| 3165 | break; |
| 3166 | |
| 3167 | case 60: |
| 3168 | #line 1223 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3169 | { |
| 3170 | for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) |
| 3171 | if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3172 | GEN_ERROR("Invalid character in section name!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3173 | (yyval.StrVal) = (yyvsp[0].StrVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3174 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3175 | ;} |
| 3176 | break; |
| 3177 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3178 | case 61: |
| 3179 | #line 1231 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3180 | { (yyval.StrVal) = 0; ;} |
| 3181 | break; |
| 3182 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3183 | case 62: |
| 3184 | #line 1232 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3185 | { (yyval.StrVal) = (yyvsp[0].StrVal); ;} |
| 3186 | break; |
| 3187 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3188 | case 63: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3189 | #line 1237 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3190 | {;} |
| 3191 | break; |
| 3192 | |
| 3193 | case 64: |
| 3194 | #line 1238 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3195 | {;} |
| 3196 | break; |
| 3197 | |
| 3198 | case 65: |
| 3199 | #line 1239 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3200 | { |
| 3201 | CurGV->setSection((yyvsp[0].StrVal)); |
| 3202 | free((yyvsp[0].StrVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3203 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3204 | ;} |
| 3205 | break; |
| 3206 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3207 | case 66: |
| 3208 | #line 1244 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3209 | { |
| 3210 | if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3211 | GEN_ERROR("Alignment must be a power of two!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3212 | CurGV->setAlignment((yyvsp[0].UInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3213 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3214 | ;} |
| 3215 | break; |
| 3216 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3217 | case 68: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3218 | #line 1258 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3219 | { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;} |
| 3220 | break; |
| 3221 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3222 | case 70: |
| 3223 | #line 1259 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3224 | { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;} |
| 3225 | break; |
| 3226 | |
| 3227 | case 71: |
| 3228 | #line 1261 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3229 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3230 | if (!UpRefs.empty()) |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3231 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 3232 | (yyval.TypeVal) = (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3233 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3234 | ;} |
| 3235 | break; |
| 3236 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3237 | case 85: |
| 3238 | #line 1273 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3239 | { |
| 3240 | (yyval.TypeVal) = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3241 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3242 | ;} |
| 3243 | break; |
| 3244 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3245 | case 86: |
| 3246 | #line 1277 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3247 | { |
| 3248 | (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3249 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3250 | ;} |
| 3251 | break; |
| 3252 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3253 | case 87: |
| 3254 | #line 1281 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3255 | { // Named types are also simple types... |
| 3256 | const Type* tmp = getTypeVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3257 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3258 | (yyval.TypeVal) = new PATypeHolder(tmp); |
| 3259 | ;} |
| 3260 | break; |
| 3261 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3262 | case 88: |
| 3263 | #line 1289 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3264 | { // Type UpReference |
| 3265 | 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] | 3266 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3267 | UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector... |
| 3268 | (yyval.TypeVal) = new PATypeHolder(OT); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3269 | UR_OUT("New Upreference!\n"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3270 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3271 | ;} |
| 3272 | break; |
| 3273 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3274 | case 89: |
| 3275 | #line 1297 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3276 | { // Function derived type? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3277 | std::vector<const Type*> Params; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3278 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(), |
| 3279 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3280 | Params.push_back(*I); |
| 3281 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3282 | if (isVarArg) Params.pop_back(); |
| 3283 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3284 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[-3].TypeVal),Params,isVarArg))); |
| 3285 | delete (yyvsp[-1].TypeList); // Delete the argument list |
| 3286 | delete (yyvsp[-3].TypeVal); // Delete the return type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3287 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3288 | ;} |
| 3289 | break; |
| 3290 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3291 | case 90: |
| 3292 | #line 1310 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3293 | { // Sized array type? |
| 3294 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); |
| 3295 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3296 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3297 | ;} |
| 3298 | break; |
| 3299 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3300 | case 91: |
| 3301 | #line 1315 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3302 | { // Packed array type? |
| 3303 | const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get(); |
| 3304 | if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3305 | GEN_ERROR("Unsigned result not equal to signed result"); |
Chris Lattner | 9547d7f | 2005-11-10 01:42:43 +0000 | [diff] [blame] | 3306 | if (!ElemTy->isPrimitiveType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3307 | GEN_ERROR("Elemental type of a PackedType must be primitive"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3308 | if (!isPowerOf2_32((yyvsp[-3].UInt64Val))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3309 | GEN_ERROR("Vector length should be a power of 2!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3310 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); |
| 3311 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3312 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3313 | ;} |
| 3314 | break; |
| 3315 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3316 | case 92: |
| 3317 | #line 1327 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3318 | { // Structure type? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3319 | std::vector<const Type*> Elements; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3320 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(), |
| 3321 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3322 | Elements.push_back(*I); |
| 3323 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3324 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 3325 | delete (yyvsp[-1].TypeList); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3326 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3327 | ;} |
| 3328 | break; |
| 3329 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3330 | case 93: |
| 3331 | #line 1337 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3332 | { // Empty structure type? |
| 3333 | (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3334 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3335 | ;} |
| 3336 | break; |
| 3337 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3338 | case 94: |
| 3339 | #line 1341 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3340 | { // Pointer type? |
| 3341 | if (*(yyvsp[-1].TypeVal) == Type::LabelTy) |
Chris Lattner | 59c85e9 | 2006-10-15 23:27:25 +0000 | [diff] [blame] | 3342 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3343 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal)))); |
| 3344 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3345 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3346 | ;} |
| 3347 | break; |
| 3348 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3349 | case 95: |
| 3350 | #line 1352 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3351 | { |
| 3352 | (yyval.TypeList) = new std::list<PATypeHolder>(); |
| 3353 | (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3354 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3355 | ;} |
| 3356 | break; |
| 3357 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3358 | case 96: |
| 3359 | #line 1357 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3360 | { |
| 3361 | ((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] | 3362 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3363 | ;} |
| 3364 | break; |
| 3365 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3366 | case 98: |
| 3367 | #line 1364 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3368 | { |
| 3369 | ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3370 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3371 | ;} |
| 3372 | break; |
| 3373 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3374 | case 99: |
| 3375 | #line 1368 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3376 | { |
| 3377 | ((yyval.TypeList) = new std::list<PATypeHolder>())->push_back(Type::VoidTy); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3378 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3379 | ;} |
| 3380 | break; |
| 3381 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3382 | case 100: |
| 3383 | #line 1372 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3384 | { |
| 3385 | (yyval.TypeList) = new std::list<PATypeHolder>(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3386 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3387 | ;} |
| 3388 | break; |
| 3389 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3390 | case 101: |
| 3391 | #line 1383 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3392 | { // Nonempty unsized arr |
| 3393 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3394 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3395 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3396 | (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3397 | const Type *ETy = ATy->getElementType(); |
| 3398 | int NumElements = ATy->getNumElements(); |
| 3399 | |
| 3400 | // Verify that we have the correct size... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3401 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3402 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3403 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3404 | itostr(NumElements) + "!"); |
| 3405 | |
| 3406 | // Verify all elements are correct type! |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3407 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 3408 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3409 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3410 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3411 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3412 | } |
| 3413 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3414 | (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector)); |
| 3415 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3416 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3417 | ;} |
| 3418 | break; |
| 3419 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3420 | case 102: |
| 3421 | #line 1409 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3422 | { |
| 3423 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3424 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3425 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3426 | (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3427 | |
| 3428 | int NumElements = ATy->getNumElements(); |
| 3429 | if (NumElements != -1 && NumElements != 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3430 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3431 | " arguments, but has size of " + itostr(NumElements) +"!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3432 | (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3433 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3434 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3435 | ;} |
| 3436 | break; |
| 3437 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3438 | case 103: |
| 3439 | #line 1423 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3440 | { |
| 3441 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3442 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3443 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3444 | (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3445 | |
| 3446 | int NumElements = ATy->getNumElements(); |
| 3447 | const Type *ETy = ATy->getElementType(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3448 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 3449 | if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3450 | GEN_ERROR("Can't build string constant of size " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3451 | itostr((int)(EndStr-(yyvsp[0].StrVal))) + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3452 | " when array has size " + itostr(NumElements) + "!"); |
| 3453 | std::vector<Constant*> Vals; |
| 3454 | if (ETy == Type::SByteTy) { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3455 | 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] | 3456 | Vals.push_back(ConstantInt::get(ETy, *C)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3457 | } else if (ETy == Type::UByteTy) { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3458 | for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3459 | C != (unsigned char*)EndStr; ++C) |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 3460 | Vals.push_back(ConstantInt::get(ETy, *C)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3461 | } else { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3462 | free((yyvsp[0].StrVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3463 | GEN_ERROR("Cannot build string arrays of non byte sized elements!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3464 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3465 | free((yyvsp[0].StrVal)); |
| 3466 | (yyval.ConstVal) = ConstantArray::get(ATy, Vals); |
| 3467 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3468 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3469 | ;} |
| 3470 | break; |
| 3471 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3472 | case 104: |
| 3473 | #line 1453 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3474 | { // Nonempty unsized arr |
| 3475 | const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3476 | if (PTy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3477 | GEN_ERROR("Cannot make packed constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3478 | (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3479 | const Type *ETy = PTy->getElementType(); |
| 3480 | int NumElements = PTy->getNumElements(); |
| 3481 | |
| 3482 | // Verify that we have the correct size... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3483 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3484 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3485 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3486 | itostr(NumElements) + "!"); |
| 3487 | |
| 3488 | // Verify all elements are correct type! |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3489 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 3490 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3491 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3492 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3493 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3494 | } |
| 3495 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3496 | (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector)); |
| 3497 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3498 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3499 | ;} |
| 3500 | break; |
| 3501 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3502 | case 105: |
| 3503 | #line 1479 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3504 | { |
| 3505 | const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get()); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3506 | if (STy == 0) |
| 3507 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3508 | (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3509 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3510 | if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3511 | GEN_ERROR("Illegal number of initializers for structure type!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3512 | |
| 3513 | // Check to ensure that constants are compatible with the type initializer! |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3514 | for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) |
| 3515 | if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3516 | GEN_ERROR("Expected type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3517 | STy->getElementType(i)->getDescription() + |
| 3518 | "' for element #" + utostr(i) + |
| 3519 | " of structure initializer!"); |
| 3520 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3521 | (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector)); |
| 3522 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3523 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3524 | ;} |
| 3525 | break; |
| 3526 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3527 | case 106: |
| 3528 | #line 1500 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3529 | { |
| 3530 | const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3531 | if (STy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3532 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3533 | (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3534 | |
| 3535 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3536 | GEN_ERROR("Illegal number of initializers for structure type!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3537 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3538 | (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3539 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3540 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3541 | ;} |
| 3542 | break; |
| 3543 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3544 | case 107: |
| 3545 | #line 1513 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3546 | { |
| 3547 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3548 | if (PTy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3549 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3550 | (*(yyvsp[-1].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3551 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3552 | (yyval.ConstVal) = ConstantPointerNull::get(PTy); |
| 3553 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3554 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3555 | ;} |
| 3556 | break; |
| 3557 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3558 | case 108: |
| 3559 | #line 1523 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3560 | { |
| 3561 | (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get()); |
| 3562 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3563 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3564 | ;} |
| 3565 | break; |
| 3566 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3567 | case 109: |
| 3568 | #line 1528 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3569 | { |
| 3570 | const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3571 | if (Ty == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3572 | GEN_ERROR("Global const reference must be a pointer type!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3573 | |
| 3574 | // ConstExprs can exist in the body of a function, thus creating |
| 3575 | // GlobalValues whenever they refer to a variable. Because we are in |
| 3576 | // the context of a function, getValNonImprovising will search the functions |
| 3577 | // symbol table instead of the module symbol table for the global symbol, |
| 3578 | // which throws things all off. To get around this, we just tell |
| 3579 | // getValNonImprovising that we are at global scope here. |
| 3580 | // |
| 3581 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3582 | CurFun.CurrentFunction = 0; |
| 3583 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3584 | Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3585 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3586 | |
| 3587 | CurFun.CurrentFunction = SavedCurFn; |
| 3588 | |
| 3589 | // If this is an initializer for a constant pointer, which is referencing a |
| 3590 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3591 | // in the future with the right type of variable. |
| 3592 | // |
| 3593 | if (V == 0) { |
| 3594 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
| 3595 | const PointerType *PT = cast<PointerType>(Ty); |
| 3596 | |
| 3597 | // First check to see if the forward references value is already created! |
| 3598 | PerModuleInfo::GlobalRefsType::iterator I = |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3599 | CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal))); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3600 | |
| 3601 | if (I != CurModule.GlobalRefs.end()) { |
| 3602 | V = I->second; // Placeholder already exists, use it... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3603 | (yyvsp[0].ValIDVal).destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3604 | } else { |
| 3605 | std::string Name; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3606 | if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3607 | |
| 3608 | // Create the forward referenced global. |
| 3609 | GlobalValue *GV; |
| 3610 | if (const FunctionType *FTy = |
| 3611 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 3612 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 3613 | CurModule.CurrentModule); |
| 3614 | } else { |
| 3615 | GV = new GlobalVariable(PT->getElementType(), false, |
| 3616 | GlobalValue::ExternalLinkage, 0, |
| 3617 | Name, CurModule.CurrentModule); |
| 3618 | } |
| 3619 | |
| 3620 | // 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] | 3621 | 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] | 3622 | V = GV; |
| 3623 | } |
| 3624 | } |
| 3625 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3626 | (yyval.ConstVal) = cast<GlobalValue>(V); |
| 3627 | delete (yyvsp[-1].TypeVal); // Free the type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3628 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3629 | ;} |
| 3630 | break; |
| 3631 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3632 | case 110: |
| 3633 | #line 1589 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3634 | { |
| 3635 | if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3636 | GEN_ERROR("Mismatched types for constant expression!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3637 | (yyval.ConstVal) = (yyvsp[0].ConstVal); |
| 3638 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3639 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3640 | ;} |
| 3641 | break; |
| 3642 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3643 | case 111: |
| 3644 | #line 1596 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3645 | { |
| 3646 | const Type *Ty = (yyvsp[-1].TypeVal)->get(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3647 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3648 | GEN_ERROR("Cannot create a null initialized value of this type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3649 | (yyval.ConstVal) = Constant::getNullValue(Ty); |
| 3650 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3651 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3652 | ;} |
| 3653 | break; |
| 3654 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3655 | case 112: |
| 3656 | #line 1605 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3657 | { // integral constants |
| 3658 | if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3659 | GEN_ERROR("Constant value doesn't fit in type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3660 | (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3661 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3662 | ;} |
| 3663 | break; |
| 3664 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3665 | case 113: |
| 3666 | #line 1611 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3667 | { // integral constants |
| 3668 | if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3669 | GEN_ERROR("Constant value doesn't fit in type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3670 | (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3671 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3672 | ;} |
| 3673 | break; |
| 3674 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3675 | case 114: |
| 3676 | #line 1617 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3677 | { // Boolean constants |
| 3678 | (yyval.ConstVal) = ConstantBool::getTrue(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3679 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3680 | ;} |
| 3681 | break; |
| 3682 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3683 | case 115: |
| 3684 | #line 1621 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3685 | { // Boolean constants |
| 3686 | (yyval.ConstVal) = ConstantBool::getFalse(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3687 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3688 | ;} |
| 3689 | break; |
| 3690 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3691 | case 116: |
| 3692 | #line 1625 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3693 | { // Float & Double constants |
| 3694 | if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3695 | GEN_ERROR("Floating point constant invalid for type!!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3696 | (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3697 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3698 | ;} |
| 3699 | break; |
| 3700 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3701 | case 117: |
| 3702 | #line 1633 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3703 | { |
| 3704 | if (!(yyvsp[-3].ConstVal)->getType()->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3705 | GEN_ERROR("cast constant expression from a non-primitive type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3706 | (yyvsp[-3].ConstVal)->getType()->getDescription() + "'!"); |
| 3707 | if (!(yyvsp[-1].TypeVal)->get()->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3708 | GEN_ERROR("cast constant expression to a non-primitive type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3709 | (yyvsp[-1].TypeVal)->get()->getDescription() + "'!"); |
| 3710 | (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get()); |
| 3711 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3712 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3713 | ;} |
| 3714 | break; |
| 3715 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3716 | case 118: |
| 3717 | #line 1644 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3718 | { |
| 3719 | if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3720 | GEN_ERROR("GetElementPtr requires a pointer operand!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3721 | |
| 3722 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct |
| 3723 | // indices to uint struct indices for compatibility. |
| 3724 | generic_gep_type_iterator<std::vector<Value*>::iterator> |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3725 | GTI = gep_type_begin((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()), |
| 3726 | GTE = gep_type_end((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()); |
| 3727 | 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] | 3728 | if (isa<StructType>(*GTI)) // Only change struct indices |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3729 | if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[-1].ValueList))[i])) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3730 | if (CUI->getType() == Type::UByteTy) |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3731 | (*(yyvsp[-1].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3732 | |
| 3733 | const Type *IdxTy = |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3734 | GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3735 | if (!IdxTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3736 | GEN_ERROR("Index list invalid for constant getelementptr!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3737 | |
| 3738 | std::vector<Constant*> IdxVec; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3739 | for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i) |
| 3740 | if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i])) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3741 | IdxVec.push_back(C); |
| 3742 | else |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3743 | GEN_ERROR("Indices to constant getelementptr must be constants!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3744 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3745 | delete (yyvsp[-1].ValueList); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3746 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3747 | (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3748 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3749 | ;} |
| 3750 | break; |
| 3751 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3752 | case 119: |
| 3753 | #line 1676 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3754 | { |
| 3755 | if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3756 | GEN_ERROR("Select condition must be of boolean type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3757 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3758 | GEN_ERROR("Select operand types must match!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3759 | (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] | 3760 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3761 | ;} |
| 3762 | break; |
| 3763 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3764 | case 120: |
| 3765 | #line 1684 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3766 | { |
| 3767 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3768 | GEN_ERROR("Binary operator types must match!"); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3769 | // First, make sure we're dealing with the right opcode by upgrading from |
| 3770 | // obsolete versions. |
| 3771 | sanitizeOpCode((yyvsp[-5].BinaryOpVal),(yyvsp[-3].ConstVal)->getType()); |
| 3772 | CHECK_FOR_ERROR; |
| 3773 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3774 | // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. |
| 3775 | // To retain backward compatibility with these early compilers, we emit a |
| 3776 | // cast to the appropriate integer type automatically if we are in the |
| 3777 | // broken case. See PR424 for more information. |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3778 | if (!isa<PointerType>((yyvsp[-3].ConstVal)->getType())) { |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3779 | (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] | 3780 | } else { |
| 3781 | const Type *IntPtrTy = 0; |
| 3782 | switch (CurModule.CurrentModule->getPointerSize()) { |
| 3783 | case Module::Pointer32: IntPtrTy = Type::IntTy; break; |
| 3784 | case Module::Pointer64: IntPtrTy = Type::LongTy; break; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3785 | default: GEN_ERROR("invalid pointer binary constant expr!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3786 | } |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3787 | (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] | 3788 | ConstantExpr::getCast((yyvsp[-1].ConstVal), IntPtrTy)); |
| 3789 | (yyval.ConstVal) = ConstantExpr::getCast((yyval.ConstVal), (yyvsp[-3].ConstVal)->getType()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3790 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3791 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3792 | ;} |
| 3793 | break; |
| 3794 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3795 | case 121: |
| 3796 | #line 1711 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3797 | { |
| 3798 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3799 | GEN_ERROR("Logical operator types must match!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3800 | if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) { |
| 3801 | if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) || |
| 3802 | !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3803 | GEN_ERROR("Logical operator requires integral operands!"); |
Chris Lattner | 524a131 | 2005-12-21 18:31:50 +0000 | [diff] [blame] | 3804 | } |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3805 | (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] | 3806 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3807 | ;} |
| 3808 | break; |
| 3809 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3810 | case 122: |
| 3811 | #line 1722 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3812 | { |
| 3813 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
| 3814 | GEN_ERROR("setcc operand types must match!"); |
| 3815 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
| 3816 | CHECK_FOR_ERROR |
| 3817 | ;} |
| 3818 | break; |
| 3819 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3820 | case 123: |
| 3821 | #line 1728 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3822 | { |
| 3823 | if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy) |
| 3824 | GEN_ERROR("Shift count for shift constant must be unsigned byte!"); |
| 3825 | if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) |
| 3826 | GEN_ERROR("Shift constant expression requires integer operand!"); |
| 3827 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
| 3828 | CHECK_FOR_ERROR |
| 3829 | ;} |
| 3830 | break; |
| 3831 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3832 | case 124: |
| 3833 | #line 1736 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3834 | { |
| 3835 | if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3836 | GEN_ERROR("Invalid extractelement operands!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3837 | (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3838 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3839 | ;} |
| 3840 | break; |
| 3841 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3842 | case 125: |
| 3843 | #line 1742 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3844 | { |
| 3845 | if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3846 | GEN_ERROR("Invalid insertelement operands!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3847 | (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] | 3848 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3849 | ;} |
| 3850 | break; |
| 3851 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3852 | case 126: |
| 3853 | #line 1748 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3854 | { |
| 3855 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3856 | GEN_ERROR("Invalid shufflevector operands!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3857 | (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] | 3858 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3859 | ;} |
| 3860 | break; |
| 3861 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3862 | case 127: |
| 3863 | #line 1757 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3864 | { |
| 3865 | ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3866 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3867 | ;} |
| 3868 | break; |
| 3869 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3870 | case 128: |
| 3871 | #line 1761 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3872 | { |
| 3873 | (yyval.ConstVector) = new std::vector<Constant*>(); |
| 3874 | (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3875 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3876 | ;} |
| 3877 | break; |
| 3878 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3879 | case 129: |
| 3880 | #line 1769 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3881 | { (yyval.BoolVal) = false; ;} |
| 3882 | break; |
| 3883 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3884 | case 130: |
| 3885 | #line 1769 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3886 | { (yyval.BoolVal) = true; ;} |
| 3887 | break; |
| 3888 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3889 | case 131: |
| 3890 | #line 1779 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3891 | { |
| 3892 | (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3893 | CurModule.ModuleDone(); |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 3894 | CHECK_FOR_ERROR; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3895 | ;} |
| 3896 | break; |
| 3897 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3898 | case 132: |
| 3899 | #line 1787 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3900 | { |
| 3901 | (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3902 | CurFun.FunctionDone(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3903 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3904 | ;} |
| 3905 | break; |
| 3906 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3907 | case 133: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3908 | #line 1792 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3909 | { |
| 3910 | (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); |
| 3911 | CHECK_FOR_ERROR |
| 3912 | ;} |
| 3913 | break; |
| 3914 | |
| 3915 | case 134: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3916 | #line 1796 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3917 | { |
| 3918 | (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); |
| 3919 | CHECK_FOR_ERROR |
| 3920 | ;} |
| 3921 | break; |
| 3922 | |
| 3923 | case 135: |
| 3924 | #line 1800 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3925 | { |
| 3926 | (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); |
| 3927 | CHECK_FOR_ERROR |
| 3928 | ;} |
| 3929 | break; |
| 3930 | |
| 3931 | case 136: |
| 3932 | #line 1804 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3933 | { |
| 3934 | (yyval.ModuleVal) = CurModule.CurrentModule; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3935 | // Emit an error if there are any unresolved types left. |
| 3936 | if (!CurModule.LateResolveTypes.empty()) { |
| 3937 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3938 | if (DID.Type == ValID::NameVal) { |
| 3939 | GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'"); |
| 3940 | } else { |
| 3941 | GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num)); |
| 3942 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3943 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3944 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3945 | ;} |
| 3946 | break; |
| 3947 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3948 | case 137: |
| 3949 | #line 1819 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3950 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3951 | // Eagerly resolve types. This is not an optimization, this is a |
| 3952 | // requirement that is due to the fact that we could have this: |
| 3953 | // |
| 3954 | // %list = type { %list * } |
| 3955 | // %list = type { %list * } ; repeated type decl |
| 3956 | // |
| 3957 | // If types are not resolved eagerly, then the two types will not be |
| 3958 | // determined to be the same type! |
| 3959 | // |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3960 | ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3961 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3962 | if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3963 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3964 | // If this is a named type that is not a redefinition, add it to the slot |
| 3965 | // table. |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3966 | CurModule.Types.push_back(*(yyvsp[0].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3967 | } |
| 3968 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3969 | delete (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3970 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3971 | ;} |
| 3972 | break; |
| 3973 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3974 | case 138: |
| 3975 | #line 1841 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3976 | { // Function prototypes can be in const pool |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3977 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3978 | ;} |
| 3979 | break; |
| 3980 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3981 | case 139: |
| 3982 | #line 1844 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3983 | { // Asm blocks can be in the const pool |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3984 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3985 | ;} |
| 3986 | break; |
| 3987 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3988 | case 140: |
| 3989 | #line 1847 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3990 | { |
| 3991 | if ((yyvsp[0].ConstVal) == 0) |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3992 | GEN_ERROR("Global value initializer is not a constant!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3993 | 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] | 3994 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 3995 | ;} |
| 3996 | break; |
| 3997 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 3998 | case 141: |
| 3999 | #line 1852 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4000 | { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4001 | CurGV = 0; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4002 | ;} |
| 4003 | break; |
| 4004 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4005 | case 142: |
| 4006 | #line 1855 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4007 | { |
| 4008 | 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] | 4009 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4010 | delete (yyvsp[0].TypeVal); |
| 4011 | ;} |
| 4012 | break; |
| 4013 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4014 | case 143: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4015 | #line 1859 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4016 | { |
| 4017 | CurGV = 0; |
| 4018 | CHECK_FOR_ERROR |
| 4019 | ;} |
| 4020 | break; |
| 4021 | |
| 4022 | case 144: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4023 | #line 1863 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4024 | { |
| 4025 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); |
| 4026 | CHECK_FOR_ERROR |
| 4027 | delete (yyvsp[0].TypeVal); |
| 4028 | ;} |
| 4029 | break; |
| 4030 | |
| 4031 | case 145: |
| 4032 | #line 1867 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4033 | { |
| 4034 | CurGV = 0; |
| 4035 | CHECK_FOR_ERROR |
| 4036 | ;} |
| 4037 | break; |
| 4038 | |
| 4039 | case 146: |
| 4040 | #line 1871 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4041 | { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4042 | CurGV = |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4043 | 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] | 4044 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4045 | delete (yyvsp[0].TypeVal); |
| 4046 | ;} |
| 4047 | break; |
| 4048 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4049 | case 147: |
| 4050 | #line 1876 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4051 | { |
Anton Korobeynikov | bcb9770 | 2006-09-17 20:25:45 +0000 | [diff] [blame] | 4052 | CurGV = 0; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4053 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4054 | ;} |
| 4055 | break; |
| 4056 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4057 | case 148: |
| 4058 | #line 1880 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4059 | { |
Anton Korobeynikov | bcb9770 | 2006-09-17 20:25:45 +0000 | [diff] [blame] | 4060 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4061 | ;} |
| 4062 | break; |
| 4063 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4064 | case 149: |
| 4065 | #line 1883 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4066 | { |
Anton Korobeynikov | bcb9770 | 2006-09-17 20:25:45 +0000 | [diff] [blame] | 4067 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4068 | ;} |
| 4069 | break; |
| 4070 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4071 | case 150: |
| 4072 | #line 1886 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4073 | { |
| 4074 | ;} |
| 4075 | break; |
| 4076 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4077 | case 151: |
| 4078 | #line 1890 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4079 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4080 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4081 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4082 | std::string NewAsm((yyvsp[0].StrVal), EndStr); |
| 4083 | free((yyvsp[0].StrVal)); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4084 | |
| 4085 | if (AsmSoFar.empty()) |
| 4086 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 4087 | else |
| 4088 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4089 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4090 | ;} |
| 4091 | break; |
| 4092 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4093 | case 152: |
| 4094 | #line 1903 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4095 | { (yyval.Endianness) = Module::BigEndian; ;} |
| 4096 | break; |
| 4097 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4098 | case 153: |
| 4099 | #line 1904 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4100 | { (yyval.Endianness) = Module::LittleEndian; ;} |
| 4101 | break; |
| 4102 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4103 | case 154: |
| 4104 | #line 1906 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4105 | { |
| 4106 | CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4107 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4108 | ;} |
| 4109 | break; |
| 4110 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4111 | case 155: |
| 4112 | #line 1910 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4113 | { |
| 4114 | if ((yyvsp[0].UInt64Val) == 32) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4115 | CurModule.CurrentModule->setPointerSize(Module::Pointer32); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4116 | else if ((yyvsp[0].UInt64Val) == 64) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4117 | CurModule.CurrentModule->setPointerSize(Module::Pointer64); |
| 4118 | else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4119 | GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4120 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4121 | ;} |
| 4122 | break; |
| 4123 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4124 | case 156: |
| 4125 | #line 1919 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4126 | { |
| 4127 | CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); |
| 4128 | free((yyvsp[0].StrVal)); |
| 4129 | ;} |
| 4130 | break; |
| 4131 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4132 | case 157: |
| 4133 | #line 1923 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4134 | { |
| 4135 | CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); |
| 4136 | free((yyvsp[0].StrVal)); |
| 4137 | ;} |
| 4138 | break; |
| 4139 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4140 | case 159: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4141 | #line 1930 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4142 | { |
| 4143 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 4144 | free((yyvsp[0].StrVal)); |
| 4145 | CHECK_FOR_ERROR |
| 4146 | ;} |
| 4147 | break; |
| 4148 | |
| 4149 | case 160: |
| 4150 | #line 1935 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4151 | { |
| 4152 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 4153 | free((yyvsp[0].StrVal)); |
| 4154 | CHECK_FOR_ERROR |
| 4155 | ;} |
| 4156 | break; |
| 4157 | |
| 4158 | case 161: |
| 4159 | #line 1940 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4160 | { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4161 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4162 | ;} |
| 4163 | break; |
| 4164 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4165 | case 165: |
| 4166 | #line 1950 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4167 | { (yyval.StrVal) = 0; ;} |
| 4168 | break; |
| 4169 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4170 | case 166: |
| 4171 | #line 1952 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4172 | { |
| 4173 | if (*(yyvsp[-1].TypeVal) == Type::VoidTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4174 | GEN_ERROR("void typed arguments are invalid!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4175 | (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] | 4176 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4177 | ;} |
| 4178 | break; |
| 4179 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4180 | case 167: |
| 4181 | #line 1959 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4182 | { |
| 4183 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
| 4184 | (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal)); |
| 4185 | delete (yyvsp[0].ArgVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4186 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4187 | ;} |
| 4188 | break; |
| 4189 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4190 | case 168: |
| 4191 | #line 1965 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4192 | { |
| 4193 | (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >(); |
| 4194 | (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); |
| 4195 | delete (yyvsp[0].ArgVal); |
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 | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4200 | case 169: |
| 4201 | #line 1972 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4202 | { |
| 4203 | (yyval.ArgList) = (yyvsp[0].ArgList); |
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 | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4208 | case 170: |
| 4209 | #line 1976 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4210 | { |
| 4211 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
| 4212 | (yyval.ArgList)->push_back(std::pair<PATypeHolder*, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4213 | char*>(new PATypeHolder(Type::VoidTy), 0)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4214 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4215 | ;} |
| 4216 | break; |
| 4217 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4218 | case 171: |
| 4219 | #line 1982 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4220 | { |
| 4221 | (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >(); |
| 4222 | (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] | 4223 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4224 | ;} |
| 4225 | break; |
| 4226 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4227 | case 172: |
| 4228 | #line 1987 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4229 | { |
| 4230 | (yyval.ArgList) = 0; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4231 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4232 | ;} |
| 4233 | break; |
| 4234 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4235 | case 173: |
| 4236 | #line 1993 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4237 | { |
| 4238 | UnEscapeLexed((yyvsp[-5].StrVal)); |
| 4239 | std::string FunctionName((yyvsp[-5].StrVal)); |
| 4240 | free((yyvsp[-5].StrVal)); // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4241 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4242 | if (!(*(yyvsp[-6].TypeVal))->isFirstClassType() && *(yyvsp[-6].TypeVal) != Type::VoidTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4243 | GEN_ERROR("LLVM functions cannot return aggregate types!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4244 | |
| 4245 | std::vector<const Type*> ParamTypeList; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4246 | if ((yyvsp[-3].ArgList)) { // If there are arguments... |
| 4247 | for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin(); |
| 4248 | I != (yyvsp[-3].ArgList)->end(); ++I) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4249 | ParamTypeList.push_back(I->first->get()); |
| 4250 | } |
| 4251 | |
| 4252 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 4253 | if (isVarArg) ParamTypeList.pop_back(); |
| 4254 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4255 | const FunctionType *FT = FunctionType::get(*(yyvsp[-6].TypeVal), ParamTypeList, isVarArg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4256 | const PointerType *PFT = PointerType::get(FT); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4257 | delete (yyvsp[-6].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4258 | |
| 4259 | ValID ID; |
| 4260 | if (!FunctionName.empty()) { |
| 4261 | ID = ValID::create((char*)FunctionName.c_str()); |
| 4262 | } else { |
| 4263 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
| 4264 | } |
| 4265 | |
| 4266 | Function *Fn = 0; |
| 4267 | // See if this function was forward referenced. If so, recycle the object. |
| 4268 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 4269 | // Move the function to the end of the list, from whereever it was |
| 4270 | // previously inserted. |
| 4271 | Fn = cast<Function>(FWRef); |
| 4272 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 4273 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 4274 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
| 4275 | (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) { |
| 4276 | // If this is the case, either we need to be a forward decl, or it needs |
| 4277 | // to be. |
| 4278 | if (!CurFun.isDeclare && !Fn->isExternal()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4279 | GEN_ERROR("Redefinition of function '" + FunctionName + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4280 | |
| 4281 | // Make sure to strip off any argument names so we can't get conflicts. |
| 4282 | if (Fn->isExternal()) |
| 4283 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 4284 | AI != AE; ++AI) |
| 4285 | AI->setName(""); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4286 | } else { // Not already defined? |
| 4287 | Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, |
| 4288 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4289 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4290 | InsertValue(Fn, CurModule.Values); |
| 4291 | } |
| 4292 | |
| 4293 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4294 | |
| 4295 | if (CurFun.isDeclare) { |
| 4296 | // If we have declaration, always overwrite linkage. This will allow us to |
| 4297 | // correctly handle cases, when pointer to function is passed as argument to |
| 4298 | // another function. |
| 4299 | Fn->setLinkage(CurFun.Linkage); |
| 4300 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4301 | Fn->setCallingConv((yyvsp[-7].UIntVal)); |
| 4302 | Fn->setAlignment((yyvsp[0].UIntVal)); |
| 4303 | if ((yyvsp[-1].StrVal)) { |
| 4304 | Fn->setSection((yyvsp[-1].StrVal)); |
| 4305 | free((yyvsp[-1].StrVal)); |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 4306 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4307 | |
| 4308 | // Add all of the arguments we parsed to the function... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4309 | if ((yyvsp[-3].ArgList)) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4310 | if (isVarArg) { // Nuke the last entry |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4311 | 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] | 4312 | "Not a varargs marker!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4313 | delete (yyvsp[-3].ArgList)->back().first; |
| 4314 | (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4315 | } |
| 4316 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4317 | for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin(); |
| 4318 | I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4319 | delete I->first; // Delete the typeholder... |
| 4320 | |
| 4321 | setValueName(ArgIt, I->second); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4322 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4323 | InsertValue(ArgIt); |
| 4324 | } |
| 4325 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4326 | delete (yyvsp[-3].ArgList); // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4327 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4328 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4329 | ;} |
| 4330 | break; |
| 4331 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4332 | case 176: |
| 4333 | #line 2089 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4334 | { |
| 4335 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4336 | |
| 4337 | // Make sure that we keep track of the linkage type even if there was a |
| 4338 | // previous "declare". |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4339 | (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage)); |
| 4340 | ;} |
| 4341 | break; |
| 4342 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4343 | case 179: |
| 4344 | #line 2099 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4345 | { |
| 4346 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4347 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4348 | ;} |
| 4349 | break; |
| 4350 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4351 | case 181: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4352 | #line 2105 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4353 | { CurFun.Linkage = GlobalValue::DLLImportLinkage ;} |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4354 | break; |
| 4355 | |
| 4356 | case 182: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4357 | #line 2106 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4358 | { CurFun.Linkage = GlobalValue::DLLImportLinkage ;} |
| 4359 | break; |
| 4360 | |
| 4361 | case 183: |
| 4362 | #line 2108 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4363 | { CurFun.isDeclare = true; ;} |
| 4364 | break; |
| 4365 | |
| 4366 | case 184: |
| 4367 | #line 2108 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4368 | { |
| 4369 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4370 | CurFun.FunctionDone(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4371 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4372 | ;} |
| 4373 | break; |
| 4374 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4375 | case 185: |
| 4376 | #line 2118 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4377 | { |
| 4378 | (yyval.BoolVal) = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4379 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4380 | ;} |
| 4381 | break; |
| 4382 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4383 | case 186: |
| 4384 | #line 2122 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4385 | { |
| 4386 | (yyval.BoolVal) = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4387 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4388 | ;} |
| 4389 | break; |
| 4390 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4391 | case 187: |
| 4392 | #line 2127 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4393 | { // A reference to a direct constant |
| 4394 | (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4395 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4396 | ;} |
| 4397 | break; |
| 4398 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4399 | case 188: |
| 4400 | #line 2131 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4401 | { |
| 4402 | (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4403 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4404 | ;} |
| 4405 | break; |
| 4406 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4407 | case 189: |
| 4408 | #line 2135 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4409 | { // Perhaps it's an FP constant? |
| 4410 | (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4411 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4412 | ;} |
| 4413 | break; |
| 4414 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4415 | case 190: |
| 4416 | #line 2139 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4417 | { |
| 4418 | (yyval.ValIDVal) = ValID::create(ConstantBool::getTrue()); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4419 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4420 | ;} |
| 4421 | break; |
| 4422 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4423 | case 191: |
| 4424 | #line 2143 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4425 | { |
| 4426 | (yyval.ValIDVal) = ValID::create(ConstantBool::getFalse()); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4427 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4428 | ;} |
| 4429 | break; |
| 4430 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4431 | case 192: |
| 4432 | #line 2147 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4433 | { |
| 4434 | (yyval.ValIDVal) = ValID::createNull(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4435 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4436 | ;} |
| 4437 | break; |
| 4438 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4439 | case 193: |
| 4440 | #line 2151 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4441 | { |
| 4442 | (yyval.ValIDVal) = ValID::createUndef(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4443 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4444 | ;} |
| 4445 | break; |
| 4446 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4447 | case 194: |
| 4448 | #line 2155 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4449 | { // A vector zero constant. |
| 4450 | (yyval.ValIDVal) = ValID::createZeroInit(); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4451 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4452 | ;} |
| 4453 | break; |
| 4454 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4455 | case 195: |
| 4456 | #line 2159 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4457 | { // Nonempty unsized packed vector |
| 4458 | const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType(); |
| 4459 | int NumElements = (yyvsp[-1].ConstVector)->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4460 | |
| 4461 | PackedType* pt = PackedType::get(ETy, NumElements); |
| 4462 | PATypeHolder* PTy = new PATypeHolder( |
| 4463 | HandleUpRefs( |
| 4464 | PackedType::get( |
| 4465 | ETy, |
| 4466 | NumElements) |
| 4467 | ) |
| 4468 | ); |
| 4469 | |
| 4470 | // Verify all elements are correct type! |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4471 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 4472 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4473 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4474 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4475 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4476 | } |
| 4477 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4478 | (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector))); |
| 4479 | delete PTy; delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4480 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4481 | ;} |
| 4482 | break; |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 4483 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4484 | case 196: |
| 4485 | #line 2184 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4486 | { |
| 4487 | (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal)); |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 4488 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4489 | ;} |
| 4490 | break; |
| 4491 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4492 | case 197: |
| 4493 | #line 2188 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4494 | { |
| 4495 | char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); |
| 4496 | std::string AsmStr = std::string((yyvsp[-2].StrVal), End); |
| 4497 | End = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4498 | std::string Constraints = std::string((yyvsp[0].StrVal), End); |
| 4499 | (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal)); |
| 4500 | free((yyvsp[-2].StrVal)); |
| 4501 | free((yyvsp[0].StrVal)); |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 4502 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4503 | ;} |
| 4504 | break; |
| 4505 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4506 | case 198: |
| 4507 | #line 2202 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4508 | { // Is it an integer reference...? |
| 4509 | (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); |
| 4510 | CHECK_FOR_ERROR |
| 4511 | ;} |
| 4512 | break; |
| 4513 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4514 | case 199: |
| 4515 | #line 2206 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4516 | { // Is it a named reference...? |
| 4517 | (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); |
| 4518 | CHECK_FOR_ERROR |
| 4519 | ;} |
| 4520 | break; |
| 4521 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4522 | case 202: |
| 4523 | #line 2218 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4524 | { |
| 4525 | (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal); |
| 4526 | CHECK_FOR_ERROR |
| 4527 | ;} |
| 4528 | break; |
| 4529 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4530 | case 203: |
| 4531 | #line 2223 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4532 | { |
| 4533 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 4534 | CHECK_FOR_ERROR |
| 4535 | ;} |
| 4536 | break; |
| 4537 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4538 | case 204: |
| 4539 | #line 2227 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4540 | { // Do not allow functions with 0 basic blocks |
| 4541 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 4542 | CHECK_FOR_ERROR |
| 4543 | ;} |
| 4544 | break; |
| 4545 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4546 | case 205: |
| 4547 | #line 2236 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4548 | { |
| 4549 | setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal)); |
| 4550 | CHECK_FOR_ERROR |
| 4551 | InsertValue((yyvsp[0].TermInstVal)); |
| 4552 | |
| 4553 | (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal)); |
| 4554 | InsertValue((yyvsp[-2].BasicBlockVal)); |
| 4555 | (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal); |
| 4556 | CHECK_FOR_ERROR |
| 4557 | ;} |
| 4558 | break; |
| 4559 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4560 | case 206: |
| 4561 | #line 2247 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4562 | { |
| 4563 | (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal)); |
| 4564 | (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); |
| 4565 | CHECK_FOR_ERROR |
| 4566 | ;} |
| 4567 | break; |
| 4568 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4569 | case 207: |
| 4570 | #line 2252 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4571 | { |
| 4572 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4573 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4574 | |
| 4575 | // Make sure to move the basic block to the correct location in the |
| 4576 | // function, instead of leaving it inserted wherever it was first |
| 4577 | // referenced. |
| 4578 | Function::BasicBlockListType &BBL = |
| 4579 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4580 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4581 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4582 | ;} |
| 4583 | break; |
| 4584 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4585 | case 208: |
| 4586 | #line 2264 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4587 | { |
| 4588 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4589 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4590 | |
| 4591 | // Make sure to move the basic block to the correct location in the |
| 4592 | // function, instead of leaving it inserted wherever it was first |
| 4593 | // referenced. |
| 4594 | Function::BasicBlockListType &BBL = |
| 4595 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4596 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4597 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4598 | ;} |
| 4599 | break; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4600 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4601 | case 209: |
| 4602 | #line 2277 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4603 | { // Return with a result... |
| 4604 | (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal)); |
| 4605 | CHECK_FOR_ERROR |
| 4606 | ;} |
| 4607 | break; |
| 4608 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4609 | case 210: |
| 4610 | #line 2281 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4611 | { // Return with no result... |
| 4612 | (yyval.TermInstVal) = new ReturnInst(); |
| 4613 | CHECK_FOR_ERROR |
| 4614 | ;} |
| 4615 | break; |
| 4616 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4617 | case 211: |
| 4618 | #line 2285 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4619 | { // Unconditional Branch... |
| 4620 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
| 4621 | CHECK_FOR_ERROR |
| 4622 | (yyval.TermInstVal) = new BranchInst(tmpBB); |
| 4623 | ;} |
| 4624 | break; |
| 4625 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4626 | case 212: |
| 4627 | #line 2290 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4628 | { |
| 4629 | BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); |
| 4630 | CHECK_FOR_ERROR |
| 4631 | BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal)); |
| 4632 | CHECK_FOR_ERROR |
| 4633 | Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal)); |
| 4634 | CHECK_FOR_ERROR |
| 4635 | (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4636 | ;} |
| 4637 | break; |
| 4638 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4639 | case 213: |
| 4640 | #line 2299 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4641 | { |
| 4642 | Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal)); |
| 4643 | CHECK_FOR_ERROR |
| 4644 | BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal)); |
| 4645 | CHECK_FOR_ERROR |
| 4646 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size()); |
| 4647 | (yyval.TermInstVal) = S; |
| 4648 | |
| 4649 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(), |
| 4650 | E = (yyvsp[-1].JumpTable)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4651 | for (; I != E; ++I) { |
| 4652 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4653 | S->addCase(CI, I->second); |
| 4654 | else |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4655 | GEN_ERROR("Switch case is constant, but not a simple integer!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4656 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4657 | delete (yyvsp[-1].JumpTable); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4658 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4659 | ;} |
| 4660 | break; |
| 4661 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4662 | case 214: |
| 4663 | #line 2318 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4664 | { |
| 4665 | Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4666 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4667 | BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4668 | CHECK_FOR_ERROR |
| 4669 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4670 | (yyval.TermInstVal) = S; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4671 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4672 | ;} |
| 4673 | break; |
| 4674 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4675 | case 215: |
| 4676 | #line 2328 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4677 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4678 | const PointerType *PFTy; |
| 4679 | const FunctionType *Ty; |
| 4680 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4681 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal)->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4682 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4683 | // Pull out the types of all of the arguments... |
| 4684 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4685 | if ((yyvsp[-7].ValueList)) { |
| 4686 | 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] | 4687 | I != E; ++I) |
| 4688 | ParamTypes.push_back((*I)->getType()); |
| 4689 | } |
| 4690 | |
| 4691 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 4692 | if (isVarArg) ParamTypes.pop_back(); |
| 4693 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4694 | Ty = FunctionType::get((yyvsp[-10].TypeVal)->get(), ParamTypes, isVarArg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4695 | PFTy = PointerType::get(Ty); |
| 4696 | } |
| 4697 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4698 | 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] | 4699 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4700 | BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4701 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4702 | BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4703 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4704 | |
| 4705 | // Create the call node... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4706 | if (!(yyvsp[-7].ValueList)) { // Has no arguments? |
| 4707 | (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4708 | } else { // Has arguments? |
| 4709 | // Loop through FunctionType's arguments and ensure they are specified |
| 4710 | // correctly! |
| 4711 | // |
| 4712 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4713 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4714 | 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] | 4715 | |
| 4716 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 4717 | if ((*ArgI)->getType() != *I) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4718 | GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4719 | (*I)->getDescription() + "'!"); |
| 4720 | |
| 4721 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4722 | GEN_ERROR("Invalid number of parameters detected!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4723 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4724 | (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4725 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4726 | cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4727 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4728 | delete (yyvsp[-10].TypeVal); |
| 4729 | delete (yyvsp[-7].ValueList); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4730 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4731 | ;} |
| 4732 | break; |
| 4733 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4734 | case 216: |
| 4735 | #line 2383 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4736 | { |
| 4737 | (yyval.TermInstVal) = new UnwindInst(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4738 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4739 | ;} |
| 4740 | break; |
| 4741 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4742 | case 217: |
| 4743 | #line 2387 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4744 | { |
| 4745 | (yyval.TermInstVal) = new UnreachableInst(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4746 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4747 | ;} |
| 4748 | break; |
| 4749 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4750 | case 218: |
| 4751 | #line 2394 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4752 | { |
| 4753 | (yyval.JumpTable) = (yyvsp[-5].JumpTable); |
| 4754 | Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4755 | CHECK_FOR_ERROR |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4756 | if (V == 0) |
| 4757 | GEN_ERROR("May only switch on a constant pool value!"); |
| 4758 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4759 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4760 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4761 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 4762 | ;} |
| 4763 | break; |
| 4764 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4765 | case 219: |
| 4766 | #line 2405 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4767 | { |
| 4768 | (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 4769 | Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4770 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4771 | |
| 4772 | if (V == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4773 | GEN_ERROR("May only switch on a constant pool value!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4774 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4775 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4776 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4777 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 4778 | ;} |
| 4779 | break; |
| 4780 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4781 | case 220: |
| 4782 | #line 2418 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4783 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4784 | // Is this definition named?? if so, assign the name... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4785 | setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal)); |
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 | InsertValue((yyvsp[0].InstVal)); |
| 4788 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4789 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4790 | ;} |
| 4791 | break; |
| 4792 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4793 | case 221: |
| 4794 | #line 2427 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4795 | { // Used for PHI nodes |
| 4796 | (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 4797 | Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4798 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4799 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4800 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4801 | (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4802 | delete (yyvsp[-5].TypeVal); |
| 4803 | ;} |
| 4804 | break; |
| 4805 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4806 | case 222: |
| 4807 | #line 2436 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4808 | { |
| 4809 | (yyval.PHIList) = (yyvsp[-6].PHIList); |
| 4810 | Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4811 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4812 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4813 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4814 | (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4815 | ;} |
| 4816 | break; |
| 4817 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4818 | case 223: |
| 4819 | #line 2446 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4820 | { // Used for call statements, and memory insts... |
| 4821 | (yyval.ValueList) = new std::vector<Value*>(); |
| 4822 | (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); |
| 4823 | ;} |
| 4824 | break; |
| 4825 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4826 | case 224: |
| 4827 | #line 2450 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4828 | { |
| 4829 | (yyval.ValueList) = (yyvsp[-2].ValueList); |
| 4830 | (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4831 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4832 | ;} |
| 4833 | break; |
| 4834 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4835 | case 226: |
| 4836 | #line 2457 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4837 | { (yyval.ValueList) = 0; ;} |
| 4838 | break; |
| 4839 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4840 | case 227: |
| 4841 | #line 2459 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4842 | { |
| 4843 | (yyval.BoolVal) = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4844 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4845 | ;} |
| 4846 | break; |
| 4847 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4848 | case 228: |
| 4849 | #line 2463 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4850 | { |
| 4851 | (yyval.BoolVal) = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4852 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4853 | ;} |
| 4854 | break; |
| 4855 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4856 | case 229: |
| 4857 | #line 2468 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4858 | { |
| 4859 | if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() && |
| 4860 | !isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4861 | GEN_ERROR( |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4862 | "Arithmetic operator requires integer, FP, or packed operands!"); |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4863 | if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) && |
| 4864 | ((yyvsp[-4].BinaryOpVal).opcode == Instruction::URem || |
| 4865 | (yyvsp[-4].BinaryOpVal).opcode == Instruction::SRem || |
| 4866 | (yyvsp[-4].BinaryOpVal).opcode == Instruction::FRem)) |
| 4867 | GEN_ERROR("U/S/FRem not supported on packed types!"); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4868 | // Upgrade the opcode from obsolete versions before we do anything with it. |
| 4869 | sanitizeOpCode((yyvsp[-4].BinaryOpVal),*(yyvsp[-3].TypeVal)); |
| 4870 | CHECK_FOR_ERROR; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4871 | Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4872 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4873 | Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4874 | CHECK_FOR_ERROR |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4875 | (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, val1, val2); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4876 | if ((yyval.InstVal) == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4877 | GEN_ERROR("binary operator returned null!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4878 | delete (yyvsp[-3].TypeVal); |
| 4879 | ;} |
| 4880 | break; |
| 4881 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4882 | case 230: |
| 4883 | #line 2490 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4884 | { |
| 4885 | if (!(*(yyvsp[-3].TypeVal))->isIntegral()) { |
| 4886 | if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) || |
| 4887 | !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4888 | GEN_ERROR("Logical operator requires integral operands!"); |
Chris Lattner | 524a131 | 2005-12-21 18:31:50 +0000 | [diff] [blame] | 4889 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4890 | Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4891 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4892 | Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4893 | CHECK_FOR_ERROR |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4894 | (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4895 | if ((yyval.InstVal) == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4896 | GEN_ERROR("binary operator returned null!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4897 | delete (yyvsp[-3].TypeVal); |
| 4898 | ;} |
| 4899 | break; |
| 4900 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4901 | case 231: |
| 4902 | #line 2505 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4903 | { |
| 4904 | if(isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4905 | GEN_ERROR( |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4906 | "PackedTypes currently not supported in setcc instructions!"); |
| 4907 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4908 | Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4909 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4910 | Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4911 | CHECK_FOR_ERROR |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4912 | (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4913 | if ((yyval.InstVal) == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4914 | GEN_ERROR("binary operator returned null!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4915 | delete (yyvsp[-3].TypeVal); |
| 4916 | ;} |
| 4917 | break; |
| 4918 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4919 | case 232: |
| 4920 | #line 2519 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4921 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4922 | std::cerr << "WARNING: Use of eliminated 'not' instruction:" |
| 4923 | << " Replacing with 'xor'.\n"; |
| 4924 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4925 | Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4926 | if (Ones == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4927 | GEN_ERROR("Expected integral type for not instruction!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4928 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4929 | (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones); |
| 4930 | if ((yyval.InstVal) == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4931 | GEN_ERROR("Could not create a xor instruction!"); |
| 4932 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4933 | ;} |
| 4934 | break; |
| 4935 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4936 | case 233: |
| 4937 | #line 2532 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4938 | { |
| 4939 | if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4940 | GEN_ERROR("Shift amount must be ubyte!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4941 | if (!(yyvsp[-2].ValueVal)->getType()->isInteger()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4942 | GEN_ERROR("Shift constant expression requires integer operand!"); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4943 | (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] | 4944 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4945 | ;} |
| 4946 | break; |
| 4947 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4948 | case 234: |
| 4949 | #line 2540 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4950 | { |
| 4951 | if (!(yyvsp[0].TypeVal)->get()->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4952 | GEN_ERROR("cast instruction to a non-primitive type: '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4953 | (yyvsp[0].TypeVal)->get()->getDescription() + "'!"); |
| 4954 | (yyval.InstVal) = new CastInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal)); |
| 4955 | delete (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4956 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4957 | ;} |
| 4958 | break; |
| 4959 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4960 | case 235: |
| 4961 | #line 2548 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4962 | { |
| 4963 | if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4964 | GEN_ERROR("select condition must be boolean!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4965 | if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4966 | GEN_ERROR("select value types should match!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4967 | (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] | 4968 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4969 | ;} |
| 4970 | break; |
| 4971 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4972 | case 236: |
| 4973 | #line 2556 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4974 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4975 | NewVarArgs = true; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4976 | (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal)); |
| 4977 | delete (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4978 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4979 | ;} |
| 4980 | break; |
| 4981 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 4982 | case 237: |
| 4983 | #line 2562 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4984 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4985 | ObsoleteVarArgs = true; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4986 | const Type* ArgTy = (yyvsp[-2].ValueVal)->getType(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4987 | Function* NF = CurModule.CurrentModule-> |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 4988 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4989 | |
| 4990 | //b = vaarg a, t -> |
| 4991 | //foo = alloca 1 of t |
| 4992 | //bar = vacopy a |
| 4993 | //store bar -> foo |
| 4994 | //b = vaarg foo, t |
| 4995 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); |
| 4996 | CurBB->getInstList().push_back(foo); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4997 | CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4998 | CurBB->getInstList().push_back(bar); |
| 4999 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5000 | (yyval.InstVal) = new VAArgInst(foo, *(yyvsp[0].TypeVal)); |
| 5001 | delete (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5002 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5003 | ;} |
| 5004 | break; |
| 5005 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5006 | case 238: |
| 5007 | #line 2582 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5008 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5009 | ObsoleteVarArgs = true; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5010 | const Type* ArgTy = (yyvsp[-2].ValueVal)->getType(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5011 | Function* NF = CurModule.CurrentModule-> |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 5012 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5013 | |
| 5014 | //b = vanext a, t -> |
| 5015 | //foo = alloca 1 of t |
| 5016 | //bar = vacopy a |
| 5017 | //store bar -> foo |
| 5018 | //tmp = vaarg foo, t |
| 5019 | //b = load foo |
| 5020 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); |
| 5021 | CurBB->getInstList().push_back(foo); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5022 | CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5023 | CurBB->getInstList().push_back(bar); |
| 5024 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5025 | Instruction* tmp = new VAArgInst(foo, *(yyvsp[0].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5026 | CurBB->getInstList().push_back(tmp); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5027 | (yyval.InstVal) = new LoadInst(foo); |
| 5028 | delete (yyvsp[0].TypeVal); |
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 | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5033 | case 239: |
| 5034 | #line 2605 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5035 | { |
| 5036 | if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5037 | GEN_ERROR("Invalid extractelement operands!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5038 | (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5039 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5040 | ;} |
| 5041 | break; |
| 5042 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5043 | case 240: |
| 5044 | #line 2611 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5045 | { |
| 5046 | if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5047 | GEN_ERROR("Invalid insertelement operands!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5048 | (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] | 5049 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5050 | ;} |
| 5051 | break; |
| 5052 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5053 | case 241: |
| 5054 | #line 2617 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5055 | { |
| 5056 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5057 | GEN_ERROR("Invalid shufflevector operands!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5058 | (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] | 5059 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5060 | ;} |
| 5061 | break; |
| 5062 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5063 | case 242: |
| 5064 | #line 2623 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5065 | { |
| 5066 | const Type *Ty = (yyvsp[0].PHIList)->front().first->getType(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5067 | if (!Ty->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5068 | GEN_ERROR("PHI node operands must be of first class type!"); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5069 | (yyval.InstVal) = new PHINode(Ty); |
| 5070 | ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size()); |
| 5071 | while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) { |
| 5072 | if ((yyvsp[0].PHIList)->front().first->getType() != Ty) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5073 | 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] | 5074 | cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second); |
| 5075 | (yyvsp[0].PHIList)->pop_front(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5076 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5077 | delete (yyvsp[0].PHIList); // Free the list... |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5078 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5079 | ;} |
| 5080 | break; |
| 5081 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5082 | case 243: |
| 5083 | #line 2638 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5084 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5085 | const PointerType *PFTy; |
| 5086 | const FunctionType *Ty; |
| 5087 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5088 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal)->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5089 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5090 | // Pull out the types of all of the arguments... |
| 5091 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5092 | if ((yyvsp[-1].ValueList)) { |
| 5093 | 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] | 5094 | I != E; ++I) |
| 5095 | ParamTypes.push_back((*I)->getType()); |
| 5096 | } |
| 5097 | |
| 5098 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 5099 | if (isVarArg) ParamTypes.pop_back(); |
| 5100 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5101 | if (!(*(yyvsp[-4].TypeVal))->isFirstClassType() && *(yyvsp[-4].TypeVal) != Type::VoidTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5102 | GEN_ERROR("LLVM functions cannot return aggregate types!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5103 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5104 | Ty = FunctionType::get((yyvsp[-4].TypeVal)->get(), ParamTypes, isVarArg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5105 | PFTy = PointerType::get(Ty); |
| 5106 | } |
| 5107 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5108 | 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] | 5109 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5110 | |
| 5111 | // Create the call node... |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5112 | if (!(yyvsp[-1].ValueList)) { // Has no arguments? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5113 | // Make sure no arguments is a good thing! |
| 5114 | if (Ty->getNumParams() != 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5115 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5116 | "expects arguments!"); |
| 5117 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5118 | (yyval.InstVal) = new CallInst(V, std::vector<Value*>()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5119 | } else { // Has arguments? |
| 5120 | // Loop through FunctionType's arguments and ensure they are specified |
| 5121 | // correctly! |
| 5122 | // |
| 5123 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5124 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5125 | 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] | 5126 | |
| 5127 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 5128 | if ((*ArgI)->getType() != *I) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5129 | GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5130 | (*I)->getDescription() + "'!"); |
| 5131 | |
| 5132 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5133 | GEN_ERROR("Invalid number of parameters detected!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5134 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5135 | (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5136 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5137 | cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal)); |
| 5138 | cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal)); |
| 5139 | delete (yyvsp[-4].TypeVal); |
| 5140 | delete (yyvsp[-1].ValueList); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5141 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5142 | ;} |
| 5143 | break; |
| 5144 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5145 | case 244: |
| 5146 | #line 2697 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5147 | { |
| 5148 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5149 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5150 | ;} |
| 5151 | break; |
| 5152 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5153 | case 245: |
| 5154 | #line 2704 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5155 | { |
| 5156 | (yyval.ValueList) = (yyvsp[0].ValueList); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5157 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5158 | ;} |
| 5159 | break; |
| 5160 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5161 | case 246: |
| 5162 | #line 2707 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5163 | { |
| 5164 | (yyval.ValueList) = new std::vector<Value*>(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5165 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5166 | ;} |
| 5167 | break; |
| 5168 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5169 | case 247: |
| 5170 | #line 2712 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5171 | { |
| 5172 | (yyval.BoolVal) = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5173 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5174 | ;} |
| 5175 | break; |
| 5176 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5177 | case 248: |
| 5178 | #line 2716 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5179 | { |
| 5180 | (yyval.BoolVal) = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5181 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5182 | ;} |
| 5183 | break; |
| 5184 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5185 | case 249: |
| 5186 | #line 2723 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5187 | { |
| 5188 | (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); |
| 5189 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5190 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5191 | ;} |
| 5192 | break; |
| 5193 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5194 | case 250: |
| 5195 | #line 2728 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5196 | { |
| 5197 | Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5198 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5199 | (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); |
| 5200 | delete (yyvsp[-4].TypeVal); |
| 5201 | ;} |
| 5202 | break; |
| 5203 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5204 | case 251: |
| 5205 | #line 2734 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5206 | { |
| 5207 | (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); |
| 5208 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5209 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5210 | ;} |
| 5211 | break; |
| 5212 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5213 | case 252: |
| 5214 | #line 2739 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5215 | { |
| 5216 | Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5217 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5218 | (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); |
| 5219 | delete (yyvsp[-4].TypeVal); |
| 5220 | ;} |
| 5221 | break; |
| 5222 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5223 | case 253: |
| 5224 | #line 2745 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5225 | { |
| 5226 | if (!isa<PointerType>((yyvsp[0].ValueVal)->getType())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5227 | GEN_ERROR("Trying to free nonpointer type " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5228 | (yyvsp[0].ValueVal)->getType()->getDescription() + "!"); |
| 5229 | (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5230 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5231 | ;} |
| 5232 | break; |
| 5233 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5234 | case 254: |
| 5235 | #line 2753 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5236 | { |
| 5237 | if (!isa<PointerType>((yyvsp[-1].TypeVal)->get())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5238 | GEN_ERROR("Can't load from nonpointer type: " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5239 | (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5240 | if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5241 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5242 | (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5243 | Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5244 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5245 | (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal)); |
| 5246 | delete (yyvsp[-1].TypeVal); |
| 5247 | ;} |
| 5248 | break; |
| 5249 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5250 | case 255: |
| 5251 | #line 2765 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5252 | { |
| 5253 | const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5254 | if (!PT) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5255 | GEN_ERROR("Can't store to a nonpointer type: " + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5256 | (*(yyvsp[-1].TypeVal))->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5257 | const Type *ElTy = PT->getElementType(); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5258 | if (ElTy != (yyvsp[-3].ValueVal)->getType()) |
| 5259 | GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5260 | "' into space of type '" + ElTy->getDescription() + "'!"); |
| 5261 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5262 | Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5263 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5264 | (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal)); |
| 5265 | delete (yyvsp[-1].TypeVal); |
| 5266 | ;} |
| 5267 | break; |
| 5268 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5269 | case 256: |
| 5270 | #line 2780 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5271 | { |
| 5272 | if (!isa<PointerType>((yyvsp[-2].TypeVal)->get())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5273 | GEN_ERROR("getelementptr insn requires pointer operand!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5274 | |
| 5275 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct |
| 5276 | // indices to uint struct indices for compatibility. |
| 5277 | generic_gep_type_iterator<std::vector<Value*>::iterator> |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5278 | GTI = gep_type_begin((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()), |
| 5279 | GTE = gep_type_end((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()); |
| 5280 | 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] | 5281 | if (isa<StructType>(*GTI)) // Only change struct indices |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5282 | if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[0].ValueList))[i])) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5283 | if (CUI->getType() == Type::UByteTy) |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5284 | (*(yyvsp[0].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5285 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5286 | if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5287 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5288 | (*(yyvsp[-2].TypeVal))->getDescription()+ "'!"); |
| 5289 | Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5290 | CHECK_FOR_ERROR |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5291 | (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList)); |
| 5292 | delete (yyvsp[-2].TypeVal); |
| 5293 | delete (yyvsp[0].ValueList); |
| 5294 | ;} |
| 5295 | break; |
| 5296 | |
| 5297 | |
| 5298 | default: break; |
| 5299 | } |
| 5300 | |
| 5301 | /* Line 1126 of yacc.c. */ |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5302 | #line 5303 "llvmAsmParser.tab.c" |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5303 | |
| 5304 | yyvsp -= yylen; |
| 5305 | yyssp -= yylen; |
| 5306 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5307 | |
| 5308 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5309 | |
| 5310 | *++yyvsp = yyval; |
| 5311 | |
| 5312 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5313 | /* Now `shift' the result of the reduction. Determine what state |
| 5314 | that goes to, based on the state we popped back to and the rule |
| 5315 | number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5316 | |
| 5317 | yyn = yyr1[yyn]; |
| 5318 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5319 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 5320 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5321 | yystate = yytable[yystate]; |
| 5322 | else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5323 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5324 | |
| 5325 | goto yynewstate; |
| 5326 | |
| 5327 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5328 | /*------------------------------------. |
| 5329 | | yyerrlab -- here on detecting error | |
| 5330 | `------------------------------------*/ |
| 5331 | yyerrlab: |
| 5332 | /* If not already recovering from an error, report this error. */ |
| 5333 | if (!yyerrstatus) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5334 | { |
| 5335 | ++yynerrs; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5336 | #if YYERROR_VERBOSE |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5337 | yyn = yypact[yystate]; |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 5338 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5339 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5340 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5341 | int yytype = YYTRANSLATE (yychar); |
| 5342 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); |
| 5343 | YYSIZE_T yysize = yysize0; |
| 5344 | YYSIZE_T yysize1; |
| 5345 | int yysize_overflow = 0; |
| 5346 | char *yymsg = 0; |
| 5347 | # define YYERROR_VERBOSE_ARGS_MAXIMUM 5 |
| 5348 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 5349 | int yyx; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5350 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5351 | #if 0 |
| 5352 | /* This is so xgettext sees the translatable formats that are |
| 5353 | constructed on the fly. */ |
| 5354 | YY_("syntax error, unexpected %s"); |
| 5355 | YY_("syntax error, unexpected %s, expecting %s"); |
| 5356 | YY_("syntax error, unexpected %s, expecting %s or %s"); |
| 5357 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); |
| 5358 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); |
| 5359 | #endif |
| 5360 | char *yyfmt; |
| 5361 | char const *yyf; |
| 5362 | static char const yyunexpected[] = "syntax error, unexpected %s"; |
| 5363 | static char const yyexpecting[] = ", expecting %s"; |
| 5364 | static char const yyor[] = " or %s"; |
| 5365 | char yyformat[sizeof yyunexpected |
| 5366 | + sizeof yyexpecting - 1 |
| 5367 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) |
| 5368 | * (sizeof yyor - 1))]; |
| 5369 | char const *yyprefix = yyexpecting; |
| 5370 | |
| 5371 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 5372 | YYCHECK. */ |
| 5373 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 5374 | |
| 5375 | /* Stay within bounds of both yycheck and yytname. */ |
| 5376 | int yychecklim = YYLAST - yyn; |
| 5377 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 5378 | int yycount = 1; |
| 5379 | |
| 5380 | yyarg[0] = yytname[yytype]; |
| 5381 | yyfmt = yystpcpy (yyformat, yyunexpected); |
| 5382 | |
| 5383 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 5384 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 5385 | { |
| 5386 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 5387 | { |
| 5388 | yycount = 1; |
| 5389 | yysize = yysize0; |
| 5390 | yyformat[sizeof yyunexpected - 1] = '\0'; |
| 5391 | break; |
| 5392 | } |
| 5393 | yyarg[yycount++] = yytname[yyx]; |
| 5394 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); |
| 5395 | yysize_overflow |= yysize1 < yysize; |
| 5396 | yysize = yysize1; |
| 5397 | yyfmt = yystpcpy (yyfmt, yyprefix); |
| 5398 | yyprefix = yyor; |
| 5399 | } |
| 5400 | |
| 5401 | yyf = YY_(yyformat); |
| 5402 | yysize1 = yysize + yystrlen (yyf); |
| 5403 | yysize_overflow |= yysize1 < yysize; |
| 5404 | yysize = yysize1; |
| 5405 | |
| 5406 | if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) |
| 5407 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
| 5408 | if (yymsg) |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5409 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5410 | /* Avoid sprintf, as that infringes on the user's name space. |
| 5411 | Don't have undefined behavior even if the translation |
| 5412 | produced a string with the wrong number of "%s"s. */ |
| 5413 | char *yyp = yymsg; |
| 5414 | int yyi = 0; |
| 5415 | while ((*yyp = *yyf)) |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5416 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5417 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) |
| 5418 | { |
| 5419 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
| 5420 | yyf += 2; |
| 5421 | } |
| 5422 | else |
| 5423 | { |
| 5424 | yyp++; |
| 5425 | yyf++; |
| 5426 | } |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5427 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5428 | yyerror (yymsg); |
| 5429 | YYSTACK_FREE (yymsg); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5430 | } |
| 5431 | else |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5432 | { |
| 5433 | yyerror (YY_("syntax error")); |
| 5434 | goto yyexhaustedlab; |
| 5435 | } |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5436 | } |
| 5437 | else |
| 5438 | #endif /* YYERROR_VERBOSE */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5439 | yyerror (YY_("syntax error")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5440 | } |
| 5441 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5442 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5443 | |
| 5444 | if (yyerrstatus == 3) |
| 5445 | { |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5446 | /* If just tried and failed to reuse look-ahead token after an |
| 5447 | error, discard it. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5448 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5449 | if (yychar <= YYEOF) |
| 5450 | { |
| 5451 | /* Return failure if at end of input. */ |
| 5452 | if (yychar == YYEOF) |
| 5453 | YYABORT; |
| 5454 | } |
| 5455 | else |
| 5456 | { |
| 5457 | yydestruct ("Error: discarding", yytoken, &yylval); |
| 5458 | yychar = YYEMPTY; |
| 5459 | } |
| 5460 | } |
| 5461 | |
| 5462 | /* Else will try to reuse look-ahead token after shifting the error |
| 5463 | token. */ |
| 5464 | goto yyerrlab1; |
| 5465 | |
| 5466 | |
| 5467 | /*---------------------------------------------------. |
| 5468 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 5469 | `---------------------------------------------------*/ |
| 5470 | yyerrorlab: |
| 5471 | |
| 5472 | /* Pacify compilers like GCC when the user code never invokes |
| 5473 | YYERROR and the label yyerrorlab therefore never appears in user |
| 5474 | code. */ |
| 5475 | if (0) |
| 5476 | goto yyerrorlab; |
| 5477 | |
| 5478 | yyvsp -= yylen; |
| 5479 | yyssp -= yylen; |
| 5480 | yystate = *yyssp; |
| 5481 | goto yyerrlab1; |
| 5482 | |
| 5483 | |
| 5484 | /*-------------------------------------------------------------. |
| 5485 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 5486 | `-------------------------------------------------------------*/ |
| 5487 | yyerrlab1: |
| 5488 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 5489 | |
| 5490 | for (;;) |
| 5491 | { |
| 5492 | yyn = yypact[yystate]; |
| 5493 | if (yyn != YYPACT_NINF) |
| 5494 | { |
| 5495 | yyn += YYTERROR; |
| 5496 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 5497 | { |
| 5498 | yyn = yytable[yyn]; |
| 5499 | if (0 < yyn) |
| 5500 | break; |
| 5501 | } |
| 5502 | } |
| 5503 | |
| 5504 | /* Pop the current state because it cannot handle the error token. */ |
| 5505 | if (yyssp == yyss) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5506 | YYABORT; |
| 5507 | |
Chris Lattner | 8335e84 | 2006-01-23 23:05:42 +0000 | [diff] [blame] | 5508 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5509 | yydestruct ("Error: popping", yystos[yystate], yyvsp); |
| 5510 | YYPOPSTACK; |
| 5511 | yystate = *yyssp; |
| 5512 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5513 | } |
| 5514 | |
| 5515 | if (yyn == YYFINAL) |
| 5516 | YYACCEPT; |
| 5517 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5518 | *++yyvsp = yylval; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5519 | |
| 5520 | |
| 5521 | /* Shift the error token. */ |
| 5522 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5523 | |
| 5524 | yystate = yyn; |
| 5525 | goto yynewstate; |
| 5526 | |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 5527 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5528 | /*-------------------------------------. |
| 5529 | | yyacceptlab -- YYACCEPT comes here. | |
| 5530 | `-------------------------------------*/ |
| 5531 | yyacceptlab: |
| 5532 | yyresult = 0; |
| 5533 | goto yyreturn; |
| 5534 | |
| 5535 | /*-----------------------------------. |
| 5536 | | yyabortlab -- YYABORT comes here. | |
| 5537 | `-----------------------------------*/ |
| 5538 | yyabortlab: |
| 5539 | yyresult = 1; |
| 5540 | goto yyreturn; |
| 5541 | |
| 5542 | #ifndef yyoverflow |
| 5543 | /*-------------------------------------------------. |
| 5544 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 5545 | `-------------------------------------------------*/ |
| 5546 | yyexhaustedlab: |
| 5547 | yyerror (YY_("memory exhausted")); |
| 5548 | yyresult = 2; |
| 5549 | /* Fall through. */ |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 5550 | #endif |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5551 | |
| 5552 | yyreturn: |
| 5553 | if (yychar != YYEOF && yychar != YYEMPTY) |
| 5554 | yydestruct ("Cleanup: discarding lookahead", |
| 5555 | yytoken, &yylval); |
| 5556 | while (yyssp != yyss) |
| 5557 | { |
| 5558 | yydestruct ("Cleanup: popping", |
| 5559 | yystos[*yyssp], yyvsp); |
| 5560 | YYPOPSTACK; |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 5561 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5562 | #ifndef yyoverflow |
| 5563 | if (yyss != yyssa) |
| 5564 | YYSTACK_FREE (yyss); |
| 5565 | #endif |
| 5566 | return yyresult; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5567 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5568 | |
| 5569 | |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame^] | 5570 | #line 2806 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5571 | |
| 5572 | |
| 5573 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 5574 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 5575 | // TODO: column number in exception |
| 5576 | if (TheParseError) |
| 5577 | TheParseError->setError(CurFilename, message, LineNo); |
| 5578 | TriggerError = 1; |
| 5579 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5580 | |
| 5581 | int yyerror(const char *ErrorMsg) { |
| 5582 | std::string where |
| 5583 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 5584 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
| 5585 | std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading "; |
| 5586 | if (yychar == YYEMPTY || yychar == 0) |
| 5587 | errMsg += "end-of-file."; |
| 5588 | else |
| 5589 | errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5590 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5591 | return 0; |
| 5592 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 5593 | |