Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +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 | 3822ff5 | 2006-11-08 06:47:33 +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 | 3822ff5 | 2006-11-08 06:47:33 +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 | 3822ff5 | 2006-11-08 06:47:33 +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 | 3822ff5 | 2006-11-08 06:47:33 +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 | 3822ff5 | 2006-11-08 06:47:33 +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 | 3822ff5 | 2006-11-08 06:47:33 +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, |
| 145 | UDIV = 336, |
| 146 | SDIV = 337, |
| 147 | FDIV = 338, |
| 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, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 166 | TRUNC = 357, |
| 167 | ZEXT = 358, |
| 168 | SEXT = 359, |
| 169 | FPTRUNC = 360, |
| 170 | FPEXT = 361, |
| 171 | BITCAST = 362, |
| 172 | UITOFP = 363, |
| 173 | SITOFP = 364, |
| 174 | FPTOUI = 365, |
| 175 | FPTOSI = 366, |
| 176 | INTTOPTR = 367, |
| 177 | PTRTOINT = 368, |
| 178 | PHI_TOK = 369, |
| 179 | SELECT = 370, |
| 180 | SHL = 371, |
| 181 | LSHR = 372, |
| 182 | ASHR = 373, |
| 183 | VAARG = 374, |
| 184 | EXTRACTELEMENT = 375, |
| 185 | INSERTELEMENT = 376, |
| 186 | SHUFFLEVECTOR = 377, |
| 187 | VAARG_old = 378, |
| 188 | VANEXT_old = 379 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 189 | }; |
| 190 | #endif |
| 191 | /* Tokens. */ |
| 192 | #define ESINT64VAL 258 |
| 193 | #define EUINT64VAL 259 |
| 194 | #define SINTVAL 260 |
| 195 | #define UINTVAL 261 |
| 196 | #define FPVAL 262 |
| 197 | #define VOID 263 |
| 198 | #define BOOL 264 |
| 199 | #define SBYTE 265 |
| 200 | #define UBYTE 266 |
| 201 | #define SHORT 267 |
| 202 | #define USHORT 268 |
| 203 | #define INT 269 |
| 204 | #define UINT 270 |
| 205 | #define LONG 271 |
| 206 | #define ULONG 272 |
| 207 | #define FLOAT 273 |
| 208 | #define DOUBLE 274 |
| 209 | #define TYPE 275 |
| 210 | #define LABEL 276 |
| 211 | #define VAR_ID 277 |
| 212 | #define LABELSTR 278 |
| 213 | #define STRINGCONSTANT 279 |
| 214 | #define IMPLEMENTATION 280 |
| 215 | #define ZEROINITIALIZER 281 |
| 216 | #define TRUETOK 282 |
| 217 | #define FALSETOK 283 |
| 218 | #define BEGINTOK 284 |
| 219 | #define ENDTOK 285 |
| 220 | #define DECLARE 286 |
| 221 | #define GLOBAL 287 |
| 222 | #define CONSTANT 288 |
| 223 | #define SECTION 289 |
| 224 | #define VOLATILE 290 |
| 225 | #define TO 291 |
| 226 | #define DOTDOTDOT 292 |
| 227 | #define NULL_TOK 293 |
| 228 | #define UNDEF 294 |
| 229 | #define CONST 295 |
| 230 | #define INTERNAL 296 |
| 231 | #define LINKONCE 297 |
| 232 | #define WEAK 298 |
| 233 | #define APPENDING 299 |
| 234 | #define DLLIMPORT 300 |
| 235 | #define DLLEXPORT 301 |
| 236 | #define EXTERN_WEAK 302 |
| 237 | #define OPAQUE 303 |
| 238 | #define NOT 304 |
| 239 | #define EXTERNAL 305 |
| 240 | #define TARGET 306 |
| 241 | #define TRIPLE 307 |
| 242 | #define ENDIAN 308 |
| 243 | #define POINTERSIZE 309 |
| 244 | #define LITTLE 310 |
| 245 | #define BIG 311 |
| 246 | #define ALIGN 312 |
| 247 | #define DEPLIBS 313 |
| 248 | #define CALL 314 |
| 249 | #define TAIL 315 |
| 250 | #define ASM_TOK 316 |
| 251 | #define MODULE 317 |
| 252 | #define SIDEEFFECT 318 |
| 253 | #define CC_TOK 319 |
| 254 | #define CCC_TOK 320 |
| 255 | #define CSRETCC_TOK 321 |
| 256 | #define FASTCC_TOK 322 |
| 257 | #define COLDCC_TOK 323 |
| 258 | #define X86_STDCALLCC_TOK 324 |
| 259 | #define X86_FASTCALLCC_TOK 325 |
| 260 | #define DATALAYOUT 326 |
| 261 | #define RET 327 |
| 262 | #define BR 328 |
| 263 | #define SWITCH 329 |
| 264 | #define INVOKE 330 |
| 265 | #define UNWIND 331 |
| 266 | #define UNREACHABLE 332 |
| 267 | #define ADD 333 |
| 268 | #define SUB 334 |
| 269 | #define MUL 335 |
| 270 | #define UDIV 336 |
| 271 | #define SDIV 337 |
| 272 | #define FDIV 338 |
| 273 | #define UREM 339 |
| 274 | #define SREM 340 |
| 275 | #define FREM 341 |
| 276 | #define AND 342 |
| 277 | #define OR 343 |
| 278 | #define XOR 344 |
| 279 | #define SETLE 345 |
| 280 | #define SETGE 346 |
| 281 | #define SETLT 347 |
| 282 | #define SETGT 348 |
| 283 | #define SETEQ 349 |
| 284 | #define SETNE 350 |
| 285 | #define MALLOC 351 |
| 286 | #define ALLOCA 352 |
| 287 | #define FREE 353 |
| 288 | #define LOAD 354 |
| 289 | #define STORE 355 |
| 290 | #define GETELEMENTPTR 356 |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 291 | #define TRUNC 357 |
| 292 | #define ZEXT 358 |
| 293 | #define SEXT 359 |
| 294 | #define FPTRUNC 360 |
| 295 | #define FPEXT 361 |
| 296 | #define BITCAST 362 |
| 297 | #define UITOFP 363 |
| 298 | #define SITOFP 364 |
| 299 | #define FPTOUI 365 |
| 300 | #define FPTOSI 366 |
| 301 | #define INTTOPTR 367 |
| 302 | #define PTRTOINT 368 |
| 303 | #define PHI_TOK 369 |
| 304 | #define SELECT 370 |
| 305 | #define SHL 371 |
| 306 | #define LSHR 372 |
| 307 | #define ASHR 373 |
| 308 | #define VAARG 374 |
| 309 | #define EXTRACTELEMENT 375 |
| 310 | #define INSERTELEMENT 376 |
| 311 | #define SHUFFLEVECTOR 377 |
| 312 | #define VAARG_old 378 |
| 313 | #define VANEXT_old 379 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | /* Copy the first part of user declarations. */ |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 319 | #line 14 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 320 | |
| 321 | #include "ParserInternals.h" |
| 322 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 323 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 324 | #include "llvm/Instructions.h" |
| 325 | #include "llvm/Module.h" |
| 326 | #include "llvm/SymbolTable.h" |
Reid Spencer | 0b11820 | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 327 | #include "llvm/Assembly/AutoUpgrade.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 328 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
| 329 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 330 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 331 | #include <algorithm> |
| 332 | #include <iostream> |
| 333 | #include <list> |
| 334 | #include <utility> |
| 335 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 336 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 337 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 338 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 339 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 340 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 341 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 342 | // GenerateError are made from inside productions and they must simulate the |
| 343 | // previous exception behavior by exiting the production immediately. We have |
| 344 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 345 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 346 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 347 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 348 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 349 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 350 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 351 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 352 | int yylex(); // declaration" of xxx warnings. |
| 353 | int yyparse(); |
| 354 | |
| 355 | namespace llvm { |
| 356 | std::string CurFilename; |
| 357 | } |
| 358 | using namespace llvm; |
| 359 | |
| 360 | static Module *ParserResult; |
| 361 | |
| 362 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 363 | // relating to upreferences in the input stream. |
| 364 | // |
| 365 | //#define DEBUG_UPREFS 1 |
| 366 | #ifdef DEBUG_UPREFS |
| 367 | #define UR_OUT(X) std::cerr << X |
| 368 | #else |
| 369 | #define UR_OUT(X) |
| 370 | #endif |
| 371 | |
| 372 | #define YYERROR_VERBOSE 1 |
| 373 | |
| 374 | static bool ObsoleteVarArgs; |
| 375 | static bool NewVarArgs; |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 376 | static BasicBlock *CurBB; |
| 377 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 378 | |
| 379 | |
| 380 | // This contains info used when building the body of a function. It is |
| 381 | // destroyed when the function is completed. |
| 382 | // |
| 383 | typedef std::vector<Value *> ValueList; // Numbered defs |
| 384 | static void |
| 385 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 386 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 387 | |
| 388 | static struct PerModuleInfo { |
| 389 | Module *CurrentModule; |
| 390 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 391 | std::map<const Type *,ValueList> LateResolveValues; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 392 | std::vector<TypeInfo> Types; |
| 393 | std::map<ValID, TypeInfo> LateResolveTypes; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 394 | |
| 395 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 396 | /// 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] | 397 | /// that we can resolve them later and print error messages as appropriate. |
| 398 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 399 | |
| 400 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 401 | // references to global values. Global values may be referenced before they |
| 402 | // are defined, and if so, the temporary object that they represent is held |
| 403 | // here. This is used for forward references of GlobalValues. |
| 404 | // |
| 405 | typedef std::map<std::pair<const PointerType *, |
| 406 | ValID>, GlobalValue*> GlobalRefsType; |
| 407 | GlobalRefsType GlobalRefs; |
| 408 | |
| 409 | void ModuleDone() { |
| 410 | // If we could not resolve some functions at function compilation time |
| 411 | // (calls to functions before they are defined), resolve them now... Types |
| 412 | // are resolved when the constant pool has been completely parsed. |
| 413 | // |
| 414 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 415 | if (TriggerError) |
| 416 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 417 | |
| 418 | // Check to make sure that all global value forward references have been |
| 419 | // resolved! |
| 420 | // |
| 421 | if (!GlobalRefs.empty()) { |
| 422 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 423 | |
| 424 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 425 | I != E; ++I) { |
| 426 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 427 | I->first.second.getName() + "\n"; |
| 428 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 429 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 430 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 431 | } |
| 432 | |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 433 | // Look for intrinsic functions and CallInst that need to be upgraded |
Chris Lattner | d5efe84 | 2006-04-08 01:18:56 +0000 | [diff] [blame] | 434 | for (Module::iterator FI = CurrentModule->begin(), |
| 435 | FE = CurrentModule->end(); FI != FE; ) |
Chris Lattner | c2c6038 | 2006-03-04 07:53:41 +0000 | [diff] [blame] | 436 | UpgradeCallsToIntrinsic(FI++); |
Reid Spencer | 0b11820 | 2006-01-16 21:12:35 +0000 | [diff] [blame] | 437 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 438 | Values.clear(); // Clear out function local definitions |
| 439 | Types.clear(); |
| 440 | CurrentModule = 0; |
| 441 | } |
| 442 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 443 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 444 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 445 | // If not, just return null. |
| 446 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 447 | // Check to see if there is a forward reference to this global variable... |
| 448 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 449 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 450 | GlobalValue *Ret = 0; |
| 451 | if (I != GlobalRefs.end()) { |
| 452 | Ret = I->second; |
| 453 | GlobalRefs.erase(I); |
| 454 | } |
| 455 | return Ret; |
| 456 | } |
| 457 | } CurModule; |
| 458 | |
| 459 | static struct PerFunctionInfo { |
| 460 | Function *CurrentFunction; // Pointer to current function being created |
| 461 | |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 462 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 463 | std::map<const Type*, ValueList> LateResolveValues; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 464 | bool isDeclare; // Is this function a forward declararation? |
| 465 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 466 | |
| 467 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 468 | /// track of them here. |
| 469 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 470 | std::vector<BasicBlock*> NumberedBlocks; |
| 471 | unsigned NextBBNum; |
| 472 | |
| 473 | inline PerFunctionInfo() { |
| 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 | |
| 479 | inline void FunctionStart(Function *M) { |
| 480 | CurrentFunction = M; |
| 481 | NextBBNum = 0; |
| 482 | } |
| 483 | |
| 484 | void FunctionDone() { |
| 485 | NumberedBlocks.clear(); |
| 486 | |
| 487 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 488 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 489 | GenerateError("Undefined reference to label " + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 490 | BBForwardRefs.begin()->first->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 491 | return; |
| 492 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 493 | |
| 494 | // Resolve all forward references now. |
| 495 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 496 | |
| 497 | Values.clear(); // Clear out function local definitions |
| 498 | CurrentFunction = 0; |
| 499 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 500 | Linkage = GlobalValue::ExternalLinkage; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 501 | } |
| 502 | } CurFun; // Info for the current function... |
| 503 | |
| 504 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 505 | |
| 506 | |
| 507 | //===----------------------------------------------------------------------===// |
| 508 | // Code to handle definitions of all the types |
| 509 | //===----------------------------------------------------------------------===// |
| 510 | |
| 511 | static int InsertValue(Value *V, |
| 512 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 513 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 514 | |
| 515 | // Yes, insert the value into the value table... |
| 516 | ValueList &List = ValueTab[V->getType()]; |
| 517 | List.push_back(V); |
| 518 | return List.size()-1; |
| 519 | } |
| 520 | |
| 521 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 522 | switch (D.Type) { |
| 523 | case ValID::NumberVal: // Is it a numbered definition? |
| 524 | // Module constants occupy the lowest numbered slots... |
| 525 | if ((unsigned)D.Num < CurModule.Types.size()) |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 526 | return CurModule.Types[(unsigned)D.Num].type->get(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 527 | break; |
| 528 | case ValID::NameVal: // Is it a named definition? |
| 529 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 530 | D.destroy(); // Free old strdup'd memory... |
| 531 | return N; |
| 532 | } |
| 533 | break; |
| 534 | default: |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 535 | GenerateError("Internal parser error: Invalid symbol type reference!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 536 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 537 | } |
| 538 | |
| 539 | // If we reached here, we referenced either a symbol that we don't know about |
| 540 | // or an id number that hasn't been read yet. We may be referencing something |
| 541 | // forward, so just create an entry to be resolved later and get to it... |
| 542 | // |
| 543 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 544 | |
| 545 | |
| 546 | if (inFunctionScope()) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 547 | if (D.Type == ValID::NameVal) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 548 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 549 | return 0; |
| 550 | } else { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 551 | GenerateError("Reference to an undefined type: #" + itostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 552 | return 0; |
| 553 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 554 | } |
| 555 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 556 | std::map<ValID, TypeInfo>::iterator I =CurModule.LateResolveTypes.find(D); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 557 | if (I != CurModule.LateResolveTypes.end()) |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 558 | return I->second.type->get(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 559 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 560 | TypeInfo TI; |
| 561 | TI.type = new PATypeHolder(OpaqueType::get()); |
| 562 | TI.signedness = isSignless; |
| 563 | CurModule.LateResolveTypes.insert(std::make_pair(D, TI)); |
| 564 | return TI.type->get(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) { |
| 568 | SymbolTable &SymTab = |
| 569 | inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() : |
| 570 | CurModule.CurrentModule->getSymbolTable(); |
| 571 | return SymTab.lookup(Ty, Name); |
| 572 | } |
| 573 | |
| 574 | // getValNonImprovising - Look up the value specified by the provided type and |
| 575 | // the provided ValID. If the value exists and has already been defined, return |
| 576 | // it. Otherwise return null. |
| 577 | // |
| 578 | static Value *getValNonImprovising(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 579 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 580 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 581 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 582 | return 0; |
| 583 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 584 | |
| 585 | switch (D.Type) { |
| 586 | case ValID::NumberVal: { // Is it a numbered definition? |
| 587 | unsigned Num = (unsigned)D.Num; |
| 588 | |
| 589 | // Module constants occupy the lowest numbered slots... |
| 590 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
| 591 | if (VI != CurModule.Values.end()) { |
| 592 | if (Num < VI->second.size()) |
| 593 | return VI->second[Num]; |
| 594 | Num -= VI->second.size(); |
| 595 | } |
| 596 | |
| 597 | // Make sure that our type is within bounds |
| 598 | VI = CurFun.Values.find(Ty); |
| 599 | if (VI == CurFun.Values.end()) return 0; |
| 600 | |
| 601 | // Check that the number is within bounds... |
| 602 | if (VI->second.size() <= Num) return 0; |
| 603 | |
| 604 | return VI->second[Num]; |
| 605 | } |
| 606 | |
| 607 | case ValID::NameVal: { // Is it a named definition? |
| 608 | Value *N = lookupInSymbolTable(Ty, std::string(D.Name)); |
| 609 | if (N == 0) return 0; |
| 610 | |
| 611 | D.destroy(); // Free old strdup'd memory... |
| 612 | return N; |
| 613 | } |
| 614 | |
| 615 | // Check to make sure that "Ty" is an integral type, and that our |
| 616 | // value will fit into the specified type... |
| 617 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 618 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 619 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 620 | itostr(D.ConstPool64) + "' is invalid for type '" + |
| 621 | Ty->getDescription() + "'!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 622 | return 0; |
| 623 | } |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 624 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 625 | |
| 626 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 627 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 628 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 629 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 630 | "' is invalid or out of range!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 631 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 632 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 633 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 634 | } |
| 635 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 636 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 640 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 641 | GenerateError("FP constant invalid for type!!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 642 | return 0; |
| 643 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 644 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 645 | |
| 646 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 647 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 648 | GenerateError("Cannot create a a non pointer null!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 649 | return 0; |
| 650 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 651 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 652 | |
| 653 | case ValID::ConstUndefVal: // Is it an undef value? |
| 654 | return UndefValue::get(Ty); |
| 655 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 656 | case ValID::ConstZeroVal: // Is it a zero value? |
| 657 | return Constant::getNullValue(Ty); |
| 658 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 659 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 660 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 661 | GenerateError("Constant expression type different from required type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 662 | return 0; |
| 663 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 664 | return D.ConstantValue; |
| 665 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 666 | case ValID::InlineAsmVal: { // Inline asm expression |
| 667 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 668 | const FunctionType *FTy = |
| 669 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 670 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 671 | GenerateError("Invalid type for asm constraint string!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 672 | return 0; |
| 673 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 674 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 675 | D.IAD->HasSideEffects); |
| 676 | D.destroy(); // Free InlineAsmDescriptor. |
| 677 | return IA; |
| 678 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 679 | default: |
| 680 | assert(0 && "Unhandled case!"); |
| 681 | return 0; |
| 682 | } // End of switch |
| 683 | |
| 684 | assert(0 && "Unhandled case!"); |
| 685 | return 0; |
| 686 | } |
| 687 | |
| 688 | // getVal - This function is identical to getValNonImprovising, except that if a |
| 689 | // value is not already defined, it "improvises" by creating a placeholder var |
| 690 | // that looks and acts just like the requested variable. When the value is |
| 691 | // defined later, all uses of the placeholder variable are replaced with the |
| 692 | // real thing. |
| 693 | // |
| 694 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 695 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 696 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 697 | return 0; |
| 698 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 699 | |
| 700 | // See if the value has already been defined. |
| 701 | Value *V = getValNonImprovising(Ty, ID); |
| 702 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 703 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 704 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 705 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 706 | GenerateError("Invalid use of a composite type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 707 | return 0; |
| 708 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 709 | |
| 710 | // If we reached here, we referenced either a symbol that we don't know about |
| 711 | // or an id number that hasn't been read yet. We may be referencing something |
| 712 | // forward, so just create an entry to be resolved later and get to it... |
| 713 | // |
| 714 | V = new Argument(Ty); |
| 715 | |
| 716 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 717 | // to recycle these things?? |
| 718 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 719 | llvmAsmlineno))); |
| 720 | |
| 721 | if (inFunctionScope()) |
| 722 | InsertValue(V, CurFun.LateResolveValues); |
| 723 | else |
| 724 | InsertValue(V, CurModule.LateResolveValues); |
| 725 | return V; |
| 726 | } |
| 727 | |
| 728 | /// getBBVal - This is used for two purposes: |
| 729 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 730 | /// defined. |
| 731 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 732 | /// or may not be a forward reference. |
| 733 | /// |
| 734 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
| 735 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 736 | |
| 737 | std::string Name; |
| 738 | BasicBlock *BB = 0; |
| 739 | switch (ID.Type) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 740 | default: |
| 741 | GenerateError("Illegal label reference " + ID.getName()); |
| 742 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 743 | case ValID::NumberVal: // Is it a numbered definition? |
| 744 | if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) |
| 745 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 746 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 747 | break; |
| 748 | case ValID::NameVal: // Is it a named definition? |
| 749 | Name = ID.Name; |
| 750 | if (Value *N = CurFun.CurrentFunction-> |
| 751 | getSymbolTable().lookup(Type::LabelTy, Name)) |
| 752 | BB = cast<BasicBlock>(N); |
| 753 | break; |
| 754 | } |
| 755 | |
| 756 | // See if the block has already been defined. |
| 757 | if (BB) { |
| 758 | // If this is the definition of the block, make sure the existing value was |
| 759 | // just a forward reference. If it was a forward reference, there will be |
| 760 | // an entry for it in the PlaceHolderInfo map. |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 761 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 762 | // The existing value was a definition, not a forward reference. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 763 | GenerateError("Redefinition of label " + ID.getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 764 | return 0; |
| 765 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 766 | |
| 767 | ID.destroy(); // Free strdup'd memory. |
| 768 | return BB; |
| 769 | } |
| 770 | |
| 771 | // Otherwise this block has not been seen before. |
| 772 | BB = new BasicBlock("", CurFun.CurrentFunction); |
| 773 | if (ID.Type == ValID::NameVal) { |
| 774 | BB->setName(ID.Name); |
| 775 | } else { |
| 776 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 777 | } |
| 778 | |
| 779 | // If this is not a definition, keep track of it so we can use it as a forward |
| 780 | // reference. |
| 781 | if (!isDefinition) { |
| 782 | // Remember where this forward reference came from. |
| 783 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno); |
| 784 | } else { |
| 785 | // The forward declaration could have been inserted anywhere in the |
| 786 | // function: insert it into the correct place now. |
| 787 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 788 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 789 | } |
| 790 | ID.destroy(); |
| 791 | return BB; |
| 792 | } |
| 793 | |
| 794 | |
| 795 | //===----------------------------------------------------------------------===// |
| 796 | // Code to handle forward references in instructions |
| 797 | //===----------------------------------------------------------------------===// |
| 798 | // |
| 799 | // This code handles the late binding needed with statements that reference |
| 800 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 801 | // a loop body. |
| 802 | // |
| 803 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 804 | // and back patchs after we are done. |
| 805 | // |
| 806 | |
| 807 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 808 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 809 | // defs now... |
| 810 | // |
| 811 | static void |
| 812 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 813 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
| 814 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 815 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 816 | E = LateResolvers.end(); LRI != E; ++LRI) { |
| 817 | ValueList &List = LRI->second; |
| 818 | while (!List.empty()) { |
| 819 | Value *V = List.back(); |
| 820 | List.pop_back(); |
| 821 | |
| 822 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 823 | CurModule.PlaceHolderInfo.find(V); |
| 824 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
| 825 | |
| 826 | ValID &DID = PHI->second.first; |
| 827 | |
| 828 | Value *TheRealValue = getValNonImprovising(LRI->first, DID); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 829 | if (TriggerError) |
| 830 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 831 | if (TheRealValue) { |
| 832 | V->replaceAllUsesWith(TheRealValue); |
| 833 | delete V; |
| 834 | CurModule.PlaceHolderInfo.erase(PHI); |
| 835 | } else if (FutureLateResolvers) { |
| 836 | // Functions have their unresolved items forwarded to the module late |
| 837 | // resolver table |
| 838 | InsertValue(V, *FutureLateResolvers); |
| 839 | } else { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 840 | if (DID.Type == ValID::NameVal) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 841 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 842 | "' of type '" + V->getType()->getDescription() + "'", |
| 843 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 844 | return; |
| 845 | } else { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 846 | GenerateError("Reference to an invalid definition: #" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 847 | itostr(DID.Num) + " of type '" + |
| 848 | V->getType()->getDescription() + "'", |
| 849 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 850 | return; |
| 851 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 852 | } |
| 853 | } |
| 854 | } |
| 855 | |
| 856 | LateResolvers.clear(); |
| 857 | } |
| 858 | |
| 859 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 860 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 861 | // refering to the number can be resolved. Do this now. |
| 862 | // |
| 863 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 864 | ValID D; |
| 865 | if (Name) D = ValID::create(Name); |
| 866 | else D = ValID::create((int)CurModule.Types.size()); |
| 867 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 868 | std::map<ValID, TypeInfo>::iterator I = |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 869 | CurModule.LateResolveTypes.find(D); |
| 870 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 871 | ((DerivedType*)I->second.type->get())->refineAbstractTypeTo(ToTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 872 | CurModule.LateResolveTypes.erase(I); |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | // setValueName - Set the specified value to the name given. The name may be |
| 877 | // null potentially, in which case this is a noop. The string passed in is |
| 878 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 879 | // |
| 880 | static void setValueName(Value *V, char *NameStr) { |
| 881 | if (NameStr) { |
| 882 | std::string Name(NameStr); // Copy string |
| 883 | free(NameStr); // Free old string |
| 884 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 885 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 886 | GenerateError("Can't assign name '" + Name+"' to value with void type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 887 | return; |
| 888 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 889 | |
| 890 | assert(inFunctionScope() && "Must be in function scope!"); |
| 891 | SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable(); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 892 | if (ST.lookup(V->getType(), Name)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 893 | GenerateError("Redefinition of value named '" + Name + "' in the '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 894 | V->getType()->getDescription() + "' type plane!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 895 | return; |
| 896 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 897 | |
| 898 | // Set the name. |
| 899 | V->setName(Name); |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 904 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 905 | static GlobalVariable * |
| 906 | ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, |
| 907 | bool isConstantGlobal, const Type *Ty, |
| 908 | Constant *Initializer) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 909 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 910 | GenerateError("Cannot declare global vars of function type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 911 | return 0; |
| 912 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 913 | |
| 914 | const PointerType *PTy = PointerType::get(Ty); |
| 915 | |
| 916 | std::string Name; |
| 917 | if (NameStr) { |
| 918 | Name = NameStr; // Copy string |
| 919 | free(NameStr); // Free old string |
| 920 | } |
| 921 | |
| 922 | // See if this global value was forward referenced. If so, recycle the |
| 923 | // object. |
| 924 | ValID ID; |
| 925 | if (!Name.empty()) { |
| 926 | ID = ValID::create((char*)Name.c_str()); |
| 927 | } else { |
| 928 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
| 929 | } |
| 930 | |
| 931 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 932 | // Move the global to the end of the list, from whereever it was |
| 933 | // previously inserted. |
| 934 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 935 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 936 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 937 | GV->setInitializer(Initializer); |
| 938 | GV->setLinkage(Linkage); |
| 939 | GV->setConstant(isConstantGlobal); |
| 940 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 941 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | // If this global has a name, check to see if there is already a definition |
| 945 | // of this global in the module. If so, merge as appropriate. Note that |
| 946 | // this is really just a hack around problems in the CFE. :( |
| 947 | if (!Name.empty()) { |
| 948 | // We are a simple redefinition of a value, check to see if it is defined |
| 949 | // the same as the old one. |
| 950 | if (GlobalVariable *EGV = |
| 951 | CurModule.CurrentModule->getGlobalVariable(Name, Ty)) { |
| 952 | // We are allowed to redefine a global variable in two circumstances: |
| 953 | // 1. If at least one of the globals is uninitialized or |
| 954 | // 2. If both initializers have the same value. |
| 955 | // |
| 956 | if (!EGV->hasInitializer() || !Initializer || |
| 957 | EGV->getInitializer() == Initializer) { |
| 958 | |
| 959 | // Make sure the existing global version gets the initializer! Make |
| 960 | // sure that it also gets marked const if the new version is. |
| 961 | if (Initializer && !EGV->hasInitializer()) |
| 962 | EGV->setInitializer(Initializer); |
| 963 | if (isConstantGlobal) |
| 964 | EGV->setConstant(true); |
| 965 | EGV->setLinkage(Linkage); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 966 | return EGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 967 | } |
| 968 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 969 | GenerateError("Redefinition of global variable named '" + Name + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 970 | "' in the '" + Ty->getDescription() + "' type plane!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 971 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 972 | } |
| 973 | } |
| 974 | |
| 975 | // Otherwise there is no existing GV to use, create one now. |
| 976 | GlobalVariable *GV = |
| 977 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 978 | CurModule.CurrentModule); |
| 979 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 980 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | // setTypeName - Set the specified type to the name given. The name may be |
| 984 | // null potentially, in which case this is a noop. The string passed in is |
| 985 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 986 | // |
| 987 | // This function returns true if the type has already been defined, but is |
| 988 | // allowed to be redefined in the specified context. If the name is a new name |
| 989 | // for the type plane, it is inserted and false is returned. |
| 990 | static bool setTypeName(const Type *T, char *NameStr) { |
| 991 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
| 992 | if (NameStr == 0) return false; |
| 993 | |
| 994 | std::string Name(NameStr); // Copy string |
| 995 | free(NameStr); // Free old string |
| 996 | |
| 997 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 998 | if (T == Type::VoidTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 999 | GenerateError("Can't assign name '" + Name + "' to the void type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1000 | return false; |
| 1001 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1002 | |
| 1003 | // Set the type name, checking for conflicts as we do so. |
| 1004 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 1005 | |
| 1006 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1007 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 1008 | assert(Existing && "Conflict but no matching type?"); |
| 1009 | |
| 1010 | // There is only one case where this is allowed: when we are refining an |
| 1011 | // opaque type. In this case, Existing will be an opaque type. |
| 1012 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1013 | // We ARE replacing an opaque type! |
| 1014 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 1015 | return true; |
| 1016 | } |
| 1017 | |
| 1018 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1019 | // the redefinition is identical to the original. This will be so if |
| 1020 | // Existing and T point to the same Type object. In this one case we |
| 1021 | // allow the equivalent redefinition. |
| 1022 | if (Existing == T) return true; // Yes, it's equal. |
| 1023 | |
| 1024 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1025 | GenerateError("Redefinition of type named '" + Name + "' in the '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1026 | T->getDescription() + "' type plane!"); |
| 1027 | } |
| 1028 | |
| 1029 | return false; |
| 1030 | } |
| 1031 | |
| 1032 | //===----------------------------------------------------------------------===// |
| 1033 | // Code for handling upreferences in type names... |
| 1034 | // |
| 1035 | |
| 1036 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1037 | // |
| 1038 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1039 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1040 | E) != Ty->subtype_end(); |
| 1041 | } |
| 1042 | |
| 1043 | namespace { |
| 1044 | struct UpRefRecord { |
| 1045 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1046 | // this type is resolved. |
| 1047 | unsigned NestingLevel; |
| 1048 | |
| 1049 | // LastContainedTy - This is the type at the current binding level for the |
| 1050 | // type. Every time we reduce the nesting level, this gets updated. |
| 1051 | const Type *LastContainedTy; |
| 1052 | |
| 1053 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1054 | // represented with. |
| 1055 | OpaqueType *UpRefTy; |
| 1056 | |
| 1057 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 1058 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 1059 | }; |
| 1060 | } |
| 1061 | |
| 1062 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1063 | static std::vector<UpRefRecord> UpRefs; |
| 1064 | |
| 1065 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1066 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1067 | /// currently active types. For each type, if the up reference is contained in |
| 1068 | /// the newly completed type, we decrement the level count. When the level |
| 1069 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1070 | /// thus we can complete the cycle. |
| 1071 | /// |
| 1072 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 1073 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1074 | // nothing to resolve here. |
| 1075 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1076 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1077 | PATypeHolder Ty(ty); |
| 1078 | UR_OUT("Type '" << Ty->getDescription() << |
| 1079 | "' newly formed. Resolving upreferences.\n" << |
| 1080 | UpRefs.size() << " upreferences active!\n"); |
| 1081 | |
| 1082 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1083 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1084 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1085 | // this variable. |
| 1086 | OpaqueType *TypeToResolve = 0; |
| 1087 | |
| 1088 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1089 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1090 | << UpRefs[i].second->getDescription() << ") = " |
| 1091 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1092 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1093 | // Decrement level of upreference |
| 1094 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1095 | UpRefs[i].LastContainedTy = Ty; |
| 1096 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1097 | if (Level == 0) { // Upreference should be resolved! |
| 1098 | if (!TypeToResolve) { |
| 1099 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1100 | } else { |
| 1101 | UR_OUT(" * Resolving upreference for " |
| 1102 | << UpRefs[i].second->getDescription() << "\n"; |
| 1103 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1104 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1105 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1106 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1107 | } |
| 1108 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1109 | --i; // Do not skip the next element... |
| 1110 | } |
| 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | if (TypeToResolve) { |
| 1115 | UR_OUT(" * Resolving upreference for " |
| 1116 | << UpRefs[i].second->getDescription() << "\n"; |
| 1117 | std::string OldName = TypeToResolve->getDescription()); |
| 1118 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1119 | } |
| 1120 | |
| 1121 | return Ty; |
| 1122 | } |
| 1123 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1124 | /// This function is used to obtain the correct opcode for an instruction when |
| 1125 | /// an obsolete opcode is encountered. The OI parameter (OpcodeInfo) has both |
| 1126 | /// an opcode and an "obsolete" flag. These are generated by the lexer and |
| 1127 | /// the "obsolete" member will be true when the lexer encounters the token for |
| 1128 | /// an obsolete opcode. For example, "div" was replaced by [usf]div but we need |
| 1129 | /// to maintain backwards compatibility for asm files that still have the "div" |
| 1130 | /// instruction. This function handles converting div -> [usf]div appropriately. |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1131 | /// @brief Convert obsolete BinaryOps opcodes to new values |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1132 | static void |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1133 | sanitizeOpcode(OpcodeInfo<Instruction::BinaryOps> &OI, const Type *Ty) |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1134 | { |
| 1135 | // If its not obsolete, don't do anything |
| 1136 | if (!OI.obsolete) |
| 1137 | return; |
| 1138 | |
| 1139 | // If its a packed type we want to use the element type |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1140 | if (const PackedType *PTy = dyn_cast<PackedType>(Ty)) |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1141 | Ty = PTy->getElementType(); |
| 1142 | |
| 1143 | // Depending on the opcode .. |
| 1144 | switch (OI.opcode) { |
| 1145 | default: |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame] | 1146 | GenerateError("Invalid obsolete opCode (check Lexer.l)"); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1147 | break; |
| 1148 | case Instruction::UDiv: |
| 1149 | // Handle cases where the opcode needs to change |
| 1150 | if (Ty->isFloatingPoint()) |
| 1151 | OI.opcode = Instruction::FDiv; |
| 1152 | else if (Ty->isSigned()) |
| 1153 | OI.opcode = Instruction::SDiv; |
| 1154 | break; |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame] | 1155 | case Instruction::URem: |
| 1156 | if (Ty->isFloatingPoint()) |
| 1157 | OI.opcode = Instruction::FRem; |
| 1158 | else if (Ty->isSigned()) |
| 1159 | OI.opcode = Instruction::SRem; |
| 1160 | break; |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1161 | } |
| 1162 | // Its not obsolete any more, we fixed it. |
| 1163 | OI.obsolete = false; |
| 1164 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1165 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1166 | /// This function is similar to the previous overload of sanitizeOpcode but |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1167 | /// operates on Instruction::OtherOps instead of Instruction::BinaryOps. |
| 1168 | /// @brief Convert obsolete OtherOps opcodes to new values |
| 1169 | static void |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1170 | sanitizeOpcode(OpcodeInfo<Instruction::OtherOps> &OI, const Type *Ty) |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1171 | { |
| 1172 | // If its not obsolete, don't do anything |
| 1173 | if (!OI.obsolete) |
| 1174 | return; |
| 1175 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1176 | switch (OI.opcode) { |
| 1177 | default: |
| 1178 | GenerateError("Invalid obsolete opcode (check Lexer.l)"); |
| 1179 | break; |
| 1180 | case Instruction::LShr: |
| 1181 | if (Ty->isSigned()) |
| 1182 | OI.opcode = Instruction::AShr; |
| 1183 | break; |
| 1184 | } |
| 1185 | // Its not obsolete any more, we fixed it. |
| 1186 | OI.obsolete = false; |
| 1187 | } |
| 1188 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1189 | // common code from the two 'RunVMAsmParser' functions |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1190 | static Module* RunParser(Module * M) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1191 | |
| 1192 | llvmAsmlineno = 1; // Reset the current line number... |
| 1193 | ObsoleteVarArgs = false; |
| 1194 | NewVarArgs = false; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1195 | CurModule.CurrentModule = M; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 1196 | |
| 1197 | // Check to make sure the parser succeeded |
| 1198 | if (yyparse()) { |
| 1199 | if (ParserResult) |
| 1200 | delete ParserResult; |
| 1201 | return 0; |
| 1202 | } |
| 1203 | |
| 1204 | // Check to make sure that parsing produced a result |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1205 | if (!ParserResult) |
| 1206 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1207 | |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 1208 | // Reset ParserResult variable while saving its value for the result. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1209 | Module *Result = ParserResult; |
| 1210 | ParserResult = 0; |
| 1211 | |
| 1212 | //Not all functions use vaarg, so make a second check for ObsoleteVarArgs |
| 1213 | { |
| 1214 | Function* F; |
| 1215 | if ((F = Result->getNamedFunction("llvm.va_start")) |
| 1216 | && F->getFunctionType()->getNumParams() == 0) |
| 1217 | ObsoleteVarArgs = true; |
| 1218 | if((F = Result->getNamedFunction("llvm.va_copy")) |
| 1219 | && F->getFunctionType()->getNumParams() == 1) |
| 1220 | ObsoleteVarArgs = true; |
| 1221 | } |
| 1222 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1223 | if (ObsoleteVarArgs && NewVarArgs) { |
| 1224 | GenerateError( |
| 1225 | "This file is corrupt: it uses both new and old style varargs"); |
| 1226 | return 0; |
| 1227 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1228 | |
| 1229 | if(ObsoleteVarArgs) { |
| 1230 | if(Function* F = Result->getNamedFunction("llvm.va_start")) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1231 | if (F->arg_size() != 0) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1232 | GenerateError("Obsolete va_start takes 0 argument!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1233 | return 0; |
| 1234 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1235 | |
| 1236 | //foo = va_start() |
| 1237 | // -> |
| 1238 | //bar = alloca typeof(foo) |
| 1239 | //va_start(bar) |
| 1240 | //foo = load bar |
| 1241 | |
| 1242 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1243 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 1244 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1245 | Function* NF = Result->getOrInsertFunction("llvm.va_start", |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 1246 | RetTy, ArgTyPtr, (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1247 | |
| 1248 | while (!F->use_empty()) { |
| 1249 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1250 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); |
| 1251 | new CallInst(NF, bar, "", CI); |
| 1252 | Value* foo = new LoadInst(bar, "vastart.fix.2", CI); |
| 1253 | CI->replaceAllUsesWith(foo); |
| 1254 | CI->getParent()->getInstList().erase(CI); |
| 1255 | } |
| 1256 | Result->getFunctionList().erase(F); |
| 1257 | } |
| 1258 | |
| 1259 | if(Function* F = Result->getNamedFunction("llvm.va_end")) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1260 | if(F->arg_size() != 1) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1261 | GenerateError("Obsolete va_end takes 1 argument!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1262 | return 0; |
| 1263 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1264 | |
| 1265 | //vaend foo |
| 1266 | // -> |
| 1267 | //bar = alloca 1 of typeof(foo) |
| 1268 | //vaend bar |
| 1269 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1270 | const Type* ArgTy = F->getFunctionType()->getParamType(0); |
| 1271 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1272 | Function* NF = Result->getOrInsertFunction("llvm.va_end", |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 1273 | RetTy, ArgTyPtr, (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1274 | |
| 1275 | while (!F->use_empty()) { |
| 1276 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1277 | AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); |
| 1278 | new StoreInst(CI->getOperand(1), bar, CI); |
| 1279 | new CallInst(NF, bar, "", CI); |
| 1280 | CI->getParent()->getInstList().erase(CI); |
| 1281 | } |
| 1282 | Result->getFunctionList().erase(F); |
| 1283 | } |
| 1284 | |
| 1285 | if(Function* F = Result->getNamedFunction("llvm.va_copy")) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1286 | if(F->arg_size() != 1) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1287 | GenerateError("Obsolete va_copy takes 1 argument!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1288 | return 0; |
| 1289 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1290 | //foo = vacopy(bar) |
| 1291 | // -> |
| 1292 | //a = alloca 1 of typeof(foo) |
| 1293 | //b = alloca 1 of typeof(foo) |
| 1294 | //store bar -> b |
| 1295 | //vacopy(a, b) |
| 1296 | //foo = load a |
| 1297 | |
| 1298 | const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); |
| 1299 | const Type* ArgTy = F->getFunctionType()->getReturnType(); |
| 1300 | const Type* ArgTyPtr = PointerType::get(ArgTy); |
| 1301 | Function* NF = Result->getOrInsertFunction("llvm.va_copy", |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 1302 | RetTy, ArgTyPtr, ArgTyPtr, |
| 1303 | (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1304 | |
| 1305 | while (!F->use_empty()) { |
| 1306 | CallInst* CI = cast<CallInst>(F->use_back()); |
| 1307 | AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI); |
| 1308 | AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI); |
| 1309 | new StoreInst(CI->getOperand(1), b, CI); |
| 1310 | new CallInst(NF, a, b, "", CI); |
| 1311 | Value* foo = new LoadInst(a, "vacopy.fix.3", CI); |
| 1312 | CI->replaceAllUsesWith(foo); |
| 1313 | CI->getParent()->getInstList().erase(CI); |
| 1314 | } |
| 1315 | Result->getFunctionList().erase(F); |
| 1316 | } |
| 1317 | } |
| 1318 | |
| 1319 | return Result; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1320 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1321 | |
| 1322 | //===----------------------------------------------------------------------===// |
| 1323 | // RunVMAsmParser - Define an interface to this parser |
| 1324 | //===----------------------------------------------------------------------===// |
| 1325 | // |
| 1326 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1327 | set_scan_file(F); |
| 1328 | |
| 1329 | CurFilename = Filename; |
| 1330 | return RunParser(new Module(CurFilename)); |
| 1331 | } |
| 1332 | |
| 1333 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1334 | set_scan_string(AsmString); |
| 1335 | |
| 1336 | CurFilename = "from_memory"; |
| 1337 | if (M == NULL) { |
| 1338 | return RunParser(new Module (CurFilename)); |
| 1339 | } else { |
| 1340 | return RunParser(M); |
| 1341 | } |
| 1342 | } |
| 1343 | |
| 1344 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1345 | |
| 1346 | /* Enabling traces. */ |
| 1347 | #ifndef YYDEBUG |
| 1348 | # define YYDEBUG 0 |
| 1349 | #endif |
| 1350 | |
| 1351 | /* Enabling verbose error messages. */ |
| 1352 | #ifdef YYERROR_VERBOSE |
| 1353 | # undef YYERROR_VERBOSE |
| 1354 | # define YYERROR_VERBOSE 1 |
| 1355 | #else |
| 1356 | # define YYERROR_VERBOSE 0 |
| 1357 | #endif |
| 1358 | |
| 1359 | /* Enabling the token table. */ |
| 1360 | #ifndef YYTOKEN_TABLE |
| 1361 | # define YYTOKEN_TABLE 0 |
| 1362 | #endif |
| 1363 | |
| 1364 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1365 | #line 1040 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1366 | typedef union YYSTYPE { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1367 | llvm::Module *ModuleVal; |
| 1368 | llvm::Function *FunctionVal; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1369 | std::pair<TypeInfo, char*> *ArgVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1370 | llvm::BasicBlock *BasicBlockVal; |
| 1371 | llvm::TerminatorInst *TermInstVal; |
| 1372 | llvm::Instruction *InstVal; |
| 1373 | llvm::Constant *ConstVal; |
| 1374 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1375 | TypeInfo TypeVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1376 | llvm::Value *ValueVal; |
| 1377 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1378 | std::vector<std::pair<TypeInfo,char*> >*ArgList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1379 | std::vector<llvm::Value*> *ValueList; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1380 | std::list<TypeInfo> *TypeList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1381 | // Represent the RHS of PHI node |
| 1382 | std::list<std::pair<llvm::Value*, |
| 1383 | llvm::BasicBlock*> > *PHIList; |
| 1384 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
| 1385 | std::vector<llvm::Constant*> *ConstVector; |
| 1386 | |
| 1387 | llvm::GlobalValue::LinkageTypes Linkage; |
| 1388 | int64_t SInt64Val; |
| 1389 | uint64_t UInt64Val; |
| 1390 | int SIntVal; |
| 1391 | unsigned UIntVal; |
| 1392 | double FPVal; |
| 1393 | bool BoolVal; |
| 1394 | |
| 1395 | char *StrVal; // This memory is strdup'd! |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1396 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1397 | |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1398 | BinaryOpInfo BinaryOpVal; |
| 1399 | TermOpInfo TermOpVal; |
| 1400 | MemOpInfo MemOpVal; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1401 | CastOpInfo CastOpVal; |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1402 | OtherOpInfo OtherOpVal; |
| 1403 | llvm::Module::Endianness Endianness; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1404 | } YYSTYPE; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1405 | /* Line 196 of yacc.c. */ |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1406 | #line 1407 "llvmAsmParser.tab.c" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1407 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 1408 | # define YYSTYPE_IS_DECLARED 1 |
| 1409 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1410 | #endif |
| 1411 | |
| 1412 | |
| 1413 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1414 | /* Copy the second part of user declarations. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1415 | |
| 1416 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1417 | /* Line 219 of yacc.c. */ |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1418 | #line 1419 "llvmAsmParser.tab.c" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1419 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1420 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
| 1421 | # define YYSIZE_T __SIZE_TYPE__ |
| 1422 | #endif |
| 1423 | #if ! defined (YYSIZE_T) && defined (size_t) |
| 1424 | # define YYSIZE_T size_t |
| 1425 | #endif |
| 1426 | #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) |
| 1427 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 1428 | # define YYSIZE_T size_t |
| 1429 | #endif |
| 1430 | #if ! defined (YYSIZE_T) |
| 1431 | # define YYSIZE_T unsigned int |
| 1432 | #endif |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 1433 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1434 | #ifndef YY_ |
| 1435 | # if YYENABLE_NLS |
| 1436 | # if ENABLE_NLS |
| 1437 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 1438 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
| 1439 | # endif |
| 1440 | # endif |
| 1441 | # ifndef YY_ |
| 1442 | # define YY_(msgid) msgid |
| 1443 | # endif |
| 1444 | #endif |
| 1445 | |
| 1446 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
| 1447 | |
| 1448 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 1449 | |
| 1450 | # ifdef YYSTACK_USE_ALLOCA |
| 1451 | # if YYSTACK_USE_ALLOCA |
| 1452 | # ifdef __GNUC__ |
| 1453 | # define YYSTACK_ALLOC __builtin_alloca |
| 1454 | # else |
| 1455 | # define YYSTACK_ALLOC alloca |
| 1456 | # if defined (__STDC__) || defined (__cplusplus) |
| 1457 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 1458 | # define YYINCLUDED_STDLIB_H |
| 1459 | # endif |
| 1460 | # endif |
| 1461 | # endif |
| 1462 | # endif |
| 1463 | |
| 1464 | # ifdef YYSTACK_ALLOC |
| 1465 | /* Pacify GCC's `empty if-body' warning. */ |
| 1466 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
| 1467 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1468 | /* The OS might guarantee only one guard page at the bottom of the stack, |
| 1469 | and a page size can be as small as 4096 bytes. So we cannot safely |
| 1470 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
| 1471 | to allow for a few compiler-allocated temporary stack slots. */ |
| 1472 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ |
| 1473 | # endif |
| 1474 | # else |
| 1475 | # define YYSTACK_ALLOC YYMALLOC |
| 1476 | # define YYSTACK_FREE YYFREE |
| 1477 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1478 | # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) |
| 1479 | # endif |
| 1480 | # ifdef __cplusplus |
| 1481 | extern "C" { |
| 1482 | # endif |
| 1483 | # ifndef YYMALLOC |
| 1484 | # define YYMALLOC malloc |
| 1485 | # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 1486 | && (defined (__STDC__) || defined (__cplusplus))) |
| 1487 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 1488 | # endif |
| 1489 | # endif |
| 1490 | # ifndef YYFREE |
| 1491 | # define YYFREE free |
| 1492 | # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 1493 | && (defined (__STDC__) || defined (__cplusplus))) |
| 1494 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 1495 | # endif |
| 1496 | # endif |
| 1497 | # ifdef __cplusplus |
| 1498 | } |
| 1499 | # endif |
| 1500 | # endif |
| 1501 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
| 1502 | |
| 1503 | |
| 1504 | #if (! defined (yyoverflow) \ |
| 1505 | && (! defined (__cplusplus) \ |
| 1506 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
| 1507 | |
| 1508 | /* A type that is properly aligned for any stack member. */ |
| 1509 | union yyalloc |
| 1510 | { |
| 1511 | short int yyss; |
| 1512 | YYSTYPE yyvs; |
| 1513 | }; |
| 1514 | |
| 1515 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 1516 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 1517 | |
| 1518 | /* The size of an array large to enough to hold all stacks, each with |
| 1519 | N elements. */ |
| 1520 | # define YYSTACK_BYTES(N) \ |
| 1521 | ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ |
| 1522 | + YYSTACK_GAP_MAXIMUM) |
| 1523 | |
| 1524 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 1525 | not overlap. */ |
| 1526 | # ifndef YYCOPY |
| 1527 | # if defined (__GNUC__) && 1 < __GNUC__ |
| 1528 | # define YYCOPY(To, From, Count) \ |
| 1529 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 1530 | # else |
| 1531 | # define YYCOPY(To, From, Count) \ |
| 1532 | do \ |
| 1533 | { \ |
| 1534 | YYSIZE_T yyi; \ |
| 1535 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 1536 | (To)[yyi] = (From)[yyi]; \ |
| 1537 | } \ |
| 1538 | while (0) |
| 1539 | # endif |
| 1540 | # endif |
| 1541 | |
| 1542 | /* Relocate STACK from its old location to the new one. The |
| 1543 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 1544 | elements in the stack, and YYPTR gives the new location of the |
| 1545 | stack. Advance YYPTR to a properly aligned location for the next |
| 1546 | stack. */ |
| 1547 | # define YYSTACK_RELOCATE(Stack) \ |
| 1548 | do \ |
| 1549 | { \ |
| 1550 | YYSIZE_T yynewbytes; \ |
| 1551 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 1552 | Stack = &yyptr->Stack; \ |
| 1553 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 1554 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 1555 | } \ |
| 1556 | while (0) |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 1557 | |
| 1558 | #endif |
| 1559 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1560 | #if defined (__STDC__) || defined (__cplusplus) |
| 1561 | typedef signed char yysigned_char; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1562 | #else |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1563 | typedef short int yysigned_char; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1564 | #endif |
| 1565 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1566 | /* YYFINAL -- State number of the termination state. */ |
| 1567 | #define YYFINAL 4 |
| 1568 | /* YYLAST -- Last index in YYTABLE. */ |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1569 | #define YYLAST 1410 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1570 | |
| 1571 | /* YYNTOKENS -- Number of terminals. */ |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1572 | #define YYNTOKENS 139 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1573 | /* YYNNTS -- Number of nonterminals. */ |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1574 | #define YYNNTS 76 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1575 | /* YYNRULES -- Number of rules. */ |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1576 | #define YYNRULES 269 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1577 | /* YYNRULES -- Number of states. */ |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1578 | #define YYNSTATES 534 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1579 | |
| 1580 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 1581 | #define YYUNDEFTOK 2 |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1582 | #define YYMAXUTOK 379 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1583 | |
| 1584 | #define YYTRANSLATE(YYX) \ |
| 1585 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 1586 | |
| 1587 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 1588 | static const unsigned char yytranslate[] = |
| 1589 | { |
| 1590 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1591 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1592 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1593 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1594 | 128, 129, 137, 2, 126, 2, 2, 2, 2, 2, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1595 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1596 | 133, 125, 134, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1597 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1598 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1599 | 2, 130, 127, 132, 2, 2, 2, 2, 2, 138, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1600 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1601 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1602 | 131, 2, 2, 135, 2, 136, 2, 2, 2, 2, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1603 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1604 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1605 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1606 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1607 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1608 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1609 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1610 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1611 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1612 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1613 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1614 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1615 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 1616 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 1617 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 1618 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 1619 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 1620 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 1621 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 1622 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 1623 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 1624 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1625 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1626 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 1627 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1628 | }; |
| 1629 | |
| 1630 | #if YYDEBUG |
| 1631 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 1632 | YYRHS. */ |
| 1633 | static const unsigned short int yyprhs[] = |
| 1634 | { |
| 1635 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 1636 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 1637 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 1638 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1639 | 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, |
| 1640 | 99, 101, 104, 105, 107, 109, 111, 113, 115, 117, |
| 1641 | 119, 120, 121, 123, 125, 127, 129, 131, 133, 136, |
| 1642 | 137, 140, 141, 145, 148, 149, 151, 152, 156, 158, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1643 | 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1644 | 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, |
| 1645 | 201, 203, 206, 211, 217, 223, 227, 230, 233, 235, |
| 1646 | 239, 241, 245, 247, 248, 253, 257, 261, 266, 271, |
| 1647 | 275, 278, 281, 284, 287, 290, 293, 296, 299, 302, |
| 1648 | 305, 312, 318, 327, 334, 341, 348, 355, 362, 371, |
| 1649 | 380, 384, 386, 388, 390, 392, 395, 398, 403, 406, |
| 1650 | 408, 413, 416, 421, 422, 430, 431, 439, 440, 448, |
| 1651 | 449, 457, 461, 466, 467, 469, 471, 473, 477, 481, |
| 1652 | 485, 489, 493, 497, 499, 500, 502, 504, 506, 507, |
| 1653 | 510, 514, 516, 518, 522, 524, 525, 534, 536, 538, |
| 1654 | 542, 544, 546, 549, 550, 552, 554, 555, 560, 561, |
| 1655 | 563, 565, 567, 569, 571, 573, 575, 577, 579, 583, |
| 1656 | 585, 591, 593, 595, 597, 599, 602, 605, 608, 612, |
| 1657 | 615, 616, 618, 621, 624, 628, 638, 648, 657, 671, |
| 1658 | 673, 675, 682, 688, 691, 698, 706, 708, 712, 714, |
| 1659 | 715, 718, 720, 726, 732, 738, 741, 746, 751, 758, |
| 1660 | 763, 768, 773, 778, 785, 792, 795, 803, 805, 808, |
| 1661 | 809, 811, 812, 816, 823, 827, 834, 837, 842, 849 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1662 | }; |
| 1663 | |
| 1664 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 1665 | static const short int yyrhs[] = |
| 1666 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1667 | 171, 0, -1, 5, -1, 6, -1, 3, -1, 4, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1668 | -1, 78, -1, 79, -1, 80, -1, 81, -1, 82, |
| 1669 | -1, 83, -1, 84, -1, 85, -1, 86, -1, 87, |
| 1670 | -1, 88, -1, 89, -1, 90, -1, 91, -1, 92, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1671 | -1, 93, -1, 94, -1, 95, -1, 102, -1, 103, |
| 1672 | -1, 104, -1, 105, -1, 106, -1, 107, -1, 108, |
| 1673 | -1, 109, -1, 110, -1, 111, -1, 112, -1, 113, |
| 1674 | -1, 116, -1, 117, -1, 118, -1, 16, -1, 14, |
| 1675 | -1, 12, -1, 10, -1, 17, -1, 15, -1, 13, |
| 1676 | -1, 11, -1, 147, -1, 148, -1, 18, -1, 19, |
| 1677 | -1, 183, 125, -1, -1, 41, -1, 42, -1, 43, |
| 1678 | -1, 44, -1, 45, -1, 46, -1, 47, -1, -1, |
| 1679 | -1, 65, -1, 66, -1, 67, -1, 68, -1, 69, |
| 1680 | -1, 70, -1, 64, 4, -1, -1, 57, 4, -1, |
| 1681 | -1, 126, 57, 4, -1, 34, 24, -1, -1, 156, |
| 1682 | -1, -1, 126, 159, 158, -1, 156, -1, 57, 4, |
| 1683 | -1, 162, -1, 8, -1, 164, -1, 8, -1, 164, |
| 1684 | -1, 9, -1, 10, -1, 11, -1, 12, -1, 13, |
| 1685 | -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, |
| 1686 | -1, 19, -1, 20, -1, 21, -1, 48, -1, 163, |
| 1687 | -1, 198, -1, 127, 4, -1, 161, 128, 166, 129, |
| 1688 | -1, 130, 4, 131, 164, 132, -1, 133, 4, 131, |
| 1689 | 164, 134, -1, 135, 165, 136, -1, 135, 136, -1, |
| 1690 | 164, 137, -1, 164, -1, 165, 126, 164, -1, 165, |
| 1691 | -1, 165, 126, 37, -1, 37, -1, -1, 162, 130, |
| 1692 | 169, 132, -1, 162, 130, 132, -1, 162, 138, 24, |
| 1693 | -1, 162, 133, 169, 134, -1, 162, 135, 169, 136, |
| 1694 | -1, 162, 135, 136, -1, 162, 38, -1, 162, 39, |
| 1695 | -1, 162, 198, -1, 162, 168, -1, 162, 26, -1, |
| 1696 | 147, 141, -1, 148, 4, -1, 9, 27, -1, 9, |
| 1697 | 28, -1, 150, 7, -1, 145, 128, 167, 36, 162, |
| 1698 | 129, -1, 101, 128, 167, 212, 129, -1, 115, 128, |
| 1699 | 167, 126, 167, 126, 167, 129, -1, 142, 128, 167, |
| 1700 | 126, 167, 129, -1, 143, 128, 167, 126, 167, 129, |
| 1701 | -1, 144, 128, 167, 126, 167, 129, -1, 146, 128, |
| 1702 | 167, 126, 167, 129, -1, 120, 128, 167, 126, 167, |
| 1703 | 129, -1, 121, 128, 167, 126, 167, 126, 167, 129, |
| 1704 | -1, 122, 128, 167, 126, 167, 126, 167, 129, -1, |
| 1705 | 169, 126, 167, -1, 167, -1, 32, -1, 33, -1, |
| 1706 | 172, -1, 172, 192, -1, 172, 194, -1, 172, 62, |
| 1707 | 61, 178, -1, 172, 25, -1, 173, -1, 173, 151, |
| 1708 | 20, 160, -1, 173, 194, -1, 173, 62, 61, 178, |
| 1709 | -1, -1, 173, 151, 152, 170, 167, 174, 158, -1, |
| 1710 | -1, 173, 151, 50, 170, 162, 175, 158, -1, -1, |
| 1711 | 173, 151, 45, 170, 162, 176, 158, -1, -1, 173, |
| 1712 | 151, 47, 170, 162, 177, 158, -1, 173, 51, 180, |
| 1713 | -1, 173, 58, 125, 181, -1, -1, 24, -1, 56, |
| 1714 | -1, 55, -1, 53, 125, 179, -1, 54, 125, 4, |
| 1715 | -1, 52, 125, 24, -1, 71, 125, 24, -1, 130, |
| 1716 | 182, 132, -1, 182, 126, 24, -1, 24, -1, -1, |
| 1717 | 22, -1, 24, -1, 183, -1, -1, 162, 184, -1, |
| 1718 | 186, 126, 185, -1, 185, -1, 186, -1, 186, 126, |
| 1719 | 37, -1, 37, -1, -1, 153, 160, 183, 128, 187, |
| 1720 | 129, 157, 154, -1, 29, -1, 135, -1, 152, 188, |
| 1721 | 189, -1, 30, -1, 136, -1, 201, 191, -1, -1, |
| 1722 | 45, -1, 47, -1, -1, 31, 195, 193, 188, -1, |
| 1723 | -1, 63, -1, 3, -1, 4, -1, 7, -1, 27, |
| 1724 | -1, 28, -1, 38, -1, 39, -1, 26, -1, 133, |
| 1725 | 169, 134, -1, 168, -1, 61, 196, 24, 126, 24, |
| 1726 | -1, 140, -1, 183, -1, 198, -1, 197, -1, 162, |
| 1727 | 199, -1, 201, 202, -1, 190, 202, -1, 203, 151, |
| 1728 | 204, -1, 203, 206, -1, -1, 23, -1, 72, 200, |
| 1729 | -1, 72, 8, -1, 73, 21, 199, -1, 73, 9, |
| 1730 | 199, 126, 21, 199, 126, 21, 199, -1, 74, 149, |
| 1731 | 199, 126, 21, 199, 130, 205, 132, -1, 74, 149, |
| 1732 | 199, 126, 21, 199, 130, 132, -1, 75, 153, 160, |
| 1733 | 199, 128, 209, 129, 36, 21, 199, 76, 21, 199, |
| 1734 | -1, 76, -1, 77, -1, 205, 149, 197, 126, 21, |
| 1735 | 199, -1, 149, 197, 126, 21, 199, -1, 151, 211, |
| 1736 | -1, 162, 130, 199, 126, 199, 132, -1, 207, 126, |
| 1737 | 130, 199, 126, 199, 132, -1, 200, -1, 208, 126, |
| 1738 | 200, -1, 208, -1, -1, 60, 59, -1, 59, -1, |
| 1739 | 142, 162, 199, 126, 199, -1, 143, 162, 199, 126, |
| 1740 | 199, -1, 144, 162, 199, 126, 199, -1, 49, 200, |
| 1741 | -1, 146, 200, 126, 200, -1, 145, 200, 36, 162, |
| 1742 | -1, 115, 200, 126, 200, 126, 200, -1, 119, 200, |
| 1743 | 126, 162, -1, 123, 200, 126, 162, -1, 124, 200, |
| 1744 | 126, 162, -1, 120, 200, 126, 200, -1, 121, 200, |
| 1745 | 126, 200, 126, 200, -1, 122, 200, 126, 200, 126, |
| 1746 | 200, -1, 114, 207, -1, 210, 153, 160, 199, 128, |
| 1747 | 209, 129, -1, 214, -1, 126, 208, -1, -1, 35, |
| 1748 | -1, -1, 96, 162, 155, -1, 96, 162, 126, 15, |
| 1749 | 199, 155, -1, 97, 162, 155, -1, 97, 162, 126, |
| 1750 | 15, 199, 155, -1, 98, 200, -1, 213, 99, 162, |
| 1751 | 199, -1, 213, 100, 200, 126, 162, 199, -1, 101, |
| 1752 | 162, 199, 212, -1 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1753 | }; |
| 1754 | |
| 1755 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 1756 | static const unsigned short int yyrline[] = |
| 1757 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1758 | 0, 1168, 1168, 1169, 1177, 1178, 1188, 1188, 1188, 1188, |
| 1759 | 1188, 1188, 1188, 1188, 1188, 1189, 1189, 1189, 1190, 1190, |
| 1760 | 1190, 1190, 1190, 1190, 1191, 1191, 1191, 1191, 1191, 1191, |
| 1761 | 1192, 1192, 1192, 1192, 1192, 1192, 1193, 1193, 1193, 1197, |
| 1762 | 1197, 1197, 1197, 1198, 1198, 1198, 1198, 1199, 1199, 1200, |
| 1763 | 1200, 1203, 1207, 1212, 1213, 1214, 1215, 1216, 1217, 1218, |
| 1764 | 1219, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1237, |
| 1765 | 1238, 1244, 1245, 1253, 1261, 1262, 1267, 1268, 1269, 1274, |
| 1766 | 1288, 1288, 1292, 1292, 1297, 1308, 1308, 1308, 1308, 1308, |
| 1767 | 1308, 1308, 1309, 1309, 1309, 1309, 1309, 1309, 1310, 1315, |
| 1768 | 1319, 1328, 1337, 1352, 1359, 1373, 1384, 1389, 1401, 1406, |
| 1769 | 1412, 1413, 1419, 1425, 1436, 1462, 1476, 1506, 1532, 1553, |
| 1770 | 1566, 1576, 1581, 1642, 1649, 1658, 1664, 1670, 1674, 1678, |
| 1771 | 1686, 1712, 1744, 1752, 1779, 1790, 1796, 1807, 1813, 1819, |
| 1772 | 1828, 1832, 1840, 1840, 1850, 1858, 1863, 1867, 1871, 1875, |
| 1773 | 1890, 1912, 1915, 1918, 1918, 1926, 1926, 1935, 1935, 1944, |
| 1774 | 1944, 1954, 1957, 1960, 1964, 1977, 1978, 1980, 1984, 1993, |
| 1775 | 1997, 2002, 2004, 2009, 2014, 2023, 2023, 2024, 2024, 2026, |
| 1776 | 2033, 2039, 2046, 2050, 2058, 2066, 2071, 2165, 2165, 2167, |
| 1777 | 2175, 2175, 2177, 2182, 2183, 2184, 2186, 2186, 2196, 2200, |
| 1778 | 2205, 2209, 2213, 2217, 2221, 2225, 2229, 2233, 2237, 2257, |
| 1779 | 2261, 2275, 2279, 2285, 2285, 2291, 2296, 2300, 2309, 2320, |
| 1780 | 2329, 2341, 2354, 2358, 2362, 2367, 2376, 2395, 2404, 2460, |
| 1781 | 2464, 2471, 2482, 2495, 2504, 2513, 2523, 2527, 2534, 2534, |
| 1782 | 2536, 2540, 2545, 2567, 2582, 2596, 2609, 2620, 2646, 2654, |
| 1783 | 2660, 2680, 2703, 2709, 2715, 2721, 2736, 2796, 2803, 2806, |
| 1784 | 2811, 2815, 2822, 2827, 2833, 2838, 2844, 2852, 2864, 2879 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1785 | }; |
| 1786 | #endif |
| 1787 | |
| 1788 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
| 1789 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 1790 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 1791 | static const char *const yytname[] = |
| 1792 | { |
| 1793 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", |
| 1794 | "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT", |
| 1795 | "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL", |
| 1796 | "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION", |
| 1797 | "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", |
| 1798 | "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", |
| 1799 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE", |
| 1800 | "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 1801 | "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", |
| 1802 | "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", |
| 1803 | "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", |
| 1804 | "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", |
| 1805 | "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", |
| 1806 | "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR", |
| 1807 | "XOR", "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "MALLOC", |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1808 | "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", |
| 1809 | "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", |
| 1810 | "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK", "SELECT", "SHL", "LSHR", |
| 1811 | "ASHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", |
| 1812 | "VAARG_old", "VANEXT_old", "'='", "','", "'\\\\'", "'('", "')'", "'['", |
| 1813 | "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept", |
| 1814 | "INTVAL", "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps", |
| 1815 | "CastOps", "ShiftOps", "SIntType", "UIntType", "IntType", "FPType", |
| 1816 | "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign", "OptCAlign", |
| 1817 | "SectionString", "OptSection", "GlobalVarAttributes", |
| 1818 | "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType", |
| 1819 | "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr", |
| 1820 | "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1", |
| 1821 | "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition", |
| 1822 | "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal", |
| 1823 | "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", |
| 1824 | "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5", |
| 1825 | "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef", |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1826 | "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList", |
| 1827 | "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ValueRefList", |
| 1828 | "ValueRefListE", "OptTailCall", "InstVal", "IndexList", "OptVolatile", |
| 1829 | "MemoryInst", 0 |
| 1830 | }; |
| 1831 | #endif |
| 1832 | |
| 1833 | # ifdef YYPRINT |
| 1834 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 1835 | token YYLEX-NUM. */ |
| 1836 | static const unsigned short int yytoknum[] = |
| 1837 | { |
| 1838 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 1839 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 1840 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 1841 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 1842 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 1843 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 1844 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 1845 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 1846 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 1847 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
| 1848 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1849 | 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, |
| 1850 | 375, 376, 377, 378, 379, 61, 44, 92, 40, 41, |
| 1851 | 91, 120, 93, 60, 62, 123, 125, 42, 99 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1852 | }; |
| 1853 | # endif |
| 1854 | |
| 1855 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 1856 | static const unsigned char yyr1[] = |
| 1857 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1858 | 0, 139, 140, 140, 141, 141, 142, 142, 142, 142, |
| 1859 | 142, 142, 142, 142, 142, 143, 143, 143, 144, 144, |
| 1860 | 144, 144, 144, 144, 145, 145, 145, 145, 145, 145, |
| 1861 | 145, 145, 145, 145, 145, 145, 146, 146, 146, 147, |
| 1862 | 147, 147, 147, 148, 148, 148, 148, 149, 149, 150, |
| 1863 | 150, 151, 151, 152, 152, 152, 152, 152, 152, 152, |
| 1864 | 152, 153, 153, 153, 153, 153, 153, 153, 153, 154, |
| 1865 | 154, 155, 155, 156, 157, 157, 158, 158, 159, 159, |
| 1866 | 160, 160, 161, 161, 162, 163, 163, 163, 163, 163, |
| 1867 | 163, 163, 163, 163, 163, 163, 163, 163, 164, 164, |
| 1868 | 164, 164, 164, 164, 164, 164, 164, 164, 165, 165, |
| 1869 | 166, 166, 166, 166, 167, 167, 167, 167, 167, 167, |
| 1870 | 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, |
| 1871 | 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, |
| 1872 | 169, 169, 170, 170, 171, 172, 172, 172, 172, 172, |
| 1873 | 173, 173, 173, 174, 173, 175, 173, 176, 173, 177, |
| 1874 | 173, 173, 173, 173, 178, 179, 179, 180, 180, 180, |
| 1875 | 180, 181, 182, 182, 182, 183, 183, 184, 184, 185, |
| 1876 | 186, 186, 187, 187, 187, 187, 188, 189, 189, 190, |
| 1877 | 191, 191, 192, 193, 193, 193, 195, 194, 196, 196, |
| 1878 | 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, |
| 1879 | 197, 198, 198, 199, 199, 200, 201, 201, 202, 203, |
| 1880 | 203, 203, 204, 204, 204, 204, 204, 204, 204, 204, |
| 1881 | 204, 205, 205, 206, 207, 207, 208, 208, 209, 209, |
| 1882 | 210, 210, 211, 211, 211, 211, 211, 211, 211, 211, |
| 1883 | 211, 211, 211, 211, 211, 211, 211, 211, 212, 212, |
| 1884 | 213, 213, 214, 214, 214, 214, 214, 214, 214, 214 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1885 | }; |
| 1886 | |
| 1887 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 1888 | static const unsigned char yyr2[] = |
| 1889 | { |
| 1890 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1891 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1892 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1893 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1894 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1895 | 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, |
| 1896 | 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, |
| 1897 | 2, 0, 3, 2, 0, 1, 0, 3, 1, 2, |
| 1898 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1899 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1900 | 1, 2, 4, 5, 5, 3, 2, 2, 1, 3, |
| 1901 | 1, 3, 1, 0, 4, 3, 3, 4, 4, 3, |
| 1902 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1903 | 6, 5, 8, 6, 6, 6, 6, 6, 8, 8, |
| 1904 | 3, 1, 1, 1, 1, 2, 2, 4, 2, 1, |
| 1905 | 4, 2, 4, 0, 7, 0, 7, 0, 7, 0, |
| 1906 | 7, 3, 4, 0, 1, 1, 1, 3, 3, 3, |
| 1907 | 3, 3, 3, 1, 0, 1, 1, 1, 0, 2, |
| 1908 | 3, 1, 1, 3, 1, 0, 8, 1, 1, 3, |
| 1909 | 1, 1, 2, 0, 1, 1, 0, 4, 0, 1, |
| 1910 | 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, |
| 1911 | 5, 1, 1, 1, 1, 2, 2, 2, 3, 2, |
| 1912 | 0, 1, 2, 2, 3, 9, 9, 8, 13, 1, |
| 1913 | 1, 6, 5, 2, 6, 7, 1, 3, 1, 0, |
| 1914 | 2, 1, 5, 5, 5, 2, 4, 4, 6, 4, |
| 1915 | 4, 4, 4, 6, 6, 2, 7, 1, 2, 0, |
| 1916 | 1, 0, 3, 6, 3, 6, 2, 4, 6, 4 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1917 | }; |
| 1918 | |
| 1919 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 1920 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 1921 | means the default is an error. */ |
| 1922 | static const unsigned short int yydefact[] = |
| 1923 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1924 | 163, 0, 60, 149, 1, 148, 196, 53, 54, 55, |
| 1925 | 56, 57, 58, 59, 0, 61, 220, 145, 146, 220, |
| 1926 | 175, 176, 0, 0, 0, 60, 0, 151, 193, 0, |
| 1927 | 0, 62, 63, 64, 65, 66, 67, 0, 0, 221, |
| 1928 | 217, 52, 190, 191, 192, 216, 0, 0, 0, 0, |
| 1929 | 161, 0, 0, 0, 0, 0, 0, 0, 51, 194, |
| 1930 | 195, 61, 164, 147, 68, 2, 3, 81, 85, 86, |
| 1931 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 1932 | 97, 98, 0, 0, 0, 0, 211, 0, 0, 80, |
| 1933 | 99, 84, 212, 100, 187, 188, 189, 261, 219, 0, |
| 1934 | 0, 0, 0, 174, 162, 152, 150, 142, 143, 0, |
| 1935 | 0, 0, 0, 197, 101, 0, 0, 83, 106, 108, |
| 1936 | 0, 0, 113, 107, 260, 0, 241, 0, 0, 0, |
| 1937 | 0, 61, 229, 230, 6, 7, 8, 9, 10, 11, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1938 | 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1939 | 22, 23, 0, 0, 0, 0, 24, 25, 26, 27, |
| 1940 | 28, 29, 30, 31, 32, 33, 34, 35, 0, 0, |
| 1941 | 36, 37, 38, 0, 0, 0, 0, 0, 0, 0, |
| 1942 | 0, 0, 0, 0, 218, 61, 233, 0, 257, 169, |
| 1943 | 166, 165, 167, 168, 170, 173, 0, 157, 159, 155, |
| 1944 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1945 | 95, 0, 0, 0, 0, 153, 0, 0, 0, 105, |
| 1946 | 185, 112, 110, 0, 0, 245, 240, 223, 222, 0, |
| 1947 | 0, 42, 46, 41, 45, 40, 44, 39, 43, 47, |
| 1948 | 48, 0, 0, 71, 71, 266, 0, 0, 255, 0, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1949 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1950 | 0, 0, 0, 0, 0, 171, 76, 76, 76, 127, |
| 1951 | 128, 4, 5, 125, 126, 129, 124, 120, 121, 0, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1952 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1953 | 0, 0, 0, 123, 122, 76, 82, 82, 109, 184, |
| 1954 | 178, 181, 182, 0, 0, 102, 200, 201, 202, 207, |
| 1955 | 203, 204, 205, 206, 198, 0, 209, 214, 213, 215, |
| 1956 | 0, 224, 0, 0, 0, 262, 0, 264, 259, 0, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1957 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1958 | 0, 0, 0, 0, 0, 0, 172, 0, 158, 160, |
| 1959 | 156, 0, 0, 0, 0, 0, 115, 141, 0, 0, |
| 1960 | 119, 0, 116, 0, 0, 0, 0, 0, 154, 103, |
| 1961 | 104, 177, 179, 0, 74, 111, 199, 0, 0, 0, |
| 1962 | 0, 0, 0, 0, 0, 0, 269, 0, 0, 0, |
| 1963 | 249, 252, 0, 0, 250, 251, 0, 0, 0, 247, |
| 1964 | 246, 0, 267, 0, 0, 0, 78, 76, 259, 0, |
| 1965 | 0, 0, 0, 0, 114, 117, 118, 0, 0, 0, |
| 1966 | 0, 0, 183, 180, 75, 69, 0, 208, 0, 0, |
| 1967 | 239, 71, 72, 71, 236, 258, 0, 0, 0, 0, |
| 1968 | 0, 242, 243, 244, 239, 0, 73, 79, 77, 0, |
| 1969 | 0, 0, 0, 0, 140, 0, 0, 0, 0, 0, |
| 1970 | 0, 186, 0, 0, 0, 238, 0, 0, 263, 265, |
| 1971 | 0, 0, 0, 248, 253, 254, 0, 268, 131, 0, |
| 1972 | 0, 0, 0, 0, 0, 0, 0, 0, 70, 210, |
| 1973 | 0, 0, 0, 237, 234, 0, 256, 0, 137, 0, |
| 1974 | 0, 133, 134, 135, 130, 136, 0, 227, 0, 0, |
| 1975 | 0, 235, 0, 0, 0, 225, 0, 226, 0, 0, |
| 1976 | 132, 138, 139, 0, 0, 0, 0, 0, 0, 232, |
| 1977 | 0, 0, 231, 228 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1978 | }; |
| 1979 | |
| 1980 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 1981 | static const short int yydefgoto[] = |
| 1982 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1983 | -1, 86, 273, 288, 289, 290, 291, 292, 211, 212, |
| 1984 | 241, 213, 25, 15, 37, 461, 325, 406, 425, 348, |
| 1985 | 407, 87, 88, 214, 90, 91, 120, 223, 357, 316, |
| 1986 | 358, 109, 1, 2, 3, 295, 268, 266, 267, 63, |
| 1987 | 192, 50, 104, 196, 92, 372, 301, 302, 303, 38, |
| 1988 | 96, 16, 44, 17, 61, 18, 28, 377, 317, 93, |
| 1989 | 319, 434, 19, 40, 41, 184, 509, 98, 248, 465, |
| 1990 | 466, 185, 186, 386, 187, 188 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1991 | }; |
| 1992 | |
| 1993 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 1994 | STATE-NUM. */ |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1995 | #define YYPACT_NINF -472 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 1996 | static const short int yypact[] = |
| 1997 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 1998 | -472, 24, 395, 501, -472, -472, -472, -472, -472, -472, |
| 1999 | -472, -472, -472, -472, -13, 112, 46, -472, -472, -11, |
| 2000 | -472, -472, -18, -41, 45, 51, -1, -472, 40, 106, |
| 2001 | 131, -472, -472, -472, -472, -472, -472, 1136, -23, -472, |
| 2002 | -472, 81, -472, -472, -472, -472, 30, 33, 49, 61, |
| 2003 | -472, 57, 106, 1136, 78, 78, 78, 78, -472, -472, |
| 2004 | -472, 112, -472, -472, -472, -472, -472, 62, -472, -472, |
| 2005 | -472, -472, -472, -472, -472, -472, -472, -472, -472, -472, |
| 2006 | -472, -472, 185, 187, 188, 619, -472, 81, 67, -472, |
| 2007 | -472, -71, -472, -472, -472, -472, -472, 1286, -472, 174, |
| 2008 | 58, 196, 177, 178, -472, -472, -472, -472, -472, 1177, |
| 2009 | 1177, 1177, 1197, -472, -472, 72, 73, -472, -472, -71, |
| 2010 | -89, 79, 151, -472, -472, 1177, -472, 147, 1222, 12, |
| 2011 | 218, 112, -472, -472, -472, -472, -472, -472, -472, -472, |
| 2012 | -472, -472, -472, -472, -472, -472, -472, -472, -472, -472, |
| 2013 | -472, -472, 1177, 1177, 1177, 1177, -472, -472, -472, -472, |
| 2014 | -472, -472, -472, -472, -472, -472, -472, -472, 1177, 1177, |
| 2015 | -472, -472, -472, 1177, 1177, 1177, 1177, 1177, 1177, 1177, |
| 2016 | 1177, 1177, 1177, 1177, -472, 112, -472, -55, -472, -472, |
| 2017 | -472, -472, -472, -472, -472, -472, -62, -472, -472, -472, |
| 2018 | 95, 123, 204, 125, 205, 130, 206, 149, 207, 208, |
| 2019 | 210, 181, 209, 214, 488, -472, 1177, 1177, 1177, -472, |
| 2020 | 944, -472, 88, 93, 698, -472, -472, 62, -472, 698, |
| 2021 | 698, -472, -472, -472, -472, -472, -472, -472, -472, -472, |
| 2022 | -472, 698, 1136, 97, 110, -472, 698, 108, 113, 114, |
| 2023 | 120, 121, 124, 126, 133, 136, 698, 698, 698, 213, |
| 2024 | 139, 1136, 1177, 1177, 227, -472, 140, 140, 140, -472, |
| 2025 | -472, -472, -472, -472, -472, -472, -472, -472, -472, 141, |
| 2026 | 142, 143, 145, 146, 985, 1197, 639, 243, 148, 154, |
| 2027 | 155, 157, 165, -472, -472, 140, -28, -51, -71, -472, |
| 2028 | 81, -472, 153, 172, 1005, -472, -472, -472, -472, -472, |
| 2029 | -472, -472, -472, -472, 244, 1197, -472, -472, -472, -472, |
| 2030 | 180, -472, 182, 698, -7, -472, -6, -472, 183, 698, |
| 2031 | 138, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 184, 186, |
| 2032 | 189, 1177, 1177, 698, 698, 190, -472, -17, -472, -472, |
| 2033 | -472, 1197, 1197, 1197, 1197, 1197, -472, -472, -24, -85, |
| 2034 | -472, -80, -472, 1197, 1197, 1197, 1197, 1197, -472, -472, |
| 2035 | -472, -472, -472, 1046, 277, -472, -472, 289, -27, 293, |
| 2036 | 296, 191, 698, 314, 698, 1177, -472, 194, 698, 195, |
| 2037 | -472, -472, 200, 201, -472, -472, 698, 698, 698, -472, |
| 2038 | -472, 202, -472, 1177, 298, 324, -472, 140, 183, 203, |
| 2039 | 211, 212, 224, 1197, -472, -472, -472, 225, 226, 230, |
| 2040 | 295, 232, -472, -472, -472, 275, 233, -472, 698, 698, |
| 2041 | 1177, 235, -472, 235, -472, 239, 698, 241, 1177, 1177, |
| 2042 | 1177, -472, -472, -472, 1177, 698, -472, -472, -472, 215, |
| 2043 | 1197, 1197, 1197, 1197, -472, 1197, 1197, 1197, 1177, 1197, |
| 2044 | 329, -472, 310, 242, 223, 239, 240, 278, -472, -472, |
| 2045 | 1177, 238, 698, -472, -472, -472, 247, -472, -472, 245, |
| 2046 | 250, 246, 255, 254, 256, 257, 259, 262, -472, -472, |
| 2047 | 318, 15, 337, -472, -472, 252, -472, 1197, -472, 1197, |
| 2048 | 1197, -472, -472, -472, -472, -472, 698, -472, 818, 65, |
| 2049 | 371, -472, 265, 267, 268, -472, 272, -472, 818, 698, |
| 2050 | -472, -472, -472, 378, 274, 328, 698, 384, 385, -472, |
| 2051 | 698, 698, -472, -472 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2052 | }; |
| 2053 | |
| 2054 | /* YYPGOTO[NTERM-NUM]. */ |
| 2055 | static const short int yypgoto[] = |
| 2056 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2057 | -472, -472, -472, 311, 312, 313, 315, 317, -129, -127, |
| 2058 | -471, -472, 370, 392, -120, -472, -237, 50, -472, -253, |
| 2059 | -472, -49, -472, -37, -472, -67, 301, -472, -110, 220, |
| 2060 | -263, 64, -472, -472, -472, -472, -472, -472, -472, 373, |
| 2061 | -472, -472, -472, -472, 2, -472, 70, -472, -472, 374, |
| 2062 | -472, -472, -472, -472, -472, 441, -472, -472, -418, 34, |
| 2063 | 31, -115, -472, 426, -472, -472, -472, -472, -472, 63, |
| 2064 | 3, -472, -472, 38, -472, -472 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2065 | }; |
| 2066 | |
| 2067 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 2068 | positive, shift that token. If negative, reduce the rule which |
| 2069 | number is the opposite. If zero, do what YYDEFACT says. |
| 2070 | If YYTABLE_NINF, syntax error. */ |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2071 | #define YYTABLE_NINF -145 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2072 | static const short int yytable[] = |
| 2073 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2074 | 89, 239, 215, 240, 106, 26, 94, 327, 382, 384, |
| 2075 | 225, 242, 39, 228, 349, 350, 89, 404, 119, 42, |
| 2076 | 508, 229, 359, 361, 4, 231, 232, 233, 234, 235, |
| 2077 | 236, 237, 238, 230, 46, 47, 48, 218, 518, 245, |
| 2078 | 405, 413, 368, 26, 262, 263, 413, 219, 29, 415, |
| 2079 | 383, 383, 378, 49, 249, 119, 416, -82, 250, 251, |
| 2080 | 252, 253, 254, 255, 264, 261, 123, 259, 260, 39, |
| 2081 | 265, 53, 197, 198, 199, 231, 232, 233, 234, 235, |
| 2082 | 236, 237, 238, 370, 51, 59, 123, 60, 224, 121, |
| 2083 | 516, 224, 7, 8, 9, 10, 54, 12, 55, 413, |
| 2084 | 524, 56, 413, 20, 369, 21, 52, 427, 414, 123, |
| 2085 | 107, 108, 95, 190, 191, 243, 244, 224, 246, 110, |
| 2086 | 111, 112, 269, 270, 58, 43, -42, -42, -41, -41, |
| 2087 | 62, 247, 224, -40, -40, 64, 224, 224, 224, 224, |
| 2088 | 224, 224, 256, 257, 258, 224, 224, 507, 345, 296, |
| 2089 | 297, 298, -39, -39, 448, 99, 65, 66, 100, 117, |
| 2090 | 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 2091 | 78, 79, 80, 20, 101, 21, 30, 31, 32, 33, |
| 2092 | 34, 35, 36, 300, 271, 272, 102, 103, 221, 114, |
| 2093 | -83, 115, 116, 323, 468, 122, 469, 517, 189, 81, |
| 2094 | 193, 194, 195, 216, 217, 89, 226, 220, -46, -45, |
| 2095 | -44, -43, 343, 274, 304, -49, 389, -50, 391, 392, |
| 2096 | 393, 275, 305, 324, 89, 344, 224, 400, 231, 232, |
| 2097 | 233, 234, 235, 236, 237, 238, 326, 298, 329, 330, |
| 2098 | 331, 408, 409, 410, 411, 412, 332, 333, 294, 341, |
| 2099 | 334, 346, 335, 417, 418, 419, 420, 421, 318, 336, |
| 2100 | 320, 321, 337, 318, 318, 342, 347, 362, 388, 351, |
| 2101 | 352, 353, 322, 354, 355, 318, 363, 328, 82, 373, |
| 2102 | 318, 83, 364, 365, 84, 366, 85, 338, 339, 340, |
| 2103 | 318, 318, 318, 367, 224, 390, 224, 224, 224, 394, |
| 2104 | 395, 374, 371, 454, 399, 224, 379, 376, 380, 385, |
| 2105 | 396, 404, 397, 426, 428, 398, 403, 429, 432, 430, |
| 2106 | 436, 438, 446, 473, 474, 475, 439, 440, 447, 450, |
| 2107 | 444, 458, 460, 488, 489, 383, 300, 451, 452, 506, |
| 2108 | 479, 480, 481, 482, 478, 483, 484, 485, 224, 487, |
| 2109 | 453, 455, 456, 491, 381, 493, 457, 318, 459, 462, |
| 2110 | 387, 467, 239, 318, 240, 470, 445, 472, 490, 492, |
| 2111 | 494, 497, 499, 510, 401, 402, 496, 318, 318, 498, |
| 2112 | 239, 500, 240, 501, 511, 502, 503, 512, 504, 513, |
| 2113 | 514, 505, 519, 224, 520, -144, 521, 522, 523, 526, |
| 2114 | 527, 224, 224, 224, 528, 530, 531, 224, 179, 180, |
| 2115 | 181, 97, 182, 431, 183, 433, 318, 57, 318, 437, |
| 2116 | 5, 486, 318, 222, 424, 105, 6, 441, 442, 443, |
| 2117 | 318, 318, 318, 224, 293, 113, 7, 8, 9, 10, |
| 2118 | 11, 12, 13, 423, 27, 45, 449, 476, 435, 0, |
| 2119 | 0, 0, 0, 0, 0, 0, 0, 14, 0, 463, |
| 2120 | 464, 0, 318, 318, 0, 0, 0, 471, 0, 0, |
| 2121 | 318, 0, 0, 0, 0, 0, 477, 0, 0, 318, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2122 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2123 | 0, 0, 0, 65, 66, 0, 0, 0, 0, 0, |
| 2124 | 0, 0, 0, 495, 0, 0, 318, 0, 0, 0, |
| 2125 | 20, 0, 21, 0, 276, 0, 0, 0, 0, 0, |
| 2126 | 0, -52, 0, 20, 0, 21, 277, 278, 0, 0, |
| 2127 | 0, 0, 6, -52, -52, 0, 0, 515, 0, 0, |
| 2128 | 318, 0, -52, -52, -52, -52, -52, -52, -52, 0, |
| 2129 | 525, -52, 22, 318, 0, 0, 0, 529, 0, 23, |
| 2130 | 318, 532, 533, 24, 318, 318, 134, 135, 136, 137, |
| 2131 | 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, |
| 2132 | 148, 149, 150, 151, 0, 0, 0, 0, 0, 279, |
| 2133 | 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, |
| 2134 | 166, 167, 0, 280, 170, 171, 172, 0, 281, 282, |
| 2135 | 283, 0, 0, 0, 0, 0, 0, 0, 284, 0, |
| 2136 | 0, 285, 0, 286, 65, 66, 287, 117, 68, 69, |
| 2137 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 2138 | 80, 20, 0, 21, 65, 66, 0, 117, 200, 201, |
| 2139 | 202, 203, 204, 205, 206, 207, 208, 209, 210, 79, |
| 2140 | 80, 20, 0, 21, 0, 0, 0, 81, 0, 0, |
| 2141 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2142 | 0, 0, 0, 0, 0, 0, 0, 81, 0, 0, |
| 2143 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2144 | 0, 306, 307, 65, 66, 308, 0, 0, 0, 0, |
| 2145 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2146 | 20, 0, 21, 0, 309, 310, 311, 0, 0, 0, |
| 2147 | 0, 0, 0, 0, 0, 0, 312, 313, 0, 0, |
| 2148 | 0, 0, 0, 0, 0, 0, 82, 0, 0, 83, |
| 2149 | 0, 0, 84, 0, 85, 118, 0, 0, 0, 314, |
| 2150 | 0, 0, 0, 0, 0, 0, 82, 0, 0, 83, |
| 2151 | 0, 0, 84, 0, 85, 360, 134, 135, 136, 137, |
| 2152 | 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, |
| 2153 | 148, 149, 150, 151, 0, 0, 0, 0, 0, 279, |
| 2154 | 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, |
| 2155 | 166, 167, 0, 280, 170, 171, 172, 0, 281, 282, |
| 2156 | 283, 306, 307, 0, 0, 308, 0, 0, 0, 0, |
| 2157 | 0, 315, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2158 | 0, 0, 0, 0, 309, 310, 311, 0, 0, 0, |
| 2159 | 0, 0, 0, 0, 0, 0, 312, 313, 0, 0, |
| 2160 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2161 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 314, |
| 2162 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2163 | 0, 0, 0, 0, 0, 0, 134, 135, 136, 137, |
| 2164 | 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2165 | 148, 149, 150, 151, 0, 0, 0, 0, 0, 279, |
| 2166 | 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, |
| 2167 | 166, 167, 0, 280, 170, 171, 172, 0, 281, 282, |
| 2168 | 283, 0, 0, 0, 0, 0, 0, 0, 0, 65, |
| 2169 | 66, 315, 117, 68, 69, 70, 71, 72, 73, 74, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2170 | 75, 76, 77, 78, 79, 80, 20, 0, 21, 0, |
| 2171 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2172 | 0, 299, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2173 | 65, 66, 81, 117, 200, 201, 202, 203, 204, 205, |
| 2174 | 206, 207, 208, 209, 210, 79, 80, 20, 0, 21, |
| 2175 | 65, 66, 0, 117, 68, 69, 70, 71, 72, 73, |
| 2176 | 74, 75, 76, 77, 78, 79, 80, 20, 0, 21, |
| 2177 | 0, 0, 0, 81, 0, 0, 0, 0, 0, 0, |
| 2178 | 0, 0, 375, 0, 0, 0, 0, 0, 0, 0, |
| 2179 | 0, 65, 66, 81, 117, 68, 69, 70, 71, 72, |
| 2180 | 73, 74, 75, 76, 77, 78, 79, 80, 20, 0, |
| 2181 | 21, 82, 0, 0, 83, 0, 0, 84, 0, 85, |
| 2182 | 0, 0, 0, 422, 0, 0, 0, 0, 0, 0, |
| 2183 | 0, 0, 0, 0, 81, 0, 0, 0, 0, 0, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2184 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2185 | 0, 0, 82, 0, 0, 83, 0, 356, 84, 0, |
| 2186 | 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2187 | 0, 0, 82, 0, 0, 83, 0, 0, 84, 0, |
| 2188 | 85, 65, 66, 0, 67, 68, 69, 70, 71, 72, |
| 2189 | 73, 74, 75, 76, 77, 78, 79, 80, 20, 0, |
| 2190 | 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2191 | 0, 0, 0, 82, 0, 0, 83, 0, 0, 84, |
| 2192 | 0, 85, 65, 66, 81, 117, 68, 69, 70, 71, |
| 2193 | 72, 73, 74, 75, 76, 77, 78, 79, 80, 20, |
| 2194 | 0, 21, 65, 66, 0, 117, 200, 201, 202, 203, |
| 2195 | 204, 205, 206, 207, 208, 209, 210, 79, 80, 20, |
| 2196 | 0, 21, 0, 0, 0, 81, 0, 65, 66, 0, |
| 2197 | 227, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 2198 | 77, 78, 79, 80, 20, 81, 21, 0, 0, 0, |
| 2199 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2200 | 0, 0, 0, 82, 0, 0, 83, 0, 0, 84, |
| 2201 | 81, 85, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2202 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2203 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2204 | 0, 0, 0, 0, 82, 0, 0, 83, 0, 0, |
| 2205 | 84, 0, 85, 0, 0, 0, 0, 0, 0, 0, |
| 2206 | 0, 124, 0, 0, 82, 0, 0, 83, 0, 0, |
| 2207 | 84, 0, 85, 0, 0, 125, 0, 0, 0, 0, |
| 2208 | 0, 0, 0, 0, 0, 126, 127, 0, 0, 82, |
| 2209 | 0, 0, 83, 0, 0, 84, 0, 85, 128, 129, |
| 2210 | 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, |
| 2211 | 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, |
| 2212 | 150, 151, 152, 153, 154, 0, 0, 155, 156, 157, |
| 2213 | 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, |
| 2214 | 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, |
| 2215 | 178 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2216 | }; |
| 2217 | |
| 2218 | static const short int yycheck[] = |
| 2219 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2220 | 37, 130, 112, 130, 53, 3, 29, 244, 15, 15, |
| 2221 | 125, 131, 23, 128, 267, 268, 53, 34, 85, 30, |
| 2222 | 491, 9, 285, 286, 0, 10, 11, 12, 13, 14, |
| 2223 | 15, 16, 17, 21, 52, 53, 54, 126, 509, 154, |
| 2224 | 57, 126, 295, 41, 99, 100, 126, 136, 61, 134, |
| 2225 | 57, 57, 315, 71, 169, 122, 136, 128, 173, 174, |
| 2226 | 175, 176, 177, 178, 126, 185, 137, 182, 183, 23, |
| 2227 | 132, 20, 109, 110, 111, 10, 11, 12, 13, 14, |
| 2228 | 15, 16, 17, 134, 125, 45, 137, 47, 125, 87, |
| 2229 | 508, 128, 41, 42, 43, 44, 45, 46, 47, 126, |
| 2230 | 518, 50, 126, 22, 132, 24, 61, 134, 132, 137, |
| 2231 | 32, 33, 135, 55, 56, 152, 153, 154, 155, 55, |
| 2232 | 56, 57, 27, 28, 125, 136, 3, 4, 3, 4, |
| 2233 | 24, 168, 169, 3, 4, 4, 173, 174, 175, 176, |
| 2234 | 177, 178, 179, 180, 181, 182, 183, 132, 263, 216, |
| 2235 | 217, 218, 3, 4, 407, 125, 5, 6, 125, 8, |
| 2236 | 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |
| 2237 | 19, 20, 21, 22, 125, 24, 64, 65, 66, 67, |
| 2238 | 68, 69, 70, 220, 3, 4, 125, 130, 37, 4, |
| 2239 | 128, 4, 4, 242, 431, 128, 433, 132, 24, 48, |
| 2240 | 4, 24, 24, 131, 131, 242, 59, 128, 4, 4, |
| 2241 | 4, 4, 261, 4, 126, 7, 331, 7, 333, 334, |
| 2242 | 335, 7, 129, 126, 261, 262, 263, 342, 10, 11, |
| 2243 | 12, 13, 14, 15, 16, 17, 126, 304, 130, 126, |
| 2244 | 126, 351, 352, 353, 354, 355, 126, 126, 214, 36, |
| 2245 | 126, 24, 126, 363, 364, 365, 366, 367, 224, 126, |
| 2246 | 229, 230, 126, 229, 230, 126, 126, 24, 130, 128, |
| 2247 | 128, 128, 241, 128, 128, 241, 128, 246, 127, 126, |
| 2248 | 246, 130, 128, 128, 133, 128, 135, 256, 257, 258, |
| 2249 | 256, 257, 258, 128, 331, 332, 333, 334, 335, 336, |
| 2250 | 337, 129, 300, 413, 341, 342, 126, 63, 126, 126, |
| 2251 | 126, 34, 126, 24, 21, 126, 126, 21, 4, 128, |
| 2252 | 126, 126, 24, 438, 439, 440, 126, 126, 4, 126, |
| 2253 | 128, 36, 57, 4, 24, 57, 373, 126, 126, 21, |
| 2254 | 450, 451, 452, 453, 129, 455, 456, 457, 385, 459, |
| 2255 | 126, 126, 126, 130, 323, 470, 126, 323, 126, 126, |
| 2256 | 329, 126, 491, 329, 491, 126, 403, 126, 126, 129, |
| 2257 | 132, 126, 126, 36, 343, 344, 129, 343, 344, 129, |
| 2258 | 509, 126, 509, 129, 132, 129, 129, 497, 129, 499, |
| 2259 | 500, 129, 21, 430, 129, 0, 129, 129, 126, 21, |
| 2260 | 126, 438, 439, 440, 76, 21, 21, 444, 97, 97, |
| 2261 | 97, 41, 97, 382, 97, 384, 382, 25, 384, 388, |
| 2262 | 25, 458, 388, 122, 374, 52, 31, 396, 397, 398, |
| 2263 | 396, 397, 398, 470, 214, 61, 41, 42, 43, 44, |
| 2264 | 45, 46, 47, 373, 3, 19, 408, 444, 385, -1, |
| 2265 | -1, -1, -1, -1, -1, -1, -1, 62, -1, 428, |
| 2266 | 429, -1, 428, 429, -1, -1, -1, 436, -1, -1, |
| 2267 | 436, -1, -1, -1, -1, -1, 445, -1, -1, 445, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2268 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2269 | -1, -1, -1, 5, 6, -1, -1, -1, -1, -1, |
| 2270 | -1, -1, -1, 472, -1, -1, 472, -1, -1, -1, |
| 2271 | 22, -1, 24, -1, 26, -1, -1, -1, -1, -1, |
| 2272 | -1, 20, -1, 22, -1, 24, 38, 39, -1, -1, |
| 2273 | -1, -1, 31, 32, 33, -1, -1, 506, -1, -1, |
| 2274 | 506, -1, 41, 42, 43, 44, 45, 46, 47, -1, |
| 2275 | 519, 50, 51, 519, -1, -1, -1, 526, -1, 58, |
| 2276 | 526, 530, 531, 62, 530, 531, 78, 79, 80, 81, |
| 2277 | 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, |
| 2278 | 92, 93, 94, 95, -1, -1, -1, -1, -1, 101, |
| 2279 | 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 2280 | 112, 113, -1, 115, 116, 117, 118, -1, 120, 121, |
| 2281 | 122, -1, -1, -1, -1, -1, -1, -1, 130, -1, |
| 2282 | -1, 133, -1, 135, 5, 6, 138, 8, 9, 10, |
| 2283 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 2284 | 21, 22, -1, 24, 5, 6, -1, 8, 9, 10, |
| 2285 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 2286 | 21, 22, -1, 24, -1, -1, -1, 48, -1, -1, |
| 2287 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2288 | -1, -1, -1, -1, -1, -1, -1, 48, -1, -1, |
| 2289 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2290 | -1, 3, 4, 5, 6, 7, -1, -1, -1, -1, |
| 2291 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2292 | 22, -1, 24, -1, 26, 27, 28, -1, -1, -1, |
| 2293 | -1, -1, -1, -1, -1, -1, 38, 39, -1, -1, |
| 2294 | -1, -1, -1, -1, -1, -1, 127, -1, -1, 130, |
| 2295 | -1, -1, 133, -1, 135, 136, -1, -1, -1, 61, |
| 2296 | -1, -1, -1, -1, -1, -1, 127, -1, -1, 130, |
| 2297 | -1, -1, 133, -1, 135, 136, 78, 79, 80, 81, |
| 2298 | 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, |
| 2299 | 92, 93, 94, 95, -1, -1, -1, -1, -1, 101, |
| 2300 | 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 2301 | 112, 113, -1, 115, 116, 117, 118, -1, 120, 121, |
| 2302 | 122, 3, 4, -1, -1, 7, -1, -1, -1, -1, |
| 2303 | -1, 133, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2304 | -1, -1, -1, -1, 26, 27, 28, -1, -1, -1, |
| 2305 | -1, -1, -1, -1, -1, -1, 38, 39, -1, -1, |
| 2306 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2307 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 61, |
| 2308 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2309 | -1, -1, -1, -1, -1, -1, 78, 79, 80, 81, |
| 2310 | 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, |
| 2311 | 92, 93, 94, 95, -1, -1, -1, -1, -1, 101, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2312 | 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 2313 | 112, 113, -1, 115, 116, 117, 118, -1, 120, 121, |
| 2314 | 122, -1, -1, -1, -1, -1, -1, -1, -1, 5, |
| 2315 | 6, 133, 8, 9, 10, 11, 12, 13, 14, 15, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2316 | 16, 17, 18, 19, 20, 21, 22, -1, 24, -1, |
| 2317 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2318 | -1, 37, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2319 | 5, 6, 48, 8, 9, 10, 11, 12, 13, 14, |
| 2320 | 15, 16, 17, 18, 19, 20, 21, 22, -1, 24, |
| 2321 | 5, 6, -1, 8, 9, 10, 11, 12, 13, 14, |
| 2322 | 15, 16, 17, 18, 19, 20, 21, 22, -1, 24, |
| 2323 | -1, -1, -1, 48, -1, -1, -1, -1, -1, -1, |
| 2324 | -1, -1, 37, -1, -1, -1, -1, -1, -1, -1, |
| 2325 | -1, 5, 6, 48, 8, 9, 10, 11, 12, 13, |
| 2326 | 14, 15, 16, 17, 18, 19, 20, 21, 22, -1, |
| 2327 | 24, 127, -1, -1, 130, -1, -1, 133, -1, 135, |
| 2328 | -1, -1, -1, 37, -1, -1, -1, -1, -1, -1, |
| 2329 | -1, -1, -1, -1, 48, -1, -1, -1, -1, -1, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2330 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2331 | -1, -1, 127, -1, -1, 130, -1, 132, 133, -1, |
| 2332 | 135, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2333 | -1, -1, 127, -1, -1, 130, -1, -1, 133, -1, |
| 2334 | 135, 5, 6, -1, 8, 9, 10, 11, 12, 13, |
| 2335 | 14, 15, 16, 17, 18, 19, 20, 21, 22, -1, |
| 2336 | 24, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2337 | -1, -1, -1, 127, -1, -1, 130, -1, -1, 133, |
| 2338 | -1, 135, 5, 6, 48, 8, 9, 10, 11, 12, |
| 2339 | 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, |
| 2340 | -1, 24, 5, 6, -1, 8, 9, 10, 11, 12, |
| 2341 | 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, |
| 2342 | -1, 24, -1, -1, -1, 48, -1, 5, 6, -1, |
| 2343 | 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
| 2344 | 18, 19, 20, 21, 22, 48, 24, -1, -1, -1, |
| 2345 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2346 | -1, -1, -1, 127, -1, -1, 130, -1, -1, 133, |
| 2347 | 48, 135, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2348 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2349 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2350 | -1, -1, -1, -1, 127, -1, -1, 130, -1, -1, |
| 2351 | 133, -1, 135, -1, -1, -1, -1, -1, -1, -1, |
| 2352 | -1, 35, -1, -1, 127, -1, -1, 130, -1, -1, |
| 2353 | 133, -1, 135, -1, -1, 49, -1, -1, -1, -1, |
| 2354 | -1, -1, -1, -1, -1, 59, 60, -1, -1, 127, |
| 2355 | -1, -1, 130, -1, -1, 133, -1, 135, 72, 73, |
| 2356 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 2357 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 2358 | 94, 95, 96, 97, 98, -1, -1, 101, 102, 103, |
| 2359 | 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, |
| 2360 | 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, |
| 2361 | 124 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2362 | }; |
| 2363 | |
| 2364 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 2365 | symbol of state STATE-NUM. */ |
| 2366 | static const unsigned char yystos[] = |
| 2367 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2368 | 0, 171, 172, 173, 0, 25, 31, 41, 42, 43, |
| 2369 | 44, 45, 46, 47, 62, 152, 190, 192, 194, 201, |
| 2370 | 22, 24, 51, 58, 62, 151, 183, 194, 195, 61, |
| 2371 | 64, 65, 66, 67, 68, 69, 70, 153, 188, 23, |
| 2372 | 202, 203, 30, 136, 191, 202, 52, 53, 54, 71, |
| 2373 | 180, 125, 61, 20, 45, 47, 50, 152, 125, 45, |
| 2374 | 47, 193, 24, 178, 4, 5, 6, 8, 9, 10, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2375 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2376 | 21, 48, 127, 130, 133, 135, 140, 160, 161, 162, |
| 2377 | 163, 164, 183, 198, 29, 135, 189, 151, 206, 125, |
| 2378 | 125, 125, 125, 130, 181, 178, 160, 32, 33, 170, |
| 2379 | 170, 170, 170, 188, 4, 4, 4, 8, 136, 164, |
| 2380 | 165, 183, 128, 137, 35, 49, 59, 60, 72, 73, |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2381 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 2382 | 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 2383 | 94, 95, 96, 97, 98, 101, 102, 103, 104, 105, |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 2384 | 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, |
| 2385 | 116, 117, 118, 119, 120, 121, 122, 123, 124, 142, |
| 2386 | 143, 144, 145, 146, 204, 210, 211, 213, 214, 24, |
| 2387 | 55, 56, 179, 4, 24, 24, 182, 162, 162, 162, |
| 2388 | 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, |
| 2389 | 19, 147, 148, 150, 162, 167, 131, 131, 126, 136, |
| 2390 | 128, 37, 165, 166, 162, 200, 59, 8, 200, 9, |
| 2391 | 21, 10, 11, 12, 13, 14, 15, 16, 17, 147, |
| 2392 | 148, 149, 153, 162, 162, 200, 162, 162, 207, 200, |
| 2393 | 200, 200, 200, 200, 200, 200, 162, 162, 162, 200, |
| 2394 | 200, 153, 99, 100, 126, 132, 176, 177, 175, 27, |
| 2395 | 28, 3, 4, 141, 4, 7, 26, 38, 39, 101, |
| 2396 | 115, 120, 121, 122, 130, 133, 135, 138, 142, 143, |
| 2397 | 144, 145, 146, 168, 198, 174, 164, 164, 164, 37, |
| 2398 | 162, 185, 186, 187, 126, 129, 3, 4, 7, 26, |
| 2399 | 27, 28, 38, 39, 61, 133, 168, 197, 198, 199, |
| 2400 | 199, 199, 199, 160, 126, 155, 126, 155, 199, 130, |
| 2401 | 126, 126, 126, 126, 126, 126, 126, 126, 199, 199, |
| 2402 | 199, 36, 126, 160, 162, 200, 24, 126, 158, 158, |
| 2403 | 158, 128, 128, 128, 128, 128, 132, 167, 169, 169, |
| 2404 | 136, 169, 24, 128, 128, 128, 128, 128, 158, 132, |
| 2405 | 134, 183, 184, 126, 129, 37, 63, 196, 169, 126, |
| 2406 | 126, 199, 15, 57, 15, 126, 212, 199, 130, 200, |
| 2407 | 162, 200, 200, 200, 162, 162, 126, 126, 126, 162, |
| 2408 | 200, 199, 199, 126, 34, 57, 156, 159, 167, 167, |
| 2409 | 167, 167, 167, 126, 132, 134, 136, 167, 167, 167, |
| 2410 | 167, 167, 37, 185, 156, 157, 24, 134, 21, 21, |
| 2411 | 128, 199, 4, 199, 200, 208, 126, 199, 126, 126, |
| 2412 | 126, 199, 199, 199, 128, 162, 24, 4, 158, 212, |
| 2413 | 126, 126, 126, 126, 167, 126, 126, 126, 36, 126, |
| 2414 | 57, 154, 126, 199, 199, 208, 209, 126, 155, 155, |
| 2415 | 126, 199, 126, 200, 200, 200, 209, 199, 129, 167, |
| 2416 | 167, 167, 167, 167, 167, 167, 162, 167, 4, 24, |
| 2417 | 126, 130, 129, 200, 132, 199, 129, 126, 129, 126, |
| 2418 | 126, 129, 129, 129, 129, 129, 21, 132, 149, 205, |
| 2419 | 36, 132, 167, 167, 167, 199, 197, 132, 149, 21, |
| 2420 | 129, 129, 129, 126, 197, 199, 21, 126, 76, 199, |
| 2421 | 21, 21, 199, 199 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2422 | }; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2423 | |
| 2424 | #define yyerrok (yyerrstatus = 0) |
| 2425 | #define yyclearin (yychar = YYEMPTY) |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2426 | #define YYEMPTY (-2) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2427 | #define YYEOF 0 |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2428 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2429 | #define YYACCEPT goto yyacceptlab |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2430 | #define YYABORT goto yyabortlab |
| 2431 | #define YYERROR goto yyerrorlab |
| 2432 | |
| 2433 | |
| 2434 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 2435 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2436 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2437 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2438 | #define YYFAIL goto yyerrlab |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2439 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2440 | #define YYRECOVERING() (!!yyerrstatus) |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2441 | |
| 2442 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2443 | do \ |
| 2444 | if (yychar == YYEMPTY && yylen == 1) \ |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2445 | { \ |
| 2446 | yychar = (Token); \ |
| 2447 | yylval = (Value); \ |
| 2448 | yytoken = YYTRANSLATE (yychar); \ |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2449 | YYPOPSTACK; \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2450 | goto yybackup; \ |
| 2451 | } \ |
| 2452 | else \ |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2453 | { \ |
| 2454 | yyerror (YY_("syntax error: cannot back up")); \ |
| 2455 | YYERROR; \ |
| 2456 | } \ |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2457 | while (0) |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2458 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2459 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2460 | #define YYTERROR 1 |
| 2461 | #define YYERRCODE 256 |
| 2462 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2463 | |
| 2464 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
| 2465 | If N is 0, then set CURRENT to the empty location which ends |
| 2466 | the previous symbol: RHS[0] (always defined). */ |
| 2467 | |
| 2468 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| 2469 | #ifndef YYLLOC_DEFAULT |
| 2470 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 2471 | do \ |
| 2472 | if (N) \ |
| 2473 | { \ |
| 2474 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
| 2475 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
| 2476 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
| 2477 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
| 2478 | } \ |
| 2479 | else \ |
| 2480 | { \ |
| 2481 | (Current).first_line = (Current).last_line = \ |
| 2482 | YYRHSLOC (Rhs, 0).last_line; \ |
| 2483 | (Current).first_column = (Current).last_column = \ |
| 2484 | YYRHSLOC (Rhs, 0).last_column; \ |
| 2485 | } \ |
| 2486 | while (0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2487 | #endif |
| 2488 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2489 | |
| 2490 | /* YY_LOCATION_PRINT -- Print the location on the stream. |
| 2491 | This macro was not mandated originally: define only if we know |
| 2492 | we won't break user code: when these are the locations we know. */ |
| 2493 | |
| 2494 | #ifndef YY_LOCATION_PRINT |
| 2495 | # if YYLTYPE_IS_TRIVIAL |
| 2496 | # define YY_LOCATION_PRINT(File, Loc) \ |
| 2497 | fprintf (File, "%d.%d-%d.%d", \ |
| 2498 | (Loc).first_line, (Loc).first_column, \ |
| 2499 | (Loc).last_line, (Loc).last_column) |
| 2500 | # else |
| 2501 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 2502 | # endif |
| 2503 | #endif |
| 2504 | |
| 2505 | |
| 2506 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 2507 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2508 | #ifdef YYLEX_PARAM |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2509 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2510 | #else |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2511 | # define YYLEX yylex () |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 2512 | #endif |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2513 | |
| 2514 | /* Enable debugging if requested. */ |
| 2515 | #if YYDEBUG |
| 2516 | |
| 2517 | # ifndef YYFPRINTF |
| 2518 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 2519 | # define YYFPRINTF fprintf |
| 2520 | # endif |
| 2521 | |
| 2522 | # define YYDPRINTF(Args) \ |
| 2523 | do { \ |
| 2524 | if (yydebug) \ |
| 2525 | YYFPRINTF Args; \ |
| 2526 | } while (0) |
| 2527 | |
| 2528 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 2529 | do { \ |
| 2530 | if (yydebug) \ |
| 2531 | { \ |
| 2532 | YYFPRINTF (stderr, "%s ", Title); \ |
| 2533 | yysymprint (stderr, \ |
| 2534 | Type, Value); \ |
| 2535 | YYFPRINTF (stderr, "\n"); \ |
| 2536 | } \ |
| 2537 | } while (0) |
| 2538 | |
| 2539 | /*------------------------------------------------------------------. |
| 2540 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 2541 | | TOP (included). | |
| 2542 | `------------------------------------------------------------------*/ |
| 2543 | |
| 2544 | #if defined (__STDC__) || defined (__cplusplus) |
| 2545 | static void |
| 2546 | yy_stack_print (short int *bottom, short int *top) |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 2547 | #else |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2548 | static void |
| 2549 | yy_stack_print (bottom, top) |
| 2550 | short int *bottom; |
| 2551 | short int *top; |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 2552 | #endif |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2553 | { |
| 2554 | YYFPRINTF (stderr, "Stack now"); |
| 2555 | for (/* Nothing. */; bottom <= top; ++bottom) |
| 2556 | YYFPRINTF (stderr, " %d", *bottom); |
| 2557 | YYFPRINTF (stderr, "\n"); |
| 2558 | } |
| 2559 | |
| 2560 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 2561 | do { \ |
| 2562 | if (yydebug) \ |
| 2563 | yy_stack_print ((Bottom), (Top)); \ |
| 2564 | } while (0) |
| 2565 | |
| 2566 | |
| 2567 | /*------------------------------------------------. |
| 2568 | | Report that the YYRULE is going to be reduced. | |
| 2569 | `------------------------------------------------*/ |
| 2570 | |
| 2571 | #if defined (__STDC__) || defined (__cplusplus) |
| 2572 | static void |
| 2573 | yy_reduce_print (int yyrule) |
| 2574 | #else |
| 2575 | static void |
| 2576 | yy_reduce_print (yyrule) |
| 2577 | int yyrule; |
Chris Lattner | 1ae022f | 2006-10-22 06:08:13 +0000 | [diff] [blame] | 2578 | #endif |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2579 | { |
| 2580 | int yyi; |
| 2581 | unsigned long int yylno = yyrline[yyrule]; |
| 2582 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", |
| 2583 | yyrule - 1, yylno); |
| 2584 | /* Print the symbols being reduced, and their result. */ |
| 2585 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
| 2586 | YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); |
| 2587 | YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); |
| 2588 | } |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2589 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2590 | # define YY_REDUCE_PRINT(Rule) \ |
| 2591 | do { \ |
| 2592 | if (yydebug) \ |
| 2593 | yy_reduce_print (Rule); \ |
| 2594 | } while (0) |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2595 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2596 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 2597 | multiple parsers can coexist. */ |
| 2598 | int yydebug; |
| 2599 | #else /* !YYDEBUG */ |
| 2600 | # define YYDPRINTF(Args) |
| 2601 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
| 2602 | # define YY_STACK_PRINT(Bottom, Top) |
| 2603 | # define YY_REDUCE_PRINT(Rule) |
| 2604 | #endif /* !YYDEBUG */ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2605 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2606 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2607 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2608 | #ifndef YYINITDEPTH |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2609 | # define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2610 | #endif |
| 2611 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2612 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 2613 | if the built-in stack extension method is used). |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2614 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2615 | Do not make this value too large; the results are undefined if |
| 2616 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
| 2617 | evaluated with infinite-precision integer arithmetic. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2618 | |
| 2619 | #ifndef YYMAXDEPTH |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2620 | # define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2621 | #endif |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2622 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2623 | |
| 2624 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2625 | #if YYERROR_VERBOSE |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2626 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2627 | # ifndef yystrlen |
| 2628 | # if defined (__GLIBC__) && defined (_STRING_H) |
| 2629 | # define yystrlen strlen |
| 2630 | # else |
| 2631 | /* Return the length of YYSTR. */ |
| 2632 | static YYSIZE_T |
| 2633 | # if defined (__STDC__) || defined (__cplusplus) |
| 2634 | yystrlen (const char *yystr) |
| 2635 | # else |
| 2636 | yystrlen (yystr) |
| 2637 | const char *yystr; |
| 2638 | # endif |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 2639 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2640 | const char *yys = yystr; |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 2641 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2642 | while (*yys++ != '\0') |
| 2643 | continue; |
| 2644 | |
| 2645 | return yys - yystr - 1; |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 2646 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2647 | # endif |
| 2648 | # endif |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 2649 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2650 | # ifndef yystpcpy |
| 2651 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
| 2652 | # define yystpcpy stpcpy |
| 2653 | # else |
| 2654 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 2655 | YYDEST. */ |
| 2656 | static char * |
| 2657 | # if defined (__STDC__) || defined (__cplusplus) |
| 2658 | yystpcpy (char *yydest, const char *yysrc) |
| 2659 | # else |
| 2660 | yystpcpy (yydest, yysrc) |
| 2661 | char *yydest; |
| 2662 | const char *yysrc; |
| 2663 | # endif |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 2664 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2665 | char *yyd = yydest; |
| 2666 | const char *yys = yysrc; |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 2667 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2668 | while ((*yyd++ = *yys++) != '\0') |
| 2669 | continue; |
| 2670 | |
| 2671 | return yyd - 1; |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 2672 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2673 | # endif |
| 2674 | # endif |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 2675 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2676 | # ifndef yytnamerr |
| 2677 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
| 2678 | quotes and backslashes, so that it's suitable for yyerror. The |
| 2679 | heuristic is that double-quoting is unnecessary unless the string |
| 2680 | contains an apostrophe, a comma, or backslash (other than |
| 2681 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
| 2682 | null, do not copy; instead, return the length of what the result |
| 2683 | would have been. */ |
| 2684 | static YYSIZE_T |
| 2685 | yytnamerr (char *yyres, const char *yystr) |
| 2686 | { |
| 2687 | if (*yystr == '"') |
| 2688 | { |
| 2689 | size_t yyn = 0; |
| 2690 | char const *yyp = yystr; |
| 2691 | |
| 2692 | for (;;) |
| 2693 | switch (*++yyp) |
| 2694 | { |
| 2695 | case '\'': |
| 2696 | case ',': |
| 2697 | goto do_not_strip_quotes; |
| 2698 | |
| 2699 | case '\\': |
| 2700 | if (*++yyp != '\\') |
| 2701 | goto do_not_strip_quotes; |
| 2702 | /* Fall through. */ |
| 2703 | default: |
| 2704 | if (yyres) |
| 2705 | yyres[yyn] = *yyp; |
| 2706 | yyn++; |
| 2707 | break; |
| 2708 | |
| 2709 | case '"': |
| 2710 | if (yyres) |
| 2711 | yyres[yyn] = '\0'; |
| 2712 | return yyn; |
| 2713 | } |
| 2714 | do_not_strip_quotes: ; |
| 2715 | } |
| 2716 | |
| 2717 | if (! yyres) |
| 2718 | return yystrlen (yystr); |
| 2719 | |
| 2720 | return yystpcpy (yyres, yystr) - yyres; |
| 2721 | } |
| 2722 | # endif |
| 2723 | |
| 2724 | #endif /* YYERROR_VERBOSE */ |
| 2725 | |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2726 | |
| 2727 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2728 | #if YYDEBUG |
| 2729 | /*--------------------------------. |
| 2730 | | Print this symbol on YYOUTPUT. | |
| 2731 | `--------------------------------*/ |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 2732 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2733 | #if defined (__STDC__) || defined (__cplusplus) |
| 2734 | static void |
| 2735 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 2736 | #else |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2737 | static void |
| 2738 | yysymprint (yyoutput, yytype, yyvaluep) |
| 2739 | FILE *yyoutput; |
| 2740 | int yytype; |
| 2741 | YYSTYPE *yyvaluep; |
| 2742 | #endif |
| 2743 | { |
| 2744 | /* Pacify ``unused variable'' warnings. */ |
| 2745 | (void) yyvaluep; |
| 2746 | |
| 2747 | if (yytype < YYNTOKENS) |
| 2748 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 2749 | else |
| 2750 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 2751 | |
| 2752 | |
| 2753 | # ifdef YYPRINT |
| 2754 | if (yytype < YYNTOKENS) |
| 2755 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 2756 | # endif |
| 2757 | switch (yytype) |
| 2758 | { |
| 2759 | default: |
| 2760 | break; |
| 2761 | } |
| 2762 | YYFPRINTF (yyoutput, ")"); |
| 2763 | } |
| 2764 | |
| 2765 | #endif /* ! YYDEBUG */ |
| 2766 | /*-----------------------------------------------. |
| 2767 | | Release the memory associated to this symbol. | |
| 2768 | `-----------------------------------------------*/ |
| 2769 | |
| 2770 | #if defined (__STDC__) || defined (__cplusplus) |
| 2771 | static void |
| 2772 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
| 2773 | #else |
| 2774 | static void |
| 2775 | yydestruct (yymsg, yytype, yyvaluep) |
| 2776 | const char *yymsg; |
| 2777 | int yytype; |
| 2778 | YYSTYPE *yyvaluep; |
| 2779 | #endif |
| 2780 | { |
| 2781 | /* Pacify ``unused variable'' warnings. */ |
| 2782 | (void) yyvaluep; |
| 2783 | |
| 2784 | if (!yymsg) |
| 2785 | yymsg = "Deleting"; |
| 2786 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 2787 | |
| 2788 | switch (yytype) |
| 2789 | { |
| 2790 | |
| 2791 | default: |
| 2792 | break; |
| 2793 | } |
| 2794 | } |
| 2795 | |
| 2796 | |
| 2797 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 2798 | |
| 2799 | #ifdef YYPARSE_PARAM |
| 2800 | # if defined (__STDC__) || defined (__cplusplus) |
| 2801 | int yyparse (void *YYPARSE_PARAM); |
| 2802 | # else |
| 2803 | int yyparse (); |
| 2804 | # endif |
| 2805 | #else /* ! YYPARSE_PARAM */ |
| 2806 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 2807 | int yyparse (void); |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 2808 | #else |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2809 | int yyparse (); |
| 2810 | #endif |
| 2811 | #endif /* ! YYPARSE_PARAM */ |
| 2812 | |
| 2813 | |
| 2814 | |
| 2815 | /* The look-ahead symbol. */ |
| 2816 | int yychar; |
| 2817 | |
| 2818 | /* The semantic value of the look-ahead symbol. */ |
| 2819 | YYSTYPE yylval; |
| 2820 | |
| 2821 | /* Number of syntax errors so far. */ |
| 2822 | int yynerrs; |
| 2823 | |
| 2824 | |
| 2825 | |
| 2826 | /*----------. |
| 2827 | | yyparse. | |
| 2828 | `----------*/ |
| 2829 | |
| 2830 | #ifdef YYPARSE_PARAM |
| 2831 | # if defined (__STDC__) || defined (__cplusplus) |
| 2832 | int yyparse (void *YYPARSE_PARAM) |
| 2833 | # else |
| 2834 | int yyparse (YYPARSE_PARAM) |
| 2835 | void *YYPARSE_PARAM; |
| 2836 | # endif |
| 2837 | #else /* ! YYPARSE_PARAM */ |
| 2838 | #if defined (__STDC__) || defined (__cplusplus) |
| 2839 | int |
| 2840 | yyparse (void) |
| 2841 | #else |
| 2842 | int |
| 2843 | yyparse () |
| 2844 | |
| 2845 | #endif |
| 2846 | #endif |
| 2847 | { |
| 2848 | |
| 2849 | int yystate; |
| 2850 | int yyn; |
| 2851 | int yyresult; |
| 2852 | /* Number of tokens to shift before error messages enabled. */ |
| 2853 | int yyerrstatus; |
| 2854 | /* Look-ahead token as an internal (translated) token number. */ |
| 2855 | int yytoken = 0; |
| 2856 | |
| 2857 | /* Three stacks and their tools: |
| 2858 | `yyss': related to states, |
| 2859 | `yyvs': related to semantic values, |
| 2860 | `yyls': related to locations. |
| 2861 | |
| 2862 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 2863 | to reallocate them elsewhere. */ |
| 2864 | |
| 2865 | /* The state stack. */ |
| 2866 | short int yyssa[YYINITDEPTH]; |
| 2867 | short int *yyss = yyssa; |
| 2868 | short int *yyssp; |
| 2869 | |
| 2870 | /* The semantic value stack. */ |
| 2871 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 2872 | YYSTYPE *yyvs = yyvsa; |
| 2873 | YYSTYPE *yyvsp; |
| 2874 | |
| 2875 | |
| 2876 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2877 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2878 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2879 | YYSIZE_T yystacksize = YYINITDEPTH; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2880 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2881 | /* The variables used to return semantic value and location from the |
| 2882 | action routines. */ |
| 2883 | YYSTYPE yyval; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2884 | |
| 2885 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2886 | /* When reducing, the number of symbols on the RHS of the reduced |
| 2887 | rule. */ |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2888 | int yylen; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2889 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2890 | YYDPRINTF ((stderr, "Starting parse\n")); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 2891 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2892 | yystate = 0; |
| 2893 | yyerrstatus = 0; |
| 2894 | yynerrs = 0; |
| 2895 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2896 | |
| 2897 | /* Initialize stack pointers. |
| 2898 | Waste one element of value and location stack |
| 2899 | so that they stay on the same level as the state stack. |
| 2900 | The wasted elements are never initialized. */ |
| 2901 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2902 | yyssp = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2903 | yyvsp = yyvs; |
| 2904 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2905 | goto yysetstate; |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2906 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2907 | /*------------------------------------------------------------. |
| 2908 | | yynewstate -- Push a new state, which is found in yystate. | |
| 2909 | `------------------------------------------------------------*/ |
| 2910 | yynewstate: |
| 2911 | /* In all cases, when you get here, the value and location stacks |
| 2912 | have just been pushed. so pushing a state here evens the stacks. |
| 2913 | */ |
| 2914 | yyssp++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2915 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2916 | yysetstate: |
| 2917 | *yyssp = yystate; |
| 2918 | |
| 2919 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2920 | { |
| 2921 | /* Get the current used size of the three stacks, in elements. */ |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2922 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2923 | |
| 2924 | #ifdef yyoverflow |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2925 | { |
| 2926 | /* Give user a chance to reallocate the stack. Use copies of |
| 2927 | these so that the &'s don't force the real ones into |
| 2928 | memory. */ |
| 2929 | YYSTYPE *yyvs1 = yyvs; |
| 2930 | short int *yyss1 = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2931 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2932 | |
| 2933 | /* Each stack pointer address is followed by the size of the |
| 2934 | data in use in that stack, in bytes. This used to be a |
| 2935 | conditional around just the two extra args, but that might |
| 2936 | be undefined if yyoverflow is a macro. */ |
| 2937 | yyoverflow (YY_("memory exhausted"), |
| 2938 | &yyss1, yysize * sizeof (*yyssp), |
| 2939 | &yyvs1, yysize * sizeof (*yyvsp), |
| 2940 | |
| 2941 | &yystacksize); |
| 2942 | |
| 2943 | yyss = yyss1; |
| 2944 | yyvs = yyvs1; |
| 2945 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2946 | #else /* no yyoverflow */ |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2947 | # ifndef YYSTACK_RELOCATE |
| 2948 | goto yyexhaustedlab; |
| 2949 | # else |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2950 | /* Extend the stack our own way. */ |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2951 | if (YYMAXDEPTH <= yystacksize) |
| 2952 | goto yyexhaustedlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2953 | yystacksize *= 2; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2954 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2955 | yystacksize = YYMAXDEPTH; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2956 | |
| 2957 | { |
| 2958 | short int *yyss1 = yyss; |
| 2959 | union yyalloc *yyptr = |
| 2960 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 2961 | if (! yyptr) |
| 2962 | goto yyexhaustedlab; |
| 2963 | YYSTACK_RELOCATE (yyss); |
| 2964 | YYSTACK_RELOCATE (yyvs); |
| 2965 | |
| 2966 | # undef YYSTACK_RELOCATE |
| 2967 | if (yyss1 != yyssa) |
| 2968 | YYSTACK_FREE (yyss1); |
| 2969 | } |
| 2970 | # endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2971 | #endif /* no yyoverflow */ |
| 2972 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2973 | yyssp = yyss + yysize - 1; |
| 2974 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2975 | |
| 2976 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2977 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 2978 | (unsigned long int) yystacksize)); |
| 2979 | |
| 2980 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2981 | YYABORT; |
| 2982 | } |
| 2983 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2984 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2985 | |
| 2986 | goto yybackup; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2987 | |
| 2988 | /*-----------. |
| 2989 | | yybackup. | |
| 2990 | `-----------*/ |
| 2991 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2992 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 2993 | /* Do appropriate processing given the current state. */ |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2994 | /* 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] | 2995 | /* yyresume: */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2996 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 2997 | /* 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] | 2998 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2999 | yyn = yypact[yystate]; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3000 | if (yyn == YYPACT_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3001 | goto yydefault; |
| 3002 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3003 | /* 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] | 3004 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3005 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3006 | if (yychar == YYEMPTY) |
| 3007 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3008 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3009 | yychar = YYLEX; |
| 3010 | } |
| 3011 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3012 | if (yychar <= YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3013 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3014 | yychar = yytoken = YYEOF; |
| 3015 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3016 | } |
| 3017 | else |
| 3018 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3019 | yytoken = YYTRANSLATE (yychar); |
| 3020 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3021 | } |
| 3022 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3023 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 3024 | detect an error, take that action. */ |
| 3025 | yyn += yytoken; |
| 3026 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3027 | goto yydefault; |
| 3028 | yyn = yytable[yyn]; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3029 | if (yyn <= 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3030 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3031 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3032 | goto yyerrlab; |
| 3033 | yyn = -yyn; |
| 3034 | goto yyreduce; |
| 3035 | } |
| 3036 | |
| 3037 | if (yyn == YYFINAL) |
| 3038 | YYACCEPT; |
| 3039 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3040 | /* Shift the look-ahead token. */ |
| 3041 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3042 | |
| 3043 | /* Discard the token being shifted unless it is eof. */ |
| 3044 | if (yychar != YYEOF) |
| 3045 | yychar = YYEMPTY; |
| 3046 | |
| 3047 | *++yyvsp = yylval; |
| 3048 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3049 | |
| 3050 | /* Count tokens shifted since error; after three, turn off error |
| 3051 | status. */ |
| 3052 | if (yyerrstatus) |
| 3053 | yyerrstatus--; |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 3054 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3055 | yystate = yyn; |
| 3056 | goto yynewstate; |
| 3057 | |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 3058 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3059 | /*-----------------------------------------------------------. |
| 3060 | | yydefault -- do the default action for the current state. | |
| 3061 | `-----------------------------------------------------------*/ |
| 3062 | yydefault: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3063 | yyn = yydefact[yystate]; |
| 3064 | if (yyn == 0) |
| 3065 | goto yyerrlab; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3066 | goto yyreduce; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3067 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3068 | |
| 3069 | /*-----------------------------. |
| 3070 | | yyreduce -- Do a reduction. | |
| 3071 | `-----------------------------*/ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3072 | yyreduce: |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3073 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3074 | yylen = yyr2[yyn]; |
| 3075 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3076 | /* If YYLEN is nonzero, implement the default value of the action: |
| 3077 | `$$ = $1'. |
| 3078 | |
| 3079 | Otherwise, the following line sets YYVAL to garbage. |
| 3080 | This behavior is undocumented and Bison |
| 3081 | users should not rely upon it. Assigning to YYVAL |
| 3082 | unconditionally makes the parser a bit smaller, and it avoids a |
| 3083 | GCC warning that YYVAL may be used uninitialized. */ |
| 3084 | yyval = yyvsp[1-yylen]; |
| 3085 | |
| 3086 | |
| 3087 | YY_REDUCE_PRINT (yyn); |
| 3088 | switch (yyn) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3089 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3090 | case 3: |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3091 | #line 1169 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3092 | { |
| 3093 | if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range! |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3094 | GEN_ERROR("Value too large for type!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3095 | (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3096 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3097 | ;} |
| 3098 | break; |
| 3099 | |
| 3100 | case 5: |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3101 | #line 1178 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3102 | { |
| 3103 | if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range! |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3104 | GEN_ERROR("Value too large for type!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3105 | (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3106 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3107 | ;} |
| 3108 | break; |
| 3109 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3110 | case 51: |
| 3111 | #line 1203 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3112 | { |
| 3113 | (yyval.StrVal) = (yyvsp[-1].StrVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3114 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3115 | ;} |
| 3116 | break; |
| 3117 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3118 | case 52: |
| 3119 | #line 1207 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3120 | { |
| 3121 | (yyval.StrVal) = 0; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3122 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3123 | ;} |
| 3124 | break; |
| 3125 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3126 | case 53: |
| 3127 | #line 1212 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3128 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3129 | break; |
| 3130 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3131 | case 54: |
| 3132 | #line 1213 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3133 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 3134 | break; |
| 3135 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3136 | case 55: |
| 3137 | #line 1214 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3138 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3139 | break; |
| 3140 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3141 | case 56: |
| 3142 | #line 1215 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3143 | { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} |
| 3144 | break; |
| 3145 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3146 | case 57: |
| 3147 | #line 1216 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3148 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 3149 | break; |
| 3150 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3151 | case 58: |
| 3152 | #line 1217 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3153 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 3154 | break; |
| 3155 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3156 | case 59: |
| 3157 | #line 1218 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3158 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 3159 | break; |
| 3160 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3161 | case 60: |
| 3162 | #line 1219 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3163 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3164 | break; |
| 3165 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3166 | case 61: |
| 3167 | #line 1221 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3168 | { (yyval.UIntVal) = CallingConv::C; ;} |
| 3169 | break; |
| 3170 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3171 | case 62: |
| 3172 | #line 1222 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3173 | { (yyval.UIntVal) = CallingConv::C; ;} |
| 3174 | break; |
| 3175 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3176 | case 63: |
| 3177 | #line 1223 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3178 | { (yyval.UIntVal) = CallingConv::CSRet; ;} |
| 3179 | break; |
| 3180 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3181 | case 64: |
| 3182 | #line 1224 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3183 | { (yyval.UIntVal) = CallingConv::Fast; ;} |
| 3184 | break; |
| 3185 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3186 | case 65: |
| 3187 | #line 1225 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3188 | { (yyval.UIntVal) = CallingConv::Cold; ;} |
| 3189 | break; |
| 3190 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3191 | case 66: |
| 3192 | #line 1226 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3193 | { (yyval.UIntVal) = CallingConv::X86_StdCall; ;} |
| 3194 | break; |
| 3195 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3196 | case 67: |
| 3197 | #line 1227 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3198 | { (yyval.UIntVal) = CallingConv::X86_FastCall; ;} |
| 3199 | break; |
| 3200 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3201 | case 68: |
| 3202 | #line 1228 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3203 | { |
| 3204 | if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3205 | GEN_ERROR("Calling conv too large!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3206 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3207 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3208 | ;} |
| 3209 | break; |
| 3210 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3211 | case 69: |
| 3212 | #line 1237 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3213 | { (yyval.UIntVal) = 0; ;} |
| 3214 | break; |
| 3215 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3216 | case 70: |
| 3217 | #line 1238 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3218 | { |
| 3219 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 3220 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3221 | GEN_ERROR("Alignment must be a power of two!"); |
| 3222 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3223 | ;} |
| 3224 | break; |
| 3225 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3226 | case 71: |
| 3227 | #line 1244 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3228 | { (yyval.UIntVal) = 0; ;} |
| 3229 | break; |
| 3230 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3231 | case 72: |
| 3232 | #line 1245 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3233 | { |
| 3234 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 3235 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame] | 3236 | GEN_ERROR("Alignment must be a power of two!"); |
| 3237 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3238 | ;} |
| 3239 | break; |
| 3240 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3241 | case 73: |
| 3242 | #line 1253 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3243 | { |
| 3244 | for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) |
| 3245 | if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3246 | GEN_ERROR("Invalid character in section name!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3247 | (yyval.StrVal) = (yyvsp[0].StrVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3248 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3249 | ;} |
| 3250 | break; |
| 3251 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3252 | case 74: |
| 3253 | #line 1261 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3254 | { (yyval.StrVal) = 0; ;} |
| 3255 | break; |
| 3256 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3257 | case 75: |
| 3258 | #line 1262 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3259 | { (yyval.StrVal) = (yyvsp[0].StrVal); ;} |
| 3260 | break; |
| 3261 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3262 | case 76: |
| 3263 | #line 1267 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3264 | {;} |
| 3265 | break; |
| 3266 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3267 | case 77: |
| 3268 | #line 1268 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3269 | {;} |
| 3270 | break; |
| 3271 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3272 | case 78: |
| 3273 | #line 1269 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3274 | { |
| 3275 | CurGV->setSection((yyvsp[0].StrVal)); |
| 3276 | free((yyvsp[0].StrVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3277 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3278 | ;} |
| 3279 | break; |
| 3280 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3281 | case 79: |
| 3282 | #line 1274 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3283 | { |
| 3284 | if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3285 | GEN_ERROR("Alignment must be a power of two!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3286 | CurGV->setAlignment((yyvsp[0].UInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3287 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3288 | ;} |
| 3289 | break; |
| 3290 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3291 | case 81: |
| 3292 | #line 1288 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3293 | { |
| 3294 | (yyval.TypeVal).type = new PATypeHolder((yyvsp[0].TypeVal).type->get()); |
| 3295 | (yyval.TypeVal).signedness = (yyvsp[0].TypeVal).signedness; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3296 | ;} |
| 3297 | break; |
| 3298 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3299 | case 83: |
| 3300 | #line 1292 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3301 | { |
| 3302 | (yyval.TypeVal).type = new PATypeHolder((yyvsp[0].TypeVal).type->get()); |
| 3303 | (yyval.TypeVal).signedness = (yyvsp[0].TypeVal).signedness; |
| 3304 | ;} |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3305 | break; |
| 3306 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3307 | case 84: |
| 3308 | #line 1297 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3309 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3310 | if (!UpRefs.empty()) |
| 3311 | GEN_ERROR("Invalid upreference in type: " + |
| 3312 | ((yyvsp[0].TypeVal).type->get())->getDescription()); |
| 3313 | (yyval.TypeVal) = (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3314 | CHECK_FOR_ERROR |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3315 | ;} |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3316 | break; |
| 3317 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3318 | case 98: |
| 3319 | #line 1310 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3320 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3321 | (yyval.TypeVal).type = new PATypeHolder(OpaqueType::get()); |
| 3322 | (yyval.TypeVal).signedness = isSignless; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3323 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3324 | ;} |
| 3325 | break; |
| 3326 | |
| 3327 | case 99: |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3328 | #line 1315 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3329 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3330 | (yyval.TypeVal) = (yyvsp[0].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3331 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3332 | ;} |
| 3333 | break; |
| 3334 | |
| 3335 | case 100: |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3336 | #line 1319 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3337 | { // Named types are also simple types... |
| 3338 | const Type* tmp = getTypeVal((yyvsp[0].ValIDVal)); |
| 3339 | CHECK_FOR_ERROR |
| 3340 | (yyval.TypeVal).type = new PATypeHolder(tmp); |
| 3341 | (yyval.TypeVal).signedness = isSignless; |
| 3342 | ;} |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3343 | break; |
| 3344 | |
| 3345 | case 101: |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3346 | #line 1328 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3347 | { // Type UpReference |
| 3348 | if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!"); |
| 3349 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
| 3350 | UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector... |
| 3351 | (yyval.TypeVal).type = new PATypeHolder(OT); |
| 3352 | (yyval.TypeVal).signedness = isSignless; |
| 3353 | UR_OUT("New Upreference!\n"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3354 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3355 | ;} |
| 3356 | break; |
| 3357 | |
| 3358 | case 102: |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3359 | #line 1337 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3360 | { // Function derived type? |
| 3361 | std::vector<const Type*> Params; |
| 3362 | for (std::list<TypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(), |
| 3363 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) |
| 3364 | Params.push_back(I->type->get()); |
| 3365 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3366 | if (isVarArg) Params.pop_back(); |
| 3367 | |
| 3368 | (yyval.TypeVal).type = new PATypeHolder(HandleUpRefs( |
| 3369 | FunctionType::get((yyvsp[-3].TypeVal).type->get(),Params,isVarArg))); |
| 3370 | (yyval.TypeVal).signedness = isSignless; |
| 3371 | delete (yyvsp[-1].TypeList); // Delete the argument list |
| 3372 | delete (yyvsp[-3].TypeVal).type; |
| 3373 | CHECK_FOR_ERROR |
| 3374 | ;} |
| 3375 | break; |
| 3376 | |
| 3377 | case 103: |
| 3378 | #line 1352 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3379 | { // Sized array type? |
| 3380 | (yyval.TypeVal).type = new PATypeHolder(HandleUpRefs( |
| 3381 | ArrayType::get((yyvsp[-1].TypeVal).type->get(), (unsigned)(yyvsp[-3].UInt64Val)))); |
| 3382 | (yyval.TypeVal).signedness = isSignless; |
| 3383 | delete (yyvsp[-1].TypeVal).type; |
| 3384 | CHECK_FOR_ERROR |
| 3385 | ;} |
| 3386 | break; |
| 3387 | |
| 3388 | case 104: |
| 3389 | #line 1359 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3390 | { // Packed array type? |
| 3391 | const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).type->get(); |
| 3392 | if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) |
| 3393 | GEN_ERROR("Unsigned result not equal to signed result"); |
| 3394 | if (!ElemTy->isPrimitiveType()) |
| 3395 | GEN_ERROR("Elemental type of a PackedType must be primitive"); |
| 3396 | if (!isPowerOf2_32((yyvsp[-3].UInt64Val))) |
| 3397 | GEN_ERROR("Vector length should be a power of 2!"); |
| 3398 | (yyval.TypeVal).type = new PATypeHolder(HandleUpRefs( |
| 3399 | PackedType::get((yyvsp[-1].TypeVal).type->get(), (unsigned)(yyvsp[-3].UInt64Val)))); |
| 3400 | (yyval.TypeVal).signedness = isSignless; |
| 3401 | delete (yyvsp[-1].TypeVal).type; |
| 3402 | CHECK_FOR_ERROR |
| 3403 | ;} |
| 3404 | break; |
| 3405 | |
| 3406 | case 105: |
| 3407 | #line 1373 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3408 | { // Structure type? |
| 3409 | std::vector<const Type*> Elements; |
| 3410 | for (std::list<TypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(), |
| 3411 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) |
| 3412 | Elements.push_back(I->type->get()); |
| 3413 | |
| 3414 | (yyval.TypeVal).type = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 3415 | (yyval.TypeVal).signedness = isSignless; |
| 3416 | delete (yyvsp[-1].TypeList); |
| 3417 | CHECK_FOR_ERROR |
| 3418 | ;} |
| 3419 | break; |
| 3420 | |
| 3421 | case 106: |
| 3422 | #line 1384 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3423 | { // Empty structure type? |
| 3424 | (yyval.TypeVal).type = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
| 3425 | (yyval.TypeVal).signedness = isSignless; |
| 3426 | CHECK_FOR_ERROR |
| 3427 | ;} |
| 3428 | break; |
| 3429 | |
| 3430 | case 107: |
| 3431 | #line 1389 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3432 | { // Pointer type? |
| 3433 | if ((yyvsp[-1].TypeVal).type->get() == Type::LabelTy) |
| 3434 | GEN_ERROR("Cannot form a pointer to a basic block"); |
| 3435 | (yyval.TypeVal).type = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).type->get()))); |
| 3436 | (yyval.TypeVal).signedness = (yyvsp[-1].TypeVal).signedness; |
| 3437 | delete (yyvsp[-1].TypeVal).type; |
| 3438 | CHECK_FOR_ERROR |
| 3439 | ;} |
| 3440 | break; |
| 3441 | |
| 3442 | case 108: |
| 3443 | #line 1401 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3444 | { |
| 3445 | (yyval.TypeList) = new std::list<TypeInfo>(); |
| 3446 | (yyval.TypeList)->push_back((yyvsp[0].TypeVal)); |
| 3447 | CHECK_FOR_ERROR |
| 3448 | ;} |
| 3449 | break; |
| 3450 | |
| 3451 | case 109: |
| 3452 | #line 1406 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3453 | { |
| 3454 | ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal)); |
| 3455 | CHECK_FOR_ERROR |
| 3456 | ;} |
| 3457 | break; |
| 3458 | |
| 3459 | case 111: |
| 3460 | #line 1413 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3461 | { |
| 3462 | TypeInfo TI; |
| 3463 | TI.type = new PATypeHolder(Type::VoidTy); TI.signedness = isSignless; |
| 3464 | ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(TI); |
| 3465 | CHECK_FOR_ERROR |
| 3466 | ;} |
| 3467 | break; |
| 3468 | |
| 3469 | case 112: |
| 3470 | #line 1419 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3471 | { |
| 3472 | TypeInfo TI; |
| 3473 | TI.type = new PATypeHolder(Type::VoidTy); TI.signedness = isSignless; |
| 3474 | ((yyval.TypeList) = new std::list<TypeInfo>())->push_back(TI); |
| 3475 | CHECK_FOR_ERROR |
| 3476 | ;} |
| 3477 | break; |
| 3478 | |
| 3479 | case 113: |
| 3480 | #line 1425 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3481 | { |
| 3482 | (yyval.TypeList) = new std::list<TypeInfo>(); |
| 3483 | CHECK_FOR_ERROR |
| 3484 | ;} |
| 3485 | break; |
| 3486 | |
| 3487 | case 114: |
| 3488 | #line 1436 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3489 | { // Nonempty unsized arr |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3490 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).type->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3491 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3492 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3493 | ((yyvsp[-3].TypeVal).type->get())->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3494 | const Type *ETy = ATy->getElementType(); |
| 3495 | int NumElements = ATy->getNumElements(); |
| 3496 | |
| 3497 | // Verify that we have the correct size... |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3498 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3499 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3500 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3501 | itostr(NumElements) + "!"); |
| 3502 | |
| 3503 | // Verify all elements are correct type! |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3504 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 3505 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3506 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3507 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3508 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3509 | } |
| 3510 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3511 | (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3512 | delete (yyvsp[-3].TypeVal).type; delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3513 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3514 | ;} |
| 3515 | break; |
| 3516 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3517 | case 115: |
| 3518 | #line 1462 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3519 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3520 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).type->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3521 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3522 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3523 | ((yyvsp[-2].TypeVal).type->get())->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3524 | |
| 3525 | int NumElements = ATy->getNumElements(); |
| 3526 | if (NumElements != -1 && NumElements != 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3527 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3528 | " arguments, but has size of " + itostr(NumElements) +"!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3529 | (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>()); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3530 | delete (yyvsp[-2].TypeVal).type; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3531 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3532 | ;} |
| 3533 | break; |
| 3534 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3535 | case 116: |
| 3536 | #line 1476 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3537 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3538 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).type->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3539 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3540 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3541 | ((yyvsp[-2].TypeVal).type->get())->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3542 | |
| 3543 | int NumElements = ATy->getNumElements(); |
| 3544 | const Type *ETy = ATy->getElementType(); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3545 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 3546 | if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3547 | GEN_ERROR("Can't build string constant of size " + |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3548 | itostr((int)(EndStr-(yyvsp[0].StrVal))) + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3549 | " when array has size " + itostr(NumElements) + "!"); |
| 3550 | std::vector<Constant*> Vals; |
| 3551 | if (ETy == Type::SByteTy) { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3552 | 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] | 3553 | Vals.push_back(ConstantInt::get(ETy, *C)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3554 | } else if (ETy == Type::UByteTy) { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3555 | for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 3556 | C != (unsigned char*)EndStr; ++C) |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 3557 | Vals.push_back(ConstantInt::get(ETy, *C)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3558 | } else { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3559 | free((yyvsp[0].StrVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3560 | GEN_ERROR("Cannot build string arrays of non byte sized elements!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3561 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3562 | free((yyvsp[0].StrVal)); |
| 3563 | (yyval.ConstVal) = ConstantArray::get(ATy, Vals); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3564 | delete (yyvsp[-2].TypeVal).type; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3565 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3566 | ;} |
| 3567 | break; |
| 3568 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3569 | case 117: |
| 3570 | #line 1506 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3571 | { // Nonempty unsized arr |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3572 | const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal).type->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3573 | if (PTy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3574 | GEN_ERROR("Cannot make packed constant with type: '" + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3575 | (yyvsp[-3].TypeVal).type->get()->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3576 | const Type *ETy = PTy->getElementType(); |
| 3577 | int NumElements = PTy->getNumElements(); |
| 3578 | |
| 3579 | // Verify that we have the correct size... |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3580 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3581 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3582 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3583 | itostr(NumElements) + "!"); |
| 3584 | |
| 3585 | // Verify all elements are correct type! |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3586 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 3587 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3588 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3589 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3590 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3591 | } |
| 3592 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3593 | (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3594 | delete (yyvsp[-3].TypeVal).type; delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3595 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3596 | ;} |
| 3597 | break; |
| 3598 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3599 | case 118: |
| 3600 | #line 1532 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3601 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3602 | const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).type->get()); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3603 | if (STy == 0) |
| 3604 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3605 | (yyvsp[-3].TypeVal).type->get()->getDescription() + "'!"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3606 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3607 | if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3608 | GEN_ERROR("Illegal number of initializers for structure type!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3609 | |
| 3610 | // Check to ensure that constants are compatible with the type initializer! |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3611 | for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) |
| 3612 | if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3613 | GEN_ERROR("Expected type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3614 | STy->getElementType(i)->getDescription() + |
| 3615 | "' for element #" + utostr(i) + |
| 3616 | " of structure initializer!"); |
| 3617 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3618 | (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3619 | delete (yyvsp[-3].TypeVal).type; delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3620 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3621 | ;} |
| 3622 | break; |
| 3623 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3624 | case 119: |
| 3625 | #line 1553 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3626 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3627 | const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).type->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3628 | if (STy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3629 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3630 | (yyvsp[-2].TypeVal).type->get()->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3631 | |
| 3632 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3633 | GEN_ERROR("Illegal number of initializers for structure type!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3634 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3635 | (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3636 | delete (yyvsp[-2].TypeVal).type; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3637 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3638 | ;} |
| 3639 | break; |
| 3640 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3641 | case 120: |
| 3642 | #line 1566 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3643 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3644 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).type->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3645 | if (PTy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3646 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3647 | (yyvsp[-1].TypeVal).type->get()->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3648 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3649 | (yyval.ConstVal) = ConstantPointerNull::get(PTy); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3650 | delete (yyvsp[-1].TypeVal).type; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3651 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3652 | ;} |
| 3653 | break; |
| 3654 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3655 | case 121: |
| 3656 | #line 1576 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3657 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3658 | (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal).type->get()); |
| 3659 | delete (yyvsp[-1].TypeVal).type; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3660 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3661 | ;} |
| 3662 | break; |
| 3663 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3664 | case 122: |
| 3665 | #line 1581 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3666 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3667 | const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).type->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3668 | if (Ty == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3669 | GEN_ERROR("Global const reference must be a pointer type!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3670 | |
| 3671 | // ConstExprs can exist in the body of a function, thus creating |
| 3672 | // GlobalValues whenever they refer to a variable. Because we are in |
| 3673 | // the context of a function, getValNonImprovising will search the functions |
| 3674 | // symbol table instead of the module symbol table for the global symbol, |
| 3675 | // which throws things all off. To get around this, we just tell |
| 3676 | // getValNonImprovising that we are at global scope here. |
| 3677 | // |
| 3678 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3679 | CurFun.CurrentFunction = 0; |
| 3680 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3681 | Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3682 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3683 | |
| 3684 | CurFun.CurrentFunction = SavedCurFn; |
| 3685 | |
| 3686 | // If this is an initializer for a constant pointer, which is referencing a |
| 3687 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3688 | // in the future with the right type of variable. |
| 3689 | // |
| 3690 | if (V == 0) { |
| 3691 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
| 3692 | const PointerType *PT = cast<PointerType>(Ty); |
| 3693 | |
| 3694 | // First check to see if the forward references value is already created! |
| 3695 | PerModuleInfo::GlobalRefsType::iterator I = |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3696 | CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal))); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3697 | |
| 3698 | if (I != CurModule.GlobalRefs.end()) { |
| 3699 | V = I->second; // Placeholder already exists, use it... |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3700 | (yyvsp[0].ValIDVal).destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3701 | } else { |
| 3702 | std::string Name; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3703 | if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3704 | |
| 3705 | // Create the forward referenced global. |
| 3706 | GlobalValue *GV; |
| 3707 | if (const FunctionType *FTy = |
| 3708 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 3709 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 3710 | CurModule.CurrentModule); |
| 3711 | } else { |
| 3712 | GV = new GlobalVariable(PT->getElementType(), false, |
| 3713 | GlobalValue::ExternalLinkage, 0, |
| 3714 | Name, CurModule.CurrentModule); |
| 3715 | } |
| 3716 | |
| 3717 | // Keep track of the fact that we have a forward ref to recycle it |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3718 | 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] | 3719 | V = GV; |
| 3720 | } |
| 3721 | } |
| 3722 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3723 | (yyval.ConstVal) = cast<GlobalValue>(V); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3724 | delete (yyvsp[-1].TypeVal).type; // Free the type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3725 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3726 | ;} |
| 3727 | break; |
| 3728 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3729 | case 123: |
| 3730 | #line 1642 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3731 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3732 | if ((yyvsp[-1].TypeVal).type->get() != (yyvsp[0].ConstVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3733 | GEN_ERROR("Mismatched types for constant expression!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3734 | (yyval.ConstVal) = (yyvsp[0].ConstVal); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3735 | delete (yyvsp[-1].TypeVal).type; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3736 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3737 | ;} |
| 3738 | break; |
| 3739 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3740 | case 124: |
| 3741 | #line 1649 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3742 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3743 | const Type *Ty = (yyvsp[-1].TypeVal).type->get(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3744 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3745 | GEN_ERROR("Cannot create a null initialized value of this type!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3746 | (yyval.ConstVal) = Constant::getNullValue(Ty); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3747 | delete (yyvsp[-1].TypeVal).type; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3748 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3749 | ;} |
| 3750 | break; |
| 3751 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3752 | case 125: |
| 3753 | #line 1658 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3754 | { // integral constants |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3755 | if (!ConstantInt::isValueValidForType((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].SInt64Val))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3756 | GEN_ERROR("Constant value doesn't fit in type!"); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3757 | (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].SInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3758 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3759 | ;} |
| 3760 | break; |
| 3761 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3762 | case 126: |
| 3763 | #line 1664 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3764 | { // integral constants |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3765 | if (!ConstantInt::isValueValidForType((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].UInt64Val))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3766 | GEN_ERROR("Constant value doesn't fit in type!"); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3767 | (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].UInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3768 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3769 | ;} |
| 3770 | break; |
| 3771 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3772 | case 127: |
| 3773 | #line 1670 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3774 | { // Boolean constants |
| 3775 | (yyval.ConstVal) = ConstantBool::getTrue(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3776 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3777 | ;} |
| 3778 | break; |
| 3779 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3780 | case 128: |
| 3781 | #line 1674 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3782 | { // Boolean constants |
| 3783 | (yyval.ConstVal) = ConstantBool::getFalse(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3784 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3785 | ;} |
| 3786 | break; |
| 3787 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3788 | case 129: |
| 3789 | #line 1678 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3790 | { // Float & Double constants |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3791 | if (!ConstantFP::isValueValidForType((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].FPVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3792 | GEN_ERROR("Floating point constant invalid for type!!"); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3793 | (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].FPVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3794 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3795 | ;} |
| 3796 | break; |
| 3797 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3798 | case 130: |
| 3799 | #line 1686 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3800 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3801 | Constant *Val = (yyvsp[-3].ConstVal); |
| 3802 | const Type *Ty = (yyvsp[-1].TypeVal).type->get(); |
| 3803 | if (!Val->getType()->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3804 | GEN_ERROR("cast constant expression from a non-primitive type: '" + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3805 | Val->getType()->getDescription() + "'!"); |
| 3806 | if (!Ty->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3807 | GEN_ERROR("cast constant expression to a non-primitive type: '" + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3808 | Ty->getDescription() + "'!"); |
| 3809 | if ((yyvsp[-5].CastOpVal).obsolete) { |
| 3810 | if (Ty == Type::BoolTy) { |
| 3811 | // The previous definition of cast to bool was a compare against zero. |
| 3812 | // We have to retain that semantic so we do it here. |
| 3813 | (yyval.ConstVal) = ConstantExpr::get(Instruction::SetNE, Val, |
| 3814 | Constant::getNullValue(Val->getType())); |
| 3815 | } else if (Val->getType()->isFloatingPoint() && isa<PointerType>(Ty)) { |
| 3816 | Constant *CE = ConstantExpr::getFPToUI(Val, Type::ULongTy); |
| 3817 | (yyval.ConstVal) = ConstantExpr::getIntToPtr(CE, Ty); |
| 3818 | } else { |
| 3819 | (yyval.ConstVal) = ConstantExpr::getCast(Val, Ty); |
| 3820 | } |
| 3821 | } else { |
| 3822 | (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal).type->get()); |
| 3823 | } |
| 3824 | delete (yyvsp[-1].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3825 | ;} |
| 3826 | break; |
| 3827 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3828 | case 131: |
| 3829 | #line 1712 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3830 | { |
| 3831 | if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3832 | GEN_ERROR("GetElementPtr requires a pointer operand!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3833 | |
| 3834 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct |
| 3835 | // indices to uint struct indices for compatibility. |
| 3836 | generic_gep_type_iterator<std::vector<Value*>::iterator> |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3837 | GTI = gep_type_begin((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()), |
| 3838 | GTE = gep_type_end((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()); |
| 3839 | 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] | 3840 | if (isa<StructType>(*GTI)) // Only change struct indices |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3841 | if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[-1].ValueList))[i])) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3842 | if (CUI->getType() == Type::UByteTy) |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3843 | (*(yyvsp[-1].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3844 | |
| 3845 | const Type *IdxTy = |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3846 | GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3847 | if (!IdxTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3848 | GEN_ERROR("Index list invalid for constant getelementptr!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3849 | |
| 3850 | std::vector<Constant*> IdxVec; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3851 | for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i) |
| 3852 | if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i])) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3853 | IdxVec.push_back(C); |
| 3854 | else |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3855 | GEN_ERROR("Indices to constant getelementptr must be constants!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3856 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3857 | delete (yyvsp[-1].ValueList); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3858 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3859 | (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3860 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3861 | ;} |
| 3862 | break; |
| 3863 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3864 | case 132: |
| 3865 | #line 1744 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3866 | { |
| 3867 | if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3868 | GEN_ERROR("Select condition must be of boolean type!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3869 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3870 | GEN_ERROR("Select operand types must match!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3871 | (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] | 3872 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3873 | ;} |
| 3874 | break; |
| 3875 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3876 | case 133: |
| 3877 | #line 1752 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3878 | { |
| 3879 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3880 | GEN_ERROR("Binary operator types must match!"); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3881 | // First, make sure we're dealing with the right opcode by upgrading from |
| 3882 | // obsolete versions. |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3883 | sanitizeOpcode((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal)->getType()); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3884 | CHECK_FOR_ERROR; |
| 3885 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3886 | // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. |
| 3887 | // To retain backward compatibility with these early compilers, we emit a |
| 3888 | // cast to the appropriate integer type automatically if we are in the |
| 3889 | // broken case. See PR424 for more information. |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3890 | if (!isa<PointerType>((yyvsp[-3].ConstVal)->getType())) { |
| 3891 | (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] | 3892 | } else { |
| 3893 | const Type *IntPtrTy = 0; |
| 3894 | switch (CurModule.CurrentModule->getPointerSize()) { |
| 3895 | case Module::Pointer32: IntPtrTy = Type::IntTy; break; |
| 3896 | case Module::Pointer64: IntPtrTy = Type::LongTy; break; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3897 | default: GEN_ERROR("invalid pointer binary constant expr!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3898 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3899 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, ConstantExpr::getCast((yyvsp[-3].ConstVal), IntPtrTy), |
| 3900 | ConstantExpr::getCast((yyvsp[-1].ConstVal), IntPtrTy)); |
| 3901 | (yyval.ConstVal) = ConstantExpr::getCast((yyval.ConstVal), (yyvsp[-3].ConstVal)->getType()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3902 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3903 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3904 | ;} |
| 3905 | break; |
| 3906 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3907 | case 134: |
| 3908 | #line 1779 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3909 | { |
| 3910 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3911 | GEN_ERROR("Logical operator types must match!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3912 | if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) { |
| 3913 | if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) || |
| 3914 | !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3915 | GEN_ERROR("Logical operator requires integral operands!"); |
Chris Lattner | 524a131 | 2005-12-21 18:31:50 +0000 | [diff] [blame] | 3916 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3917 | (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] | 3918 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3919 | ;} |
| 3920 | break; |
| 3921 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3922 | case 135: |
| 3923 | #line 1790 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3924 | { |
| 3925 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3926 | GEN_ERROR("setcc operand types must match!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3927 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3928 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3929 | ;} |
| 3930 | break; |
| 3931 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3932 | case 136: |
| 3933 | #line 1796 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3934 | { |
| 3935 | if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy) |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3936 | GEN_ERROR("Shift count for shift constant must be unsigned byte!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3937 | if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3938 | GEN_ERROR("Shift constant expression requires integer operand!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3939 | // Handle opcode upgrade situations |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3940 | sanitizeOpcode((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal)->getType()); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3941 | CHECK_FOR_ERROR; |
| 3942 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 3943 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3944 | ;} |
| 3945 | break; |
| 3946 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3947 | case 137: |
| 3948 | #line 1807 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3949 | { |
| 3950 | if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3951 | GEN_ERROR("Invalid extractelement operands!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3952 | (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3953 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3954 | ;} |
| 3955 | break; |
| 3956 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3957 | case 138: |
| 3958 | #line 1813 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3959 | { |
| 3960 | if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3961 | GEN_ERROR("Invalid insertelement operands!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3962 | (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] | 3963 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3964 | ;} |
| 3965 | break; |
| 3966 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3967 | case 139: |
| 3968 | #line 1819 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3969 | { |
| 3970 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3971 | GEN_ERROR("Invalid shufflevector operands!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3972 | (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] | 3973 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3974 | ;} |
| 3975 | break; |
| 3976 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3977 | case 140: |
| 3978 | #line 1828 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3979 | { |
| 3980 | ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3981 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3982 | ;} |
| 3983 | break; |
| 3984 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3985 | case 141: |
| 3986 | #line 1832 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3987 | { |
| 3988 | (yyval.ConstVector) = new std::vector<Constant*>(); |
| 3989 | (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3990 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3991 | ;} |
| 3992 | break; |
| 3993 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3994 | case 142: |
| 3995 | #line 1840 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 3996 | { (yyval.BoolVal) = false; ;} |
| 3997 | break; |
| 3998 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 3999 | case 143: |
| 4000 | #line 1840 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4001 | { (yyval.BoolVal) = true; ;} |
| 4002 | break; |
| 4003 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4004 | case 144: |
| 4005 | #line 1850 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4006 | { |
| 4007 | (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4008 | CurModule.ModuleDone(); |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 4009 | CHECK_FOR_ERROR; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4010 | ;} |
| 4011 | break; |
| 4012 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4013 | case 145: |
| 4014 | #line 1858 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4015 | { |
| 4016 | (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4017 | CurFun.FunctionDone(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4018 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4019 | ;} |
| 4020 | break; |
| 4021 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4022 | case 146: |
| 4023 | #line 1863 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4024 | { |
| 4025 | (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4026 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4027 | ;} |
| 4028 | break; |
| 4029 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4030 | case 147: |
| 4031 | #line 1867 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4032 | { |
| 4033 | (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame] | 4034 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4035 | ;} |
| 4036 | break; |
| 4037 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4038 | case 148: |
| 4039 | #line 1871 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4040 | { |
| 4041 | (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame] | 4042 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4043 | ;} |
| 4044 | break; |
| 4045 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4046 | case 149: |
| 4047 | #line 1875 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4048 | { |
| 4049 | (yyval.ModuleVal) = CurModule.CurrentModule; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4050 | // Emit an error if there are any unresolved types left. |
| 4051 | if (!CurModule.LateResolveTypes.empty()) { |
| 4052 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4053 | if (DID.Type == ValID::NameVal) { |
| 4054 | GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'"); |
| 4055 | } else { |
| 4056 | GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num)); |
| 4057 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4058 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4059 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4060 | ;} |
| 4061 | break; |
| 4062 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4063 | case 150: |
| 4064 | #line 1890 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4065 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4066 | // Eagerly resolve types. This is not an optimization, this is a |
| 4067 | // requirement that is due to the fact that we could have this: |
| 4068 | // |
| 4069 | // %list = type { %list * } |
| 4070 | // %list = type { %list * } ; repeated type decl |
| 4071 | // |
| 4072 | // If types are not resolved eagerly, then the two types will not be |
| 4073 | // determined to be the same type! |
| 4074 | // |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4075 | ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].TypeVal).type->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4076 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4077 | if (!setTypeName((yyvsp[0].TypeVal).type->get(), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4078 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4079 | // If this is a named type that is not a redefinition, add it to the slot |
| 4080 | // table. |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4081 | CurModule.Types.push_back((yyvsp[0].TypeVal)); |
| 4082 | } else { |
| 4083 | delete (yyvsp[0].TypeVal).type; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4084 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4085 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4086 | ;} |
| 4087 | break; |
| 4088 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4089 | case 151: |
| 4090 | #line 1912 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4091 | { // Function prototypes can be in const pool |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4092 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4093 | ;} |
| 4094 | break; |
| 4095 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4096 | case 152: |
| 4097 | #line 1915 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4098 | { // Asm blocks can be in the const pool |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4099 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4100 | ;} |
| 4101 | break; |
| 4102 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4103 | case 153: |
| 4104 | #line 1918 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4105 | { |
| 4106 | if ((yyvsp[0].ConstVal) == 0) |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4107 | GEN_ERROR("Global value initializer is not a constant!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4108 | 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] | 4109 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4110 | ;} |
| 4111 | break; |
| 4112 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4113 | case 154: |
| 4114 | #line 1923 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4115 | { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4116 | CurGV = 0; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4117 | ;} |
| 4118 | break; |
| 4119 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4120 | case 155: |
| 4121 | #line 1926 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4122 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4123 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), |
| 4124 | (yyvsp[0].TypeVal).type->get(), 0); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4125 | CHECK_FOR_ERROR |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4126 | delete (yyvsp[0].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4127 | ;} |
| 4128 | break; |
| 4129 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4130 | case 156: |
| 4131 | #line 1931 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4132 | { |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4133 | CurGV = 0; |
| 4134 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4135 | ;} |
| 4136 | break; |
| 4137 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4138 | case 157: |
| 4139 | #line 1935 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4140 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4141 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), |
| 4142 | (yyvsp[0].TypeVal).type->get(), 0); |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame] | 4143 | CHECK_FOR_ERROR |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4144 | delete (yyvsp[0].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4145 | ;} |
| 4146 | break; |
| 4147 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4148 | case 158: |
| 4149 | #line 1940 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4150 | { |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame] | 4151 | CurGV = 0; |
| 4152 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4153 | ;} |
| 4154 | break; |
| 4155 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4156 | case 159: |
| 4157 | #line 1944 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4158 | { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4159 | CurGV = |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4160 | ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), |
| 4161 | (yyvsp[0].TypeVal).type->get(), 0); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4162 | CHECK_FOR_ERROR |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4163 | delete (yyvsp[0].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4164 | ;} |
| 4165 | break; |
| 4166 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4167 | case 160: |
| 4168 | #line 1950 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4169 | { |
Anton Korobeynikov | bcb9770 | 2006-09-17 20:25:45 +0000 | [diff] [blame] | 4170 | CurGV = 0; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4171 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4172 | ;} |
| 4173 | break; |
| 4174 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4175 | case 161: |
| 4176 | #line 1954 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4177 | { |
Anton Korobeynikov | bcb9770 | 2006-09-17 20:25:45 +0000 | [diff] [blame] | 4178 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4179 | ;} |
| 4180 | break; |
| 4181 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4182 | case 162: |
| 4183 | #line 1957 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4184 | { |
Anton Korobeynikov | bcb9770 | 2006-09-17 20:25:45 +0000 | [diff] [blame] | 4185 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4186 | ;} |
| 4187 | break; |
| 4188 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4189 | case 163: |
| 4190 | #line 1960 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4191 | { |
| 4192 | ;} |
| 4193 | break; |
| 4194 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4195 | case 164: |
| 4196 | #line 1964 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4197 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4198 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4199 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4200 | std::string NewAsm((yyvsp[0].StrVal), EndStr); |
| 4201 | free((yyvsp[0].StrVal)); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4202 | |
| 4203 | if (AsmSoFar.empty()) |
| 4204 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 4205 | else |
| 4206 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4207 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4208 | ;} |
| 4209 | break; |
| 4210 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4211 | case 165: |
| 4212 | #line 1977 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4213 | { (yyval.Endianness) = Module::BigEndian; ;} |
| 4214 | break; |
| 4215 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4216 | case 166: |
| 4217 | #line 1978 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4218 | { (yyval.Endianness) = Module::LittleEndian; ;} |
| 4219 | break; |
| 4220 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4221 | case 167: |
| 4222 | #line 1980 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4223 | { |
| 4224 | CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4225 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4226 | ;} |
| 4227 | break; |
| 4228 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4229 | case 168: |
| 4230 | #line 1984 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4231 | { |
| 4232 | if ((yyvsp[0].UInt64Val) == 32) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4233 | CurModule.CurrentModule->setPointerSize(Module::Pointer32); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4234 | else if ((yyvsp[0].UInt64Val) == 64) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4235 | CurModule.CurrentModule->setPointerSize(Module::Pointer64); |
| 4236 | else |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4237 | GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4238 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4239 | ;} |
| 4240 | break; |
| 4241 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4242 | case 169: |
| 4243 | #line 1993 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4244 | { |
| 4245 | CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); |
| 4246 | free((yyvsp[0].StrVal)); |
| 4247 | ;} |
| 4248 | break; |
| 4249 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4250 | case 170: |
| 4251 | #line 1997 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4252 | { |
| 4253 | CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); |
| 4254 | free((yyvsp[0].StrVal)); |
| 4255 | ;} |
| 4256 | break; |
| 4257 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4258 | case 172: |
| 4259 | #line 2004 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4260 | { |
| 4261 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 4262 | free((yyvsp[0].StrVal)); |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame] | 4263 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4264 | ;} |
| 4265 | break; |
| 4266 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4267 | case 173: |
| 4268 | #line 2009 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4269 | { |
| 4270 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 4271 | free((yyvsp[0].StrVal)); |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame] | 4272 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4273 | ;} |
| 4274 | break; |
| 4275 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4276 | case 174: |
| 4277 | #line 2014 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4278 | { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4279 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4280 | ;} |
| 4281 | break; |
| 4282 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4283 | case 178: |
| 4284 | #line 2024 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4285 | { (yyval.StrVal) = 0; ;} |
| 4286 | break; |
| 4287 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4288 | case 179: |
| 4289 | #line 2026 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4290 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4291 | if ((yyvsp[-1].TypeVal).type->get() == Type::VoidTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4292 | GEN_ERROR("void typed arguments are invalid!"); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4293 | (yyval.ArgVal) = new std::pair<TypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4294 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4295 | ;} |
| 4296 | break; |
| 4297 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4298 | case 180: |
| 4299 | #line 2033 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4300 | { |
| 4301 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
| 4302 | (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal)); |
| 4303 | delete (yyvsp[0].ArgVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4304 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4305 | ;} |
| 4306 | break; |
| 4307 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4308 | case 181: |
| 4309 | #line 2039 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4310 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4311 | (yyval.ArgList) = new std::vector<std::pair<TypeInfo,char*> >(); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4312 | (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); |
| 4313 | delete (yyvsp[0].ArgVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4314 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4315 | ;} |
| 4316 | break; |
| 4317 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4318 | case 182: |
| 4319 | #line 2046 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4320 | { |
| 4321 | (yyval.ArgList) = (yyvsp[0].ArgList); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4322 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4323 | ;} |
| 4324 | break; |
| 4325 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4326 | case 183: |
| 4327 | #line 2050 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4328 | { |
| 4329 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4330 | TypeInfo TI; |
| 4331 | TI.type = new PATypeHolder(Type::VoidTy); |
| 4332 | TI.signedness = isSignless; |
| 4333 | (yyval.ArgList)->push_back(std::pair<TypeInfo,char*>(TI,(char*)0)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4334 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4335 | ;} |
| 4336 | break; |
| 4337 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4338 | case 184: |
| 4339 | #line 2058 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4340 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4341 | (yyval.ArgList) = new std::vector<std::pair<TypeInfo,char*> >(); |
| 4342 | TypeInfo TI; |
| 4343 | TI.type = new PATypeHolder(Type::VoidTy); |
| 4344 | TI.signedness = isSignless; |
| 4345 | (yyval.ArgList)->push_back(std::make_pair(TI, (char*)0)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4346 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4347 | ;} |
| 4348 | break; |
| 4349 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4350 | case 185: |
| 4351 | #line 2066 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4352 | { |
| 4353 | (yyval.ArgList) = 0; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4354 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4355 | ;} |
| 4356 | break; |
| 4357 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4358 | case 186: |
| 4359 | #line 2072 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4360 | { |
| 4361 | UnEscapeLexed((yyvsp[-5].StrVal)); |
| 4362 | std::string FunctionName((yyvsp[-5].StrVal)); |
| 4363 | free((yyvsp[-5].StrVal)); // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4364 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4365 | if (!((yyvsp[-6].TypeVal).type->get())->isFirstClassType() && (yyvsp[-6].TypeVal).type->get() != Type::VoidTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4366 | GEN_ERROR("LLVM functions cannot return aggregate types!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4367 | |
| 4368 | std::vector<const Type*> ParamTypeList; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4369 | if ((yyvsp[-3].ArgList)) { // If there are arguments... |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4370 | for (std::vector<std::pair<TypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin(); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4371 | I != (yyvsp[-3].ArgList)->end(); ++I) |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4372 | ParamTypeList.push_back(I->first.type->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4373 | } |
| 4374 | |
| 4375 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 4376 | if (isVarArg) ParamTypeList.pop_back(); |
| 4377 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4378 | const FunctionType *FT = FunctionType::get((yyvsp[-6].TypeVal).type->get(), ParamTypeList, |
| 4379 | isVarArg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4380 | const PointerType *PFT = PointerType::get(FT); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4381 | delete (yyvsp[-6].TypeVal).type; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4382 | |
| 4383 | ValID ID; |
| 4384 | if (!FunctionName.empty()) { |
| 4385 | ID = ValID::create((char*)FunctionName.c_str()); |
| 4386 | } else { |
| 4387 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
| 4388 | } |
| 4389 | |
| 4390 | Function *Fn = 0; |
| 4391 | // See if this function was forward referenced. If so, recycle the object. |
| 4392 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 4393 | // Move the function to the end of the list, from whereever it was |
| 4394 | // previously inserted. |
| 4395 | Fn = cast<Function>(FWRef); |
| 4396 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 4397 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 4398 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
| 4399 | (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) { |
| 4400 | // If this is the case, either we need to be a forward decl, or it needs |
| 4401 | // to be. |
| 4402 | if (!CurFun.isDeclare && !Fn->isExternal()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4403 | GEN_ERROR("Redefinition of function '" + FunctionName + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4404 | |
| 4405 | // Make sure to strip off any argument names so we can't get conflicts. |
| 4406 | if (Fn->isExternal()) |
| 4407 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 4408 | AI != AE; ++AI) |
| 4409 | AI->setName(""); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4410 | } else { // Not already defined? |
| 4411 | Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, |
| 4412 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4413 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4414 | InsertValue(Fn, CurModule.Values); |
| 4415 | } |
| 4416 | |
| 4417 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4418 | |
| 4419 | if (CurFun.isDeclare) { |
| 4420 | // If we have declaration, always overwrite linkage. This will allow us to |
| 4421 | // correctly handle cases, when pointer to function is passed as argument to |
| 4422 | // another function. |
| 4423 | Fn->setLinkage(CurFun.Linkage); |
| 4424 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4425 | Fn->setCallingConv((yyvsp[-7].UIntVal)); |
| 4426 | Fn->setAlignment((yyvsp[0].UIntVal)); |
| 4427 | if ((yyvsp[-1].StrVal)) { |
| 4428 | Fn->setSection((yyvsp[-1].StrVal)); |
| 4429 | free((yyvsp[-1].StrVal)); |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 4430 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4431 | |
| 4432 | // Add all of the arguments we parsed to the function... |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4433 | if ((yyvsp[-3].ArgList)) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4434 | if (isVarArg) { // Nuke the last entry |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4435 | assert((yyvsp[-3].ArgList)->back().first.type->get() == Type::VoidTy && |
| 4436 | (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker!"); |
| 4437 | delete (yyvsp[-3].ArgList)->back().first.type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4438 | (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4439 | } |
| 4440 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4441 | for (std::vector<std::pair<TypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin(); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4442 | I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4443 | delete I->first.type; // Delete the typeholder... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4444 | setValueName(ArgIt, I->second); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4445 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4446 | InsertValue(ArgIt); |
| 4447 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4448 | delete (yyvsp[-3].ArgList); // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4449 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4450 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4451 | ;} |
| 4452 | break; |
| 4453 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4454 | case 189: |
| 4455 | #line 2167 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4456 | { |
| 4457 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4458 | |
| 4459 | // Make sure that we keep track of the linkage type even if there was a |
| 4460 | // previous "declare". |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4461 | (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage)); |
| 4462 | ;} |
| 4463 | break; |
| 4464 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4465 | case 192: |
| 4466 | #line 2177 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4467 | { |
| 4468 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4469 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4470 | ;} |
| 4471 | break; |
| 4472 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4473 | case 194: |
| 4474 | #line 2183 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4475 | { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;} |
| 4476 | break; |
| 4477 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4478 | case 195: |
| 4479 | #line 2184 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4480 | { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;} |
| 4481 | break; |
| 4482 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4483 | case 196: |
| 4484 | #line 2186 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4485 | { CurFun.isDeclare = true; ;} |
| 4486 | break; |
| 4487 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4488 | case 197: |
| 4489 | #line 2186 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4490 | { |
| 4491 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4492 | CurFun.FunctionDone(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4493 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4494 | ;} |
| 4495 | break; |
| 4496 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4497 | case 198: |
| 4498 | #line 2196 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4499 | { |
| 4500 | (yyval.BoolVal) = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4501 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4502 | ;} |
| 4503 | break; |
| 4504 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4505 | case 199: |
| 4506 | #line 2200 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4507 | { |
| 4508 | (yyval.BoolVal) = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4509 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4510 | ;} |
| 4511 | break; |
| 4512 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4513 | case 200: |
| 4514 | #line 2205 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4515 | { // A reference to a direct constant |
| 4516 | (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4517 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4518 | ;} |
| 4519 | break; |
| 4520 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4521 | case 201: |
| 4522 | #line 2209 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4523 | { |
| 4524 | (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4525 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4526 | ;} |
| 4527 | break; |
| 4528 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4529 | case 202: |
| 4530 | #line 2213 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4531 | { // Perhaps it's an FP constant? |
| 4532 | (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4533 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4534 | ;} |
| 4535 | break; |
| 4536 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4537 | case 203: |
| 4538 | #line 2217 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4539 | { |
| 4540 | (yyval.ValIDVal) = ValID::create(ConstantBool::getTrue()); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4541 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4542 | ;} |
| 4543 | break; |
| 4544 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4545 | case 204: |
| 4546 | #line 2221 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4547 | { |
| 4548 | (yyval.ValIDVal) = ValID::create(ConstantBool::getFalse()); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4549 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4550 | ;} |
| 4551 | break; |
| 4552 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4553 | case 205: |
| 4554 | #line 2225 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4555 | { |
| 4556 | (yyval.ValIDVal) = ValID::createNull(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4557 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4558 | ;} |
| 4559 | break; |
| 4560 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4561 | case 206: |
| 4562 | #line 2229 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4563 | { |
| 4564 | (yyval.ValIDVal) = ValID::createUndef(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4565 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4566 | ;} |
| 4567 | break; |
| 4568 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4569 | case 207: |
| 4570 | #line 2233 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4571 | { // A vector zero constant. |
| 4572 | (yyval.ValIDVal) = ValID::createZeroInit(); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4573 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4574 | ;} |
| 4575 | break; |
| 4576 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4577 | case 208: |
| 4578 | #line 2237 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4579 | { // Nonempty unsized packed vector |
| 4580 | const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType(); |
| 4581 | int NumElements = (yyvsp[-1].ConstVector)->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4582 | |
| 4583 | PackedType* pt = PackedType::get(ETy, NumElements); |
| 4584 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4585 | HandleUpRefs(PackedType::get( ETy, NumElements))); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4586 | |
| 4587 | // Verify all elements are correct type! |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4588 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 4589 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4590 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4591 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4592 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4593 | } |
| 4594 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4595 | (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector))); |
| 4596 | delete PTy; delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4597 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4598 | ;} |
| 4599 | break; |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4600 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4601 | case 209: |
| 4602 | #line 2257 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4603 | { |
| 4604 | (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal)); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4605 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4606 | ;} |
| 4607 | break; |
| 4608 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4609 | case 210: |
| 4610 | #line 2261 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4611 | { |
| 4612 | char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); |
| 4613 | std::string AsmStr = std::string((yyvsp[-2].StrVal), End); |
| 4614 | End = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4615 | std::string Constraints = std::string((yyvsp[0].StrVal), End); |
| 4616 | (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal)); |
| 4617 | free((yyvsp[-2].StrVal)); |
| 4618 | free((yyvsp[0].StrVal)); |
Reid Spencer | 21be865 | 2006-10-22 07:03:43 +0000 | [diff] [blame] | 4619 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4620 | ;} |
| 4621 | break; |
| 4622 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4623 | case 211: |
| 4624 | #line 2275 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4625 | { // Is it an integer reference...? |
| 4626 | (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); |
| 4627 | CHECK_FOR_ERROR |
| 4628 | ;} |
| 4629 | break; |
| 4630 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4631 | case 212: |
| 4632 | #line 2279 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4633 | { // Is it a named reference...? |
| 4634 | (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); |
| 4635 | CHECK_FOR_ERROR |
| 4636 | ;} |
| 4637 | break; |
| 4638 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4639 | case 215: |
| 4640 | #line 2291 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4641 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4642 | (yyval.ValueVal) = getVal((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4643 | CHECK_FOR_ERROR |
| 4644 | ;} |
| 4645 | break; |
| 4646 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4647 | case 216: |
| 4648 | #line 2296 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4649 | { |
| 4650 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 4651 | CHECK_FOR_ERROR |
| 4652 | ;} |
| 4653 | break; |
| 4654 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4655 | case 217: |
| 4656 | #line 2300 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4657 | { // Do not allow functions with 0 basic blocks |
| 4658 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 4659 | CHECK_FOR_ERROR |
| 4660 | ;} |
| 4661 | break; |
| 4662 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4663 | case 218: |
| 4664 | #line 2309 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4665 | { |
| 4666 | setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal)); |
| 4667 | CHECK_FOR_ERROR |
| 4668 | InsertValue((yyvsp[0].TermInstVal)); |
| 4669 | |
| 4670 | (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal)); |
| 4671 | InsertValue((yyvsp[-2].BasicBlockVal)); |
| 4672 | (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal); |
| 4673 | CHECK_FOR_ERROR |
| 4674 | ;} |
| 4675 | break; |
| 4676 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4677 | case 219: |
| 4678 | #line 2320 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4679 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4680 | if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal))) |
| 4681 | if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0))) |
| 4682 | if (CI2->getParent() == 0) |
| 4683 | (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4684 | (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal)); |
| 4685 | (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); |
| 4686 | CHECK_FOR_ERROR |
| 4687 | ;} |
| 4688 | break; |
| 4689 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4690 | case 220: |
| 4691 | #line 2329 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4692 | { |
| 4693 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4694 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4695 | |
| 4696 | // Make sure to move the basic block to the correct location in the |
| 4697 | // function, instead of leaving it inserted wherever it was first |
| 4698 | // referenced. |
| 4699 | Function::BasicBlockListType &BBL = |
| 4700 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4701 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4702 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4703 | ;} |
| 4704 | break; |
| 4705 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4706 | case 221: |
| 4707 | #line 2341 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4708 | { |
| 4709 | (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4710 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4711 | |
| 4712 | // Make sure to move the basic block to the correct location in the |
| 4713 | // function, instead of leaving it inserted wherever it was first |
| 4714 | // referenced. |
| 4715 | Function::BasicBlockListType &BBL = |
| 4716 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4717 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4718 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4719 | ;} |
| 4720 | break; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4721 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4722 | case 222: |
| 4723 | #line 2354 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4724 | { // Return with a result... |
| 4725 | (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal)); |
| 4726 | CHECK_FOR_ERROR |
| 4727 | ;} |
| 4728 | break; |
| 4729 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4730 | case 223: |
| 4731 | #line 2358 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4732 | { // Return with no result... |
| 4733 | (yyval.TermInstVal) = new ReturnInst(); |
| 4734 | CHECK_FOR_ERROR |
| 4735 | ;} |
| 4736 | break; |
| 4737 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4738 | case 224: |
| 4739 | #line 2362 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4740 | { // Unconditional Branch... |
| 4741 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
| 4742 | CHECK_FOR_ERROR |
| 4743 | (yyval.TermInstVal) = new BranchInst(tmpBB); |
| 4744 | ;} |
| 4745 | break; |
| 4746 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4747 | case 225: |
| 4748 | #line 2367 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4749 | { |
| 4750 | BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); |
| 4751 | CHECK_FOR_ERROR |
| 4752 | BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal)); |
| 4753 | CHECK_FOR_ERROR |
| 4754 | Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal)); |
| 4755 | CHECK_FOR_ERROR |
| 4756 | (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4757 | ;} |
| 4758 | break; |
| 4759 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4760 | case 226: |
| 4761 | #line 2376 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4762 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4763 | Value* tmpVal = getVal((yyvsp[-7].TypeVal).type->get(), (yyvsp[-6].ValIDVal)); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4764 | CHECK_FOR_ERROR |
| 4765 | BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal)); |
| 4766 | CHECK_FOR_ERROR |
| 4767 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size()); |
| 4768 | (yyval.TermInstVal) = S; |
| 4769 | |
| 4770 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(), |
| 4771 | E = (yyvsp[-1].JumpTable)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4772 | for (; I != E; ++I) { |
| 4773 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4774 | S->addCase(CI, I->second); |
| 4775 | else |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4776 | GEN_ERROR("Switch case is constant, but not a simple integer!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4777 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4778 | delete (yyvsp[-1].JumpTable); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4779 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4780 | ;} |
| 4781 | break; |
| 4782 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4783 | case 227: |
| 4784 | #line 2395 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4785 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4786 | Value* tmpVal = getVal((yyvsp[-6].TypeVal).type->get(), (yyvsp[-5].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4787 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4788 | BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4789 | CHECK_FOR_ERROR |
| 4790 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4791 | (yyval.TermInstVal) = S; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4792 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4793 | ;} |
| 4794 | break; |
| 4795 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4796 | case 228: |
| 4797 | #line 2405 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4798 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4799 | const PointerType *PFTy; |
| 4800 | const FunctionType *Ty; |
| 4801 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4802 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).type->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4803 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4804 | // Pull out the types of all of the arguments... |
| 4805 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4806 | if ((yyvsp[-7].ValueList)) { |
| 4807 | 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] | 4808 | I != E; ++I) |
| 4809 | ParamTypes.push_back((*I)->getType()); |
| 4810 | } |
| 4811 | |
| 4812 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 4813 | if (isVarArg) ParamTypes.pop_back(); |
| 4814 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4815 | Ty = FunctionType::get((yyvsp[-10].TypeVal).type->get(), ParamTypes, isVarArg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4816 | PFTy = PointerType::get(Ty); |
| 4817 | } |
| 4818 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4819 | 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] | 4820 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4821 | BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4822 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4823 | BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4824 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4825 | |
| 4826 | // Create the call node... |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4827 | if (!(yyvsp[-7].ValueList)) { // Has no arguments? |
| 4828 | (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4829 | } else { // Has arguments? |
| 4830 | // Loop through FunctionType's arguments and ensure they are specified |
| 4831 | // correctly! |
| 4832 | // |
| 4833 | FunctionType::param_iterator I = Ty->param_begin(); |
| 4834 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4835 | 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] | 4836 | |
| 4837 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 4838 | if ((*ArgI)->getType() != *I) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4839 | GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4840 | (*I)->getDescription() + "'!"); |
| 4841 | |
| 4842 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4843 | GEN_ERROR("Invalid number of parameters detected!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4844 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4845 | (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4846 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4847 | cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4848 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4849 | delete (yyvsp[-10].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4850 | delete (yyvsp[-7].ValueList); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4851 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4852 | ;} |
| 4853 | break; |
| 4854 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4855 | case 229: |
| 4856 | #line 2460 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4857 | { |
| 4858 | (yyval.TermInstVal) = new UnwindInst(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4859 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4860 | ;} |
| 4861 | break; |
| 4862 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4863 | case 230: |
| 4864 | #line 2464 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4865 | { |
| 4866 | (yyval.TermInstVal) = new UnreachableInst(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4867 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4868 | ;} |
| 4869 | break; |
| 4870 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4871 | case 231: |
| 4872 | #line 2471 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4873 | { |
| 4874 | (yyval.JumpTable) = (yyvsp[-5].JumpTable); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4875 | Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].TypeVal).type->get(), (yyvsp[-3].ValIDVal))); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4876 | CHECK_FOR_ERROR |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4877 | if (V == 0) |
| 4878 | GEN_ERROR("May only switch on a constant pool value!"); |
| 4879 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4880 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4881 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4882 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 4883 | ;} |
| 4884 | break; |
| 4885 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4886 | case 232: |
| 4887 | #line 2482 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4888 | { |
| 4889 | (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4890 | Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].TypeVal).type->get(), (yyvsp[-3].ValIDVal))); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4891 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4892 | |
| 4893 | if (V == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4894 | GEN_ERROR("May only switch on a constant pool value!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4895 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4896 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4897 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4898 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 4899 | ;} |
| 4900 | break; |
| 4901 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4902 | case 233: |
| 4903 | #line 2495 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4904 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4905 | // Is this definition named?? if so, assign the name... |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4906 | setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4907 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4908 | InsertValue((yyvsp[0].InstVal)); |
| 4909 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4910 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4911 | ;} |
| 4912 | break; |
| 4913 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4914 | case 234: |
| 4915 | #line 2504 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4916 | { // Used for PHI nodes |
| 4917 | (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >(); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4918 | Value* tmpVal = getVal((yyvsp[-5].TypeVal).type->get(), (yyvsp[-3].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4919 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4920 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4921 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4922 | (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4923 | delete (yyvsp[-5].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4924 | ;} |
| 4925 | break; |
| 4926 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4927 | case 235: |
| 4928 | #line 2513 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4929 | { |
| 4930 | (yyval.PHIList) = (yyvsp[-6].PHIList); |
| 4931 | Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4932 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4933 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4934 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4935 | (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 4936 | ;} |
| 4937 | break; |
| 4938 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4939 | case 236: |
| 4940 | #line 2523 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4941 | { // Used for call statements, and memory insts... |
| 4942 | (yyval.ValueList) = new std::vector<Value*>(); |
| 4943 | (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); |
| 4944 | ;} |
| 4945 | break; |
| 4946 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4947 | case 237: |
| 4948 | #line 2527 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4949 | { |
| 4950 | (yyval.ValueList) = (yyvsp[-2].ValueList); |
| 4951 | (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4952 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4953 | ;} |
| 4954 | break; |
| 4955 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4956 | case 239: |
| 4957 | #line 2534 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4958 | { (yyval.ValueList) = 0; ;} |
| 4959 | break; |
| 4960 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4961 | case 240: |
| 4962 | #line 2536 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4963 | { |
| 4964 | (yyval.BoolVal) = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4965 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4966 | ;} |
| 4967 | break; |
| 4968 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4969 | case 241: |
| 4970 | #line 2540 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4971 | { |
| 4972 | (yyval.BoolVal) = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4973 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4974 | ;} |
| 4975 | break; |
| 4976 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4977 | case 242: |
| 4978 | #line 2545 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4979 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4980 | if (!(yyvsp[-3].TypeVal).type->get()->isInteger() && !(yyvsp[-3].TypeVal).type->get()->isFloatingPoint() && |
| 4981 | !isa<PackedType>((yyvsp[-3].TypeVal).type->get())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4982 | GEN_ERROR( |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4983 | "Arithmetic operator requires integer, FP, or packed operands!"); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4984 | if (isa<PackedType>((yyvsp[-3].TypeVal).type->get()) && |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4985 | ((yyvsp[-4].BinaryOpVal).opcode == Instruction::URem || |
| 4986 | (yyvsp[-4].BinaryOpVal).opcode == Instruction::SRem || |
| 4987 | (yyvsp[-4].BinaryOpVal).opcode == Instruction::FRem)) |
Reid Spencer | 3ed469c | 2006-11-02 20:25:50 +0000 | [diff] [blame] | 4988 | GEN_ERROR("U/S/FRem not supported on packed types!"); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4989 | // Upgrade the opcode from obsolete versions before we do anything with it. |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4990 | sanitizeOpcode((yyvsp[-4].BinaryOpVal),(yyvsp[-3].TypeVal).type->get()); |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 4991 | CHECK_FOR_ERROR; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4992 | Value* val1 = getVal((yyvsp[-3].TypeVal).type->get(), (yyvsp[-2].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4993 | CHECK_FOR_ERROR |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4994 | Value* val2 = getVal((yyvsp[-3].TypeVal).type->get(), (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4995 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4996 | (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, val1, val2); |
| 4997 | if ((yyval.InstVal) == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4998 | GEN_ERROR("binary operator returned null!"); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 4999 | delete (yyvsp[-3].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5000 | ;} |
| 5001 | break; |
| 5002 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5003 | case 243: |
| 5004 | #line 2567 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5005 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5006 | if (!(yyvsp[-3].TypeVal).type->get()->isIntegral()) { |
| 5007 | if (!isa<PackedType>((yyvsp[-3].TypeVal).type->get()) || |
| 5008 | !cast<PackedType>((yyvsp[-3].TypeVal).type->get())->getElementType()->isIntegral()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5009 | GEN_ERROR("Logical operator requires integral operands!"); |
Chris Lattner | 524a131 | 2005-12-21 18:31:50 +0000 | [diff] [blame] | 5010 | } |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5011 | Value* tmpVal1 = getVal((yyvsp[-3].TypeVal).type->get(), (yyvsp[-2].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5012 | CHECK_FOR_ERROR |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5013 | Value* tmpVal2 = getVal((yyvsp[-3].TypeVal).type->get(), (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5014 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5015 | (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2); |
| 5016 | if ((yyval.InstVal) == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5017 | GEN_ERROR("binary operator returned null!"); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5018 | delete (yyvsp[-3].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5019 | ;} |
| 5020 | break; |
| 5021 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5022 | case 244: |
| 5023 | #line 2582 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5024 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5025 | if(isa<PackedType>((yyvsp[-3].TypeVal).type->get())) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5026 | GEN_ERROR( |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5027 | "PackedTypes currently not supported in setcc instructions!"); |
| 5028 | } |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5029 | Value* tmpVal1 = getVal((yyvsp[-3].TypeVal).type->get(), (yyvsp[-2].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5030 | CHECK_FOR_ERROR |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5031 | Value* tmpVal2 = getVal((yyvsp[-3].TypeVal).type->get(), (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5032 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5033 | (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2); |
| 5034 | if ((yyval.InstVal) == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5035 | GEN_ERROR("binary operator returned null!"); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5036 | delete (yyvsp[-3].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5037 | ;} |
| 5038 | break; |
| 5039 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5040 | case 245: |
| 5041 | #line 2596 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5042 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5043 | std::cerr << "WARNING: Use of eliminated 'not' instruction:" |
| 5044 | << " Replacing with 'xor'.\n"; |
| 5045 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5046 | Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5047 | if (Ones == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5048 | GEN_ERROR("Expected integral type for not instruction!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5049 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5050 | (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones); |
| 5051 | if ((yyval.InstVal) == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5052 | GEN_ERROR("Could not create a xor instruction!"); |
| 5053 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5054 | ;} |
| 5055 | break; |
| 5056 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5057 | case 246: |
| 5058 | #line 2609 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5059 | { |
| 5060 | if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5061 | GEN_ERROR("Shift amount must be ubyte!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5062 | if (!(yyvsp[-2].ValueVal)->getType()->isInteger()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5063 | GEN_ERROR("Shift constant expression requires integer operand!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5064 | // Handle opcode upgrade situations |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5065 | sanitizeOpcode((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal)->getType()); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5066 | CHECK_FOR_ERROR; |
| 5067 | (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] | 5068 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5069 | ;} |
| 5070 | break; |
| 5071 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5072 | case 247: |
| 5073 | #line 2620 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5074 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5075 | Value* Val = (yyvsp[-2].ValueVal); |
| 5076 | const Type* Ty = (yyvsp[0].TypeVal).type->get(); |
| 5077 | if (!Val->getType()->isFirstClassType()) |
| 5078 | GEN_ERROR("cast from a non-primitive type: '" + |
| 5079 | Val->getType()->getDescription() + "'!"); |
| 5080 | if (!Ty->isFirstClassType()) |
| 5081 | GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!"); |
| 5082 | |
| 5083 | if ((yyvsp[-3].CastOpVal).obsolete) { |
| 5084 | if (Ty == Type::BoolTy) { |
| 5085 | // The previous definition of cast to bool was a compare against zero. |
| 5086 | // We have to retain that semantic so we do it here. |
| 5087 | (yyval.InstVal) = new SetCondInst(Instruction::SetNE, (yyvsp[-2].ValueVal), |
| 5088 | Constant::getNullValue((yyvsp[-2].ValueVal)->getType())); |
| 5089 | } else if (Val->getType()->isFloatingPoint() && isa<PointerType>(Ty)) { |
| 5090 | CastInst *CI = new FPToUIInst(Val, Type::ULongTy); |
| 5091 | (yyval.InstVal) = new IntToPtrInst(CI, Ty); |
| 5092 | } else { |
| 5093 | (yyval.InstVal) = CastInst::createInferredCast(Val, Ty); |
| 5094 | } |
| 5095 | } else { |
| 5096 | (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal).opcode, (yyvsp[-2].ValueVal), (yyvsp[0].TypeVal).type->get()); |
| 5097 | } |
| 5098 | delete (yyvsp[0].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5099 | ;} |
| 5100 | break; |
| 5101 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5102 | case 248: |
| 5103 | #line 2646 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5104 | { |
| 5105 | if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5106 | GEN_ERROR("select condition must be boolean!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5107 | if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5108 | GEN_ERROR("select value types should match!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5109 | (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] | 5110 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5111 | ;} |
| 5112 | break; |
| 5113 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5114 | case 249: |
| 5115 | #line 2654 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5116 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5117 | NewVarArgs = true; |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5118 | (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), (yyvsp[0].TypeVal).type->get()); |
| 5119 | delete (yyvsp[0].TypeVal).type; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5120 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5121 | ;} |
| 5122 | break; |
| 5123 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5124 | case 250: |
| 5125 | #line 2660 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5126 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5127 | ObsoleteVarArgs = true; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5128 | const Type* ArgTy = (yyvsp[-2].ValueVal)->getType(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5129 | Function* NF = CurModule.CurrentModule-> |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 5130 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5131 | |
| 5132 | //b = vaarg a, t -> |
| 5133 | //foo = alloca 1 of t |
| 5134 | //bar = vacopy a |
| 5135 | //store bar -> foo |
| 5136 | //b = vaarg foo, t |
| 5137 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix"); |
| 5138 | CurBB->getInstList().push_back(foo); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5139 | CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5140 | CurBB->getInstList().push_back(bar); |
| 5141 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5142 | (yyval.InstVal) = new VAArgInst(foo, (yyvsp[0].TypeVal).type->get()); |
| 5143 | delete (yyvsp[0].TypeVal).type; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5144 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5145 | ;} |
| 5146 | break; |
| 5147 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5148 | case 251: |
| 5149 | #line 2680 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5150 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5151 | ObsoleteVarArgs = true; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5152 | const Type* ArgTy = (yyvsp[-2].ValueVal)->getType(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5153 | Function* NF = CurModule.CurrentModule-> |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 5154 | getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5155 | |
| 5156 | //b = vanext a, t -> |
| 5157 | //foo = alloca 1 of t |
| 5158 | //bar = vacopy a |
| 5159 | //store bar -> foo |
| 5160 | //tmp = vaarg foo, t |
| 5161 | //b = load foo |
| 5162 | AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix"); |
| 5163 | CurBB->getInstList().push_back(foo); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5164 | CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5165 | CurBB->getInstList().push_back(bar); |
| 5166 | CurBB->getInstList().push_back(new StoreInst(bar, foo)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5167 | Instruction* tmp = new VAArgInst(foo, (yyvsp[0].TypeVal).type->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5168 | CurBB->getInstList().push_back(tmp); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5169 | (yyval.InstVal) = new LoadInst(foo); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5170 | delete (yyvsp[0].TypeVal).type; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5171 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5172 | ;} |
| 5173 | break; |
| 5174 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5175 | case 252: |
| 5176 | #line 2703 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5177 | { |
| 5178 | if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5179 | GEN_ERROR("Invalid extractelement operands!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5180 | (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5181 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5182 | ;} |
| 5183 | break; |
| 5184 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5185 | case 253: |
| 5186 | #line 2709 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5187 | { |
| 5188 | if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5189 | GEN_ERROR("Invalid insertelement operands!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5190 | (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] | 5191 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5192 | ;} |
| 5193 | break; |
| 5194 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5195 | case 254: |
| 5196 | #line 2715 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5197 | { |
| 5198 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5199 | GEN_ERROR("Invalid shufflevector operands!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5200 | (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] | 5201 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5202 | ;} |
| 5203 | break; |
| 5204 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5205 | case 255: |
| 5206 | #line 2721 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5207 | { |
| 5208 | const Type *Ty = (yyvsp[0].PHIList)->front().first->getType(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5209 | if (!Ty->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5210 | GEN_ERROR("PHI node operands must be of first class type!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5211 | (yyval.InstVal) = new PHINode(Ty); |
| 5212 | ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size()); |
| 5213 | while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) { |
| 5214 | if ((yyvsp[0].PHIList)->front().first->getType() != Ty) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5215 | GEN_ERROR("All elements of a PHI node must be of the same type!"); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5216 | cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second); |
| 5217 | (yyvsp[0].PHIList)->pop_front(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5218 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5219 | delete (yyvsp[0].PHIList); // Free the list... |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5220 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5221 | ;} |
| 5222 | break; |
| 5223 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5224 | case 256: |
| 5225 | #line 2736 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5226 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5227 | const PointerType *PFTy = 0; |
| 5228 | const FunctionType *Ty = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5229 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5230 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).type->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5231 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5232 | // Pull out the types of all of the arguments... |
| 5233 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5234 | if ((yyvsp[-1].ValueList)) { |
| 5235 | 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] | 5236 | I != E; ++I) |
| 5237 | ParamTypes.push_back((*I)->getType()); |
| 5238 | } |
| 5239 | |
| 5240 | bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; |
| 5241 | if (isVarArg) ParamTypes.pop_back(); |
| 5242 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5243 | if (!(yyvsp[-4].TypeVal).type->get()->isFirstClassType() && |
| 5244 | (yyvsp[-4].TypeVal).type->get() != Type::VoidTy) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5245 | GEN_ERROR("LLVM functions cannot return aggregate types!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5246 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5247 | Ty = FunctionType::get((yyvsp[-4].TypeVal).type->get(), ParamTypes, isVarArg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5248 | PFTy = PointerType::get(Ty); |
| 5249 | } |
| 5250 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5251 | 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] | 5252 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5253 | |
| 5254 | // Create the call node... |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5255 | if (!(yyvsp[-1].ValueList)) { // Has no arguments? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5256 | // Make sure no arguments is a good thing! |
| 5257 | if (Ty->getNumParams() != 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5258 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5259 | "expects arguments!"); |
| 5260 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5261 | (yyval.InstVal) = new CallInst(V, std::vector<Value*>()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5262 | } else { // Has arguments? |
| 5263 | // Loop through FunctionType's arguments and ensure they are specified |
| 5264 | // correctly! |
| 5265 | // |
| 5266 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5267 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5268 | 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] | 5269 | |
| 5270 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) |
| 5271 | if ((*ArgI)->getType() != *I) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5272 | GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5273 | (*I)->getDescription() + "'!"); |
| 5274 | |
| 5275 | if (I != E || (ArgI != ArgE && !Ty->isVarArg())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5276 | GEN_ERROR("Invalid number of parameters detected!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5277 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5278 | (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5279 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5280 | cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal)); |
| 5281 | cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5282 | delete (yyvsp[-4].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5283 | delete (yyvsp[-1].ValueList); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5284 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5285 | ;} |
| 5286 | break; |
| 5287 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5288 | case 257: |
| 5289 | #line 2796 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5290 | { |
| 5291 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5292 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5293 | ;} |
| 5294 | break; |
| 5295 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5296 | case 258: |
| 5297 | #line 2803 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5298 | { |
| 5299 | (yyval.ValueList) = (yyvsp[0].ValueList); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5300 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5301 | ;} |
| 5302 | break; |
| 5303 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5304 | case 259: |
| 5305 | #line 2806 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5306 | { |
| 5307 | (yyval.ValueList) = new std::vector<Value*>(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5308 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5309 | ;} |
| 5310 | break; |
| 5311 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5312 | case 260: |
| 5313 | #line 2811 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5314 | { |
| 5315 | (yyval.BoolVal) = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5316 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5317 | ;} |
| 5318 | break; |
| 5319 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5320 | case 261: |
| 5321 | #line 2815 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5322 | { |
| 5323 | (yyval.BoolVal) = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5324 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5325 | ;} |
| 5326 | break; |
| 5327 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5328 | case 262: |
| 5329 | #line 2822 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5330 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5331 | (yyval.InstVal) = new MallocInst((yyvsp[-1].TypeVal).type->get(), 0, (yyvsp[0].UIntVal)); |
| 5332 | delete (yyvsp[-1].TypeVal).type; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5333 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5334 | ;} |
| 5335 | break; |
| 5336 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5337 | case 263: |
| 5338 | #line 2827 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5339 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5340 | Value* tmpVal = getVal((yyvsp[-2].TypeVal).type->get(), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5341 | CHECK_FOR_ERROR |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5342 | (yyval.InstVal) = new MallocInst((yyvsp[-4].TypeVal).type->get(), tmpVal, (yyvsp[0].UIntVal)); |
| 5343 | delete (yyvsp[-4].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5344 | ;} |
| 5345 | break; |
| 5346 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5347 | case 264: |
| 5348 | #line 2833 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5349 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5350 | (yyval.InstVal) = new AllocaInst((yyvsp[-1].TypeVal).type->get(), 0, (yyvsp[0].UIntVal)); |
| 5351 | delete (yyvsp[-1].TypeVal).type; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5352 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5353 | ;} |
| 5354 | break; |
| 5355 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5356 | case 265: |
| 5357 | #line 2838 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5358 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5359 | Value* tmpVal = getVal((yyvsp[-2].TypeVal).type->get(), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5360 | CHECK_FOR_ERROR |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5361 | (yyval.InstVal) = new AllocaInst((yyvsp[-4].TypeVal).type->get(), tmpVal, (yyvsp[0].UIntVal)); |
| 5362 | delete (yyvsp[-4].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5363 | ;} |
| 5364 | break; |
| 5365 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5366 | case 266: |
| 5367 | #line 2844 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5368 | { |
| 5369 | if (!isa<PointerType>((yyvsp[0].ValueVal)->getType())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5370 | GEN_ERROR("Trying to free nonpointer type " + |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5371 | (yyvsp[0].ValueVal)->getType()->getDescription() + "!"); |
| 5372 | (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5373 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5374 | ;} |
| 5375 | break; |
| 5376 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5377 | case 267: |
| 5378 | #line 2852 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5379 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5380 | if (!isa<PointerType>((yyvsp[-1].TypeVal).type->get())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5381 | GEN_ERROR("Can't load from nonpointer type: " + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5382 | (yyvsp[-1].TypeVal).type->get()->getDescription()); |
| 5383 | if (!cast<PointerType>((yyvsp[-1].TypeVal).type->get())->getElementType()->isFirstClassType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5384 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5385 | (yyvsp[-1].TypeVal).type->get()->getDescription()); |
| 5386 | Value* tmpVal = getVal((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5387 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5388 | (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5389 | delete (yyvsp[-1].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5390 | ;} |
| 5391 | break; |
| 5392 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5393 | case 268: |
| 5394 | #line 2864 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5395 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5396 | const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal).type->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5397 | if (!PT) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5398 | GEN_ERROR("Can't store to a nonpointer type: " + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5399 | ((yyvsp[-1].TypeVal).type->get())->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5400 | const Type *ElTy = PT->getElementType(); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5401 | if (ElTy != (yyvsp[-3].ValueVal)->getType()) |
| 5402 | GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5403 | "' into space of type '" + ElTy->getDescription() + "'!"); |
| 5404 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5405 | Value* tmpVal = getVal((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5406 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5407 | (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5408 | delete (yyvsp[-1].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5409 | ;} |
| 5410 | break; |
| 5411 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5412 | case 269: |
| 5413 | #line 2879 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5414 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5415 | if (!isa<PointerType>((yyvsp[-2].TypeVal).type->get())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5416 | GEN_ERROR("getelementptr insn requires pointer operand!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5417 | |
| 5418 | // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct |
| 5419 | // indices to uint struct indices for compatibility. |
| 5420 | generic_gep_type_iterator<std::vector<Value*>::iterator> |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5421 | GTI = gep_type_begin((yyvsp[-2].TypeVal).type->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()), |
| 5422 | GTE = gep_type_end((yyvsp[-2].TypeVal).type->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5423 | 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] | 5424 | if (isa<StructType>(*GTI)) // Only change struct indices |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5425 | if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[0].ValueList))[i])) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5426 | if (CUI->getType() == Type::UByteTy) |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5427 | (*(yyvsp[0].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5428 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5429 | if (!GetElementPtrInst::getIndexedType((yyvsp[-2].TypeVal).type->get(), *(yyvsp[0].ValueList), true)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5430 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5431 | (yyvsp[-2].TypeVal).type->get()->getDescription()+ "'!"); |
| 5432 | Value* tmpVal = getVal((yyvsp[-2].TypeVal).type->get(), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5433 | CHECK_FOR_ERROR |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5434 | (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5435 | delete (yyvsp[-2].TypeVal).type; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5436 | delete (yyvsp[0].ValueList); |
| 5437 | ;} |
| 5438 | break; |
| 5439 | |
| 5440 | |
| 5441 | default: break; |
| 5442 | } |
| 5443 | |
| 5444 | /* Line 1126 of yacc.c. */ |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5445 | #line 5446 "llvmAsmParser.tab.c" |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5446 | |
| 5447 | yyvsp -= yylen; |
| 5448 | yyssp -= yylen; |
| 5449 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5450 | |
| 5451 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5452 | |
| 5453 | *++yyvsp = yyval; |
| 5454 | |
| 5455 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5456 | /* Now `shift' the result of the reduction. Determine what state |
| 5457 | that goes to, based on the state we popped back to and the rule |
| 5458 | number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5459 | |
| 5460 | yyn = yyr1[yyn]; |
| 5461 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5462 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 5463 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5464 | yystate = yytable[yystate]; |
| 5465 | else |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5466 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5467 | |
| 5468 | goto yynewstate; |
| 5469 | |
| 5470 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5471 | /*------------------------------------. |
| 5472 | | yyerrlab -- here on detecting error | |
| 5473 | `------------------------------------*/ |
| 5474 | yyerrlab: |
| 5475 | /* If not already recovering from an error, report this error. */ |
| 5476 | if (!yyerrstatus) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5477 | { |
| 5478 | ++yynerrs; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5479 | #if YYERROR_VERBOSE |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5480 | yyn = yypact[yystate]; |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 5481 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5482 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5483 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5484 | int yytype = YYTRANSLATE (yychar); |
| 5485 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); |
| 5486 | YYSIZE_T yysize = yysize0; |
| 5487 | YYSIZE_T yysize1; |
| 5488 | int yysize_overflow = 0; |
| 5489 | char *yymsg = 0; |
| 5490 | # define YYERROR_VERBOSE_ARGS_MAXIMUM 5 |
| 5491 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 5492 | int yyx; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5493 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5494 | #if 0 |
| 5495 | /* This is so xgettext sees the translatable formats that are |
| 5496 | constructed on the fly. */ |
| 5497 | YY_("syntax error, unexpected %s"); |
| 5498 | YY_("syntax error, unexpected %s, expecting %s"); |
| 5499 | YY_("syntax error, unexpected %s, expecting %s or %s"); |
| 5500 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); |
| 5501 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); |
| 5502 | #endif |
| 5503 | char *yyfmt; |
| 5504 | char const *yyf; |
| 5505 | static char const yyunexpected[] = "syntax error, unexpected %s"; |
| 5506 | static char const yyexpecting[] = ", expecting %s"; |
| 5507 | static char const yyor[] = " or %s"; |
| 5508 | char yyformat[sizeof yyunexpected |
| 5509 | + sizeof yyexpecting - 1 |
| 5510 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) |
| 5511 | * (sizeof yyor - 1))]; |
| 5512 | char const *yyprefix = yyexpecting; |
| 5513 | |
| 5514 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 5515 | YYCHECK. */ |
| 5516 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 5517 | |
| 5518 | /* Stay within bounds of both yycheck and yytname. */ |
| 5519 | int yychecklim = YYLAST - yyn; |
| 5520 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 5521 | int yycount = 1; |
| 5522 | |
| 5523 | yyarg[0] = yytname[yytype]; |
| 5524 | yyfmt = yystpcpy (yyformat, yyunexpected); |
| 5525 | |
| 5526 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 5527 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 5528 | { |
| 5529 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 5530 | { |
| 5531 | yycount = 1; |
| 5532 | yysize = yysize0; |
| 5533 | yyformat[sizeof yyunexpected - 1] = '\0'; |
| 5534 | break; |
| 5535 | } |
| 5536 | yyarg[yycount++] = yytname[yyx]; |
| 5537 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); |
| 5538 | yysize_overflow |= yysize1 < yysize; |
| 5539 | yysize = yysize1; |
| 5540 | yyfmt = yystpcpy (yyfmt, yyprefix); |
| 5541 | yyprefix = yyor; |
| 5542 | } |
| 5543 | |
| 5544 | yyf = YY_(yyformat); |
| 5545 | yysize1 = yysize + yystrlen (yyf); |
| 5546 | yysize_overflow |= yysize1 < yysize; |
| 5547 | yysize = yysize1; |
| 5548 | |
| 5549 | if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) |
| 5550 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
| 5551 | if (yymsg) |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5552 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5553 | /* Avoid sprintf, as that infringes on the user's name space. |
| 5554 | Don't have undefined behavior even if the translation |
| 5555 | produced a string with the wrong number of "%s"s. */ |
| 5556 | char *yyp = yymsg; |
| 5557 | int yyi = 0; |
| 5558 | while ((*yyp = *yyf)) |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5559 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5560 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) |
| 5561 | { |
| 5562 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
| 5563 | yyf += 2; |
| 5564 | } |
| 5565 | else |
| 5566 | { |
| 5567 | yyp++; |
| 5568 | yyf++; |
| 5569 | } |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5570 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5571 | yyerror (yymsg); |
| 5572 | YYSTACK_FREE (yymsg); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5573 | } |
| 5574 | else |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5575 | { |
| 5576 | yyerror (YY_("syntax error")); |
| 5577 | goto yyexhaustedlab; |
| 5578 | } |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5579 | } |
| 5580 | else |
| 5581 | #endif /* YYERROR_VERBOSE */ |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5582 | yyerror (YY_("syntax error")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5583 | } |
| 5584 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5585 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5586 | |
| 5587 | if (yyerrstatus == 3) |
| 5588 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5589 | /* If just tried and failed to reuse look-ahead token after an |
| 5590 | error, discard it. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5591 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5592 | if (yychar <= YYEOF) |
| 5593 | { |
| 5594 | /* Return failure if at end of input. */ |
| 5595 | if (yychar == YYEOF) |
| 5596 | YYABORT; |
| 5597 | } |
| 5598 | else |
| 5599 | { |
| 5600 | yydestruct ("Error: discarding", yytoken, &yylval); |
| 5601 | yychar = YYEMPTY; |
| 5602 | } |
| 5603 | } |
| 5604 | |
| 5605 | /* Else will try to reuse look-ahead token after shifting the error |
| 5606 | token. */ |
| 5607 | goto yyerrlab1; |
| 5608 | |
| 5609 | |
| 5610 | /*---------------------------------------------------. |
| 5611 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 5612 | `---------------------------------------------------*/ |
| 5613 | yyerrorlab: |
| 5614 | |
| 5615 | /* Pacify compilers like GCC when the user code never invokes |
| 5616 | YYERROR and the label yyerrorlab therefore never appears in user |
| 5617 | code. */ |
| 5618 | if (0) |
| 5619 | goto yyerrorlab; |
| 5620 | |
| 5621 | yyvsp -= yylen; |
| 5622 | yyssp -= yylen; |
| 5623 | yystate = *yyssp; |
| 5624 | goto yyerrlab1; |
| 5625 | |
| 5626 | |
| 5627 | /*-------------------------------------------------------------. |
| 5628 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 5629 | `-------------------------------------------------------------*/ |
| 5630 | yyerrlab1: |
| 5631 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 5632 | |
| 5633 | for (;;) |
| 5634 | { |
| 5635 | yyn = yypact[yystate]; |
| 5636 | if (yyn != YYPACT_NINF) |
| 5637 | { |
| 5638 | yyn += YYTERROR; |
| 5639 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 5640 | { |
| 5641 | yyn = yytable[yyn]; |
| 5642 | if (0 < yyn) |
| 5643 | break; |
| 5644 | } |
| 5645 | } |
| 5646 | |
| 5647 | /* Pop the current state because it cannot handle the error token. */ |
| 5648 | if (yyssp == yyss) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5649 | YYABORT; |
| 5650 | |
Chris Lattner | 8335e84 | 2006-01-23 23:05:42 +0000 | [diff] [blame] | 5651 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5652 | yydestruct ("Error: popping", yystos[yystate], yyvsp); |
| 5653 | YYPOPSTACK; |
| 5654 | yystate = *yyssp; |
| 5655 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5656 | } |
| 5657 | |
| 5658 | if (yyn == YYFINAL) |
| 5659 | YYACCEPT; |
| 5660 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5661 | *++yyvsp = yylval; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5662 | |
| 5663 | |
| 5664 | /* Shift the error token. */ |
| 5665 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5666 | |
| 5667 | yystate = yyn; |
| 5668 | goto yynewstate; |
| 5669 | |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 5670 | |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5671 | /*-------------------------------------. |
| 5672 | | yyacceptlab -- YYACCEPT comes here. | |
| 5673 | `-------------------------------------*/ |
| 5674 | yyacceptlab: |
| 5675 | yyresult = 0; |
| 5676 | goto yyreturn; |
| 5677 | |
| 5678 | /*-----------------------------------. |
| 5679 | | yyabortlab -- YYABORT comes here. | |
| 5680 | `-----------------------------------*/ |
| 5681 | yyabortlab: |
| 5682 | yyresult = 1; |
| 5683 | goto yyreturn; |
| 5684 | |
| 5685 | #ifndef yyoverflow |
| 5686 | /*-------------------------------------------------. |
| 5687 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 5688 | `-------------------------------------------------*/ |
| 5689 | yyexhaustedlab: |
| 5690 | yyerror (YY_("memory exhausted")); |
| 5691 | yyresult = 2; |
| 5692 | /* Fall through. */ |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 5693 | #endif |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5694 | |
| 5695 | yyreturn: |
| 5696 | if (yychar != YYEOF && yychar != YYEMPTY) |
| 5697 | yydestruct ("Cleanup: discarding lookahead", |
| 5698 | yytoken, &yylval); |
| 5699 | while (yyssp != yyss) |
| 5700 | { |
| 5701 | yydestruct ("Cleanup: popping", |
| 5702 | yystos[*yyssp], yyvsp); |
| 5703 | YYPOPSTACK; |
Chris Lattner | f49c176 | 2006-11-08 05:58:47 +0000 | [diff] [blame] | 5704 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5705 | #ifndef yyoverflow |
| 5706 | if (yyss != yyssa) |
| 5707 | YYSTACK_FREE (yyss); |
| 5708 | #endif |
| 5709 | return yyresult; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5710 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5711 | |
| 5712 | |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame^] | 5713 | #line 2905 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5714 | |
| 5715 | |
| 5716 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 5717 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 5718 | // TODO: column number in exception |
| 5719 | if (TheParseError) |
| 5720 | TheParseError->setError(CurFilename, message, LineNo); |
| 5721 | TriggerError = 1; |
| 5722 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5723 | |
| 5724 | int yyerror(const char *ErrorMsg) { |
| 5725 | std::string where |
| 5726 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 5727 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
| 5728 | std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading "; |
| 5729 | if (yychar == YYEMPTY || yychar == 0) |
| 5730 | errMsg += "end-of-file."; |
| 5731 | else |
| 5732 | errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5733 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5734 | return 0; |
| 5735 | } |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5736 | |