Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 1 | /* A Bison parser, made by GNU Bison 2.3. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3 | /* Skeleton implementation for Bison's Yacc-like parsers in C |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 |
| 6 | Free Software Foundation, Inc. |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 7 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation; either version 2, or (at your option) |
| 11 | any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program; if not, write to the Free Software |
| 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 | Boston, MA 02110-1301, USA. */ |
| 22 | |
| 23 | /* As a special exception, you may create a larger work that contains |
| 24 | part or all of the Bison parser skeleton and distribute that work |
| 25 | under terms of your choice, so long as that work isn't itself a |
| 26 | parser generator using the skeleton or a modified version thereof |
| 27 | as a parser skeleton. Alternatively, if you modify or redistribute |
| 28 | the parser skeleton itself, you may (at your option) remove this |
| 29 | special exception, which will cause the skeleton and the resulting |
| 30 | Bison output files to be licensed under the GNU General Public |
| 31 | License without this special exception. |
| 32 | |
| 33 | This special exception was added by the Free Software Foundation in |
| 34 | version 2.2 of Bison. */ |
| 35 | |
| 36 | /* C LALR(1) parser skeleton written by Richard Stallman, by |
| 37 | simplifying the original so-called "semantic" parser. */ |
| 38 | |
| 39 | /* All symbols defined below should begin with yy or YY, to avoid |
| 40 | infringing on user name space. This should be done even for local |
| 41 | variables, as they might otherwise be expanded by user macros. |
| 42 | There are some unavoidable exceptions within include files to |
| 43 | define necessary library symbols; they are noted "INFRINGES ON |
| 44 | USER NAME SPACE" below. */ |
| 45 | |
| 46 | /* Identify Bison output. */ |
| 47 | #define YYBISON 1 |
| 48 | |
| 49 | /* Bison version. */ |
| 50 | #define YYBISON_VERSION "2.3" |
| 51 | |
| 52 | /* Skeleton name. */ |
| 53 | #define YYSKELETON_NAME "yacc.c" |
| 54 | |
| 55 | /* Pure parsers. */ |
| 56 | #define YYPURE 0 |
| 57 | |
| 58 | /* Using locations. */ |
| 59 | #define YYLSP_NEEDED 0 |
| 60 | |
| 61 | /* Substitute the variable and function names. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 62 | #define yyparse llvmAsmparse |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 63 | #define yylex llvmAsmlex |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 64 | #define yyerror llvmAsmerror |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 65 | #define yylval llvmAsmlval |
| 66 | #define yychar llvmAsmchar |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 67 | #define yydebug llvmAsmdebug |
| 68 | #define yynerrs llvmAsmnerrs |
| 69 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 70 | |
| 71 | /* Tokens. */ |
| 72 | #ifndef YYTOKENTYPE |
| 73 | # define YYTOKENTYPE |
| 74 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
| 75 | know about them. */ |
| 76 | enum yytokentype { |
| 77 | ESINT64VAL = 258, |
| 78 | EUINT64VAL = 259, |
| 79 | ESAPINTVAL = 260, |
| 80 | EUAPINTVAL = 261, |
| 81 | LOCALVAL_ID = 262, |
| 82 | GLOBALVAL_ID = 263, |
| 83 | FPVAL = 264, |
| 84 | VOID = 265, |
| 85 | INTTYPE = 266, |
| 86 | FLOAT = 267, |
| 87 | DOUBLE = 268, |
| 88 | LABEL = 269, |
| 89 | TYPE = 270, |
| 90 | LOCALVAR = 271, |
| 91 | GLOBALVAR = 272, |
| 92 | LABELSTR = 273, |
| 93 | STRINGCONSTANT = 274, |
| 94 | ATSTRINGCONSTANT = 275, |
| 95 | ZEROINITIALIZER = 276, |
| 96 | TRUETOK = 277, |
| 97 | FALSETOK = 278, |
| 98 | BEGINTOK = 279, |
| 99 | ENDTOK = 280, |
| 100 | DECLARE = 281, |
| 101 | DEFINE = 282, |
| 102 | GLOBAL = 283, |
| 103 | CONSTANT = 284, |
| 104 | SECTION = 285, |
| 105 | ALIAS = 286, |
| 106 | VOLATILE = 287, |
| 107 | THREAD_LOCAL = 288, |
| 108 | TO = 289, |
| 109 | DOTDOTDOT = 290, |
| 110 | NULL_TOK = 291, |
| 111 | UNDEF = 292, |
| 112 | INTERNAL = 293, |
| 113 | LINKONCE = 294, |
| 114 | WEAK = 295, |
| 115 | APPENDING = 296, |
| 116 | DLLIMPORT = 297, |
| 117 | DLLEXPORT = 298, |
| 118 | EXTERN_WEAK = 299, |
| 119 | OPAQUE = 300, |
| 120 | EXTERNAL = 301, |
| 121 | TARGET = 302, |
| 122 | TRIPLE = 303, |
| 123 | ALIGN = 304, |
| 124 | DEPLIBS = 305, |
| 125 | CALL = 306, |
| 126 | TAIL = 307, |
| 127 | ASM_TOK = 308, |
| 128 | MODULE = 309, |
| 129 | SIDEEFFECT = 310, |
| 130 | CC_TOK = 311, |
| 131 | CCC_TOK = 312, |
| 132 | FASTCC_TOK = 313, |
| 133 | COLDCC_TOK = 314, |
| 134 | X86_STDCALLCC_TOK = 315, |
| 135 | X86_FASTCALLCC_TOK = 316, |
| 136 | DATALAYOUT = 317, |
| 137 | RET = 318, |
| 138 | BR = 319, |
| 139 | SWITCH = 320, |
| 140 | INVOKE = 321, |
| 141 | UNWIND = 322, |
| 142 | UNREACHABLE = 323, |
| 143 | ADD = 324, |
| 144 | SUB = 325, |
| 145 | MUL = 326, |
| 146 | UDIV = 327, |
| 147 | SDIV = 328, |
| 148 | FDIV = 329, |
| 149 | UREM = 330, |
| 150 | SREM = 331, |
| 151 | FREM = 332, |
| 152 | AND = 333, |
| 153 | OR = 334, |
| 154 | XOR = 335, |
| 155 | SHL = 336, |
| 156 | LSHR = 337, |
| 157 | ASHR = 338, |
| 158 | ICMP = 339, |
| 159 | FCMP = 340, |
| 160 | EQ = 341, |
| 161 | NE = 342, |
| 162 | SLT = 343, |
| 163 | SGT = 344, |
| 164 | SLE = 345, |
| 165 | SGE = 346, |
| 166 | ULT = 347, |
| 167 | UGT = 348, |
| 168 | ULE = 349, |
| 169 | UGE = 350, |
| 170 | OEQ = 351, |
| 171 | ONE = 352, |
| 172 | OLT = 353, |
| 173 | OGT = 354, |
| 174 | OLE = 355, |
| 175 | OGE = 356, |
| 176 | ORD = 357, |
| 177 | UNO = 358, |
| 178 | UEQ = 359, |
| 179 | UNE = 360, |
| 180 | MALLOC = 361, |
| 181 | ALLOCA = 362, |
| 182 | FREE = 363, |
| 183 | LOAD = 364, |
| 184 | STORE = 365, |
| 185 | GETELEMENTPTR = 366, |
| 186 | TRUNC = 367, |
| 187 | ZEXT = 368, |
| 188 | SEXT = 369, |
| 189 | FPTRUNC = 370, |
| 190 | FPEXT = 371, |
| 191 | BITCAST = 372, |
| 192 | UITOFP = 373, |
| 193 | SITOFP = 374, |
| 194 | FPTOUI = 375, |
| 195 | FPTOSI = 376, |
| 196 | INTTOPTR = 377, |
| 197 | PTRTOINT = 378, |
| 198 | PHI_TOK = 379, |
| 199 | SELECT = 380, |
| 200 | VAARG = 381, |
| 201 | EXTRACTELEMENT = 382, |
| 202 | INSERTELEMENT = 383, |
| 203 | SHUFFLEVECTOR = 384, |
| 204 | NORETURN = 385, |
| 205 | INREG = 386, |
| 206 | SRET = 387, |
| 207 | NOUNWIND = 388, |
| 208 | DEFAULT = 389, |
| 209 | HIDDEN = 390 |
| 210 | }; |
| 211 | #endif |
| 212 | /* Tokens. */ |
| 213 | #define ESINT64VAL 258 |
| 214 | #define EUINT64VAL 259 |
| 215 | #define ESAPINTVAL 260 |
| 216 | #define EUAPINTVAL 261 |
| 217 | #define LOCALVAL_ID 262 |
| 218 | #define GLOBALVAL_ID 263 |
| 219 | #define FPVAL 264 |
| 220 | #define VOID 265 |
| 221 | #define INTTYPE 266 |
| 222 | #define FLOAT 267 |
| 223 | #define DOUBLE 268 |
| 224 | #define LABEL 269 |
| 225 | #define TYPE 270 |
| 226 | #define LOCALVAR 271 |
| 227 | #define GLOBALVAR 272 |
| 228 | #define LABELSTR 273 |
| 229 | #define STRINGCONSTANT 274 |
| 230 | #define ATSTRINGCONSTANT 275 |
| 231 | #define ZEROINITIALIZER 276 |
| 232 | #define TRUETOK 277 |
| 233 | #define FALSETOK 278 |
| 234 | #define BEGINTOK 279 |
| 235 | #define ENDTOK 280 |
| 236 | #define DECLARE 281 |
| 237 | #define DEFINE 282 |
| 238 | #define GLOBAL 283 |
| 239 | #define CONSTANT 284 |
| 240 | #define SECTION 285 |
| 241 | #define ALIAS 286 |
| 242 | #define VOLATILE 287 |
| 243 | #define THREAD_LOCAL 288 |
| 244 | #define TO 289 |
| 245 | #define DOTDOTDOT 290 |
| 246 | #define NULL_TOK 291 |
| 247 | #define UNDEF 292 |
| 248 | #define INTERNAL 293 |
| 249 | #define LINKONCE 294 |
| 250 | #define WEAK 295 |
| 251 | #define APPENDING 296 |
| 252 | #define DLLIMPORT 297 |
| 253 | #define DLLEXPORT 298 |
| 254 | #define EXTERN_WEAK 299 |
| 255 | #define OPAQUE 300 |
| 256 | #define EXTERNAL 301 |
| 257 | #define TARGET 302 |
| 258 | #define TRIPLE 303 |
| 259 | #define ALIGN 304 |
| 260 | #define DEPLIBS 305 |
| 261 | #define CALL 306 |
| 262 | #define TAIL 307 |
| 263 | #define ASM_TOK 308 |
| 264 | #define MODULE 309 |
| 265 | #define SIDEEFFECT 310 |
| 266 | #define CC_TOK 311 |
| 267 | #define CCC_TOK 312 |
| 268 | #define FASTCC_TOK 313 |
| 269 | #define COLDCC_TOK 314 |
| 270 | #define X86_STDCALLCC_TOK 315 |
| 271 | #define X86_FASTCALLCC_TOK 316 |
| 272 | #define DATALAYOUT 317 |
| 273 | #define RET 318 |
| 274 | #define BR 319 |
| 275 | #define SWITCH 320 |
| 276 | #define INVOKE 321 |
| 277 | #define UNWIND 322 |
| 278 | #define UNREACHABLE 323 |
| 279 | #define ADD 324 |
| 280 | #define SUB 325 |
| 281 | #define MUL 326 |
| 282 | #define UDIV 327 |
| 283 | #define SDIV 328 |
| 284 | #define FDIV 329 |
| 285 | #define UREM 330 |
| 286 | #define SREM 331 |
| 287 | #define FREM 332 |
| 288 | #define AND 333 |
| 289 | #define OR 334 |
| 290 | #define XOR 335 |
| 291 | #define SHL 336 |
| 292 | #define LSHR 337 |
| 293 | #define ASHR 338 |
| 294 | #define ICMP 339 |
| 295 | #define FCMP 340 |
| 296 | #define EQ 341 |
| 297 | #define NE 342 |
| 298 | #define SLT 343 |
| 299 | #define SGT 344 |
| 300 | #define SLE 345 |
| 301 | #define SGE 346 |
| 302 | #define ULT 347 |
| 303 | #define UGT 348 |
| 304 | #define ULE 349 |
| 305 | #define UGE 350 |
| 306 | #define OEQ 351 |
| 307 | #define ONE 352 |
| 308 | #define OLT 353 |
| 309 | #define OGT 354 |
| 310 | #define OLE 355 |
| 311 | #define OGE 356 |
| 312 | #define ORD 357 |
| 313 | #define UNO 358 |
| 314 | #define UEQ 359 |
| 315 | #define UNE 360 |
| 316 | #define MALLOC 361 |
| 317 | #define ALLOCA 362 |
| 318 | #define FREE 363 |
| 319 | #define LOAD 364 |
| 320 | #define STORE 365 |
| 321 | #define GETELEMENTPTR 366 |
| 322 | #define TRUNC 367 |
| 323 | #define ZEXT 368 |
| 324 | #define SEXT 369 |
| 325 | #define FPTRUNC 370 |
| 326 | #define FPEXT 371 |
| 327 | #define BITCAST 372 |
| 328 | #define UITOFP 373 |
| 329 | #define SITOFP 374 |
| 330 | #define FPTOUI 375 |
| 331 | #define FPTOSI 376 |
| 332 | #define INTTOPTR 377 |
| 333 | #define PTRTOINT 378 |
| 334 | #define PHI_TOK 379 |
| 335 | #define SELECT 380 |
| 336 | #define VAARG 381 |
| 337 | #define EXTRACTELEMENT 382 |
| 338 | #define INSERTELEMENT 383 |
| 339 | #define SHUFFLEVECTOR 384 |
| 340 | #define NORETURN 385 |
| 341 | #define INREG 386 |
| 342 | #define SRET 387 |
| 343 | #define NOUNWIND 388 |
| 344 | #define DEFAULT 389 |
| 345 | #define HIDDEN 390 |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | /* Copy the first part of user declarations. */ |
| 351 | #line 14 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 352 | |
| 353 | #include "ParserInternals.h" |
| 354 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 355 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 356 | #include "llvm/Instructions.h" |
| 357 | #include "llvm/Module.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 358 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 359 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 360 | #include "llvm/Support/CommandLine.h" |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 361 | #include "llvm/ADT/SmallVector.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 362 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 363 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 481169e | 2006-12-01 00:33:46 +0000 | [diff] [blame] | 364 | #include "llvm/Support/Streams.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 365 | #include <algorithm> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 366 | #include <list> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 367 | #include <map> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 368 | #include <utility> |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 369 | #ifndef NDEBUG |
| 370 | #define YYDEBUG 1 |
| 371 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 372 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 373 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 374 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 375 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 376 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 377 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 378 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 379 | // GenerateError are made from inside productions and they must simulate the |
| 380 | // previous exception behavior by exiting the production immediately. We have |
| 381 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 382 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 383 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 384 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 385 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 386 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 387 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 388 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 389 | int yylex(); // declaration" of xxx warnings. |
| 390 | int yyparse(); |
| 391 | |
| 392 | namespace llvm { |
| 393 | std::string CurFilename; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 394 | #if YYDEBUG |
| 395 | static cl::opt<bool> |
| 396 | Debug("debug-yacc", cl::desc("Print yacc debug state changes"), |
| 397 | cl::Hidden, cl::init(false)); |
| 398 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 399 | } |
| 400 | using namespace llvm; |
| 401 | |
| 402 | static Module *ParserResult; |
| 403 | |
| 404 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 405 | // relating to upreferences in the input stream. |
| 406 | // |
| 407 | //#define DEBUG_UPREFS 1 |
| 408 | #ifdef DEBUG_UPREFS |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 409 | #define UR_OUT(X) cerr << X |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 410 | #else |
| 411 | #define UR_OUT(X) |
| 412 | #endif |
| 413 | |
| 414 | #define YYERROR_VERBOSE 1 |
| 415 | |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 416 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 417 | |
| 418 | |
| 419 | // This contains info used when building the body of a function. It is |
| 420 | // destroyed when the function is completed. |
| 421 | // |
| 422 | typedef std::vector<Value *> ValueList; // Numbered defs |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 423 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 424 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 425 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 426 | |
| 427 | static struct PerModuleInfo { |
| 428 | Module *CurrentModule; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 429 | ValueList Values; // Module level numbered definitions |
| 430 | ValueList LateResolveValues; |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 431 | std::vector<PATypeHolder> Types; |
| 432 | std::map<ValID, PATypeHolder> LateResolveTypes; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 433 | |
| 434 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 435 | /// 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] | 436 | /// that we can resolve them later and print error messages as appropriate. |
| 437 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 438 | |
| 439 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 440 | // references to global values. Global values may be referenced before they |
| 441 | // are defined, and if so, the temporary object that they represent is held |
| 442 | // here. This is used for forward references of GlobalValues. |
| 443 | // |
| 444 | typedef std::map<std::pair<const PointerType *, |
| 445 | ValID>, GlobalValue*> GlobalRefsType; |
| 446 | GlobalRefsType GlobalRefs; |
| 447 | |
| 448 | void ModuleDone() { |
| 449 | // If we could not resolve some functions at function compilation time |
| 450 | // (calls to functions before they are defined), resolve them now... Types |
| 451 | // are resolved when the constant pool has been completely parsed. |
| 452 | // |
| 453 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 454 | if (TriggerError) |
| 455 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 456 | |
| 457 | // Check to make sure that all global value forward references have been |
| 458 | // resolved! |
| 459 | // |
| 460 | if (!GlobalRefs.empty()) { |
| 461 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 462 | |
| 463 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 464 | I != E; ++I) { |
| 465 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 466 | I->first.second.getName() + "\n"; |
| 467 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 468 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 469 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | Values.clear(); // Clear out function local definitions |
| 473 | Types.clear(); |
| 474 | CurrentModule = 0; |
| 475 | } |
| 476 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 477 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 478 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 479 | // If not, just return null. |
| 480 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 481 | // Check to see if there is a forward reference to this global variable... |
| 482 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 483 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 484 | GlobalValue *Ret = 0; |
| 485 | if (I != GlobalRefs.end()) { |
| 486 | Ret = I->second; |
| 487 | GlobalRefs.erase(I); |
| 488 | } |
| 489 | return Ret; |
| 490 | } |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 491 | |
| 492 | bool TypeIsUnresolved(PATypeHolder* PATy) { |
| 493 | // If it isn't abstract, its resolved |
| 494 | const Type* Ty = PATy->get(); |
| 495 | if (!Ty->isAbstract()) |
| 496 | return false; |
| 497 | // Traverse the type looking for abstract types. If it isn't abstract then |
| 498 | // we don't need to traverse that leg of the type. |
| 499 | std::vector<const Type*> WorkList, SeenList; |
| 500 | WorkList.push_back(Ty); |
| 501 | while (!WorkList.empty()) { |
| 502 | const Type* Ty = WorkList.back(); |
| 503 | SeenList.push_back(Ty); |
| 504 | WorkList.pop_back(); |
| 505 | if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) { |
| 506 | // Check to see if this is an unresolved type |
| 507 | std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin(); |
| 508 | std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end(); |
| 509 | for ( ; I != E; ++I) { |
| 510 | if (I->second.get() == OpTy) |
| 511 | return true; |
| 512 | } |
| 513 | } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) { |
| 514 | const Type* TheTy = SeqTy->getElementType(); |
| 515 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 516 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 517 | E = SeenList.end(); |
| 518 | for ( ; I != E; ++I) |
| 519 | if (*I == TheTy) |
| 520 | break; |
| 521 | if (I == E) |
| 522 | WorkList.push_back(TheTy); |
| 523 | } |
| 524 | } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) { |
| 525 | for (unsigned i = 0; i < StrTy->getNumElements(); ++i) { |
| 526 | const Type* TheTy = StrTy->getElementType(i); |
| 527 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 528 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 529 | E = SeenList.end(); |
| 530 | for ( ; I != E; ++I) |
| 531 | if (*I == TheTy) |
| 532 | break; |
| 533 | if (I == E) |
| 534 | WorkList.push_back(TheTy); |
| 535 | } |
| 536 | } |
| 537 | } |
| 538 | } |
| 539 | return false; |
| 540 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 541 | } CurModule; |
| 542 | |
| 543 | static struct PerFunctionInfo { |
| 544 | Function *CurrentFunction; // Pointer to current function being created |
| 545 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 546 | ValueList Values; // Keep track of #'d definitions |
| 547 | unsigned NextValNum; |
| 548 | ValueList LateResolveValues; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 549 | bool isDeclare; // Is this function a forward declararation? |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 550 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 551 | GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 552 | |
| 553 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 554 | /// track of them here. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 555 | std::map<ValID, BasicBlock*> BBForwardRefs; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 556 | |
| 557 | inline PerFunctionInfo() { |
| 558 | CurrentFunction = 0; |
| 559 | isDeclare = false; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 560 | Linkage = GlobalValue::ExternalLinkage; |
| 561 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | inline void FunctionStart(Function *M) { |
| 565 | CurrentFunction = M; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 566 | NextValNum = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | void FunctionDone() { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 570 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 571 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 572 | GenerateError("Undefined reference to label " + |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 573 | BBForwardRefs.begin()->second->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 574 | return; |
| 575 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 576 | |
| 577 | // Resolve all forward references now. |
| 578 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 579 | |
| 580 | Values.clear(); // Clear out function local definitions |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 581 | BBForwardRefs.clear(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 582 | CurrentFunction = 0; |
| 583 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 584 | Linkage = GlobalValue::ExternalLinkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 585 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 586 | } |
| 587 | } CurFun; // Info for the current function... |
| 588 | |
| 589 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 590 | |
| 591 | |
| 592 | //===----------------------------------------------------------------------===// |
| 593 | // Code to handle definitions of all the types |
| 594 | //===----------------------------------------------------------------------===// |
| 595 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 596 | static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) { |
| 597 | // Things that have names or are void typed don't get slot numbers |
| 598 | if (V->hasName() || (V->getType() == Type::VoidTy)) |
| 599 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 600 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 601 | // In the case of function values, we have to allow for the forward reference |
| 602 | // of basic blocks, which are included in the numbering. Consequently, we keep |
| 603 | // track of the next insertion location with NextValNum. When a BB gets |
| 604 | // inserted, it could change the size of the CurFun.Values vector. |
| 605 | if (&ValueTab == &CurFun.Values) { |
| 606 | if (ValueTab.size() <= CurFun.NextValNum) |
| 607 | ValueTab.resize(CurFun.NextValNum+1); |
| 608 | ValueTab[CurFun.NextValNum++] = V; |
| 609 | return; |
| 610 | } |
| 611 | // For all other lists, its okay to just tack it on the back of the vector. |
| 612 | ValueTab.push_back(V); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 616 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 617 | case ValID::LocalID: // Is it a numbered definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 618 | // Module constants occupy the lowest numbered slots... |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 619 | if (D.Num < CurModule.Types.size()) |
| 620 | return CurModule.Types[D.Num]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 621 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 622 | case ValID::LocalName: // Is it a named definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 623 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 624 | D.destroy(); // Free old strdup'd memory... |
| 625 | return N; |
| 626 | } |
| 627 | break; |
| 628 | default: |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 629 | GenerateError("Internal parser error: Invalid symbol type reference"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 630 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | // If we reached here, we referenced either a symbol that we don't know about |
| 634 | // or an id number that hasn't been read yet. We may be referencing something |
| 635 | // forward, so just create an entry to be resolved later and get to it... |
| 636 | // |
| 637 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 638 | |
| 639 | |
| 640 | if (inFunctionScope()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 641 | if (D.Type == ValID::LocalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 642 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 643 | return 0; |
| 644 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 645 | GenerateError("Reference to an undefined type: #" + utostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 646 | return 0; |
| 647 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 648 | } |
| 649 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 650 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 651 | if (I != CurModule.LateResolveTypes.end()) |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 652 | return I->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 653 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 654 | Type *Typ = OpaqueType::get(); |
| 655 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 656 | return Typ; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 657 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 658 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 659 | // getExistingVal - Look up the value specified by the provided type and |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 660 | // the provided ValID. If the value exists and has already been defined, return |
| 661 | // it. Otherwise return null. |
| 662 | // |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 663 | static Value *getExistingVal(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 664 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 665 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 666 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 667 | return 0; |
| 668 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 669 | |
| 670 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 671 | case ValID::LocalID: { // Is it a numbered definition? |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 672 | // Check that the number is within bounds. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 673 | if (D.Num >= CurFun.Values.size()) |
| 674 | return 0; |
| 675 | Value *Result = CurFun.Values[D.Num]; |
| 676 | if (Ty != Result->getType()) { |
| 677 | GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" + |
| 678 | Result->getType()->getDescription() + "' does not match " |
| 679 | "expected type, '" + Ty->getDescription() + "'"); |
| 680 | return 0; |
| 681 | } |
| 682 | return Result; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 683 | } |
| 684 | case ValID::GlobalID: { // Is it a numbered definition? |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 685 | if (D.Num >= CurModule.Values.size()) |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 686 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 687 | Value *Result = CurModule.Values[D.Num]; |
| 688 | if (Ty != Result->getType()) { |
| 689 | GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" + |
| 690 | Result->getType()->getDescription() + "' does not match " |
| 691 | "expected type, '" + Ty->getDescription() + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 692 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 693 | } |
| 694 | return Result; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 695 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 696 | |
| 697 | case ValID::LocalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 698 | if (!inFunctionScope()) |
| 699 | return 0; |
| 700 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
| 701 | Value *N = SymTab.lookup(D.Name); |
| 702 | if (N == 0) |
| 703 | return 0; |
| 704 | if (N->getType() != Ty) |
| 705 | return 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 706 | |
| 707 | D.destroy(); // Free old strdup'd memory... |
| 708 | return N; |
| 709 | } |
| 710 | case ValID::GlobalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 711 | ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable(); |
| 712 | Value *N = SymTab.lookup(D.Name); |
| 713 | if (N == 0) |
| 714 | return 0; |
| 715 | if (N->getType() != Ty) |
| 716 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 717 | |
| 718 | D.destroy(); // Free old strdup'd memory... |
| 719 | return N; |
| 720 | } |
| 721 | |
| 722 | // Check to make sure that "Ty" is an integral type, and that our |
| 723 | // value will fit into the specified type... |
| 724 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 725 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 726 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 727 | itostr(D.ConstPool64) + "' is invalid for type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 728 | Ty->getDescription() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 729 | return 0; |
| 730 | } |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 731 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 732 | |
| 733 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 734 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 735 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 736 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 737 | "' is invalid or out of range"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 738 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 739 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 740 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 741 | } |
| 742 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 743 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 744 | } |
| 745 | |
| 746 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 747 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 748 | GenerateError("FP constant invalid for type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 749 | return 0; |
| 750 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 751 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 752 | |
| 753 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 754 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 755 | GenerateError("Cannot create a a non pointer null"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 756 | return 0; |
| 757 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 758 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 759 | |
| 760 | case ValID::ConstUndefVal: // Is it an undef value? |
| 761 | return UndefValue::get(Ty); |
| 762 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 763 | case ValID::ConstZeroVal: // Is it a zero value? |
| 764 | return Constant::getNullValue(Ty); |
| 765 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 766 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 767 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 768 | GenerateError("Constant expression type different from required type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 769 | return 0; |
| 770 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 771 | return D.ConstantValue; |
| 772 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 773 | case ValID::InlineAsmVal: { // Inline asm expression |
| 774 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 775 | const FunctionType *FTy = |
| 776 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 777 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 778 | GenerateError("Invalid type for asm constraint string"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 779 | return 0; |
| 780 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 781 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 782 | D.IAD->HasSideEffects); |
| 783 | D.destroy(); // Free InlineAsmDescriptor. |
| 784 | return IA; |
| 785 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 786 | default: |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 787 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 788 | return 0; |
| 789 | } // End of switch |
| 790 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 791 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 792 | return 0; |
| 793 | } |
| 794 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 795 | // getVal - This function is identical to getExistingVal, except that if a |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 796 | // value is not already defined, it "improvises" by creating a placeholder var |
| 797 | // that looks and acts just like the requested variable. When the value is |
| 798 | // defined later, all uses of the placeholder variable are replaced with the |
| 799 | // real thing. |
| 800 | // |
| 801 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 802 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 803 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 804 | return 0; |
| 805 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 806 | |
| 807 | // See if the value has already been defined. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 808 | Value *V = getExistingVal(Ty, ID); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 809 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 810 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 811 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 812 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 813 | GenerateError("Invalid use of a composite type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 814 | return 0; |
| 815 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 816 | |
| 817 | // If we reached here, we referenced either a symbol that we don't know about |
| 818 | // or an id number that hasn't been read yet. We may be referencing something |
| 819 | // forward, so just create an entry to be resolved later and get to it... |
| 820 | // |
| 821 | V = new Argument(Ty); |
| 822 | |
| 823 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 824 | // to recycle these things?? |
| 825 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 826 | llvmAsmlineno))); |
| 827 | |
| 828 | if (inFunctionScope()) |
| 829 | InsertValue(V, CurFun.LateResolveValues); |
| 830 | else |
| 831 | InsertValue(V, CurModule.LateResolveValues); |
| 832 | return V; |
| 833 | } |
| 834 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 835 | /// defineBBVal - This is a definition of a new basic block with the specified |
| 836 | /// identifier which must be the same as CurFun.NextValNum, if its numeric. |
| 837 | static BasicBlock *defineBBVal(const ValID &ID) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 838 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 839 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 840 | BasicBlock *BB = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 841 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 842 | // First, see if this was forward referenced |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 843 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 844 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 845 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 846 | BB = BBI->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 847 | // The forward declaration could have been inserted anywhere in the |
| 848 | // function: insert it into the correct place now. |
| 849 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 850 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 851 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 852 | // We're about to erase the entry, save the key so we can clean it up. |
| 853 | ValID Tmp = BBI->first; |
| 854 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 855 | // Erase the forward ref from the map as its no longer "forward" |
| 856 | CurFun.BBForwardRefs.erase(ID); |
| 857 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 858 | // The key has been removed from the map but so we don't want to leave |
| 859 | // strdup'd memory around so destroy it too. |
| 860 | Tmp.destroy(); |
| 861 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 862 | // If its a numbered definition, bump the number and set the BB value. |
| 863 | if (ID.Type == ValID::LocalID) { |
| 864 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 865 | InsertValue(BB); |
| 866 | } |
| 867 | |
| 868 | ID.destroy(); |
| 869 | return BB; |
| 870 | } |
| 871 | |
| 872 | // We haven't seen this BB before and its first mention is a definition. |
| 873 | // Just create it and return it. |
| 874 | std::string Name (ID.Type == ValID::LocalName ? ID.Name : ""); |
| 875 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 876 | if (ID.Type == ValID::LocalID) { |
| 877 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 878 | InsertValue(BB); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 879 | } |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 880 | |
| 881 | ID.destroy(); // Free strdup'd memory |
| 882 | return BB; |
| 883 | } |
| 884 | |
| 885 | /// getBBVal - get an existing BB value or create a forward reference for it. |
| 886 | /// |
| 887 | static BasicBlock *getBBVal(const ValID &ID) { |
| 888 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 889 | |
| 890 | BasicBlock *BB = 0; |
| 891 | |
| 892 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 893 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 894 | BB = BBI->second; |
| 895 | } if (ID.Type == ValID::LocalName) { |
| 896 | std::string Name = ID.Name; |
| 897 | Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name); |
| 898 | if (N) |
| 899 | if (N->getType()->getTypeID() == Type::LabelTyID) |
| 900 | BB = cast<BasicBlock>(N); |
| 901 | else |
| 902 | GenerateError("Reference to label '" + Name + "' is actually of type '"+ |
| 903 | N->getType()->getDescription() + "'"); |
| 904 | } else if (ID.Type == ValID::LocalID) { |
| 905 | if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) { |
| 906 | if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID) |
| 907 | BB = cast<BasicBlock>(CurFun.Values[ID.Num]); |
| 908 | else |
| 909 | GenerateError("Reference to label '%" + utostr(ID.Num) + |
| 910 | "' is actually of type '"+ |
| 911 | CurFun.Values[ID.Num]->getType()->getDescription() + "'"); |
| 912 | } |
| 913 | } else { |
| 914 | GenerateError("Illegal label reference " + ID.getName()); |
| 915 | return 0; |
| 916 | } |
| 917 | |
| 918 | // If its already been defined, return it now. |
| 919 | if (BB) { |
| 920 | ID.destroy(); // Free strdup'd memory. |
| 921 | return BB; |
| 922 | } |
| 923 | |
| 924 | // Otherwise, this block has not been seen before, create it. |
| 925 | std::string Name; |
| 926 | if (ID.Type == ValID::LocalName) |
| 927 | Name = ID.Name; |
| 928 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 929 | |
| 930 | // Insert it in the forward refs map. |
| 931 | CurFun.BBForwardRefs[ID] = BB; |
| 932 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 933 | return BB; |
| 934 | } |
| 935 | |
| 936 | |
| 937 | //===----------------------------------------------------------------------===// |
| 938 | // Code to handle forward references in instructions |
| 939 | //===----------------------------------------------------------------------===// |
| 940 | // |
| 941 | // This code handles the late binding needed with statements that reference |
| 942 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 943 | // a loop body. |
| 944 | // |
| 945 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 946 | // and back patchs after we are done. |
| 947 | // |
| 948 | |
| 949 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 950 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 951 | // defs now... |
| 952 | // |
| 953 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 954 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 955 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 956 | while (!LateResolvers.empty()) { |
| 957 | Value *V = LateResolvers.back(); |
| 958 | LateResolvers.pop_back(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 959 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 960 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 961 | CurModule.PlaceHolderInfo.find(V); |
| 962 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 963 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 964 | ValID &DID = PHI->second.first; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 965 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 966 | Value *TheRealValue = getExistingVal(V->getType(), DID); |
| 967 | if (TriggerError) |
| 968 | return; |
| 969 | if (TheRealValue) { |
| 970 | V->replaceAllUsesWith(TheRealValue); |
| 971 | delete V; |
| 972 | CurModule.PlaceHolderInfo.erase(PHI); |
| 973 | } else if (FutureLateResolvers) { |
| 974 | // Functions have their unresolved items forwarded to the module late |
| 975 | // resolver table |
| 976 | InsertValue(V, *FutureLateResolvers); |
| 977 | } else { |
| 978 | if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) { |
| 979 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
| 980 | "' of type '" + V->getType()->getDescription() + "'", |
| 981 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 982 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 983 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 984 | GenerateError("Reference to an invalid definition: #" + |
| 985 | itostr(DID.Num) + " of type '" + |
| 986 | V->getType()->getDescription() + "'", |
| 987 | PHI->second.second); |
| 988 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 989 | } |
| 990 | } |
| 991 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 992 | LateResolvers.clear(); |
| 993 | } |
| 994 | |
| 995 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 996 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 997 | // refering to the number can be resolved. Do this now. |
| 998 | // |
| 999 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 1000 | ValID D; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1001 | if (Name) D = ValID::createLocalName(Name); |
| 1002 | else D = ValID::createLocalID(CurModule.Types.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1003 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 1004 | std::map<ValID, PATypeHolder>::iterator I = |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1005 | CurModule.LateResolveTypes.find(D); |
| 1006 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 1007 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1008 | CurModule.LateResolveTypes.erase(I); |
| 1009 | } |
| 1010 | } |
| 1011 | |
| 1012 | // setValueName - Set the specified value to the name given. The name may be |
| 1013 | // null potentially, in which case this is a noop. The string passed in is |
| 1014 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 1015 | // |
| 1016 | static void setValueName(Value *V, char *NameStr) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1017 | if (!NameStr) return; |
| 1018 | std::string Name(NameStr); // Copy string |
| 1019 | free(NameStr); // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1020 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1021 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1022 | GenerateError("Can't assign name '" + Name+"' to value with void type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1023 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1024 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1025 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 1026 | assert(inFunctionScope() && "Must be in function scope!"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 1027 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 1028 | if (ST.lookup(Name)) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1029 | GenerateError("Redefinition of value '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1030 | V->getType()->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1031 | return; |
| 1032 | } |
| 1033 | |
| 1034 | // Set the name. |
| 1035 | V->setName(Name); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 1039 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1040 | static GlobalVariable * |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1041 | ParseGlobalVariable(char *NameStr, |
| 1042 | GlobalValue::LinkageTypes Linkage, |
| 1043 | GlobalValue::VisibilityTypes Visibility, |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1044 | bool isConstantGlobal, const Type *Ty, |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 1045 | Constant *Initializer, bool IsThreadLocal) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1046 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1047 | GenerateError("Cannot declare global vars of function type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1048 | return 0; |
| 1049 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1050 | |
| 1051 | const PointerType *PTy = PointerType::get(Ty); |
| 1052 | |
| 1053 | std::string Name; |
| 1054 | if (NameStr) { |
| 1055 | Name = NameStr; // Copy string |
| 1056 | free(NameStr); // Free old string |
| 1057 | } |
| 1058 | |
| 1059 | // See if this global value was forward referenced. If so, recycle the |
| 1060 | // object. |
| 1061 | ValID ID; |
| 1062 | if (!Name.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1063 | ID = ValID::createGlobalName((char*)Name.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1064 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 1065 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1066 | } |
| 1067 | |
| 1068 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 1069 | // Move the global to the end of the list, from whereever it was |
| 1070 | // previously inserted. |
| 1071 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 1072 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 1073 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 1074 | GV->setInitializer(Initializer); |
| 1075 | GV->setLinkage(Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1076 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1077 | GV->setConstant(isConstantGlobal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 1078 | GV->setThreadLocal(IsThreadLocal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1079 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1080 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1081 | } |
| 1082 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 1083 | // If this global has a name |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1084 | if (!Name.empty()) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 1085 | // if the global we're parsing has an initializer (is a definition) and |
| 1086 | // has external linkage. |
| 1087 | if (Initializer && Linkage != GlobalValue::InternalLinkage) |
| 1088 | // If there is already a global with external linkage with this name |
| 1089 | if (CurModule.CurrentModule->getGlobalVariable(Name, false)) { |
| 1090 | // If we allow this GVar to get created, it will be renamed in the |
| 1091 | // symbol table because it conflicts with an existing GVar. We can't |
| 1092 | // allow redefinition of GVars whose linking indicates that their name |
| 1093 | // must stay the same. Issue the error. |
| 1094 | GenerateError("Redefinition of global variable named '" + Name + |
| 1095 | "' of type '" + Ty->getDescription() + "'"); |
| 1096 | return 0; |
| 1097 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1098 | } |
| 1099 | |
| 1100 | // Otherwise there is no existing GV to use, create one now. |
| 1101 | GlobalVariable *GV = |
| 1102 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 1103 | CurModule.CurrentModule, IsThreadLocal); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1104 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1105 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1106 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1107 | } |
| 1108 | |
| 1109 | // setTypeName - Set the specified type to the name given. The name may be |
| 1110 | // null potentially, in which case this is a noop. The string passed in is |
| 1111 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 1112 | // |
| 1113 | // This function returns true if the type has already been defined, but is |
| 1114 | // allowed to be redefined in the specified context. If the name is a new name |
| 1115 | // for the type plane, it is inserted and false is returned. |
| 1116 | static bool setTypeName(const Type *T, char *NameStr) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 1117 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1118 | if (NameStr == 0) return false; |
| 1119 | |
| 1120 | std::string Name(NameStr); // Copy string |
| 1121 | free(NameStr); // Free old string |
| 1122 | |
| 1123 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1124 | if (T == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1125 | GenerateError("Can't assign name '" + Name + "' to the void type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1126 | return false; |
| 1127 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1128 | |
| 1129 | // Set the type name, checking for conflicts as we do so. |
| 1130 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 1131 | |
| 1132 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1133 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 1134 | assert(Existing && "Conflict but no matching type?!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1135 | |
| 1136 | // There is only one case where this is allowed: when we are refining an |
| 1137 | // opaque type. In this case, Existing will be an opaque type. |
| 1138 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1139 | // We ARE replacing an opaque type! |
| 1140 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 1141 | return true; |
| 1142 | } |
| 1143 | |
| 1144 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1145 | // the redefinition is identical to the original. This will be so if |
| 1146 | // Existing and T point to the same Type object. In this one case we |
| 1147 | // allow the equivalent redefinition. |
| 1148 | if (Existing == T) return true; // Yes, it's equal. |
| 1149 | |
| 1150 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 1151 | GenerateError("Redefinition of type named '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1152 | T->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1153 | } |
| 1154 | |
| 1155 | return false; |
| 1156 | } |
| 1157 | |
| 1158 | //===----------------------------------------------------------------------===// |
| 1159 | // Code for handling upreferences in type names... |
| 1160 | // |
| 1161 | |
| 1162 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1163 | // |
| 1164 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1165 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1166 | E) != Ty->subtype_end(); |
| 1167 | } |
| 1168 | |
| 1169 | namespace { |
| 1170 | struct UpRefRecord { |
| 1171 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1172 | // this type is resolved. |
| 1173 | unsigned NestingLevel; |
| 1174 | |
| 1175 | // LastContainedTy - This is the type at the current binding level for the |
| 1176 | // type. Every time we reduce the nesting level, this gets updated. |
| 1177 | const Type *LastContainedTy; |
| 1178 | |
| 1179 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1180 | // represented with. |
| 1181 | OpaqueType *UpRefTy; |
| 1182 | |
| 1183 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 1184 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 1185 | }; |
| 1186 | } |
| 1187 | |
| 1188 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1189 | static std::vector<UpRefRecord> UpRefs; |
| 1190 | |
| 1191 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1192 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1193 | /// currently active types. For each type, if the up reference is contained in |
| 1194 | /// the newly completed type, we decrement the level count. When the level |
| 1195 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1196 | /// thus we can complete the cycle. |
| 1197 | /// |
| 1198 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 1199 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1200 | // nothing to resolve here. |
| 1201 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1202 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1203 | PATypeHolder Ty(ty); |
| 1204 | UR_OUT("Type '" << Ty->getDescription() << |
| 1205 | "' newly formed. Resolving upreferences.\n" << |
| 1206 | UpRefs.size() << " upreferences active!\n"); |
| 1207 | |
| 1208 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1209 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1210 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1211 | // this variable. |
| 1212 | OpaqueType *TypeToResolve = 0; |
| 1213 | |
| 1214 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1215 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1216 | << UpRefs[i].second->getDescription() << ") = " |
| 1217 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1218 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1219 | // Decrement level of upreference |
| 1220 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1221 | UpRefs[i].LastContainedTy = Ty; |
| 1222 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1223 | if (Level == 0) { // Upreference should be resolved! |
| 1224 | if (!TypeToResolve) { |
| 1225 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1226 | } else { |
| 1227 | UR_OUT(" * Resolving upreference for " |
| 1228 | << UpRefs[i].second->getDescription() << "\n"; |
| 1229 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1230 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1231 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1232 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1233 | } |
| 1234 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1235 | --i; // Do not skip the next element... |
| 1236 | } |
| 1237 | } |
| 1238 | } |
| 1239 | |
| 1240 | if (TypeToResolve) { |
| 1241 | UR_OUT(" * Resolving upreference for " |
| 1242 | << UpRefs[i].second->getDescription() << "\n"; |
| 1243 | std::string OldName = TypeToResolve->getDescription()); |
| 1244 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1245 | } |
| 1246 | |
| 1247 | return Ty; |
| 1248 | } |
| 1249 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1250 | //===----------------------------------------------------------------------===// |
| 1251 | // RunVMAsmParser - Define an interface to this parser |
| 1252 | //===----------------------------------------------------------------------===// |
| 1253 | // |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1254 | static Module* RunParser(Module * M); |
| 1255 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1256 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1257 | set_scan_file(F); |
| 1258 | |
| 1259 | CurFilename = Filename; |
| 1260 | return RunParser(new Module(CurFilename)); |
| 1261 | } |
| 1262 | |
| 1263 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1264 | set_scan_string(AsmString); |
| 1265 | |
| 1266 | CurFilename = "from_memory"; |
| 1267 | if (M == NULL) { |
| 1268 | return RunParser(new Module (CurFilename)); |
| 1269 | } else { |
| 1270 | return RunParser(M); |
| 1271 | } |
| 1272 | } |
| 1273 | |
| 1274 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 1275 | |
| 1276 | /* Enabling traces. */ |
| 1277 | #ifndef YYDEBUG |
| 1278 | # define YYDEBUG 0 |
| 1279 | #endif |
| 1280 | |
| 1281 | /* Enabling verbose error messages. */ |
| 1282 | #ifdef YYERROR_VERBOSE |
| 1283 | # undef YYERROR_VERBOSE |
| 1284 | # define YYERROR_VERBOSE 1 |
| 1285 | #else |
| 1286 | # define YYERROR_VERBOSE 0 |
| 1287 | #endif |
| 1288 | |
| 1289 | /* Enabling the token table. */ |
| 1290 | #ifndef YYTOKEN_TABLE |
| 1291 | # define YYTOKEN_TABLE 0 |
| 1292 | #endif |
| 1293 | |
| 1294 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
| 1295 | typedef union YYSTYPE |
| 1296 | #line 938 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 1297 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1298 | llvm::Module *ModuleVal; |
| 1299 | llvm::Function *FunctionVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1300 | llvm::BasicBlock *BasicBlockVal; |
| 1301 | llvm::TerminatorInst *TermInstVal; |
| 1302 | llvm::Instruction *InstVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1303 | llvm::Constant *ConstVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1304 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1305 | const llvm::Type *PrimType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1306 | std::list<llvm::PATypeHolder> *TypeList; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1307 | llvm::PATypeHolder *TypeVal; |
| 1308 | llvm::Value *ValueVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1309 | std::vector<llvm::Value*> *ValueList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1310 | llvm::ArgListType *ArgList; |
| 1311 | llvm::TypeWithAttrs TypeWithAttrs; |
| 1312 | llvm::TypeWithAttrsList *TypeWithAttrsList; |
| 1313 | llvm::ValueRefList *ValueRefList; |
| 1314 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1315 | // Represent the RHS of PHI node |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1316 | std::list<std::pair<llvm::Value*, |
| 1317 | llvm::BasicBlock*> > *PHIList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1318 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1319 | std::vector<llvm::Constant*> *ConstVector; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1320 | |
| 1321 | llvm::GlobalValue::LinkageTypes Linkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1322 | llvm::GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 1323 | uint16_t ParamAttrs; |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 1324 | llvm::APInt *APIntVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1325 | int64_t SInt64Val; |
| 1326 | uint64_t UInt64Val; |
| 1327 | int SIntVal; |
| 1328 | unsigned UIntVal; |
| 1329 | double FPVal; |
| 1330 | bool BoolVal; |
| 1331 | |
| 1332 | char *StrVal; // This memory is strdup'd! |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1333 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1334 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1335 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1336 | llvm::Instruction::TermOps TermOpVal; |
| 1337 | llvm::Instruction::MemoryOps MemOpVal; |
| 1338 | llvm::Instruction::CastOps CastOpVal; |
| 1339 | llvm::Instruction::OtherOps OtherOpVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1340 | llvm::ICmpInst::Predicate IPredicate; |
| 1341 | llvm::FCmpInst::Predicate FPredicate; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 1342 | } |
| 1343 | /* Line 187 of yacc.c. */ |
| 1344 | #line 1345 "llvmAsmParser.tab.c" |
| 1345 | YYSTYPE; |
| 1346 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 1347 | # define YYSTYPE_IS_DECLARED 1 |
| 1348 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1349 | #endif |
| 1350 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1351 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1352 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 1353 | /* Copy the second part of user declarations. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1354 | |
| 1355 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 1356 | /* Line 216 of yacc.c. */ |
| 1357 | #line 1358 "llvmAsmParser.tab.c" |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1358 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 1359 | #ifdef short |
| 1360 | # undef short |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1361 | #endif |
| 1362 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 1363 | #ifdef YYTYPE_UINT8 |
| 1364 | typedef YYTYPE_UINT8 yytype_uint8; |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 1365 | #else |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 1366 | typedef unsigned char yytype_uint8; |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 1367 | #endif |
| 1368 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 1369 | #ifdef YYTYPE_INT8 |
| 1370 | typedef YYTYPE_INT8 yytype_int8; |
| 1371 | #elif (defined __STDC__ || defined __C99__FUNC__ \ |
| 1372 | || defined __cplusplus || defined _MSC_VER) |
| 1373 | typedef signed char yytype_int8; |
| 1374 | #else |
| 1375 | typedef short int yytype_int8; |
| 1376 | #endif |
| 1377 | |
| 1378 | #ifdef YYTYPE_UINT16 |
| 1379 | typedef YYTYPE_UINT16 yytype_uint16; |
| 1380 | #else |
| 1381 | typedef unsigned short int yytype_uint16; |
| 1382 | #endif |
| 1383 | |
| 1384 | #ifdef YYTYPE_INT16 |
| 1385 | typedef YYTYPE_INT16 yytype_int16; |
| 1386 | #else |
| 1387 | typedef short int yytype_int16; |
| 1388 | #endif |
| 1389 | |
| 1390 | #ifndef YYSIZE_T |
| 1391 | # ifdef __SIZE_TYPE__ |
| 1392 | # define YYSIZE_T __SIZE_TYPE__ |
| 1393 | # elif defined size_t |
| 1394 | # define YYSIZE_T size_t |
| 1395 | # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ |
| 1396 | || defined __cplusplus || defined _MSC_VER) |
| 1397 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 1398 | # define YYSIZE_T size_t |
| 1399 | # else |
| 1400 | # define YYSIZE_T unsigned int |
| 1401 | # endif |
| 1402 | #endif |
| 1403 | |
| 1404 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
| 1405 | |
| 1406 | #ifndef YY_ |
| 1407 | # if YYENABLE_NLS |
| 1408 | # if ENABLE_NLS |
| 1409 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 1410 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
| 1411 | # endif |
| 1412 | # endif |
| 1413 | # ifndef YY_ |
| 1414 | # define YY_(msgid) msgid |
| 1415 | # endif |
| 1416 | #endif |
| 1417 | |
| 1418 | /* Suppress unused-variable warnings by "using" E. */ |
| 1419 | #if ! defined lint || defined __GNUC__ |
| 1420 | # define YYUSE(e) ((void) (e)) |
| 1421 | #else |
| 1422 | # define YYUSE(e) /* empty */ |
| 1423 | #endif |
| 1424 | |
| 1425 | /* Identity function, used to suppress warnings about constant conditions. */ |
| 1426 | #ifndef lint |
| 1427 | # define YYID(n) (n) |
| 1428 | #else |
| 1429 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 1430 | || defined __cplusplus || defined _MSC_VER) |
| 1431 | static int |
| 1432 | YYID (int i) |
| 1433 | #else |
| 1434 | static int |
| 1435 | YYID (i) |
| 1436 | int i; |
| 1437 | #endif |
| 1438 | { |
| 1439 | return i; |
| 1440 | } |
| 1441 | #endif |
| 1442 | |
| 1443 | #if ! defined yyoverflow || YYERROR_VERBOSE |
| 1444 | |
| 1445 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 1446 | |
| 1447 | # ifdef YYSTACK_USE_ALLOCA |
| 1448 | # if YYSTACK_USE_ALLOCA |
| 1449 | # ifdef __GNUC__ |
| 1450 | # define YYSTACK_ALLOC __builtin_alloca |
| 1451 | # elif defined __BUILTIN_VA_ARG_INCR |
| 1452 | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ |
| 1453 | # elif defined _AIX |
| 1454 | # define YYSTACK_ALLOC __alloca |
| 1455 | # elif defined _MSC_VER |
| 1456 | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ |
| 1457 | # define alloca _alloca |
| 1458 | # else |
| 1459 | # define YYSTACK_ALLOC alloca |
| 1460 | # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ |
| 1461 | || defined __cplusplus || defined _MSC_VER) |
| 1462 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 1463 | # ifndef _STDLIB_H |
| 1464 | # define _STDLIB_H 1 |
| 1465 | # endif |
| 1466 | # endif |
| 1467 | # endif |
| 1468 | # endif |
| 1469 | # endif |
| 1470 | |
| 1471 | # ifdef YYSTACK_ALLOC |
| 1472 | /* Pacify GCC's `empty if-body' warning. */ |
| 1473 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) |
| 1474 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1475 | /* The OS might guarantee only one guard page at the bottom of the stack, |
| 1476 | and a page size can be as small as 4096 bytes. So we cannot safely |
| 1477 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
| 1478 | to allow for a few compiler-allocated temporary stack slots. */ |
| 1479 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ |
| 1480 | # endif |
| 1481 | # else |
| 1482 | # define YYSTACK_ALLOC YYMALLOC |
| 1483 | # define YYSTACK_FREE YYFREE |
| 1484 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1485 | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
| 1486 | # endif |
| 1487 | # if (defined __cplusplus && ! defined _STDLIB_H \ |
| 1488 | && ! ((defined YYMALLOC || defined malloc) \ |
| 1489 | && (defined YYFREE || defined free))) |
| 1490 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 1491 | # ifndef _STDLIB_H |
| 1492 | # define _STDLIB_H 1 |
| 1493 | # endif |
| 1494 | # endif |
| 1495 | # ifndef YYMALLOC |
| 1496 | # define YYMALLOC malloc |
| 1497 | # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ |
| 1498 | || defined __cplusplus || defined _MSC_VER) |
| 1499 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 1500 | # endif |
| 1501 | # endif |
| 1502 | # ifndef YYFREE |
| 1503 | # define YYFREE free |
| 1504 | # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ |
| 1505 | || defined __cplusplus || defined _MSC_VER) |
| 1506 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 1507 | # endif |
| 1508 | # endif |
| 1509 | # endif |
| 1510 | #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ |
| 1511 | |
| 1512 | |
| 1513 | #if (! defined yyoverflow \ |
| 1514 | && (! defined __cplusplus \ |
| 1515 | || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) |
| 1516 | |
| 1517 | /* A type that is properly aligned for any stack member. */ |
| 1518 | union yyalloc |
| 1519 | { |
| 1520 | yytype_int16 yyss; |
| 1521 | YYSTYPE yyvs; |
| 1522 | }; |
| 1523 | |
| 1524 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 1525 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 1526 | |
| 1527 | /* The size of an array large to enough to hold all stacks, each with |
| 1528 | N elements. */ |
| 1529 | # define YYSTACK_BYTES(N) \ |
| 1530 | ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ |
| 1531 | + YYSTACK_GAP_MAXIMUM) |
| 1532 | |
| 1533 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 1534 | not overlap. */ |
| 1535 | # ifndef YYCOPY |
| 1536 | # if defined __GNUC__ && 1 < __GNUC__ |
| 1537 | # define YYCOPY(To, From, Count) \ |
| 1538 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 1539 | # else |
| 1540 | # define YYCOPY(To, From, Count) \ |
| 1541 | do \ |
| 1542 | { \ |
| 1543 | YYSIZE_T yyi; \ |
| 1544 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 1545 | (To)[yyi] = (From)[yyi]; \ |
| 1546 | } \ |
| 1547 | while (YYID (0)) |
| 1548 | # endif |
| 1549 | # endif |
| 1550 | |
| 1551 | /* Relocate STACK from its old location to the new one. The |
| 1552 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 1553 | elements in the stack, and YYPTR gives the new location of the |
| 1554 | stack. Advance YYPTR to a properly aligned location for the next |
| 1555 | stack. */ |
| 1556 | # define YYSTACK_RELOCATE(Stack) \ |
| 1557 | do \ |
| 1558 | { \ |
| 1559 | YYSIZE_T yynewbytes; \ |
| 1560 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 1561 | Stack = &yyptr->Stack; \ |
| 1562 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 1563 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 1564 | } \ |
| 1565 | while (YYID (0)) |
| 1566 | |
| 1567 | #endif |
| 1568 | |
| 1569 | /* YYFINAL -- State number of the termination state. */ |
| 1570 | #define YYFINAL 41 |
| 1571 | /* YYLAST -- Last index in YYTABLE. */ |
| 1572 | #define YYLAST 1455 |
| 1573 | |
| 1574 | /* YYNTOKENS -- Number of terminals. */ |
| 1575 | #define YYNTOKENS 150 |
| 1576 | /* YYNNTS -- Number of nonterminals. */ |
| 1577 | #define YYNNTS 81 |
| 1578 | /* YYNRULES -- Number of rules. */ |
| 1579 | #define YYNRULES 294 |
| 1580 | /* YYNRULES -- Number of states. */ |
| 1581 | #define YYNSTATES 573 |
| 1582 | |
| 1583 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 1584 | #define YYUNDEFTOK 2 |
| 1585 | #define YYMAXUTOK 390 |
| 1586 | |
| 1587 | #define YYTRANSLATE(YYX) \ |
| 1588 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 1589 | |
| 1590 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 1591 | static const yytype_uint8 yytranslate[] = |
| 1592 | { |
| 1593 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1594 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1595 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1596 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1597 | 140, 141, 138, 2, 137, 2, 2, 2, 2, 2, |
| 1598 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1599 | 145, 136, 146, 2, 2, 2, 2, 2, 2, 2, |
| 1600 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1601 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1602 | 2, 142, 139, 144, 2, 2, 2, 2, 2, 149, |
| 1603 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1604 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1605 | 143, 2, 2, 147, 2, 148, 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, 2, 2, 2, 2, |
| 1616 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1617 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1618 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 1619 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 1620 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 1621 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 1622 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 1623 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 1624 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 1625 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 1626 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 1627 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1628 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 1629 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 1630 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 1631 | 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, |
| 1632 | 135 |
| 1633 | }; |
| 1634 | |
| 1635 | #if YYDEBUG |
| 1636 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 1637 | YYRHS. */ |
| 1638 | static const yytype_uint16 yyprhs[] = |
| 1639 | { |
| 1640 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 1641 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 1642 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 1643 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, |
| 1644 | 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, |
| 1645 | 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, |
| 1646 | 119, 121, 122, 125, 126, 128, 130, 132, 133, 136, |
| 1647 | 138, 140, 142, 144, 146, 148, 150, 152, 153, 155, |
| 1648 | 157, 158, 160, 162, 163, 165, 167, 169, 171, 172, |
| 1649 | 174, 176, 177, 179, 181, 183, 185, 187, 190, 192, |
| 1650 | 194, 196, 198, 199, 202, 204, 206, 208, 209, 212, |
| 1651 | 213, 216, 217, 221, 224, 225, 227, 228, 232, 234, |
| 1652 | 237, 239, 241, 243, 245, 247, 249, 252, 254, 257, |
| 1653 | 263, 269, 275, 281, 285, 288, 294, 299, 302, 304, |
| 1654 | 306, 308, 312, 314, 318, 320, 321, 323, 327, 332, |
| 1655 | 336, 340, 345, 350, 354, 361, 367, 370, 373, 376, |
| 1656 | 379, 382, 385, 388, 391, 394, 397, 400, 403, 410, |
| 1657 | 416, 425, 432, 439, 447, 455, 462, 471, 480, 484, |
| 1658 | 486, 488, 490, 492, 493, 495, 496, 498, 501, 502, |
| 1659 | 506, 507, 511, 515, 519, 523, 524, 532, 533, 542, |
| 1660 | 543, 552, 559, 562, 566, 568, 572, 576, 580, 584, |
| 1661 | 586, 587, 593, 597, 599, 603, 605, 606, 616, 618, |
| 1662 | 620, 625, 627, 629, 632, 636, 637, 639, 641, 643, |
| 1663 | 645, 647, 649, 651, 653, 655, 659, 661, 667, 669, |
| 1664 | 671, 673, 675, 677, 679, 682, 685, 688, 692, 695, |
| 1665 | 696, 698, 701, 704, 708, 718, 728, 737, 752, 754, |
| 1666 | 756, 763, 769, 772, 779, 787, 791, 797, 798, 799, |
| 1667 | 803, 806, 808, 814, 820, 827, 834, 839, 846, 851, |
| 1668 | 856, 863, 870, 873, 882, 884, 886, 887, 891, 898, |
| 1669 | 902, 909, 912, 918, 926 |
| 1670 | }; |
| 1671 | |
| 1672 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 1673 | static const yytype_int16 yyrhs[] = |
| 1674 | { |
| 1675 | 193, 0, -1, 69, -1, 70, -1, 71, -1, 72, |
| 1676 | -1, 73, -1, 74, -1, 75, -1, 76, -1, 77, |
| 1677 | -1, 81, -1, 82, -1, 83, -1, 78, -1, 79, |
| 1678 | -1, 80, -1, 112, -1, 113, -1, 114, -1, 115, |
| 1679 | -1, 116, -1, 117, -1, 118, -1, 119, -1, 120, |
| 1680 | -1, 121, -1, 122, -1, 123, -1, 86, -1, 87, |
| 1681 | -1, 88, -1, 89, -1, 90, -1, 91, -1, 92, |
| 1682 | -1, 93, -1, 94, -1, 95, -1, 96, -1, 97, |
| 1683 | -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, |
| 1684 | -1, 103, -1, 104, -1, 105, -1, 92, -1, 93, |
| 1685 | -1, 94, -1, 95, -1, 22, -1, 23, -1, 11, |
| 1686 | -1, 12, -1, 13, -1, 16, -1, 19, -1, 158, |
| 1687 | -1, -1, 158, 136, -1, -1, 17, -1, 20, -1, |
| 1688 | 163, -1, -1, 161, 136, -1, 38, -1, 40, -1, |
| 1689 | 39, -1, 41, -1, 43, -1, 42, -1, 44, -1, |
| 1690 | 46, -1, -1, 134, -1, 135, -1, -1, 42, -1, |
| 1691 | 44, -1, -1, 38, -1, 39, -1, 40, -1, 43, |
| 1692 | -1, -1, 40, -1, 38, -1, -1, 57, -1, 58, |
| 1693 | -1, 59, -1, 60, -1, 61, -1, 56, 4, -1, |
| 1694 | 113, -1, 114, -1, 131, -1, 132, -1, -1, 172, |
| 1695 | 171, -1, 130, -1, 133, -1, 171, -1, -1, 174, |
| 1696 | 173, -1, -1, 49, 4, -1, -1, 137, 49, 4, |
| 1697 | -1, 30, 19, -1, -1, 177, -1, -1, 137, 180, |
| 1698 | 179, -1, 177, -1, 49, 4, -1, 11, -1, 12, |
| 1699 | -1, 13, -1, 14, -1, 45, -1, 181, -1, 182, |
| 1700 | 138, -1, 215, -1, 139, 4, -1, 182, 140, 186, |
| 1701 | 141, 174, -1, 10, 140, 186, 141, 174, -1, 142, |
| 1702 | 4, 143, 182, 144, -1, 145, 4, 143, 182, 146, |
| 1703 | -1, 147, 187, 148, -1, 147, 148, -1, 145, 147, |
| 1704 | 187, 148, 146, -1, 145, 147, 148, 146, -1, 182, |
| 1705 | 172, -1, 182, -1, 10, -1, 183, -1, 185, 137, |
| 1706 | 183, -1, 185, -1, 185, 137, 35, -1, 35, -1, |
| 1707 | -1, 182, -1, 187, 137, 182, -1, 182, 142, 190, |
| 1708 | 144, -1, 182, 142, 144, -1, 182, 149, 19, -1, |
| 1709 | 182, 145, 190, 146, -1, 182, 147, 190, 148, -1, |
| 1710 | 182, 147, 148, -1, 182, 145, 147, 190, 148, 146, |
| 1711 | -1, 182, 145, 147, 148, 146, -1, 182, 36, -1, |
| 1712 | 182, 37, -1, 182, 215, -1, 182, 189, -1, 182, |
| 1713 | 21, -1, 156, 3, -1, 156, 5, -1, 156, 4, |
| 1714 | -1, 156, 6, -1, 11, 22, -1, 11, 23, -1, |
| 1715 | 157, 9, -1, 153, 140, 188, 34, 182, 141, -1, |
| 1716 | 111, 140, 188, 226, 141, -1, 125, 140, 188, 137, |
| 1717 | 188, 137, 188, 141, -1, 151, 140, 188, 137, 188, |
| 1718 | 141, -1, 152, 140, 188, 137, 188, 141, -1, 84, |
| 1719 | 154, 140, 188, 137, 188, 141, -1, 85, 155, 140, |
| 1720 | 188, 137, 188, 141, -1, 127, 140, 188, 137, 188, |
| 1721 | 141, -1, 128, 140, 188, 137, 188, 137, 188, 141, |
| 1722 | -1, 129, 140, 188, 137, 188, 137, 188, 141, -1, |
| 1723 | 190, 137, 188, -1, 188, -1, 28, -1, 29, -1, |
| 1724 | 33, -1, -1, 194, -1, -1, 195, -1, 194, 195, |
| 1725 | -1, -1, 27, 196, 211, -1, -1, 26, 197, 212, |
| 1726 | -1, 54, 53, 201, -1, 160, 15, 182, -1, 160, |
| 1727 | 15, 10, -1, -1, 162, 166, 192, 191, 188, 198, |
| 1728 | 179, -1, -1, 162, 164, 166, 192, 191, 188, 199, |
| 1729 | 179, -1, -1, 162, 165, 166, 192, 191, 182, 200, |
| 1730 | 179, -1, 162, 166, 31, 169, 184, 215, -1, 47, |
| 1731 | 202, -1, 50, 136, 203, -1, 19, -1, 48, 136, |
| 1732 | 19, -1, 62, 136, 19, -1, 142, 204, 144, -1, |
| 1733 | 204, 137, 19, -1, 19, -1, -1, 205, 137, 182, |
| 1734 | 172, 159, -1, 182, 172, 159, -1, 205, -1, 205, |
| 1735 | 137, 35, -1, 35, -1, -1, 170, 184, 161, 140, |
| 1736 | 206, 141, 174, 178, 175, -1, 24, -1, 147, -1, |
| 1737 | 168, 166, 207, 208, -1, 25, -1, 148, -1, 218, |
| 1738 | 210, -1, 167, 166, 207, -1, -1, 55, -1, 3, |
| 1739 | -1, 4, -1, 9, -1, 22, -1, 23, -1, 36, |
| 1740 | -1, 37, -1, 21, -1, 145, 190, 146, -1, 189, |
| 1741 | -1, 53, 213, 19, 137, 19, -1, 7, -1, 8, |
| 1742 | -1, 158, -1, 161, -1, 215, -1, 214, -1, 182, |
| 1743 | 216, -1, 218, 219, -1, 209, 219, -1, 220, 160, |
| 1744 | 221, -1, 220, 223, -1, -1, 18, -1, 63, 217, |
| 1745 | -1, 63, 10, -1, 64, 14, 216, -1, 64, 11, |
| 1746 | 216, 137, 14, 216, 137, 14, 216, -1, 65, 156, |
| 1747 | 216, 137, 14, 216, 142, 222, 144, -1, 65, 156, |
| 1748 | 216, 137, 14, 216, 142, 144, -1, 66, 170, 184, |
| 1749 | 216, 140, 225, 141, 174, 34, 14, 216, 67, 14, |
| 1750 | 216, -1, 67, -1, 68, -1, 222, 156, 214, 137, |
| 1751 | 14, 216, -1, 156, 214, 137, 14, 216, -1, 160, |
| 1752 | 228, -1, 182, 142, 216, 137, 216, 144, -1, 224, |
| 1753 | 137, 142, 216, 137, 216, 144, -1, 182, 216, 172, |
| 1754 | -1, 225, 137, 182, 216, 172, -1, -1, -1, 226, |
| 1755 | 137, 217, -1, 52, 51, -1, 51, -1, 151, 182, |
| 1756 | 216, 137, 216, -1, 152, 182, 216, 137, 216, -1, |
| 1757 | 84, 154, 182, 216, 137, 216, -1, 85, 155, 182, |
| 1758 | 216, 137, 216, -1, 153, 217, 34, 182, -1, 125, |
| 1759 | 217, 137, 217, 137, 217, -1, 126, 217, 137, 182, |
| 1760 | -1, 127, 217, 137, 217, -1, 128, 217, 137, 217, |
| 1761 | 137, 217, -1, 129, 217, 137, 217, 137, 217, -1, |
| 1762 | 124, 224, -1, 227, 170, 184, 216, 140, 225, 141, |
| 1763 | 174, -1, 230, -1, 32, -1, -1, 106, 182, 176, |
| 1764 | -1, 106, 182, 137, 11, 216, 176, -1, 107, 182, |
| 1765 | 176, -1, 107, 182, 137, 11, 216, 176, -1, 108, |
| 1766 | 217, -1, 229, 109, 182, 216, 176, -1, 229, 110, |
| 1767 | 217, 137, 182, 216, 176, -1, 111, 182, 216, 226, |
| 1768 | -1 |
| 1769 | }; |
| 1770 | |
| 1771 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 1772 | static const yytype_uint16 yyrline[] = |
| 1773 | { |
| 1774 | 0, 1094, 1094, 1094, 1094, 1094, 1094, 1094, 1094, 1094, |
| 1775 | 1094, 1095, 1095, 1095, 1095, 1095, 1095, 1096, 1096, 1096, |
| 1776 | 1096, 1096, 1096, 1097, 1097, 1097, 1097, 1097, 1097, 1100, |
| 1777 | 1100, 1101, 1101, 1102, 1102, 1103, 1103, 1104, 1104, 1108, |
| 1778 | 1108, 1109, 1109, 1110, 1110, 1111, 1111, 1112, 1112, 1113, |
| 1779 | 1113, 1114, 1114, 1115, 1116, 1121, 1122, 1122, 1124, 1124, |
| 1780 | 1125, 1125, 1129, 1133, 1138, 1138, 1140, 1141, 1146, 1152, |
| 1781 | 1153, 1154, 1155, 1156, 1160, 1161, 1162, 1166, 1167, 1168, |
| 1782 | 1172, 1173, 1174, 1178, 1179, 1180, 1181, 1182, 1186, 1187, |
| 1783 | 1188, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1204, 1205, |
| 1784 | 1206, 1207, 1210, 1211, 1216, 1217, 1218, 1221, 1222, 1229, |
| 1785 | 1230, 1236, 1237, 1245, 1253, 1254, 1259, 1260, 1261, 1266, |
| 1786 | 1279, 1279, 1279, 1279, 1282, 1286, 1290, 1297, 1302, 1310, |
| 1787 | 1340, 1371, 1376, 1388, 1398, 1402, 1412, 1419, 1426, 1433, |
| 1788 | 1438, 1443, 1450, 1451, 1458, 1465, 1473, 1479, 1491, 1519, |
| 1789 | 1535, 1564, 1592, 1617, 1636, 1662, 1682, 1694, 1701, 1767, |
| 1790 | 1777, 1787, 1793, 1803, 1809, 1819, 1824, 1829, 1837, 1849, |
| 1791 | 1871, 1879, 1885, 1896, 1901, 1906, 1912, 1918, 1927, 1931, |
| 1792 | 1939, 1939, 1942, 1942, 1953, 1958, 1966, 1967, 1971, 1971, |
| 1793 | 1975, 1975, 1978, 1981, 2005, 2016, 2016, 2026, 2026, 2034, |
| 1794 | 2034, 2044, 2072, 2075, 2081, 2094, 2098, 2103, 2105, 2110, |
| 1795 | 2115, 2124, 2134, 2145, 2149, 2158, 2167, 2172, 2294, 2294, |
| 1796 | 2296, 2305, 2305, 2307, 2312, 2324, 2328, 2333, 2337, 2341, |
| 1797 | 2345, 2349, 2353, 2357, 2361, 2365, 2390, 2394, 2408, 2412, |
| 1798 | 2416, 2420, 2426, 2426, 2432, 2441, 2445, 2454, 2463, 2472, |
| 1799 | 2476, 2481, 2485, 2489, 2494, 2504, 2523, 2532, 2612, 2616, |
| 1800 | 2623, 2634, 2647, 2657, 2668, 2678, 2687, 2696, 2699, 2700, |
| 1801 | 2707, 2711, 2716, 2737, 2754, 2768, 2782, 2794, 2802, 2809, |
| 1802 | 2815, 2821, 2827, 2842, 2927, 2932, 2936, 2943, 2950, 2958, |
| 1803 | 2965, 2973, 2981, 2995, 3012 |
| 1804 | }; |
| 1805 | #endif |
| 1806 | |
| 1807 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
| 1808 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 1809 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 1810 | static const char *const yytname[] = |
| 1811 | { |
| 1812 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL", |
| 1813 | "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE", |
| 1814 | "FLOAT", "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR", |
| 1815 | "STRINGCONSTANT", "ATSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK", |
| 1816 | "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL", |
| 1817 | "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO", |
| 1818 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK", |
| 1819 | "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 1820 | "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL", |
| 1821 | "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK", |
| 1822 | "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", |
| 1823 | "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", |
| 1824 | "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR", |
| 1825 | "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", |
| 1826 | "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", |
| 1827 | "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", |
| 1828 | "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", |
| 1829 | "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", |
| 1830 | "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT", |
| 1831 | "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET", |
| 1832 | "NOUNWIND", "DEFAULT", "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('", |
| 1833 | "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", |
| 1834 | "ArithmeticOps", "LogicalOps", "CastOps", "IPredicates", "FPredicates", |
| 1835 | "IntType", "FPType", "LocalName", "OptLocalName", "OptLocalAssign", |
| 1836 | "GlobalName", "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage", |
| 1837 | "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage", |
| 1838 | "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr", |
| 1839 | "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptAlign", "OptCAlign", |
| 1840 | "SectionString", "OptSection", "GlobalVarAttributes", |
| 1841 | "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes", |
| 1842 | "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr", |
| 1843 | "ConstVector", "GlobalType", "ThreadLocal", "Module", "DefinitionList", |
| 1844 | "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock", |
| 1845 | "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH", |
| 1846 | "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", |
| 1847 | "Function", "FunctionProto", "OptSideEffect", "ConstValueRef", |
| 1848 | "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList", |
| 1849 | "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst", |
| 1850 | "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal", |
| 1851 | "OptVolatile", "MemoryInst", 0 |
| 1852 | }; |
| 1853 | #endif |
| 1854 | |
| 1855 | # ifdef YYPRINT |
| 1856 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 1857 | token YYLEX-NUM. */ |
| 1858 | static const yytype_uint16 yytoknum[] = |
| 1859 | { |
| 1860 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 1861 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 1862 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 1863 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 1864 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 1865 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 1866 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 1867 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 1868 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 1869 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
| 1870 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
| 1871 | 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, |
| 1872 | 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, |
| 1873 | 385, 386, 387, 388, 389, 390, 61, 44, 42, 92, |
| 1874 | 40, 41, 91, 120, 93, 60, 62, 123, 125, 99 |
| 1875 | }; |
| 1876 | # endif |
| 1877 | |
| 1878 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 1879 | static const yytype_uint8 yyr1[] = |
| 1880 | { |
| 1881 | 0, 150, 151, 151, 151, 151, 151, 151, 151, 151, |
| 1882 | 151, 152, 152, 152, 152, 152, 152, 153, 153, 153, |
| 1883 | 153, 153, 153, 153, 153, 153, 153, 153, 153, 154, |
| 1884 | 154, 154, 154, 154, 154, 154, 154, 154, 154, 155, |
| 1885 | 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, |
| 1886 | 155, 155, 155, 155, 155, 156, 157, 157, 158, 158, |
| 1887 | 159, 159, 160, 160, 161, 161, 162, 162, 163, 164, |
| 1888 | 164, 164, 164, 164, 165, 165, 165, 166, 166, 166, |
| 1889 | 167, 167, 167, 168, 168, 168, 168, 168, 169, 169, |
| 1890 | 169, 170, 170, 170, 170, 170, 170, 170, 171, 171, |
| 1891 | 171, 171, 172, 172, 173, 173, 173, 174, 174, 175, |
| 1892 | 175, 176, 176, 177, 178, 178, 179, 179, 180, 180, |
| 1893 | 181, 181, 181, 181, 182, 182, 182, 182, 182, 182, |
| 1894 | 182, 182, 182, 182, 182, 182, 182, 183, 184, 184, |
| 1895 | 185, 185, 186, 186, 186, 186, 187, 187, 188, 188, |
| 1896 | 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, |
| 1897 | 188, 188, 188, 188, 188, 188, 188, 188, 189, 189, |
| 1898 | 189, 189, 189, 189, 189, 189, 189, 189, 190, 190, |
| 1899 | 191, 191, 192, 192, 193, 193, 194, 194, 196, 195, |
| 1900 | 197, 195, 195, 195, 195, 198, 195, 199, 195, 200, |
| 1901 | 195, 195, 195, 195, 201, 202, 202, 203, 204, 204, |
| 1902 | 204, 205, 205, 206, 206, 206, 206, 207, 208, 208, |
| 1903 | 209, 210, 210, 211, 212, 213, 213, 214, 214, 214, |
| 1904 | 214, 214, 214, 214, 214, 214, 214, 214, 215, 215, |
| 1905 | 215, 215, 216, 216, 217, 218, 218, 219, 220, 220, |
| 1906 | 220, 221, 221, 221, 221, 221, 221, 221, 221, 221, |
| 1907 | 222, 222, 223, 224, 224, 225, 225, 225, 226, 226, |
| 1908 | 227, 227, 228, 228, 228, 228, 228, 228, 228, 228, |
| 1909 | 228, 228, 228, 228, 228, 229, 229, 230, 230, 230, |
| 1910 | 230, 230, 230, 230, 230 |
| 1911 | }; |
| 1912 | |
| 1913 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 1914 | static const yytype_uint8 yyr2[] = |
| 1915 | { |
| 1916 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1917 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1918 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1919 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1920 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1921 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1922 | 1, 0, 2, 0, 1, 1, 1, 0, 2, 1, |
| 1923 | 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, |
| 1924 | 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, |
| 1925 | 1, 0, 1, 1, 1, 1, 1, 2, 1, 1, |
| 1926 | 1, 1, 0, 2, 1, 1, 1, 0, 2, 0, |
| 1927 | 2, 0, 3, 2, 0, 1, 0, 3, 1, 2, |
| 1928 | 1, 1, 1, 1, 1, 1, 2, 1, 2, 5, |
| 1929 | 5, 5, 5, 3, 2, 5, 4, 2, 1, 1, |
| 1930 | 1, 3, 1, 3, 1, 0, 1, 3, 4, 3, |
| 1931 | 3, 4, 4, 3, 6, 5, 2, 2, 2, 2, |
| 1932 | 2, 2, 2, 2, 2, 2, 2, 2, 6, 5, |
| 1933 | 8, 6, 6, 7, 7, 6, 8, 8, 3, 1, |
| 1934 | 1, 1, 1, 0, 1, 0, 1, 2, 0, 3, |
| 1935 | 0, 3, 3, 3, 3, 0, 7, 0, 8, 0, |
| 1936 | 8, 6, 2, 3, 1, 3, 3, 3, 3, 1, |
| 1937 | 0, 5, 3, 1, 3, 1, 0, 9, 1, 1, |
| 1938 | 4, 1, 1, 2, 3, 0, 1, 1, 1, 1, |
| 1939 | 1, 1, 1, 1, 1, 3, 1, 5, 1, 1, |
| 1940 | 1, 1, 1, 1, 2, 2, 2, 3, 2, 0, |
| 1941 | 1, 2, 2, 3, 9, 9, 8, 14, 1, 1, |
| 1942 | 6, 5, 2, 6, 7, 3, 5, 0, 0, 3, |
| 1943 | 2, 1, 5, 5, 6, 6, 4, 6, 4, 4, |
| 1944 | 6, 6, 2, 8, 1, 1, 0, 3, 6, 3, |
| 1945 | 6, 2, 5, 7, 4 |
| 1946 | }; |
| 1947 | |
| 1948 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 1949 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 1950 | means the default is an error. */ |
| 1951 | static const yytype_uint16 yydefact[] = |
| 1952 | { |
| 1953 | 67, 58, 64, 59, 65, 190, 188, 0, 0, 0, |
| 1954 | 0, 0, 0, 77, 66, 0, 67, 186, 80, 83, |
| 1955 | 0, 0, 202, 0, 0, 62, 0, 68, 69, 71, |
| 1956 | 70, 72, 74, 73, 75, 76, 78, 79, 77, 77, |
| 1957 | 183, 1, 187, 81, 82, 77, 191, 84, 85, 86, |
| 1958 | 87, 77, 249, 189, 249, 0, 0, 210, 203, 204, |
| 1959 | 192, 238, 239, 194, 120, 121, 122, 123, 124, 0, |
| 1960 | 0, 0, 0, 240, 241, 125, 193, 127, 183, 183, |
| 1961 | 88, 182, 0, 91, 91, 250, 246, 63, 221, 222, |
| 1962 | 223, 245, 205, 206, 209, 0, 145, 128, 0, 0, |
| 1963 | 0, 0, 134, 146, 0, 126, 145, 0, 0, 90, |
| 1964 | 89, 0, 180, 181, 0, 0, 92, 93, 94, 95, |
| 1965 | 96, 0, 224, 0, 286, 248, 0, 207, 144, 102, |
| 1966 | 140, 142, 0, 0, 0, 0, 0, 0, 133, 0, |
| 1967 | 0, 0, 139, 138, 0, 120, 121, 122, 0, 0, |
| 1968 | 0, 195, 97, 0, 218, 219, 220, 285, 271, 0, |
| 1969 | 0, 0, 0, 91, 258, 259, 2, 3, 4, 5, |
| 1970 | 6, 7, 8, 9, 10, 14, 15, 16, 11, 12, |
| 1971 | 13, 0, 0, 0, 0, 0, 0, 17, 18, 19, |
| 1972 | 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, |
| 1973 | 0, 0, 0, 0, 0, 0, 0, 0, 247, 91, |
| 1974 | 262, 0, 284, 208, 137, 0, 107, 0, 0, 136, |
| 1975 | 0, 147, 107, 197, 199, 201, 165, 166, 161, 163, |
| 1976 | 162, 164, 167, 160, 156, 157, 0, 0, 0, 0, |
| 1977 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1978 | 159, 158, 116, 0, 270, 252, 0, 251, 0, 0, |
| 1979 | 55, 0, 0, 29, 30, 31, 32, 33, 34, 35, |
| 1980 | 36, 37, 38, 0, 53, 54, 49, 50, 51, 52, |
| 1981 | 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, |
| 1982 | 0, 111, 111, 291, 0, 0, 282, 0, 0, 0, |
| 1983 | 0, 0, 0, 0, 0, 0, 0, 0, 98, 99, |
| 1984 | 100, 101, 103, 143, 141, 130, 131, 132, 135, 129, |
| 1985 | 116, 116, 0, 0, 0, 0, 0, 0, 0, 149, |
| 1986 | 179, 0, 0, 0, 153, 0, 150, 0, 0, 0, |
| 1987 | 0, 196, 216, 227, 228, 229, 234, 230, 231, 232, |
| 1988 | 233, 225, 0, 236, 243, 242, 244, 0, 253, 0, |
| 1989 | 0, 0, 0, 0, 287, 0, 289, 268, 0, 0, |
| 1990 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1991 | 0, 104, 105, 106, 108, 198, 200, 0, 0, 268, |
| 1992 | 0, 0, 0, 0, 0, 148, 134, 146, 0, 151, |
| 1993 | 152, 0, 0, 0, 0, 0, 118, 116, 215, 102, |
| 1994 | 213, 0, 226, 0, 0, 0, 0, 0, 0, 0, |
| 1995 | 0, 0, 0, 294, 0, 0, 0, 278, 279, 0, |
| 1996 | 0, 0, 0, 276, 0, 111, 0, 0, 0, 0, |
| 1997 | 0, 0, 0, 0, 178, 155, 0, 0, 0, 0, |
| 1998 | 113, 119, 117, 61, 0, 107, 0, 235, 0, 0, |
| 1999 | 267, 0, 0, 111, 112, 111, 0, 0, 0, 0, |
| 2000 | 0, 0, 272, 273, 267, 0, 292, 0, 0, 0, |
| 2001 | 169, 0, 0, 0, 0, 154, 0, 0, 0, 60, |
| 2002 | 212, 214, 102, 114, 0, 0, 0, 0, 0, 274, |
| 2003 | 275, 288, 290, 269, 0, 0, 277, 280, 281, 0, |
| 2004 | 111, 0, 0, 0, 175, 0, 0, 171, 172, 168, |
| 2005 | 61, 115, 109, 237, 0, 0, 102, 0, 107, 263, |
| 2006 | 0, 107, 293, 173, 174, 0, 0, 0, 211, 0, |
| 2007 | 217, 0, 256, 0, 0, 265, 0, 0, 264, 283, |
| 2008 | 170, 176, 177, 110, 254, 0, 255, 0, 102, 0, |
| 2009 | 0, 0, 266, 0, 0, 0, 0, 261, 0, 0, |
| 2010 | 260, 0, 257 |
| 2011 | }; |
| 2012 | |
| 2013 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 2014 | static const yytype_int16 yydefgoto[] = |
| 2015 | { |
| 2016 | -1, 247, 248, 249, 273, 290, 148, 149, 73, 490, |
| 2017 | 11, 74, 13, 14, 38, 39, 40, 45, 51, 111, |
| 2018 | 121, 312, 214, 384, 315, 540, 364, 406, 522, 341, |
| 2019 | 407, 75, 150, 130, 144, 131, 132, 104, 330, 353, |
| 2020 | 331, 114, 82, 15, 16, 17, 19, 18, 252, 320, |
| 2021 | 321, 60, 22, 58, 95, 410, 411, 122, 156, 52, |
| 2022 | 90, 53, 46, 413, 354, 77, 356, 257, 54, 86, |
| 2023 | 87, 208, 544, 125, 296, 498, 423, 209, 210, 211, |
| 2024 | 212 |
| 2025 | }; |
| 2026 | |
| 2027 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 2028 | STATE-NUM. */ |
| 2029 | #define YYPACT_NINF -467 |
| 2030 | static const yytype_int16 yypact[] = |
| 2031 | { |
| 2032 | 601, -467, -467, -467, -467, -467, -467, 28, -64, 41, |
| 2033 | -37, 98, 10, 16, -467, 139, 856, -467, 36, 170, |
| 2034 | 18, 26, -467, 31, 148, -467, 1069, -467, -467, -467, |
| 2035 | -467, -467, -467, -467, -467, -467, -467, -467, 81, 81, |
| 2036 | 107, -467, -467, -467, -467, 81, -467, -467, -467, -467, |
| 2037 | -467, 81, 179, -467, 8, 209, 220, 226, -467, -467, |
| 2038 | -467, -467, -467, 118, -467, -467, -467, -467, -467, 269, |
| 2039 | 275, 1, 541, -467, -467, -467, 100, -467, 251, 251, |
| 2040 | 229, -467, 204, 196, 196, -467, -467, 104, -467, -467, |
| 2041 | -467, -467, -467, -467, -467, -100, 981, -467, 143, 146, |
| 2042 | 754, 118, -467, 100, -96, -467, 981, 204, 204, -467, |
| 2043 | -467, 1086, -467, -467, 1137, 289, -467, -467, -467, -467, |
| 2044 | -467, 1086, -467, -15, 1326, -467, 277, -467, -467, 100, |
| 2045 | -467, 162, 163, 1181, 1181, 167, -95, 1181, -467, 173, |
| 2046 | 1137, 1181, 118, 100, 227, 45, 299, 306, 216, 309, |
| 2047 | 712, -467, -467, 23, -467, -467, -467, -467, -467, 268, |
| 2048 | 1227, 200, 312, 196, -467, -467, -467, -467, -467, -467, |
| 2049 | -467, -467, -467, -467, -467, -467, -467, -467, -467, -467, |
| 2050 | -467, 303, 1195, 1181, 1181, 1181, 1181, -467, -467, -467, |
| 2051 | -467, -467, -467, -467, -467, -467, -467, -467, -467, 1181, |
| 2052 | 1181, 1181, 1181, 1181, 1181, 1181, 1181, 1181, -467, 196, |
| 2053 | -467, 140, -467, -467, -68, 995, -467, 58, -9, -467, |
| 2054 | 174, 100, -467, -467, 100, -467, -467, -467, -467, -467, |
| 2055 | -467, -467, -467, -467, -467, -467, 303, 1195, 186, 187, |
| 2056 | 188, 189, 191, 633, 1241, 793, 313, 193, 194, 195, |
| 2057 | -467, -467, 201, 197, -467, 118, 462, -467, 589, 589, |
| 2058 | -467, 589, 1086, -467, -467, -467, -467, -467, -467, -467, |
| 2059 | -467, -467, -467, 1181, -467, -467, -467, -467, -467, -467, |
| 2060 | -467, -467, -467, -467, -467, -467, -467, -467, -467, -467, |
| 2061 | 1181, 89, 165, -467, 462, 134, 202, 205, 206, 213, |
| 2062 | 214, 217, 462, 462, 307, 1086, 1181, 1181, -467, -467, |
| 2063 | -467, -467, -467, -467, -467, -48, -467, -467, -467, -48, |
| 2064 | 201, 201, 215, 218, 1137, 1137, 1137, 1137, 1137, -467, |
| 2065 | -467, -26, 965, -67, -467, -45, -467, 1137, 1137, 1137, |
| 2066 | -10, -467, 1025, -467, -467, -467, -467, -467, -467, -467, |
| 2067 | -467, 298, 1137, -467, -467, -467, -467, 219, -467, 222, |
| 2068 | 589, 462, 462, 24, -467, 25, -467, -467, 589, 221, |
| 2069 | 1181, 1181, 1181, 1181, 1181, 224, 225, 1181, 589, 462, |
| 2070 | 230, -467, -467, -467, -467, -467, -467, 1137, 1137, -467, |
| 2071 | 233, 234, 235, 241, 1137, -467, 211, 712, -44, -467, |
| 2072 | -467, 242, 244, 330, 347, 365, -467, 201, -467, 100, |
| 2073 | 245, 258, -467, 364, -31, 386, 387, 265, 271, 276, |
| 2074 | 589, 402, 589, 278, 279, 589, 280, 100, -467, 281, |
| 2075 | 282, 589, 589, 100, 272, 283, 1181, 284, 285, -27, |
| 2076 | 1137, 1137, 1137, 1137, -467, -467, 286, 1137, 1137, 1181, |
| 2077 | -467, -467, -467, 13, 1039, -467, 288, -467, 589, 589, |
| 2078 | 1181, 589, 589, 283, -467, 283, 1181, 589, 291, 1181, |
| 2079 | 1181, 1181, -467, -467, 1181, 374, -467, 462, 1137, 1137, |
| 2080 | -467, 293, 273, 296, 301, -467, 310, 311, 137, -467, |
| 2081 | -467, -467, 100, 39, 420, 305, 308, 462, -7, -467, |
| 2082 | -467, -467, -467, -467, 304, 589, -467, -467, -467, 47, |
| 2083 | 283, 314, 315, 1137, -467, 1137, 1137, -467, -467, -467, |
| 2084 | 13, -467, 391, -467, 433, -1, -467, 1181, -467, -467, |
| 2085 | 316, -467, -467, -467, -467, 317, 318, 320, -467, 450, |
| 2086 | -467, 589, -467, 842, 3, -68, 462, 73, -467, -48, |
| 2087 | -467, -467, -467, -467, -467, 325, -467, 842, -467, 443, |
| 2088 | 449, 327, -68, 589, 589, 453, 401, -467, 589, 458, |
| 2089 | -467, 589, -467 |
| 2090 | }; |
| 2091 | |
| 2092 | /* YYPGOTO[NTERM-NUM]. */ |
| 2093 | static const yytype_int16 yypgoto[] = |
| 2094 | { |
| 2095 | -467, 349, 350, 351, 240, 243, -160, -467, 0, -43, |
| 2096 | 399, 11, -467, -467, -467, -467, 50, -467, -467, -467, |
| 2097 | -148, -281, -390, -467, -219, -467, -280, -6, -467, -290, |
| 2098 | -467, -467, -25, 290, -113, -467, 382, 393, 49, -146, |
| 2099 | -227, 155, 232, -467, -467, 478, -467, -467, -467, -467, |
| 2100 | -467, -467, -467, -467, -467, -467, -467, 411, -467, -467, |
| 2101 | -467, -467, -467, -467, -466, -137, -161, -179, -467, 446, |
| 2102 | -467, -467, -467, -467, -467, 27, 114, -467, -467, -467, |
| 2103 | -467 |
| 2104 | }; |
| 2105 | |
| 2106 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 2107 | positive, shift that token. If negative, reduce the rule which |
| 2108 | number is the opposite. If zero, do what YYDEFACT says. |
| 2109 | If YYTABLE_NINF, syntax error. */ |
| 2110 | #define YYTABLE_NINF -186 |
| 2111 | static const yytype_int16 yytable[] = |
| 2112 | { |
| 2113 | 10, 76, 261, 319, 250, 99, 293, 225, 153, 154, |
| 2114 | 260, 12, 366, 251, 260, 262, 10, 333, 335, 453, |
| 2115 | 404, 297, 298, 299, 300, 301, 85, 12, 304, 1, |
| 2116 | 385, 386, 3, 88, 383, 420, 422, 126, 383, 405, |
| 2117 | 2, 137, 137, 4, 127, 308, 309, 103, -55, -55, |
| 2118 | -55, -55, 138, 220, 28, 29, 30, 31, 32, 33, |
| 2119 | 34, 305, 35, 310, 311, 308, 309, 226, 227, 404, |
| 2120 | 394, 129, 23, 421, 421, 103, 20, 555, 43, 399, |
| 2121 | 44, 129, 381, 310, 311, 382, 143, 10, 78, 79, |
| 2122 | 21, 561, 394, 394, 24, 83, 143, 357, 358, 25, |
| 2123 | 359, 84, 520, 400, 446, 398, 394, 559, 217, 218, |
| 2124 | 466, 394, 221, 26, 480, 457, 224, 452, 395, 355, |
| 2125 | 1, 355, 355, 3, 355, 414, 308, 309, 380, 105, |
| 2126 | 527, 106, 155, 367, 528, 256, 545, 317, 80, 41, |
| 2127 | 81, 375, 376, 542, 310, 311, 27, 556, 100, 360, |
| 2128 | 36, 37, 308, 309, 55, 476, 89, 355, 291, 292, |
| 2129 | 256, 294, 56, 151, 253, 355, 355, 59, 562, 381, |
| 2130 | 310, 311, 382, 57, 295, 256, 256, 256, 256, 256, |
| 2131 | 302, 303, 256, 501, 527, 502, 308, 309, 531, 223, |
| 2132 | 129, 426, 378, 428, 429, 430, 105, 85, 106, 417, |
| 2133 | 418, 419, 316, 381, 310, 311, 382, 424, 47, 48, |
| 2134 | 49, 258, 383, 50, 259, 36, 37, 434, 435, 228, |
| 2135 | 229, 230, 231, 355, 355, 355, 363, 105, 92, 106, |
| 2136 | 532, 355, 112, 113, 61, 62, 493, 143, 105, 93, |
| 2137 | 106, 355, 355, 1, 2, 94, 3, 4, 361, 306, |
| 2138 | 307, 250, 115, 116, 117, 118, 119, 120, 96, 463, |
| 2139 | 251, 465, 140, 141, 468, 362, 383, 109, 383, 110, |
| 2140 | 472, 473, 105, 97, 106, 105, 368, 106, 519, 98, |
| 2141 | 143, 379, 256, 355, 81, 355, 133, 503, 355, 134, |
| 2142 | 506, 507, 508, 152, 355, 355, 213, 495, 496, 215, |
| 2143 | 499, 500, 365, 105, 216, 106, 504, 397, -56, 547, |
| 2144 | 107, 108, 549, 219, 222, -57, 510, 409, 232, 254, |
| 2145 | 318, 355, 355, 260, 355, 355, 324, 325, 326, 327, |
| 2146 | 355, 328, 336, 337, 338, 339, 526, 342, 340, 369, |
| 2147 | 355, 377, 370, 371, 530, 256, 427, 256, 256, 256, |
| 2148 | 372, 373, 433, 412, 374, 387, 415, 445, 388, 416, |
| 2149 | 355, 431, 432, 425, 449, 543, 450, 436, 355, 451, |
| 2150 | 440, 441, 442, 389, 390, 391, 392, 393, 443, 447, |
| 2151 | 554, 448, 454, 456, 557, 558, 401, 402, 403, 263, |
| 2152 | 264, 265, 266, 267, 268, 269, 270, 271, 272, 455, |
| 2153 | 458, 459, 566, 567, 355, 460, 464, 570, 461, 355, |
| 2154 | 572, 477, 474, 462, 514, 466, 467, 469, 470, 471, |
| 2155 | 475, 478, 479, 421, 488, 494, 355, 355, 505, 492, |
| 2156 | 513, 355, 485, 515, 355, 497, 437, 438, 516, 523, |
| 2157 | 539, 256, 524, 444, 256, 256, 256, 541, 529, 497, |
| 2158 | 525, 517, 518, 489, 553, 533, 534, 563, 550, 551, |
| 2159 | 548, 552, 560, 564, 565, 343, 344, 568, 569, 61, |
| 2160 | 62, 345, 571, 205, 206, 207, 322, 538, 1, 2, |
| 2161 | 323, 3, 4, 346, 347, 348, 124, 521, 139, 481, |
| 2162 | 482, 483, 484, 136, 42, 123, 486, 487, 349, 350, |
| 2163 | 91, 509, 546, 439, 0, 314, 0, 0, 0, 0, |
| 2164 | 0, 0, 0, 0, 0, 351, 0, 0, 0, 0, |
| 2165 | 489, 0, 0, 0, 0, 0, 0, 511, 512, 0, |
| 2166 | 0, 166, 167, 168, 169, 170, 171, 172, 173, 174, |
| 2167 | 175, 176, 177, 178, 179, 180, 236, 237, 61, 62, |
| 2168 | 0, 101, 64, 65, 66, 67, 0, 1, 2, 0, |
| 2169 | 3, 4, 535, 0, 536, 537, 0, 0, 0, 0, |
| 2170 | 0, 0, 0, 238, 187, 188, 189, 190, 191, 192, |
| 2171 | 193, 194, 195, 196, 197, 198, 68, 239, 0, 240, |
| 2172 | 241, 242, 343, 344, 0, 0, 61, 62, 345, 0, |
| 2173 | 105, -185, 106, 0, 0, 1, 2, 352, 3, 4, |
| 2174 | 346, 347, 348, 0, 0, 0, -63, 1, 2, 0, |
| 2175 | 3, 4, 0, 0, 0, 349, 350, 5, 6, 0, |
| 2176 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2177 | 61, 62, 351, 101, 145, 146, 147, 67, 7, 1, |
| 2178 | 2, 8, 3, 4, 0, 9, 0, 0, 166, 167, |
| 2179 | 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, |
| 2180 | 178, 179, 180, 236, 237, 0, 0, 0, 68, 0, |
| 2181 | 69, 0, 0, 70, 0, 0, 71, 0, 72, 102, |
| 2182 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2183 | 238, 187, 188, 189, 190, 191, 192, 193, 194, 195, |
| 2184 | 196, 197, 198, 0, 239, 0, 240, 241, 242, 61, |
| 2185 | 62, 0, 0, 0, 0, 0, 0, 0, 1, 2, |
| 2186 | 0, 3, 4, 233, 352, 0, 0, 0, 0, 0, |
| 2187 | 0, 0, 0, 0, 0, 0, 0, 0, 234, 235, |
| 2188 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2189 | 0, 61, 62, 0, 101, 64, 65, 66, 67, 0, |
| 2190 | 1, 2, 69, 3, 4, 70, 0, 329, 71, 0, |
| 2191 | 72, 166, 167, 168, 169, 170, 171, 172, 173, 174, |
| 2192 | 175, 176, 177, 178, 179, 180, 236, 237, 0, 68, |
| 2193 | 61, 62, 0, 101, 145, 146, 147, 67, 0, 1, |
| 2194 | 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, |
| 2195 | 0, 0, 0, 238, 187, 188, 189, 190, 191, 192, |
| 2196 | 193, 194, 195, 196, 197, 198, 0, 239, 68, 240, |
| 2197 | 241, 242, 0, 0, 0, 343, 344, 0, 0, 0, |
| 2198 | 105, 345, 106, 0, 243, 0, -184, 244, 0, 245, |
| 2199 | 0, 246, 0, 346, 347, 348, 0, 0, 0, 0, |
| 2200 | 0, -63, 1, 2, 0, 3, 4, 0, 349, 350, |
| 2201 | 0, 0, 5, 6, 0, 0, 0, 0, 0, 0, |
| 2202 | 0, 0, 0, 69, 0, 351, 70, 0, 0, 71, |
| 2203 | 0, 72, 135, 7, 0, 0, 8, 0, 0, 0, |
| 2204 | 9, 166, 167, 168, 169, 170, 171, 172, 173, 174, |
| 2205 | 175, 176, 177, 178, 179, 180, 236, 237, 0, 0, |
| 2206 | 0, 0, 69, 0, 0, 70, 0, 0, 71, 0, |
| 2207 | 72, 334, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2208 | 0, 0, 0, 238, 187, 188, 189, 190, 191, 192, |
| 2209 | 193, 194, 195, 196, 197, 198, 0, 239, 0, 240, |
| 2210 | 241, 242, 61, 62, 0, 101, 145, 146, 147, 67, |
| 2211 | 0, 1, 2, 0, 3, 4, 0, 352, 61, 62, |
| 2212 | 0, 101, 64, 65, 66, 67, 0, 1, 2, 0, |
| 2213 | 3, 4, 61, 62, 0, 101, 64, 65, 66, 67, |
| 2214 | 68, 1, 2, 0, 3, 4, 128, 0, 0, 0, |
| 2215 | 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, |
| 2216 | 313, 0, 61, 62, 0, 101, 64, 65, 66, 67, |
| 2217 | 68, 1, 2, 0, 3, 4, 61, 62, 0, 101, |
| 2218 | 64, 65, 66, 67, 0, 1, 2, 0, 3, 4, |
| 2219 | 408, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2220 | 68, 0, 0, 0, 491, 0, 61, 62, 0, 63, |
| 2221 | 64, 65, 66, 67, 68, 1, 2, 0, 3, 4, |
| 2222 | 0, 0, 0, 61, 62, 0, 142, 64, 65, 66, |
| 2223 | 67, 0, 1, 2, 69, 3, 4, 70, 0, 0, |
| 2224 | 71, 0, 72, 396, 68, 0, 0, 0, 0, 0, |
| 2225 | 69, 0, 0, 70, 0, 0, 71, 0, 72, 0, |
| 2226 | 0, 68, 0, 0, 69, 0, 0, 70, 0, 0, |
| 2227 | 71, 0, 72, 0, 61, 62, 0, 101, 145, 146, |
| 2228 | 147, 67, 0, 1, 2, 0, 3, 4, 0, 0, |
| 2229 | 0, 0, 0, 0, 69, 0, 0, 70, 0, 0, |
| 2230 | 71, 0, 72, 0, 0, 0, 0, 0, 69, 0, |
| 2231 | 0, 70, 68, 0, 71, 0, 72, 0, 61, 62, |
| 2232 | 0, 101, 64, 65, 66, 67, 0, 1, 2, 0, |
| 2233 | 3, 4, 0, 0, 0, 0, 0, 0, 69, 0, |
| 2234 | 0, 70, 0, 0, 71, 0, 72, 274, 275, 0, |
| 2235 | 0, 0, 0, 0, 0, 69, 68, 0, 70, 0, |
| 2236 | 0, 71, 0, 72, 61, 62, 0, 255, 64, 65, |
| 2237 | 66, 67, 0, 1, 2, 0, 3, 4, 61, 62, |
| 2238 | 0, 101, 145, 146, 147, 67, 0, 1, 2, 0, |
| 2239 | 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2240 | 0, 0, 68, 0, 0, 0, 69, 0, 0, 70, |
| 2241 | 0, 0, 71, 0, 72, 0, 68, 276, 277, 278, |
| 2242 | 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, |
| 2243 | 289, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2244 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2245 | 69, 0, 0, 70, 0, 0, 71, 0, 72, 0, |
| 2246 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2247 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2248 | 0, 0, 0, 0, 0, 0, 0, 0, 157, 0, |
| 2249 | 0, 0, 0, 0, 0, 0, 69, 0, 0, 70, |
| 2250 | 0, 0, 71, 0, 72, 0, 0, 158, 159, 0, |
| 2251 | 69, 0, 0, 70, 0, 0, 71, 0, 332, 160, |
| 2252 | 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, |
| 2253 | 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, |
| 2254 | 181, 182, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2255 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2256 | 0, 0, 183, 184, 185, 0, 0, 186, 187, 188, |
| 2257 | 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, |
| 2258 | 199, 200, 201, 202, 203, 204 |
| 2259 | }; |
| 2260 | |
| 2261 | static const yytype_int16 yycheck[] = |
| 2262 | { |
| 2263 | 0, 26, 162, 222, 150, 4, 185, 144, 121, 24, |
| 2264 | 11, 0, 292, 150, 11, 163, 16, 244, 245, 409, |
| 2265 | 30, 200, 201, 202, 203, 204, 18, 16, 207, 16, |
| 2266 | 320, 321, 19, 25, 315, 11, 11, 137, 319, 49, |
| 2267 | 17, 137, 137, 20, 144, 113, 114, 72, 3, 4, |
| 2268 | 5, 6, 148, 148, 38, 39, 40, 41, 42, 43, |
| 2269 | 44, 209, 46, 131, 132, 113, 114, 22, 23, 30, |
| 2270 | 137, 96, 136, 49, 49, 100, 48, 543, 42, 146, |
| 2271 | 44, 106, 130, 131, 132, 133, 111, 87, 38, 39, |
| 2272 | 62, 557, 137, 137, 53, 45, 121, 258, 259, 136, |
| 2273 | 261, 51, 492, 148, 148, 332, 137, 34, 133, 134, |
| 2274 | 137, 137, 137, 15, 141, 146, 141, 407, 144, 256, |
| 2275 | 16, 258, 259, 19, 261, 352, 113, 114, 307, 138, |
| 2276 | 137, 140, 147, 294, 141, 160, 526, 146, 31, 0, |
| 2277 | 33, 302, 303, 144, 131, 132, 136, 144, 147, 262, |
| 2278 | 134, 135, 113, 114, 136, 435, 148, 294, 183, 184, |
| 2279 | 185, 186, 136, 114, 153, 302, 303, 19, 558, 130, |
| 2280 | 131, 132, 133, 142, 199, 200, 201, 202, 203, 204, |
| 2281 | 205, 206, 207, 463, 137, 465, 113, 114, 141, 140, |
| 2282 | 215, 370, 305, 372, 373, 374, 138, 18, 140, 360, |
| 2283 | 361, 362, 144, 130, 131, 132, 133, 368, 38, 39, |
| 2284 | 40, 11, 493, 43, 14, 134, 135, 378, 379, 3, |
| 2285 | 4, 5, 6, 360, 361, 362, 137, 138, 19, 140, |
| 2286 | 510, 368, 28, 29, 7, 8, 455, 262, 138, 19, |
| 2287 | 140, 378, 379, 16, 17, 19, 19, 20, 273, 109, |
| 2288 | 110, 397, 56, 57, 58, 59, 60, 61, 140, 420, |
| 2289 | 397, 422, 107, 108, 425, 290, 547, 38, 549, 40, |
| 2290 | 431, 432, 138, 4, 140, 138, 142, 140, 141, 4, |
| 2291 | 305, 306, 307, 420, 33, 422, 143, 466, 425, 143, |
| 2292 | 469, 470, 471, 4, 431, 432, 19, 458, 459, 137, |
| 2293 | 461, 462, 137, 138, 141, 140, 467, 332, 9, 528, |
| 2294 | 78, 79, 531, 146, 141, 9, 477, 342, 9, 51, |
| 2295 | 146, 458, 459, 11, 461, 462, 140, 140, 140, 140, |
| 2296 | 467, 140, 19, 140, 140, 140, 497, 140, 137, 137, |
| 2297 | 477, 34, 137, 137, 505, 370, 371, 372, 373, 374, |
| 2298 | 137, 137, 377, 55, 137, 140, 137, 146, 140, 137, |
| 2299 | 497, 137, 137, 142, 34, 525, 19, 137, 505, 4, |
| 2300 | 137, 137, 137, 324, 325, 326, 327, 328, 137, 137, |
| 2301 | 541, 137, 137, 19, 544, 546, 337, 338, 339, 86, |
| 2302 | 87, 88, 89, 90, 91, 92, 93, 94, 95, 141, |
| 2303 | 14, 14, 563, 564, 541, 140, 4, 568, 137, 546, |
| 2304 | 571, 436, 140, 137, 141, 137, 137, 137, 137, 137, |
| 2305 | 137, 137, 137, 49, 449, 137, 563, 564, 137, 454, |
| 2306 | 137, 568, 146, 137, 571, 460, 387, 388, 137, 19, |
| 2307 | 49, 466, 137, 394, 469, 470, 471, 14, 144, 474, |
| 2308 | 142, 141, 141, 453, 4, 141, 141, 14, 141, 141, |
| 2309 | 144, 141, 137, 14, 137, 3, 4, 14, 67, 7, |
| 2310 | 8, 9, 14, 124, 124, 124, 236, 520, 16, 17, |
| 2311 | 237, 19, 20, 21, 22, 23, 87, 493, 106, 440, |
| 2312 | 441, 442, 443, 100, 16, 84, 447, 448, 36, 37, |
| 2313 | 54, 474, 527, 389, -1, 215, -1, -1, -1, -1, |
| 2314 | -1, -1, -1, -1, -1, 53, -1, -1, -1, -1, |
| 2315 | 520, -1, -1, -1, -1, -1, -1, 478, 479, -1, |
| 2316 | -1, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 2317 | 78, 79, 80, 81, 82, 83, 84, 85, 7, 8, |
| 2318 | -1, 10, 11, 12, 13, 14, -1, 16, 17, -1, |
| 2319 | 19, 20, 513, -1, 515, 516, -1, -1, -1, -1, |
| 2320 | -1, -1, -1, 111, 112, 113, 114, 115, 116, 117, |
| 2321 | 118, 119, 120, 121, 122, 123, 45, 125, -1, 127, |
| 2322 | 128, 129, 3, 4, -1, -1, 7, 8, 9, -1, |
| 2323 | 138, 0, 140, -1, -1, 16, 17, 145, 19, 20, |
| 2324 | 21, 22, 23, -1, -1, -1, 15, 16, 17, -1, |
| 2325 | 19, 20, -1, -1, -1, 36, 37, 26, 27, -1, |
| 2326 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2327 | 7, 8, 53, 10, 11, 12, 13, 14, 47, 16, |
| 2328 | 17, 50, 19, 20, -1, 54, -1, -1, 69, 70, |
| 2329 | 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 2330 | 81, 82, 83, 84, 85, -1, -1, -1, 45, -1, |
| 2331 | 139, -1, -1, 142, -1, -1, 145, -1, 147, 148, |
| 2332 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2333 | 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, |
| 2334 | 121, 122, 123, -1, 125, -1, 127, 128, 129, 7, |
| 2335 | 8, -1, -1, -1, -1, -1, -1, -1, 16, 17, |
| 2336 | -1, 19, 20, 21, 145, -1, -1, -1, -1, -1, |
| 2337 | -1, -1, -1, -1, -1, -1, -1, -1, 36, 37, |
| 2338 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2339 | -1, 7, 8, -1, 10, 11, 12, 13, 14, -1, |
| 2340 | 16, 17, 139, 19, 20, 142, -1, 144, 145, -1, |
| 2341 | 147, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 2342 | 78, 79, 80, 81, 82, 83, 84, 85, -1, 45, |
| 2343 | 7, 8, -1, 10, 11, 12, 13, 14, -1, 16, |
| 2344 | 17, -1, 19, 20, -1, -1, -1, -1, -1, -1, |
| 2345 | -1, -1, -1, 111, 112, 113, 114, 115, 116, 117, |
| 2346 | 118, 119, 120, 121, 122, 123, -1, 125, 45, 127, |
| 2347 | 128, 129, -1, -1, -1, 3, 4, -1, -1, -1, |
| 2348 | 138, 9, 140, -1, 142, -1, 0, 145, -1, 147, |
| 2349 | -1, 149, -1, 21, 22, 23, -1, -1, -1, -1, |
| 2350 | -1, 15, 16, 17, -1, 19, 20, -1, 36, 37, |
| 2351 | -1, -1, 26, 27, -1, -1, -1, -1, -1, -1, |
| 2352 | -1, -1, -1, 139, -1, 53, 142, -1, -1, 145, |
| 2353 | -1, 147, 148, 47, -1, -1, 50, -1, -1, -1, |
| 2354 | 54, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 2355 | 78, 79, 80, 81, 82, 83, 84, 85, -1, -1, |
| 2356 | -1, -1, 139, -1, -1, 142, -1, -1, 145, -1, |
| 2357 | 147, 148, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2358 | -1, -1, -1, 111, 112, 113, 114, 115, 116, 117, |
| 2359 | 118, 119, 120, 121, 122, 123, -1, 125, -1, 127, |
| 2360 | 128, 129, 7, 8, -1, 10, 11, 12, 13, 14, |
| 2361 | -1, 16, 17, -1, 19, 20, -1, 145, 7, 8, |
| 2362 | -1, 10, 11, 12, 13, 14, -1, 16, 17, -1, |
| 2363 | 19, 20, 7, 8, -1, 10, 11, 12, 13, 14, |
| 2364 | 45, 16, 17, -1, 19, 20, 35, -1, -1, -1, |
| 2365 | -1, -1, -1, -1, -1, -1, 45, -1, -1, -1, |
| 2366 | 35, -1, 7, 8, -1, 10, 11, 12, 13, 14, |
| 2367 | 45, 16, 17, -1, 19, 20, 7, 8, -1, 10, |
| 2368 | 11, 12, 13, 14, -1, 16, 17, -1, 19, 20, |
| 2369 | 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2370 | 45, -1, -1, -1, 35, -1, 7, 8, -1, 10, |
| 2371 | 11, 12, 13, 14, 45, 16, 17, -1, 19, 20, |
| 2372 | -1, -1, -1, 7, 8, -1, 10, 11, 12, 13, |
| 2373 | 14, -1, 16, 17, 139, 19, 20, 142, -1, -1, |
| 2374 | 145, -1, 147, 148, 45, -1, -1, -1, -1, -1, |
| 2375 | 139, -1, -1, 142, -1, -1, 145, -1, 147, -1, |
| 2376 | -1, 45, -1, -1, 139, -1, -1, 142, -1, -1, |
| 2377 | 145, -1, 147, -1, 7, 8, -1, 10, 11, 12, |
| 2378 | 13, 14, -1, 16, 17, -1, 19, 20, -1, -1, |
| 2379 | -1, -1, -1, -1, 139, -1, -1, 142, -1, -1, |
| 2380 | 145, -1, 147, -1, -1, -1, -1, -1, 139, -1, |
| 2381 | -1, 142, 45, -1, 145, -1, 147, -1, 7, 8, |
| 2382 | -1, 10, 11, 12, 13, 14, -1, 16, 17, -1, |
| 2383 | 19, 20, -1, -1, -1, -1, -1, -1, 139, -1, |
| 2384 | -1, 142, -1, -1, 145, -1, 147, 22, 23, -1, |
| 2385 | -1, -1, -1, -1, -1, 139, 45, -1, 142, -1, |
| 2386 | -1, 145, -1, 147, 7, 8, -1, 10, 11, 12, |
| 2387 | 13, 14, -1, 16, 17, -1, 19, 20, 7, 8, |
| 2388 | -1, 10, 11, 12, 13, 14, -1, 16, 17, -1, |
| 2389 | 19, 20, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2390 | -1, -1, 45, -1, -1, -1, 139, -1, -1, 142, |
| 2391 | -1, -1, 145, -1, 147, -1, 45, 92, 93, 94, |
| 2392 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 2393 | 105, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2394 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2395 | 139, -1, -1, 142, -1, -1, 145, -1, 147, -1, |
| 2396 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2397 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2398 | -1, -1, -1, -1, -1, -1, -1, -1, 32, -1, |
| 2399 | -1, -1, -1, -1, -1, -1, 139, -1, -1, 142, |
| 2400 | -1, -1, 145, -1, 147, -1, -1, 51, 52, -1, |
| 2401 | 139, -1, -1, 142, -1, -1, 145, -1, 147, 63, |
| 2402 | 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, |
| 2403 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 2404 | 84, 85, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2405 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2406 | -1, -1, 106, 107, 108, -1, -1, 111, 112, 113, |
| 2407 | 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, |
| 2408 | 124, 125, 126, 127, 128, 129 |
| 2409 | }; |
| 2410 | |
| 2411 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 2412 | symbol of state STATE-NUM. */ |
| 2413 | static const yytype_uint8 yystos[] = |
| 2414 | { |
| 2415 | 0, 16, 17, 19, 20, 26, 27, 47, 50, 54, |
| 2416 | 158, 160, 161, 162, 163, 193, 194, 195, 197, 196, |
| 2417 | 48, 62, 202, 136, 53, 136, 15, 136, 38, 39, |
| 2418 | 40, 41, 42, 43, 44, 46, 134, 135, 164, 165, |
| 2419 | 166, 0, 195, 42, 44, 167, 212, 38, 39, 40, |
| 2420 | 43, 168, 209, 211, 218, 136, 136, 142, 203, 19, |
| 2421 | 201, 7, 8, 10, 11, 12, 13, 14, 45, 139, |
| 2422 | 142, 145, 147, 158, 161, 181, 182, 215, 166, 166, |
| 2423 | 31, 33, 192, 166, 166, 18, 219, 220, 25, 148, |
| 2424 | 210, 219, 19, 19, 19, 204, 140, 4, 4, 4, |
| 2425 | 147, 10, 148, 182, 187, 138, 140, 192, 192, 38, |
| 2426 | 40, 169, 28, 29, 191, 56, 57, 58, 59, 60, |
| 2427 | 61, 170, 207, 207, 160, 223, 137, 144, 35, 182, |
| 2428 | 183, 185, 186, 143, 143, 148, 187, 137, 148, 186, |
| 2429 | 191, 191, 10, 182, 184, 11, 12, 13, 156, 157, |
| 2430 | 182, 188, 4, 184, 24, 147, 208, 32, 51, 52, |
| 2431 | 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, |
| 2432 | 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, |
| 2433 | 83, 84, 85, 106, 107, 108, 111, 112, 113, 114, |
| 2434 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 2435 | 125, 126, 127, 128, 129, 151, 152, 153, 221, 227, |
| 2436 | 228, 229, 230, 19, 172, 137, 141, 182, 182, 146, |
| 2437 | 148, 182, 141, 188, 182, 215, 22, 23, 3, 4, |
| 2438 | 5, 6, 9, 21, 36, 37, 84, 85, 111, 125, |
| 2439 | 127, 128, 129, 142, 145, 147, 149, 151, 152, 153, |
| 2440 | 189, 215, 198, 161, 51, 10, 182, 217, 11, 14, |
| 2441 | 11, 156, 170, 86, 87, 88, 89, 90, 91, 92, |
| 2442 | 93, 94, 95, 154, 22, 23, 92, 93, 94, 95, |
| 2443 | 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, |
| 2444 | 155, 182, 182, 217, 182, 182, 224, 217, 217, 217, |
| 2445 | 217, 217, 182, 182, 217, 170, 109, 110, 113, 114, |
| 2446 | 131, 132, 171, 35, 183, 174, 144, 146, 146, 174, |
| 2447 | 199, 200, 154, 155, 140, 140, 140, 140, 140, 144, |
| 2448 | 188, 190, 147, 190, 148, 190, 19, 140, 140, 140, |
| 2449 | 137, 179, 140, 3, 4, 9, 21, 22, 23, 36, |
| 2450 | 37, 53, 145, 189, 214, 215, 216, 216, 216, 216, |
| 2451 | 184, 182, 182, 137, 176, 137, 176, 216, 142, 137, |
| 2452 | 137, 137, 137, 137, 137, 216, 216, 34, 184, 182, |
| 2453 | 217, 130, 133, 171, 173, 179, 179, 140, 140, 188, |
| 2454 | 188, 188, 188, 188, 137, 144, 148, 182, 190, 146, |
| 2455 | 148, 188, 188, 188, 30, 49, 177, 180, 35, 182, |
| 2456 | 205, 206, 55, 213, 190, 137, 137, 216, 216, 216, |
| 2457 | 11, 49, 11, 226, 216, 142, 217, 182, 217, 217, |
| 2458 | 217, 137, 137, 182, 216, 216, 137, 188, 188, 226, |
| 2459 | 137, 137, 137, 137, 188, 146, 148, 137, 137, 34, |
| 2460 | 19, 4, 179, 172, 137, 141, 19, 146, 14, 14, |
| 2461 | 140, 137, 137, 216, 4, 216, 137, 137, 216, 137, |
| 2462 | 137, 137, 216, 216, 140, 137, 176, 182, 137, 137, |
| 2463 | 141, 188, 188, 188, 188, 146, 188, 188, 182, 158, |
| 2464 | 159, 35, 182, 174, 137, 216, 216, 182, 225, 216, |
| 2465 | 216, 176, 176, 217, 216, 137, 217, 217, 217, 225, |
| 2466 | 216, 188, 188, 137, 141, 137, 137, 141, 141, 141, |
| 2467 | 172, 177, 178, 19, 137, 142, 216, 137, 141, 144, |
| 2468 | 216, 141, 176, 141, 141, 188, 188, 188, 159, 49, |
| 2469 | 175, 14, 144, 156, 222, 172, 182, 174, 144, 174, |
| 2470 | 141, 141, 141, 4, 216, 214, 144, 156, 216, 34, |
| 2471 | 137, 214, 172, 14, 14, 137, 216, 216, 14, 67, |
| 2472 | 216, 14, 216 |
| 2473 | }; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2474 | |
| 2475 | #define yyerrok (yyerrstatus = 0) |
| 2476 | #define yyclearin (yychar = YYEMPTY) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2477 | #define YYEMPTY (-2) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2478 | #define YYEOF 0 |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2479 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2480 | #define YYACCEPT goto yyacceptlab |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2481 | #define YYABORT goto yyabortlab |
| 2482 | #define YYERROR goto yyerrorlab |
| 2483 | |
| 2484 | |
| 2485 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 2486 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2487 | Once GCC version 2 has supplanted version 1, this can go. */ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2488 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2489 | #define YYFAIL goto yyerrlab |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2490 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2491 | #define YYRECOVERING() (!!yyerrstatus) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2492 | |
| 2493 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2494 | do \ |
| 2495 | if (yychar == YYEMPTY && yylen == 1) \ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2496 | { \ |
| 2497 | yychar = (Token); \ |
| 2498 | yylval = (Value); \ |
| 2499 | yytoken = YYTRANSLATE (yychar); \ |
| 2500 | YYPOPSTACK (1); \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2501 | goto yybackup; \ |
| 2502 | } \ |
| 2503 | else \ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2504 | { \ |
| 2505 | yyerror (YY_("syntax error: cannot back up")); \ |
| 2506 | YYERROR; \ |
| 2507 | } \ |
| 2508 | while (YYID (0)) |
| 2509 | |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2510 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2511 | #define YYTERROR 1 |
| 2512 | #define YYERRCODE 256 |
| 2513 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2514 | |
| 2515 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
| 2516 | If N is 0, then set CURRENT to the empty location which ends |
| 2517 | the previous symbol: RHS[0] (always defined). */ |
| 2518 | |
| 2519 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| 2520 | #ifndef YYLLOC_DEFAULT |
| 2521 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 2522 | do \ |
| 2523 | if (YYID (N)) \ |
| 2524 | { \ |
| 2525 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
| 2526 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
| 2527 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
| 2528 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
| 2529 | } \ |
| 2530 | else \ |
| 2531 | { \ |
| 2532 | (Current).first_line = (Current).last_line = \ |
| 2533 | YYRHSLOC (Rhs, 0).last_line; \ |
| 2534 | (Current).first_column = (Current).last_column = \ |
| 2535 | YYRHSLOC (Rhs, 0).last_column; \ |
| 2536 | } \ |
| 2537 | while (YYID (0)) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2538 | #endif |
| 2539 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2540 | |
| 2541 | /* YY_LOCATION_PRINT -- Print the location on the stream. |
| 2542 | This macro was not mandated originally: define only if we know |
| 2543 | we won't break user code: when these are the locations we know. */ |
| 2544 | |
| 2545 | #ifndef YY_LOCATION_PRINT |
| 2546 | # if YYLTYPE_IS_TRIVIAL |
| 2547 | # define YY_LOCATION_PRINT(File, Loc) \ |
| 2548 | fprintf (File, "%d.%d-%d.%d", \ |
| 2549 | (Loc).first_line, (Loc).first_column, \ |
| 2550 | (Loc).last_line, (Loc).last_column) |
| 2551 | # else |
| 2552 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 2553 | # endif |
| 2554 | #endif |
| 2555 | |
| 2556 | |
| 2557 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 2558 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2559 | #ifdef YYLEX_PARAM |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2560 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2561 | #else |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2562 | # define YYLEX yylex () |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2563 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2564 | |
| 2565 | /* Enable debugging if requested. */ |
| 2566 | #if YYDEBUG |
| 2567 | |
| 2568 | # ifndef YYFPRINTF |
| 2569 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 2570 | # define YYFPRINTF fprintf |
| 2571 | # endif |
| 2572 | |
| 2573 | # define YYDPRINTF(Args) \ |
| 2574 | do { \ |
| 2575 | if (yydebug) \ |
| 2576 | YYFPRINTF Args; \ |
| 2577 | } while (YYID (0)) |
| 2578 | |
| 2579 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 2580 | do { \ |
| 2581 | if (yydebug) \ |
| 2582 | { \ |
| 2583 | YYFPRINTF (stderr, "%s ", Title); \ |
| 2584 | yy_symbol_print (stderr, \ |
| 2585 | Type, Value); \ |
| 2586 | YYFPRINTF (stderr, "\n"); \ |
| 2587 | } \ |
| 2588 | } while (YYID (0)) |
| 2589 | |
| 2590 | |
| 2591 | /*--------------------------------. |
| 2592 | | Print this symbol on YYOUTPUT. | |
| 2593 | `--------------------------------*/ |
| 2594 | |
| 2595 | /*ARGSUSED*/ |
| 2596 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2597 | || defined __cplusplus || defined _MSC_VER) |
| 2598 | static void |
| 2599 | yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2600 | #else |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2601 | static void |
| 2602 | yy_symbol_value_print (yyoutput, yytype, yyvaluep) |
| 2603 | FILE *yyoutput; |
| 2604 | int yytype; |
| 2605 | YYSTYPE const * const yyvaluep; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2606 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2607 | { |
| 2608 | if (!yyvaluep) |
| 2609 | return; |
| 2610 | # ifdef YYPRINT |
| 2611 | if (yytype < YYNTOKENS) |
| 2612 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 2613 | # else |
| 2614 | YYUSE (yyoutput); |
| 2615 | # endif |
| 2616 | switch (yytype) |
| 2617 | { |
| 2618 | default: |
| 2619 | break; |
| 2620 | } |
| 2621 | } |
| 2622 | |
| 2623 | |
| 2624 | /*--------------------------------. |
| 2625 | | Print this symbol on YYOUTPUT. | |
| 2626 | `--------------------------------*/ |
| 2627 | |
| 2628 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2629 | || defined __cplusplus || defined _MSC_VER) |
| 2630 | static void |
| 2631 | yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) |
| 2632 | #else |
| 2633 | static void |
| 2634 | yy_symbol_print (yyoutput, yytype, yyvaluep) |
| 2635 | FILE *yyoutput; |
| 2636 | int yytype; |
| 2637 | YYSTYPE const * const yyvaluep; |
Christopher Lamb | 2330e4d | 2007-04-21 08:16:25 +0000 | [diff] [blame] | 2638 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2639 | { |
| 2640 | if (yytype < YYNTOKENS) |
| 2641 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 2642 | else |
| 2643 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2644 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2645 | yy_symbol_value_print (yyoutput, yytype, yyvaluep); |
| 2646 | YYFPRINTF (yyoutput, ")"); |
| 2647 | } |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2648 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2649 | /*------------------------------------------------------------------. |
| 2650 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 2651 | | TOP (included). | |
| 2652 | `------------------------------------------------------------------*/ |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2653 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2654 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2655 | || defined __cplusplus || defined _MSC_VER) |
| 2656 | static void |
| 2657 | yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) |
| 2658 | #else |
| 2659 | static void |
| 2660 | yy_stack_print (bottom, top) |
| 2661 | yytype_int16 *bottom; |
| 2662 | yytype_int16 *top; |
Christopher Lamb | 2330e4d | 2007-04-21 08:16:25 +0000 | [diff] [blame] | 2663 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2664 | { |
| 2665 | YYFPRINTF (stderr, "Stack now"); |
| 2666 | for (; bottom <= top; ++bottom) |
| 2667 | YYFPRINTF (stderr, " %d", *bottom); |
| 2668 | YYFPRINTF (stderr, "\n"); |
| 2669 | } |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2670 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2671 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 2672 | do { \ |
| 2673 | if (yydebug) \ |
| 2674 | yy_stack_print ((Bottom), (Top)); \ |
| 2675 | } while (YYID (0)) |
Reid Spencer | c67bdc2 | 2007-04-21 18:36:27 +0000 | [diff] [blame] | 2676 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2677 | |
| 2678 | /*------------------------------------------------. |
| 2679 | | Report that the YYRULE is going to be reduced. | |
| 2680 | `------------------------------------------------*/ |
| 2681 | |
| 2682 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2683 | || defined __cplusplus || defined _MSC_VER) |
| 2684 | static void |
| 2685 | yy_reduce_print (YYSTYPE *yyvsp, int yyrule) |
| 2686 | #else |
| 2687 | static void |
| 2688 | yy_reduce_print (yyvsp, yyrule) |
| 2689 | YYSTYPE *yyvsp; |
| 2690 | int yyrule; |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 2691 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2692 | { |
| 2693 | int yynrhs = yyr2[yyrule]; |
| 2694 | int yyi; |
| 2695 | unsigned long int yylno = yyrline[yyrule]; |
| 2696 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", |
| 2697 | yyrule - 1, yylno); |
| 2698 | /* The symbols being reduced. */ |
| 2699 | for (yyi = 0; yyi < yynrhs; yyi++) |
| 2700 | { |
| 2701 | fprintf (stderr, " $%d = ", yyi + 1); |
| 2702 | yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], |
| 2703 | &(yyvsp[(yyi + 1) - (yynrhs)]) |
| 2704 | ); |
| 2705 | fprintf (stderr, "\n"); |
| 2706 | } |
| 2707 | } |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 2708 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2709 | # define YY_REDUCE_PRINT(Rule) \ |
| 2710 | do { \ |
| 2711 | if (yydebug) \ |
| 2712 | yy_reduce_print (yyvsp, Rule); \ |
| 2713 | } while (YYID (0)) |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 2714 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2715 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 2716 | multiple parsers can coexist. */ |
| 2717 | int yydebug; |
| 2718 | #else /* !YYDEBUG */ |
| 2719 | # define YYDPRINTF(Args) |
| 2720 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
| 2721 | # define YY_STACK_PRINT(Bottom, Top) |
| 2722 | # define YY_REDUCE_PRINT(Rule) |
| 2723 | #endif /* !YYDEBUG */ |
| 2724 | |
| 2725 | |
| 2726 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2727 | #ifndef YYINITDEPTH |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2728 | # define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2729 | #endif |
| 2730 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2731 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 2732 | if the built-in stack extension method is used). |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2733 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2734 | Do not make this value too large; the results are undefined if |
| 2735 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
| 2736 | evaluated with infinite-precision integer arithmetic. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2737 | |
| 2738 | #ifndef YYMAXDEPTH |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2739 | # define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2740 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2741 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2742 | |
| 2743 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2744 | #if YYERROR_VERBOSE |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2745 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2746 | # ifndef yystrlen |
| 2747 | # if defined __GLIBC__ && defined _STRING_H |
| 2748 | # define yystrlen strlen |
| 2749 | # else |
| 2750 | /* Return the length of YYSTR. */ |
| 2751 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2752 | || defined __cplusplus || defined _MSC_VER) |
| 2753 | static YYSIZE_T |
| 2754 | yystrlen (const char *yystr) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2755 | #else |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2756 | static YYSIZE_T |
| 2757 | yystrlen (yystr) |
| 2758 | const char *yystr; |
| 2759 | #endif |
| 2760 | { |
| 2761 | YYSIZE_T yylen; |
| 2762 | for (yylen = 0; yystr[yylen]; yylen++) |
| 2763 | continue; |
| 2764 | return yylen; |
| 2765 | } |
| 2766 | # endif |
| 2767 | # endif |
| 2768 | |
| 2769 | # ifndef yystpcpy |
| 2770 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE |
| 2771 | # define yystpcpy stpcpy |
| 2772 | # else |
| 2773 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 2774 | YYDEST. */ |
| 2775 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2776 | || defined __cplusplus || defined _MSC_VER) |
| 2777 | static char * |
| 2778 | yystpcpy (char *yydest, const char *yysrc) |
| 2779 | #else |
| 2780 | static char * |
| 2781 | yystpcpy (yydest, yysrc) |
| 2782 | char *yydest; |
| 2783 | const char *yysrc; |
| 2784 | #endif |
| 2785 | { |
| 2786 | char *yyd = yydest; |
| 2787 | const char *yys = yysrc; |
| 2788 | |
| 2789 | while ((*yyd++ = *yys++) != '\0') |
| 2790 | continue; |
| 2791 | |
| 2792 | return yyd - 1; |
| 2793 | } |
| 2794 | # endif |
| 2795 | # endif |
| 2796 | |
| 2797 | # ifndef yytnamerr |
| 2798 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
| 2799 | quotes and backslashes, so that it's suitable for yyerror. The |
| 2800 | heuristic is that double-quoting is unnecessary unless the string |
| 2801 | contains an apostrophe, a comma, or backslash (other than |
| 2802 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
| 2803 | null, do not copy; instead, return the length of what the result |
| 2804 | would have been. */ |
| 2805 | static YYSIZE_T |
| 2806 | yytnamerr (char *yyres, const char *yystr) |
| 2807 | { |
| 2808 | if (*yystr == '"') |
| 2809 | { |
| 2810 | YYSIZE_T yyn = 0; |
| 2811 | char const *yyp = yystr; |
| 2812 | |
| 2813 | for (;;) |
| 2814 | switch (*++yyp) |
| 2815 | { |
| 2816 | case '\'': |
| 2817 | case ',': |
| 2818 | goto do_not_strip_quotes; |
| 2819 | |
| 2820 | case '\\': |
| 2821 | if (*++yyp != '\\') |
| 2822 | goto do_not_strip_quotes; |
| 2823 | /* Fall through. */ |
| 2824 | default: |
| 2825 | if (yyres) |
| 2826 | yyres[yyn] = *yyp; |
| 2827 | yyn++; |
| 2828 | break; |
| 2829 | |
| 2830 | case '"': |
| 2831 | if (yyres) |
| 2832 | yyres[yyn] = '\0'; |
| 2833 | return yyn; |
| 2834 | } |
| 2835 | do_not_strip_quotes: ; |
| 2836 | } |
| 2837 | |
| 2838 | if (! yyres) |
| 2839 | return yystrlen (yystr); |
| 2840 | |
| 2841 | return yystpcpy (yyres, yystr) - yyres; |
| 2842 | } |
| 2843 | # endif |
| 2844 | |
| 2845 | /* Copy into YYRESULT an error message about the unexpected token |
| 2846 | YYCHAR while in state YYSTATE. Return the number of bytes copied, |
| 2847 | including the terminating null byte. If YYRESULT is null, do not |
| 2848 | copy anything; just return the number of bytes that would be |
| 2849 | copied. As a special case, return 0 if an ordinary "syntax error" |
| 2850 | message will do. Return YYSIZE_MAXIMUM if overflow occurs during |
| 2851 | size calculation. */ |
| 2852 | static YYSIZE_T |
| 2853 | yysyntax_error (char *yyresult, int yystate, int yychar) |
| 2854 | { |
| 2855 | int yyn = yypact[yystate]; |
| 2856 | |
| 2857 | if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) |
| 2858 | return 0; |
| 2859 | else |
| 2860 | { |
| 2861 | int yytype = YYTRANSLATE (yychar); |
| 2862 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); |
| 2863 | YYSIZE_T yysize = yysize0; |
| 2864 | YYSIZE_T yysize1; |
| 2865 | int yysize_overflow = 0; |
| 2866 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; |
| 2867 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 2868 | int yyx; |
| 2869 | |
| 2870 | # if 0 |
| 2871 | /* This is so xgettext sees the translatable formats that are |
| 2872 | constructed on the fly. */ |
| 2873 | YY_("syntax error, unexpected %s"); |
| 2874 | YY_("syntax error, unexpected %s, expecting %s"); |
| 2875 | YY_("syntax error, unexpected %s, expecting %s or %s"); |
| 2876 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); |
| 2877 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); |
| 2878 | # endif |
| 2879 | char *yyfmt; |
| 2880 | char const *yyf; |
| 2881 | static char const yyunexpected[] = "syntax error, unexpected %s"; |
| 2882 | static char const yyexpecting[] = ", expecting %s"; |
| 2883 | static char const yyor[] = " or %s"; |
| 2884 | char yyformat[sizeof yyunexpected |
| 2885 | + sizeof yyexpecting - 1 |
| 2886 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) |
| 2887 | * (sizeof yyor - 1))]; |
| 2888 | char const *yyprefix = yyexpecting; |
| 2889 | |
| 2890 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 2891 | YYCHECK. */ |
| 2892 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 2893 | |
| 2894 | /* Stay within bounds of both yycheck and yytname. */ |
| 2895 | int yychecklim = YYLAST - yyn + 1; |
| 2896 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 2897 | int yycount = 1; |
| 2898 | |
| 2899 | yyarg[0] = yytname[yytype]; |
| 2900 | yyfmt = yystpcpy (yyformat, yyunexpected); |
| 2901 | |
| 2902 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 2903 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 2904 | { |
| 2905 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 2906 | { |
| 2907 | yycount = 1; |
| 2908 | yysize = yysize0; |
| 2909 | yyformat[sizeof yyunexpected - 1] = '\0'; |
| 2910 | break; |
| 2911 | } |
| 2912 | yyarg[yycount++] = yytname[yyx]; |
| 2913 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); |
| 2914 | yysize_overflow |= (yysize1 < yysize); |
| 2915 | yysize = yysize1; |
| 2916 | yyfmt = yystpcpy (yyfmt, yyprefix); |
| 2917 | yyprefix = yyor; |
| 2918 | } |
| 2919 | |
| 2920 | yyf = YY_(yyformat); |
| 2921 | yysize1 = yysize + yystrlen (yyf); |
| 2922 | yysize_overflow |= (yysize1 < yysize); |
| 2923 | yysize = yysize1; |
| 2924 | |
| 2925 | if (yysize_overflow) |
| 2926 | return YYSIZE_MAXIMUM; |
| 2927 | |
| 2928 | if (yyresult) |
| 2929 | { |
| 2930 | /* Avoid sprintf, as that infringes on the user's name space. |
| 2931 | Don't have undefined behavior even if the translation |
| 2932 | produced a string with the wrong number of "%s"s. */ |
| 2933 | char *yyp = yyresult; |
| 2934 | int yyi = 0; |
| 2935 | while ((*yyp = *yyf) != '\0') |
| 2936 | { |
| 2937 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) |
| 2938 | { |
| 2939 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
| 2940 | yyf += 2; |
| 2941 | } |
| 2942 | else |
| 2943 | { |
| 2944 | yyp++; |
| 2945 | yyf++; |
| 2946 | } |
| 2947 | } |
| 2948 | } |
| 2949 | return yysize; |
| 2950 | } |
| 2951 | } |
| 2952 | #endif /* YYERROR_VERBOSE */ |
| 2953 | |
| 2954 | |
| 2955 | /*-----------------------------------------------. |
| 2956 | | Release the memory associated to this symbol. | |
| 2957 | `-----------------------------------------------*/ |
| 2958 | |
| 2959 | /*ARGSUSED*/ |
| 2960 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2961 | || defined __cplusplus || defined _MSC_VER) |
| 2962 | static void |
| 2963 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
| 2964 | #else |
| 2965 | static void |
| 2966 | yydestruct (yymsg, yytype, yyvaluep) |
| 2967 | const char *yymsg; |
| 2968 | int yytype; |
| 2969 | YYSTYPE *yyvaluep; |
| 2970 | #endif |
| 2971 | { |
| 2972 | YYUSE (yyvaluep); |
| 2973 | |
| 2974 | if (!yymsg) |
| 2975 | yymsg = "Deleting"; |
| 2976 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 2977 | |
| 2978 | switch (yytype) |
| 2979 | { |
| 2980 | |
| 2981 | default: |
| 2982 | break; |
| 2983 | } |
| 2984 | } |
| 2985 | |
| 2986 | |
| 2987 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 2988 | |
| 2989 | #ifdef YYPARSE_PARAM |
| 2990 | #if defined __STDC__ || defined __cplusplus |
| 2991 | int yyparse (void *YYPARSE_PARAM); |
| 2992 | #else |
| 2993 | int yyparse (); |
| 2994 | #endif |
| 2995 | #else /* ! YYPARSE_PARAM */ |
| 2996 | #if defined __STDC__ || defined __cplusplus |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 2997 | int yyparse (void); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 2998 | #else |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 2999 | int yyparse (); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3000 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3001 | #endif /* ! YYPARSE_PARAM */ |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 3002 | |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 3003 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3004 | |
| 3005 | /* The look-ahead symbol. */ |
| 3006 | int yychar; |
| 3007 | |
| 3008 | /* The semantic value of the look-ahead symbol. */ |
| 3009 | YYSTYPE yylval; |
| 3010 | |
| 3011 | /* Number of syntax errors so far. */ |
| 3012 | int yynerrs; |
| 3013 | |
| 3014 | |
| 3015 | |
| 3016 | /*----------. |
| 3017 | | yyparse. | |
| 3018 | `----------*/ |
| 3019 | |
| 3020 | #ifdef YYPARSE_PARAM |
| 3021 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3022 | || defined __cplusplus || defined _MSC_VER) |
| 3023 | int |
| 3024 | yyparse (void *YYPARSE_PARAM) |
| 3025 | #else |
| 3026 | int |
| 3027 | yyparse (YYPARSE_PARAM) |
| 3028 | void *YYPARSE_PARAM; |
| 3029 | #endif |
| 3030 | #else /* ! YYPARSE_PARAM */ |
| 3031 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3032 | || defined __cplusplus || defined _MSC_VER) |
| 3033 | int |
| 3034 | yyparse (void) |
| 3035 | #else |
| 3036 | int |
| 3037 | yyparse () |
| 3038 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3039 | #endif |
| 3040 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3041 | { |
| 3042 | |
| 3043 | int yystate; |
| 3044 | int yyn; |
| 3045 | int yyresult; |
| 3046 | /* Number of tokens to shift before error messages enabled. */ |
| 3047 | int yyerrstatus; |
| 3048 | /* Look-ahead token as an internal (translated) token number. */ |
| 3049 | int yytoken = 0; |
| 3050 | #if YYERROR_VERBOSE |
| 3051 | /* Buffer for error messages, and its allocated size. */ |
| 3052 | char yymsgbuf[128]; |
| 3053 | char *yymsg = yymsgbuf; |
| 3054 | YYSIZE_T yymsg_alloc = sizeof yymsgbuf; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3055 | #endif |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 3056 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3057 | /* Three stacks and their tools: |
| 3058 | `yyss': related to states, |
| 3059 | `yyvs': related to semantic values, |
| 3060 | `yyls': related to locations. |
| 3061 | |
| 3062 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 3063 | to reallocate them elsewhere. */ |
| 3064 | |
| 3065 | /* The state stack. */ |
| 3066 | yytype_int16 yyssa[YYINITDEPTH]; |
| 3067 | yytype_int16 *yyss = yyssa; |
| 3068 | yytype_int16 *yyssp; |
| 3069 | |
| 3070 | /* The semantic value stack. */ |
| 3071 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 3072 | YYSTYPE *yyvs = yyvsa; |
| 3073 | YYSTYPE *yyvsp; |
| 3074 | |
| 3075 | |
| 3076 | |
| 3077 | #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) |
| 3078 | |
| 3079 | YYSIZE_T yystacksize = YYINITDEPTH; |
| 3080 | |
| 3081 | /* The variables used to return semantic value and location from the |
| 3082 | action routines. */ |
| 3083 | YYSTYPE yyval; |
| 3084 | |
| 3085 | |
| 3086 | /* The number of symbols on the RHS of the reduced rule. |
| 3087 | Keep to zero when no symbol should be popped. */ |
| 3088 | int yylen = 0; |
| 3089 | |
| 3090 | YYDPRINTF ((stderr, "Starting parse\n")); |
| 3091 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3092 | yystate = 0; |
| 3093 | yyerrstatus = 0; |
| 3094 | yynerrs = 0; |
| 3095 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 3096 | |
| 3097 | /* Initialize stack pointers. |
| 3098 | Waste one element of value and location stack |
| 3099 | so that they stay on the same level as the state stack. |
| 3100 | The wasted elements are never initialized. */ |
| 3101 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3102 | yyssp = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3103 | yyvsp = yyvs; |
| 3104 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3105 | goto yysetstate; |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 3106 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3107 | /*------------------------------------------------------------. |
| 3108 | | yynewstate -- Push a new state, which is found in yystate. | |
| 3109 | `------------------------------------------------------------*/ |
| 3110 | yynewstate: |
| 3111 | /* In all cases, when you get here, the value and location stacks |
| 3112 | have just been pushed. So pushing a state here evens the stacks. */ |
| 3113 | yyssp++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3114 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3115 | yysetstate: |
| 3116 | *yyssp = yystate; |
| 3117 | |
| 3118 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3119 | { |
| 3120 | /* Get the current used size of the three stacks, in elements. */ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3121 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3122 | |
| 3123 | #ifdef yyoverflow |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3124 | { |
| 3125 | /* Give user a chance to reallocate the stack. Use copies of |
| 3126 | these so that the &'s don't force the real ones into |
| 3127 | memory. */ |
| 3128 | YYSTYPE *yyvs1 = yyvs; |
| 3129 | yytype_int16 *yyss1 = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3130 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3131 | |
| 3132 | /* Each stack pointer address is followed by the size of the |
| 3133 | data in use in that stack, in bytes. This used to be a |
| 3134 | conditional around just the two extra args, but that might |
| 3135 | be undefined if yyoverflow is a macro. */ |
| 3136 | yyoverflow (YY_("memory exhausted"), |
| 3137 | &yyss1, yysize * sizeof (*yyssp), |
| 3138 | &yyvs1, yysize * sizeof (*yyvsp), |
| 3139 | |
| 3140 | &yystacksize); |
| 3141 | |
| 3142 | yyss = yyss1; |
| 3143 | yyvs = yyvs1; |
| 3144 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3145 | #else /* no yyoverflow */ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3146 | # ifndef YYSTACK_RELOCATE |
| 3147 | goto yyexhaustedlab; |
| 3148 | # else |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3149 | /* Extend the stack our own way. */ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3150 | if (YYMAXDEPTH <= yystacksize) |
| 3151 | goto yyexhaustedlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3152 | yystacksize *= 2; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3153 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3154 | yystacksize = YYMAXDEPTH; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3155 | |
| 3156 | { |
| 3157 | yytype_int16 *yyss1 = yyss; |
| 3158 | union yyalloc *yyptr = |
| 3159 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 3160 | if (! yyptr) |
| 3161 | goto yyexhaustedlab; |
| 3162 | YYSTACK_RELOCATE (yyss); |
| 3163 | YYSTACK_RELOCATE (yyvs); |
| 3164 | |
| 3165 | # undef YYSTACK_RELOCATE |
| 3166 | if (yyss1 != yyssa) |
| 3167 | YYSTACK_FREE (yyss1); |
| 3168 | } |
| 3169 | # endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3170 | #endif /* no yyoverflow */ |
| 3171 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3172 | yyssp = yyss + yysize - 1; |
| 3173 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3174 | |
| 3175 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3176 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 3177 | (unsigned long int) yystacksize)); |
| 3178 | |
| 3179 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3180 | YYABORT; |
| 3181 | } |
| 3182 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3183 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3184 | |
| 3185 | goto yybackup; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3186 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3187 | /*-----------. |
| 3188 | | yybackup. | |
| 3189 | `-----------*/ |
| 3190 | yybackup: |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3191 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3192 | /* Do appropriate processing given the current state. Read a |
| 3193 | look-ahead token if we need one and don't already have one. */ |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 3194 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3195 | /* First try to decide what to do without reference to look-ahead token. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3196 | yyn = yypact[yystate]; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3197 | if (yyn == YYPACT_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3198 | goto yydefault; |
| 3199 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3200 | /* 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] | 3201 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3202 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3203 | if (yychar == YYEMPTY) |
| 3204 | { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3205 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3206 | yychar = YYLEX; |
| 3207 | } |
| 3208 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3209 | if (yychar <= YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3210 | { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3211 | yychar = yytoken = YYEOF; |
| 3212 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3213 | } |
| 3214 | else |
| 3215 | { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3216 | yytoken = YYTRANSLATE (yychar); |
| 3217 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3218 | } |
| 3219 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3220 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 3221 | detect an error, take that action. */ |
| 3222 | yyn += yytoken; |
| 3223 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3224 | goto yydefault; |
| 3225 | yyn = yytable[yyn]; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3226 | if (yyn <= 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3227 | { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3228 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3229 | goto yyerrlab; |
| 3230 | yyn = -yyn; |
| 3231 | goto yyreduce; |
| 3232 | } |
| 3233 | |
| 3234 | if (yyn == YYFINAL) |
| 3235 | YYACCEPT; |
| 3236 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3237 | /* Count tokens shifted since error; after three, turn off error |
| 3238 | status. */ |
| 3239 | if (yyerrstatus) |
| 3240 | yyerrstatus--; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3241 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3242 | /* Shift the look-ahead token. */ |
| 3243 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 3244 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3245 | /* Discard the shifted token unless it is eof. */ |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 3246 | if (yychar != YYEOF) |
| 3247 | yychar = YYEMPTY; |
| 3248 | |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 3249 | yystate = yyn; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3250 | *++yyvsp = yylval; |
| 3251 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3252 | goto yynewstate; |
| 3253 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3254 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3255 | /*-----------------------------------------------------------. |
| 3256 | | yydefault -- do the default action for the current state. | |
| 3257 | `-----------------------------------------------------------*/ |
| 3258 | yydefault: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3259 | yyn = yydefact[yystate]; |
| 3260 | if (yyn == 0) |
| 3261 | goto yyerrlab; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3262 | goto yyreduce; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3263 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3264 | |
| 3265 | /*-----------------------------. |
| 3266 | | yyreduce -- Do a reduction. | |
| 3267 | `-----------------------------*/ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3268 | yyreduce: |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3269 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3270 | yylen = yyr2[yyn]; |
| 3271 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3272 | /* If YYLEN is nonzero, implement the default value of the action: |
| 3273 | `$$ = $1'. |
| 3274 | |
| 3275 | Otherwise, the following line sets YYVAL to garbage. |
| 3276 | This behavior is undocumented and Bison |
| 3277 | users should not rely upon it. Assigning to YYVAL |
| 3278 | unconditionally makes the parser a bit smaller, and it avoids a |
| 3279 | GCC warning that YYVAL may be used uninitialized. */ |
| 3280 | yyval = yyvsp[1-yylen]; |
| 3281 | |
| 3282 | |
| 3283 | YY_REDUCE_PRINT (yyn); |
| 3284 | switch (yyn) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3285 | { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3286 | case 29: |
| 3287 | #line 1100 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3288 | { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;} |
| 3289 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3290 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3291 | case 30: |
| 3292 | #line 1100 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3293 | { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;} |
| 3294 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3295 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3296 | case 31: |
| 3297 | #line 1101 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3298 | { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;} |
| 3299 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3300 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3301 | case 32: |
| 3302 | #line 1101 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3303 | { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;} |
| 3304 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3305 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3306 | case 33: |
| 3307 | #line 1102 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3308 | { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;} |
| 3309 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3310 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3311 | case 34: |
| 3312 | #line 1102 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3313 | { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;} |
| 3314 | break; |
| 3315 | |
| 3316 | case 35: |
| 3317 | #line 1103 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3318 | { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;} |
| 3319 | break; |
| 3320 | |
| 3321 | case 36: |
| 3322 | #line 1103 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3323 | { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;} |
| 3324 | break; |
| 3325 | |
| 3326 | case 37: |
| 3327 | #line 1104 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3328 | { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;} |
| 3329 | break; |
| 3330 | |
| 3331 | case 38: |
| 3332 | #line 1104 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3333 | { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;} |
| 3334 | break; |
| 3335 | |
| 3336 | case 39: |
| 3337 | #line 1108 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3338 | { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;} |
| 3339 | break; |
| 3340 | |
| 3341 | case 40: |
| 3342 | #line 1108 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3343 | { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;} |
| 3344 | break; |
| 3345 | |
| 3346 | case 41: |
| 3347 | #line 1109 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3348 | { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;} |
| 3349 | break; |
| 3350 | |
| 3351 | case 42: |
| 3352 | #line 1109 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3353 | { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;} |
| 3354 | break; |
| 3355 | |
| 3356 | case 43: |
| 3357 | #line 1110 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3358 | { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;} |
| 3359 | break; |
| 3360 | |
| 3361 | case 44: |
| 3362 | #line 1110 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3363 | { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;} |
| 3364 | break; |
| 3365 | |
| 3366 | case 45: |
| 3367 | #line 1111 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3368 | { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;} |
| 3369 | break; |
| 3370 | |
| 3371 | case 46: |
| 3372 | #line 1111 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3373 | { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;} |
| 3374 | break; |
| 3375 | |
| 3376 | case 47: |
| 3377 | #line 1112 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3378 | { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;} |
| 3379 | break; |
| 3380 | |
| 3381 | case 48: |
| 3382 | #line 1112 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3383 | { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;} |
| 3384 | break; |
| 3385 | |
| 3386 | case 49: |
| 3387 | #line 1113 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3388 | { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;} |
| 3389 | break; |
| 3390 | |
| 3391 | case 50: |
| 3392 | #line 1113 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3393 | { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;} |
| 3394 | break; |
| 3395 | |
| 3396 | case 51: |
| 3397 | #line 1114 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3398 | { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;} |
| 3399 | break; |
| 3400 | |
| 3401 | case 52: |
| 3402 | #line 1114 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3403 | { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;} |
| 3404 | break; |
| 3405 | |
| 3406 | case 53: |
| 3407 | #line 1115 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3408 | { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;} |
| 3409 | break; |
| 3410 | |
| 3411 | case 54: |
| 3412 | #line 1116 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3413 | { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;} |
| 3414 | break; |
| 3415 | |
| 3416 | case 61: |
| 3417 | #line 1125 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3418 | { (yyval.StrVal) = 0; ;} |
| 3419 | break; |
| 3420 | |
| 3421 | case 62: |
| 3422 | #line 1129 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3423 | { |
| 3424 | (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3425 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3426 | ;} |
| 3427 | break; |
| 3428 | |
| 3429 | case 63: |
| 3430 | #line 1133 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3431 | { |
| 3432 | (yyval.StrVal) = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3433 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3434 | ;} |
| 3435 | break; |
| 3436 | |
| 3437 | case 67: |
| 3438 | #line 1141 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3439 | { |
| 3440 | (yyval.StrVal) = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3441 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3442 | ;} |
| 3443 | break; |
| 3444 | |
| 3445 | case 68: |
| 3446 | #line 1146 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3447 | { |
| 3448 | (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3449 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3450 | ;} |
| 3451 | break; |
| 3452 | |
| 3453 | case 69: |
| 3454 | #line 1152 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3455 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3456 | break; |
| 3457 | |
| 3458 | case 70: |
| 3459 | #line 1153 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3460 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3461 | break; |
| 3462 | |
| 3463 | case 71: |
| 3464 | #line 1154 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3465 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 3466 | break; |
| 3467 | |
| 3468 | case 72: |
| 3469 | #line 1155 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3470 | { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} |
| 3471 | break; |
| 3472 | |
| 3473 | case 73: |
| 3474 | #line 1156 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3475 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 3476 | break; |
| 3477 | |
| 3478 | case 74: |
| 3479 | #line 1160 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3480 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 3481 | break; |
| 3482 | |
| 3483 | case 75: |
| 3484 | #line 1161 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3485 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 3486 | break; |
| 3487 | |
| 3488 | case 76: |
| 3489 | #line 1162 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3490 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3491 | break; |
| 3492 | |
| 3493 | case 77: |
| 3494 | #line 1166 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3495 | { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;} |
| 3496 | break; |
| 3497 | |
| 3498 | case 78: |
| 3499 | #line 1167 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3500 | { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;} |
| 3501 | break; |
| 3502 | |
| 3503 | case 79: |
| 3504 | #line 1168 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3505 | { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;} |
| 3506 | break; |
| 3507 | |
| 3508 | case 80: |
| 3509 | #line 1172 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3510 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3511 | break; |
| 3512 | |
| 3513 | case 81: |
| 3514 | #line 1173 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3515 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 3516 | break; |
| 3517 | |
| 3518 | case 82: |
| 3519 | #line 1174 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3520 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 3521 | break; |
| 3522 | |
| 3523 | case 83: |
| 3524 | #line 1178 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3525 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3526 | break; |
| 3527 | |
| 3528 | case 84: |
| 3529 | #line 1179 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3530 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3531 | break; |
| 3532 | |
| 3533 | case 85: |
| 3534 | #line 1180 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3535 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 3536 | break; |
| 3537 | |
| 3538 | case 86: |
| 3539 | #line 1181 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3540 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3541 | break; |
| 3542 | |
| 3543 | case 87: |
| 3544 | #line 1182 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3545 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 3546 | break; |
| 3547 | |
| 3548 | case 88: |
| 3549 | #line 1186 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3550 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3551 | break; |
| 3552 | |
| 3553 | case 89: |
| 3554 | #line 1187 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3555 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3556 | break; |
| 3557 | |
| 3558 | case 90: |
| 3559 | #line 1188 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3560 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3561 | break; |
| 3562 | |
| 3563 | case 91: |
| 3564 | #line 1191 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3565 | { (yyval.UIntVal) = CallingConv::C; ;} |
| 3566 | break; |
| 3567 | |
| 3568 | case 92: |
| 3569 | #line 1192 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3570 | { (yyval.UIntVal) = CallingConv::C; ;} |
| 3571 | break; |
| 3572 | |
| 3573 | case 93: |
| 3574 | #line 1193 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3575 | { (yyval.UIntVal) = CallingConv::Fast; ;} |
| 3576 | break; |
| 3577 | |
| 3578 | case 94: |
| 3579 | #line 1194 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3580 | { (yyval.UIntVal) = CallingConv::Cold; ;} |
| 3581 | break; |
| 3582 | |
| 3583 | case 95: |
| 3584 | #line 1195 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3585 | { (yyval.UIntVal) = CallingConv::X86_StdCall; ;} |
| 3586 | break; |
| 3587 | |
| 3588 | case 96: |
| 3589 | #line 1196 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3590 | { (yyval.UIntVal) = CallingConv::X86_FastCall; ;} |
| 3591 | break; |
| 3592 | |
| 3593 | case 97: |
| 3594 | #line 1197 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3595 | { |
| 3596 | if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3597 | GEN_ERROR("Calling conv too large"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3598 | (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3599 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3600 | ;} |
| 3601 | break; |
| 3602 | |
| 3603 | case 98: |
| 3604 | #line 1204 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3605 | { (yyval.ParamAttrs) = ParamAttr::ZExt; ;} |
| 3606 | break; |
| 3607 | |
| 3608 | case 99: |
| 3609 | #line 1205 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3610 | { (yyval.ParamAttrs) = ParamAttr::SExt; ;} |
| 3611 | break; |
| 3612 | |
| 3613 | case 100: |
| 3614 | #line 1206 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3615 | { (yyval.ParamAttrs) = ParamAttr::InReg; ;} |
| 3616 | break; |
| 3617 | |
| 3618 | case 101: |
| 3619 | #line 1207 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3620 | { (yyval.ParamAttrs) = ParamAttr::StructRet; ;} |
| 3621 | break; |
| 3622 | |
| 3623 | case 102: |
| 3624 | #line 1210 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3625 | { (yyval.ParamAttrs) = ParamAttr::None; ;} |
| 3626 | break; |
| 3627 | |
| 3628 | case 103: |
| 3629 | #line 1211 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3630 | { |
| 3631 | (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs); |
| 3632 | ;} |
| 3633 | break; |
| 3634 | |
| 3635 | case 104: |
| 3636 | #line 1216 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3637 | { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;} |
| 3638 | break; |
| 3639 | |
| 3640 | case 105: |
| 3641 | #line 1217 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3642 | { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;} |
| 3643 | break; |
| 3644 | |
| 3645 | case 107: |
| 3646 | #line 1221 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3647 | { (yyval.ParamAttrs) = ParamAttr::None; ;} |
| 3648 | break; |
| 3649 | |
| 3650 | case 108: |
| 3651 | #line 1222 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3652 | { |
| 3653 | (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs); |
| 3654 | ;} |
| 3655 | break; |
| 3656 | |
| 3657 | case 109: |
| 3658 | #line 1229 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3659 | { (yyval.UIntVal) = 0; ;} |
| 3660 | break; |
| 3661 | |
| 3662 | case 110: |
| 3663 | #line 1230 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3664 | { |
| 3665 | (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val); |
| 3666 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3667 | GEN_ERROR("Alignment must be a power of two"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3668 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3669 | ;} |
| 3670 | break; |
| 3671 | |
| 3672 | case 111: |
| 3673 | #line 1236 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3674 | { (yyval.UIntVal) = 0; ;} |
| 3675 | break; |
| 3676 | |
| 3677 | case 112: |
| 3678 | #line 1237 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3679 | { |
| 3680 | (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val); |
| 3681 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 3682 | GEN_ERROR("Alignment must be a power of two"); |
| 3683 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3684 | ;} |
| 3685 | break; |
| 3686 | |
| 3687 | case 113: |
| 3688 | #line 1245 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3689 | { |
| 3690 | for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i) |
| 3691 | if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\') |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3692 | GEN_ERROR("Invalid character in section name"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3693 | (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3694 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3695 | ;} |
| 3696 | break; |
| 3697 | |
| 3698 | case 114: |
| 3699 | #line 1253 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3700 | { (yyval.StrVal) = 0; ;} |
| 3701 | break; |
| 3702 | |
| 3703 | case 115: |
| 3704 | #line 1254 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3705 | { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;} |
| 3706 | break; |
| 3707 | |
| 3708 | case 116: |
| 3709 | #line 1259 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3710 | {;} |
| 3711 | break; |
| 3712 | |
| 3713 | case 117: |
| 3714 | #line 1260 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3715 | {;} |
| 3716 | break; |
| 3717 | |
| 3718 | case 118: |
| 3719 | #line 1261 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3720 | { |
| 3721 | CurGV->setSection((yyvsp[(1) - (1)].StrVal)); |
| 3722 | free((yyvsp[(1) - (1)].StrVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3723 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3724 | ;} |
| 3725 | break; |
| 3726 | |
| 3727 | case 119: |
| 3728 | #line 1266 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3729 | { |
| 3730 | if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3731 | GEN_ERROR("Alignment must be a power of two"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3732 | CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3733 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3734 | ;} |
| 3735 | break; |
| 3736 | |
| 3737 | case 124: |
| 3738 | #line 1282 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3739 | { |
| 3740 | (yyval.TypeVal) = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3741 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3742 | ;} |
| 3743 | break; |
| 3744 | |
| 3745 | case 125: |
| 3746 | #line 1286 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3747 | { |
| 3748 | (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3749 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3750 | ;} |
| 3751 | break; |
| 3752 | |
| 3753 | case 126: |
| 3754 | #line 1290 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3755 | { // Pointer type? |
| 3756 | if (*(yyvsp[(1) - (2)].TypeVal) == Type::LabelTy) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3757 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3758 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (2)].TypeVal)))); |
| 3759 | delete (yyvsp[(1) - (2)].TypeVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3760 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3761 | ;} |
| 3762 | break; |
| 3763 | |
| 3764 | case 127: |
| 3765 | #line 1297 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3766 | { // Named types are also simple types... |
| 3767 | const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3768 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3769 | (yyval.TypeVal) = new PATypeHolder(tmp); |
| 3770 | ;} |
| 3771 | break; |
| 3772 | |
| 3773 | case 128: |
| 3774 | #line 1302 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3775 | { // Type UpReference |
| 3776 | if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3777 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3778 | UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector... |
| 3779 | (yyval.TypeVal) = new PATypeHolder(OT); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3780 | UR_OUT("New Upreference!\n"); |
| 3781 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3782 | ;} |
| 3783 | break; |
| 3784 | |
| 3785 | case 129: |
| 3786 | #line 1310 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3787 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3788 | std::vector<const Type*> Params; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3789 | ParamAttrsVector Attrs; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3790 | if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) { |
| 3791 | ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3792 | Attrs.push_back(X); |
| 3793 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3794 | unsigned index = 1; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3795 | TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3796 | for (; I != E; ++I, ++index) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 3797 | const Type *Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 3798 | Params.push_back(Ty); |
| 3799 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3800 | if (I->Attrs != ParamAttr::None) { |
| 3801 | ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; |
| 3802 | Attrs.push_back(X); |
| 3803 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3804 | } |
| 3805 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3806 | if (isVarArg) Params.pop_back(); |
| 3807 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3808 | ParamAttrsList *ActualAttrs = 0; |
| 3809 | if (!Attrs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3810 | ActualAttrs = ParamAttrsList::get(Attrs); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3811 | FunctionType *FT = FunctionType::get(*(yyvsp[(1) - (5)].TypeVal), Params, isVarArg, ActualAttrs); |
| 3812 | delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list |
| 3813 | delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle |
| 3814 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3815 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3816 | ;} |
| 3817 | break; |
| 3818 | |
| 3819 | case 130: |
| 3820 | #line 1340 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3821 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3822 | std::vector<const Type*> Params; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3823 | ParamAttrsVector Attrs; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3824 | if ((yyvsp[(5) - (5)].ParamAttrs) != ParamAttr::None) { |
| 3825 | ParamAttrsWithIndex X; X.index = 0; X.attrs = (yyvsp[(5) - (5)].ParamAttrs); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3826 | Attrs.push_back(X); |
| 3827 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3828 | TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3829 | unsigned index = 1; |
| 3830 | for ( ; I != E; ++I, ++index) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 3831 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 3832 | Params.push_back(Ty); |
| 3833 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3834 | if (I->Attrs != ParamAttr::None) { |
| 3835 | ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; |
| 3836 | Attrs.push_back(X); |
| 3837 | } |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3838 | } |
| 3839 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3840 | if (isVarArg) Params.pop_back(); |
| 3841 | |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3842 | ParamAttrsList *ActualAttrs = 0; |
| 3843 | if (!Attrs.empty()) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 3844 | ActualAttrs = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 3845 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3846 | FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg, ActualAttrs); |
| 3847 | delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list |
| 3848 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3849 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3850 | ;} |
| 3851 | break; |
| 3852 | |
| 3853 | case 131: |
| 3854 | #line 1371 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3855 | { // Sized array type? |
| 3856 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val)))); |
| 3857 | delete (yyvsp[(4) - (5)].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3858 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3859 | ;} |
| 3860 | break; |
| 3861 | |
| 3862 | case 132: |
| 3863 | #line 1376 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3864 | { // Vector type? |
| 3865 | const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get(); |
| 3866 | if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3867 | GEN_ERROR("Unsigned result not equal to signed result"); |
| 3868 | if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 3869 | GEN_ERROR("Element type of a VectorType must be primitive"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3870 | if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3871 | GEN_ERROR("Vector length should be a power of 2"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3872 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val)))); |
| 3873 | delete (yyvsp[(4) - (5)].TypeVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3874 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3875 | ;} |
| 3876 | break; |
| 3877 | |
| 3878 | case 133: |
| 3879 | #line 1388 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3880 | { // Structure type? |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3881 | std::vector<const Type*> Elements; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3882 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(), |
| 3883 | E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3884 | Elements.push_back(*I); |
| 3885 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3886 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 3887 | delete (yyvsp[(2) - (3)].TypeList); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3888 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3889 | ;} |
| 3890 | break; |
| 3891 | |
| 3892 | case 134: |
| 3893 | #line 1398 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3894 | { // Empty structure type? |
| 3895 | (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3896 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3897 | ;} |
| 3898 | break; |
| 3899 | |
| 3900 | case 135: |
| 3901 | #line 1402 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3902 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3903 | std::vector<const Type*> Elements; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3904 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(), |
| 3905 | E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3906 | Elements.push_back(*I); |
| 3907 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3908 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); |
| 3909 | delete (yyvsp[(3) - (5)].TypeList); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3910 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3911 | ;} |
| 3912 | break; |
| 3913 | |
| 3914 | case 136: |
| 3915 | #line 1412 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3916 | { // Empty structure type? |
| 3917 | (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3918 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3919 | ;} |
| 3920 | break; |
| 3921 | |
| 3922 | case 137: |
| 3923 | #line 1419 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3924 | { |
| 3925 | (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal); |
| 3926 | (yyval.TypeWithAttrs).Attrs = (yyvsp[(2) - (2)].ParamAttrs); |
| 3927 | ;} |
| 3928 | break; |
| 3929 | |
| 3930 | case 138: |
| 3931 | #line 1426 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3932 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3933 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3934 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription()); |
| 3935 | if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3936 | GEN_ERROR("LLVM functions cannot return aggregate types"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3937 | (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal); |
| 3938 | ;} |
| 3939 | break; |
| 3940 | |
| 3941 | case 139: |
| 3942 | #line 1433 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3943 | { |
| 3944 | (yyval.TypeVal) = new PATypeHolder(Type::VoidTy); |
| 3945 | ;} |
| 3946 | break; |
| 3947 | |
| 3948 | case 140: |
| 3949 | #line 1438 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3950 | { |
| 3951 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); |
| 3952 | (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3953 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3954 | ;} |
| 3955 | break; |
| 3956 | |
| 3957 | case 141: |
| 3958 | #line 1443 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3959 | { |
| 3960 | ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3961 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3962 | ;} |
| 3963 | break; |
| 3964 | |
| 3965 | case 143: |
| 3966 | #line 1451 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3967 | { |
| 3968 | (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList); |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 3969 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3970 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3971 | (yyval.TypeWithAttrsList)->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3972 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3973 | ;} |
| 3974 | break; |
| 3975 | |
| 3976 | case 144: |
| 3977 | #line 1458 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3978 | { |
| 3979 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 3980 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3981 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3982 | (yyval.TypeWithAttrsList)->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3983 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3984 | ;} |
| 3985 | break; |
| 3986 | |
| 3987 | case 145: |
| 3988 | #line 1465 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3989 | { |
| 3990 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3991 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 3992 | ;} |
| 3993 | break; |
| 3994 | |
| 3995 | case 146: |
| 3996 | #line 1473 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 3997 | { |
| 3998 | (yyval.TypeList) = new std::list<PATypeHolder>(); |
| 3999 | (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal)); |
| 4000 | delete (yyvsp[(1) - (1)].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4001 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4002 | ;} |
| 4003 | break; |
| 4004 | |
| 4005 | case 147: |
| 4006 | #line 1479 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4007 | { |
| 4008 | ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal)); |
| 4009 | delete (yyvsp[(3) - (3)].TypeVal); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 4010 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4011 | ;} |
| 4012 | break; |
| 4013 | |
| 4014 | case 148: |
| 4015 | #line 1491 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4016 | { // Nonempty unsized arr |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4017 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4018 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription()); |
| 4019 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4020 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4021 | GEN_ERROR("Cannot make array constant with type: '" + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4022 | (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4023 | const Type *ETy = ATy->getElementType(); |
| 4024 | int NumElements = ATy->getNumElements(); |
| 4025 | |
| 4026 | // Verify that we have the correct size... |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4027 | if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4028 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4029 | utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4030 | itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4031 | |
| 4032 | // Verify all elements are correct type! |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4033 | for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) { |
| 4034 | if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4035 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 4036 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4037 | (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4038 | } |
| 4039 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4040 | (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector)); |
| 4041 | delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4042 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4043 | ;} |
| 4044 | break; |
| 4045 | |
| 4046 | case 149: |
| 4047 | #line 1519 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4048 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4049 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4050 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription()); |
| 4051 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4052 | if (ATy == 0) |
| 4053 | GEN_ERROR("Cannot make array constant with type: '" + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4054 | (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4055 | |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4056 | int NumElements = ATy->getNumElements(); |
| 4057 | if (NumElements != -1 && NumElements != 0) |
| 4058 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4059 | " arguments, but has size of " + itostr(NumElements) +""); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4060 | (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 4061 | delete (yyvsp[(1) - (3)].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4062 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4063 | ;} |
| 4064 | break; |
| 4065 | |
| 4066 | case 150: |
| 4067 | #line 1535 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4068 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4069 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4070 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription()); |
| 4071 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4072 | if (ATy == 0) |
| 4073 | GEN_ERROR("Cannot make array constant with type: '" + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4074 | (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4075 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4076 | int NumElements = ATy->getNumElements(); |
| 4077 | const Type *ETy = ATy->getElementType(); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4078 | char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true); |
| 4079 | if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal))) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4080 | GEN_ERROR("Can't build string constant of size " + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4081 | itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4082 | " when array has size " + itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4083 | std::vector<Constant*> Vals; |
| 4084 | if (ETy == Type::Int8Ty) { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4085 | for (unsigned char *C = (unsigned char *)(yyvsp[(3) - (3)].StrVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4086 | C != (unsigned char*)EndStr; ++C) |
| 4087 | Vals.push_back(ConstantInt::get(ETy, *C)); |
| 4088 | } else { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4089 | free((yyvsp[(3) - (3)].StrVal)); |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4090 | GEN_ERROR("Cannot build string arrays of non byte sized elements"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4091 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4092 | free((yyvsp[(3) - (3)].StrVal)); |
| 4093 | (yyval.ConstVal) = ConstantArray::get(ATy, Vals); |
| 4094 | delete (yyvsp[(1) - (3)].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4095 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4096 | ;} |
| 4097 | break; |
| 4098 | |
| 4099 | case 151: |
| 4100 | #line 1564 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4101 | { // Nonempty unsized arr |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4102 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4103 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription()); |
| 4104 | const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4105 | if (PTy == 0) |
| 4106 | GEN_ERROR("Cannot make packed constant with type: '" + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4107 | (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4108 | const Type *ETy = PTy->getElementType(); |
| 4109 | int NumElements = PTy->getNumElements(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4110 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4111 | // Verify that we have the correct size... |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4112 | if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4113 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4114 | utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4115 | itostr(NumElements) + ""); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4116 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4117 | // Verify all elements are correct type! |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4118 | for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) { |
| 4119 | if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4120 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 4121 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4122 | (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4123 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4124 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4125 | (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector)); |
| 4126 | delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4127 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4128 | ;} |
| 4129 | break; |
| 4130 | |
| 4131 | case 152: |
| 4132 | #line 1592 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4133 | { |
| 4134 | const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4135 | if (STy == 0) |
| 4136 | GEN_ERROR("Cannot make struct constant with type: '" + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4137 | (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4138 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4139 | if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4140 | GEN_ERROR("Illegal number of initializers for structure type"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4141 | |
| 4142 | // Check to ensure that constants are compatible with the type initializer! |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4143 | for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i) |
| 4144 | if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4145 | GEN_ERROR("Expected type '" + |
| 4146 | STy->getElementType(i)->getDescription() + |
| 4147 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4148 | " of structure initializer"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4149 | |
| 4150 | // Check to ensure that Type is not packed |
| 4151 | if (STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 4152 | GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4153 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4154 | (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector)); |
| 4155 | delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4156 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4157 | ;} |
| 4158 | break; |
| 4159 | |
| 4160 | case 153: |
| 4161 | #line 1617 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4162 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4163 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4164 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription()); |
| 4165 | const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4166 | if (STy == 0) |
| 4167 | GEN_ERROR("Cannot make struct constant with type: '" + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4168 | (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4169 | |
| 4170 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4171 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4172 | |
| 4173 | // Check to ensure that Type is not packed |
| 4174 | if (STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 4175 | GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4176 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4177 | (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 4178 | delete (yyvsp[(1) - (3)].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4179 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4180 | ;} |
| 4181 | break; |
| 4182 | |
| 4183 | case 154: |
| 4184 | #line 1636 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4185 | { |
| 4186 | const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4187 | if (STy == 0) |
| 4188 | GEN_ERROR("Cannot make struct constant with type: '" + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4189 | (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4190 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4191 | if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4192 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4193 | |
| 4194 | // Check to ensure that constants are compatible with the type initializer! |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4195 | for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i) |
| 4196 | if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4197 | GEN_ERROR("Expected type '" + |
| 4198 | STy->getElementType(i)->getDescription() + |
| 4199 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4200 | " of structure initializer"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4201 | |
| 4202 | // Check to ensure that Type is packed |
| 4203 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 4204 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 4205 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4206 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4207 | (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector)); |
| 4208 | delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4209 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4210 | ;} |
| 4211 | break; |
| 4212 | |
| 4213 | case 155: |
| 4214 | #line 1662 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4215 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4216 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4217 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription()); |
| 4218 | const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4219 | if (STy == 0) |
| 4220 | GEN_ERROR("Cannot make struct constant with type: '" + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4221 | (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4222 | |
| 4223 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4224 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4225 | |
| 4226 | // Check to ensure that Type is packed |
| 4227 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 4228 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 4229 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4230 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4231 | (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 4232 | delete (yyvsp[(1) - (5)].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4233 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4234 | ;} |
| 4235 | break; |
| 4236 | |
| 4237 | case 156: |
| 4238 | #line 1682 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4239 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4240 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4241 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); |
| 4242 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4243 | if (PTy == 0) |
| 4244 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4245 | (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4246 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4247 | (yyval.ConstVal) = ConstantPointerNull::get(PTy); |
| 4248 | delete (yyvsp[(1) - (2)].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4249 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4250 | ;} |
| 4251 | break; |
| 4252 | |
| 4253 | case 157: |
| 4254 | #line 1694 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4255 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4256 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4257 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); |
| 4258 | (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get()); |
| 4259 | delete (yyvsp[(1) - (2)].TypeVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4260 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4261 | ;} |
| 4262 | break; |
| 4263 | |
| 4264 | case 158: |
| 4265 | #line 1701 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4266 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4267 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4268 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); |
| 4269 | const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4270 | if (Ty == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4271 | GEN_ERROR("Global const reference must be a pointer type"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4272 | |
| 4273 | // ConstExprs can exist in the body of a function, thus creating |
| 4274 | // GlobalValues whenever they refer to a variable. Because we are in |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 4275 | // the context of a function, getExistingVal will search the functions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4276 | // symbol table instead of the module symbol table for the global symbol, |
| 4277 | // which throws things all off. To get around this, we just tell |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 4278 | // getExistingVal that we are at global scope here. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4279 | // |
| 4280 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 4281 | CurFun.CurrentFunction = 0; |
| 4282 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4283 | Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4284 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4285 | |
| 4286 | CurFun.CurrentFunction = SavedCurFn; |
| 4287 | |
| 4288 | // If this is an initializer for a constant pointer, which is referencing a |
| 4289 | // (currently) undefined variable, create a stub now that shall be replaced |
| 4290 | // in the future with the right type of variable. |
| 4291 | // |
| 4292 | if (V == 0) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 4293 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4294 | const PointerType *PT = cast<PointerType>(Ty); |
| 4295 | |
| 4296 | // First check to see if the forward references value is already created! |
| 4297 | PerModuleInfo::GlobalRefsType::iterator I = |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4298 | CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal))); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4299 | |
| 4300 | if (I != CurModule.GlobalRefs.end()) { |
| 4301 | V = I->second; // Placeholder already exists, use it... |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4302 | (yyvsp[(2) - (2)].ValIDVal).destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4303 | } else { |
| 4304 | std::string Name; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4305 | if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName) |
| 4306 | Name = (yyvsp[(2) - (2)].ValIDVal).Name; |
| 4307 | else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4308 | GEN_ERROR("Invalid reference to global"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4309 | |
| 4310 | // Create the forward referenced global. |
| 4311 | GlobalValue *GV; |
| 4312 | if (const FunctionType *FTy = |
| 4313 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 4314 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 4315 | CurModule.CurrentModule); |
| 4316 | } else { |
| 4317 | GV = new GlobalVariable(PT->getElementType(), false, |
| 4318 | GlobalValue::ExternalLinkage, 0, |
| 4319 | Name, CurModule.CurrentModule); |
| 4320 | } |
| 4321 | |
| 4322 | // Keep track of the fact that we have a forward ref to recycle it |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4323 | CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4324 | V = GV; |
| 4325 | } |
| 4326 | } |
| 4327 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4328 | (yyval.ConstVal) = cast<GlobalValue>(V); |
| 4329 | delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4330 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4331 | ;} |
| 4332 | break; |
| 4333 | |
| 4334 | case 159: |
| 4335 | #line 1767 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4336 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4337 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4338 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); |
| 4339 | if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4340 | GEN_ERROR("Mismatched types for constant expression: " + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4341 | (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription()); |
| 4342 | (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal); |
| 4343 | delete (yyvsp[(1) - (2)].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4344 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4345 | ;} |
| 4346 | break; |
| 4347 | |
| 4348 | case 160: |
| 4349 | #line 1777 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4350 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4351 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4352 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); |
| 4353 | const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get(); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4354 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4355 | GEN_ERROR("Cannot create a null initialized value of this type"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4356 | (yyval.ConstVal) = Constant::getNullValue(Ty); |
| 4357 | delete (yyvsp[(1) - (2)].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4358 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4359 | ;} |
| 4360 | break; |
| 4361 | |
| 4362 | case 161: |
| 4363 | #line 1787 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4364 | { // integral constants |
| 4365 | if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4366 | GEN_ERROR("Constant value doesn't fit in type"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4367 | (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4368 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4369 | ;} |
| 4370 | break; |
| 4371 | |
| 4372 | case 162: |
| 4373 | #line 1793 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4374 | { // arbitrary precision integer constants |
| 4375 | uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth(); |
| 4376 | if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) { |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 4377 | GEN_ERROR("Constant value does not fit in type"); |
Reid Spencer | 1079427 | 2007-03-01 19:41:47 +0000 | [diff] [blame] | 4378 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4379 | (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth); |
| 4380 | (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal)); |
| 4381 | delete (yyvsp[(2) - (2)].APIntVal); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 4382 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4383 | ;} |
| 4384 | break; |
| 4385 | |
| 4386 | case 163: |
| 4387 | #line 1803 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4388 | { // integral constants |
| 4389 | if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4390 | GEN_ERROR("Constant value doesn't fit in type"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4391 | (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val), false); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4392 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4393 | ;} |
| 4394 | break; |
| 4395 | |
| 4396 | case 164: |
| 4397 | #line 1809 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4398 | { // arbitrary precision integer constants |
| 4399 | uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth(); |
| 4400 | if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) { |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 4401 | GEN_ERROR("Constant value does not fit in type"); |
Reid Spencer | 1079427 | 2007-03-01 19:41:47 +0000 | [diff] [blame] | 4402 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4403 | (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth); |
| 4404 | (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal)); |
| 4405 | delete (yyvsp[(2) - (2)].APIntVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4406 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4407 | ;} |
| 4408 | break; |
| 4409 | |
| 4410 | case 165: |
| 4411 | #line 1819 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4412 | { // Boolean constants |
| 4413 | assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 4414 | (yyval.ConstVal) = ConstantInt::getTrue(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4415 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4416 | ;} |
| 4417 | break; |
| 4418 | |
| 4419 | case 166: |
| 4420 | #line 1824 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4421 | { // Boolean constants |
| 4422 | assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 4423 | (yyval.ConstVal) = ConstantInt::getFalse(); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 4424 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4425 | ;} |
| 4426 | break; |
| 4427 | |
| 4428 | case 167: |
| 4429 | #line 1829 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4430 | { // Float & Double constants |
| 4431 | if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4432 | GEN_ERROR("Floating point constant invalid for type"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4433 | (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4434 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4435 | ;} |
| 4436 | break; |
| 4437 | |
| 4438 | case 168: |
| 4439 | #line 1837 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4440 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4441 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4442 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription()); |
| 4443 | Constant *Val = (yyvsp[(3) - (6)].ConstVal); |
| 4444 | const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get(); |
| 4445 | if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4446 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 4447 | Val->getType()->getDescription() + "' to '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4448 | DestTy->getDescription() + "'"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4449 | (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy); |
| 4450 | delete (yyvsp[(5) - (6)].TypeVal); |
| 4451 | ;} |
| 4452 | break; |
| 4453 | |
| 4454 | case 169: |
| 4455 | #line 1849 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4456 | { |
| 4457 | if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4458 | GEN_ERROR("GetElementPtr requires a pointer operand"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4459 | |
| 4460 | const Type *IdxTy = |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4461 | GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), &(*(yyvsp[(4) - (5)].ValueList))[0], (yyvsp[(4) - (5)].ValueList)->size(), |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 4462 | true); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4463 | if (!IdxTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4464 | GEN_ERROR("Index list invalid for constant getelementptr"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4465 | |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 4466 | SmallVector<Constant*, 8> IdxVec; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4467 | for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i) |
| 4468 | if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i])) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4469 | IdxVec.push_back(C); |
| 4470 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4471 | GEN_ERROR("Indices to constant getelementptr must be constants"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4472 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4473 | delete (yyvsp[(4) - (5)].ValueList); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4474 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4475 | (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4476 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4477 | ;} |
| 4478 | break; |
| 4479 | |
| 4480 | case 170: |
| 4481 | #line 1871 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4482 | { |
| 4483 | if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4484 | GEN_ERROR("Select condition must be of boolean type"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4485 | if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4486 | GEN_ERROR("Select operand types must match"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4487 | (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4488 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4489 | ;} |
| 4490 | break; |
| 4491 | |
| 4492 | case 171: |
| 4493 | #line 1879 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4494 | { |
| 4495 | if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4496 | GEN_ERROR("Binary operator types must match"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4497 | CHECK_FOR_ERROR; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4498 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)); |
| 4499 | ;} |
| 4500 | break; |
| 4501 | |
| 4502 | case 172: |
| 4503 | #line 1885 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4504 | { |
| 4505 | if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4506 | GEN_ERROR("Logical operator types must match"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4507 | if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) { |
| 4508 | if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) || |
| 4509 | !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4510 | GEN_ERROR("Logical operator requires integral operands"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4511 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4512 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4513 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4514 | ;} |
| 4515 | break; |
| 4516 | |
| 4517 | case 173: |
| 4518 | #line 1896 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4519 | { |
| 4520 | if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4521 | GEN_ERROR("icmp operand types must match"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4522 | (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal)); |
| 4523 | ;} |
| 4524 | break; |
| 4525 | |
| 4526 | case 174: |
| 4527 | #line 1901 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4528 | { |
| 4529 | if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4530 | GEN_ERROR("fcmp operand types must match"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4531 | (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal)); |
| 4532 | ;} |
| 4533 | break; |
| 4534 | |
| 4535 | case 175: |
| 4536 | #line 1906 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4537 | { |
| 4538 | if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4539 | GEN_ERROR("Invalid extractelement operands"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4540 | (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4541 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4542 | ;} |
| 4543 | break; |
| 4544 | |
| 4545 | case 176: |
| 4546 | #line 1912 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4547 | { |
| 4548 | if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4549 | GEN_ERROR("Invalid insertelement operands"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4550 | (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4551 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4552 | ;} |
| 4553 | break; |
| 4554 | |
| 4555 | case 177: |
| 4556 | #line 1918 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4557 | { |
| 4558 | if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4559 | GEN_ERROR("Invalid shufflevector operands"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4560 | (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4561 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4562 | ;} |
| 4563 | break; |
| 4564 | |
| 4565 | case 178: |
| 4566 | #line 1927 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4567 | { |
| 4568 | ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4569 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4570 | ;} |
| 4571 | break; |
| 4572 | |
| 4573 | case 179: |
| 4574 | #line 1931 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4575 | { |
| 4576 | (yyval.ConstVector) = new std::vector<Constant*>(); |
| 4577 | (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4578 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4579 | ;} |
| 4580 | break; |
| 4581 | |
| 4582 | case 180: |
| 4583 | #line 1939 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4584 | { (yyval.BoolVal) = false; ;} |
| 4585 | break; |
| 4586 | |
| 4587 | case 181: |
| 4588 | #line 1939 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4589 | { (yyval.BoolVal) = true; ;} |
| 4590 | break; |
| 4591 | |
| 4592 | case 182: |
| 4593 | #line 1942 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4594 | { (yyval.BoolVal) = true; ;} |
| 4595 | break; |
| 4596 | |
| 4597 | case 183: |
| 4598 | #line 1942 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4599 | { (yyval.BoolVal) = false; ;} |
| 4600 | break; |
| 4601 | |
| 4602 | case 184: |
| 4603 | #line 1953 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4604 | { |
| 4605 | (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; |
Reid Spencer | 67d8ed9 | 2007-03-22 02:14:08 +0000 | [diff] [blame] | 4606 | CurModule.ModuleDone(); |
| 4607 | CHECK_FOR_ERROR; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4608 | ;} |
| 4609 | break; |
| 4610 | |
| 4611 | case 185: |
| 4612 | #line 1958 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4613 | { |
| 4614 | (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4615 | CurModule.ModuleDone(); |
| 4616 | CHECK_FOR_ERROR; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4617 | ;} |
| 4618 | break; |
| 4619 | |
| 4620 | case 188: |
| 4621 | #line 1971 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4622 | { CurFun.isDeclare = false; ;} |
| 4623 | break; |
| 4624 | |
| 4625 | case 189: |
| 4626 | #line 1971 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4627 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4628 | CurFun.FunctionDone(); |
| 4629 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4630 | ;} |
| 4631 | break; |
| 4632 | |
| 4633 | case 190: |
| 4634 | #line 1975 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4635 | { CurFun.isDeclare = true; ;} |
| 4636 | break; |
| 4637 | |
| 4638 | case 191: |
| 4639 | #line 1975 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4640 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4641 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4642 | ;} |
| 4643 | break; |
| 4644 | |
| 4645 | case 192: |
| 4646 | #line 1978 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4647 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4648 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4649 | ;} |
| 4650 | break; |
| 4651 | |
| 4652 | case 193: |
| 4653 | #line 1981 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4654 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4655 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4656 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4657 | // Eagerly resolve types. This is not an optimization, this is a |
| 4658 | // requirement that is due to the fact that we could have this: |
| 4659 | // |
| 4660 | // %list = type { %list * } |
| 4661 | // %list = type { %list * } ; repeated type decl |
| 4662 | // |
| 4663 | // If types are not resolved eagerly, then the two types will not be |
| 4664 | // determined to be the same type! |
| 4665 | // |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4666 | ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4667 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4668 | if (!setTypeName(*(yyvsp[(3) - (3)].TypeVal), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4669 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4670 | // If this is a named type that is not a redefinition, add it to the slot |
| 4671 | // table. |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4672 | CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4673 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4674 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4675 | delete (yyvsp[(3) - (3)].TypeVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4676 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4677 | ;} |
| 4678 | break; |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 4679 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4680 | case 194: |
| 4681 | #line 2005 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4682 | { |
| 4683 | ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType)); |
| 4684 | |
| 4685 | if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4686 | CHECK_FOR_ERROR |
| 4687 | // If this is a named type that is not a redefinition, add it to the slot |
| 4688 | // table. |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4689 | CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4690 | } |
| 4691 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4692 | ;} |
| 4693 | break; |
| 4694 | |
| 4695 | case 195: |
| 4696 | #line 2016 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4697 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4698 | /* "Externally Visible" Linkage */ |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4699 | if ((yyvsp[(5) - (5)].ConstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4700 | GEN_ERROR("Global value initializer is not a constant"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4701 | CurGV = ParseGlobalVariable((yyvsp[(1) - (5)].StrVal), GlobalValue::ExternalLinkage, |
| 4702 | (yyvsp[(2) - (5)].Visibility), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal)->getType(), (yyvsp[(5) - (5)].ConstVal), (yyvsp[(3) - (5)].BoolVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4703 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4704 | ;} |
| 4705 | break; |
| 4706 | |
| 4707 | case 196: |
| 4708 | #line 2023 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4709 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4710 | CurGV = 0; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4711 | ;} |
| 4712 | break; |
| 4713 | |
| 4714 | case 197: |
| 4715 | #line 2026 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4716 | { |
| 4717 | if ((yyvsp[(6) - (6)].ConstVal) == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4718 | GEN_ERROR("Global value initializer is not a constant"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4719 | CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), (yyvsp[(2) - (6)].Linkage), (yyvsp[(3) - (6)].Visibility), (yyvsp[(5) - (6)].BoolVal), (yyvsp[(6) - (6)].ConstVal)->getType(), (yyvsp[(6) - (6)].ConstVal), (yyvsp[(4) - (6)].BoolVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4720 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4721 | ;} |
| 4722 | break; |
| 4723 | |
| 4724 | case 198: |
| 4725 | #line 2031 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4726 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4727 | CurGV = 0; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4728 | ;} |
| 4729 | break; |
| 4730 | |
| 4731 | case 199: |
| 4732 | #line 2034 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4733 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4734 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4735 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (6)].TypeVal))->getDescription()); |
| 4736 | CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), (yyvsp[(2) - (6)].Linkage), (yyvsp[(3) - (6)].Visibility), (yyvsp[(5) - (6)].BoolVal), *(yyvsp[(6) - (6)].TypeVal), 0, (yyvsp[(4) - (6)].BoolVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4737 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4738 | delete (yyvsp[(6) - (6)].TypeVal); |
| 4739 | ;} |
| 4740 | break; |
| 4741 | |
| 4742 | case 200: |
| 4743 | #line 2040 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4744 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4745 | CurGV = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4746 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4747 | ;} |
| 4748 | break; |
| 4749 | |
| 4750 | case 201: |
| 4751 | #line 2044 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4752 | { |
| 4753 | std::string Name((yyvsp[(1) - (6)].StrVal)); |
| 4754 | if (Name.empty()) |
| 4755 | GEN_ERROR("Alias name cannot be empty") |
| 4756 | const PointerType *PFTy = 0; |
| 4757 | const FunctionType *Ty = 0; |
| 4758 | Value* V = 0; |
| 4759 | const Type* VTy = 0; |
| 4760 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[(5) - (6)].TypeVal)->get())) || |
| 4761 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4762 | VTy = (yyvsp[(5) - (6)].TypeVal)->get(); |
| 4763 | V = getExistingVal(VTy, (yyvsp[(6) - (6)].ValIDVal)); |
| 4764 | } else { |
| 4765 | VTy = PFTy; |
| 4766 | V = getExistingVal(PFTy, (yyvsp[(6) - (6)].ValIDVal)); |
| 4767 | } |
| 4768 | if (V == 0) |
| 4769 | GEN_ERROR(std::string("Invalid aliasee for alias: ") + (yyvsp[(1) - (6)].StrVal)); |
| 4770 | GlobalValue* Aliasee; |
| 4771 | if (Aliasee = dyn_cast<GlobalValue>(V)) { |
| 4772 | GlobalAlias* GA = new GlobalAlias(VTy, (yyvsp[(4) - (6)].Linkage), Name, Aliasee, CurModule.CurrentModule); |
| 4773 | GA->setVisibility((yyvsp[(2) - (6)].Visibility)); |
| 4774 | InsertValue(GA, CurModule.Values); |
| 4775 | } else |
| 4776 | GEN_ERROR("Aliases can be created only to global values"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4777 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4778 | delete (yyvsp[(5) - (6)].TypeVal); |
| 4779 | ;} |
| 4780 | break; |
| 4781 | |
| 4782 | case 202: |
| 4783 | #line 2072 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4784 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4785 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4786 | ;} |
| 4787 | break; |
| 4788 | |
| 4789 | case 203: |
| 4790 | #line 2075 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4791 | { |
| 4792 | CHECK_FOR_ERROR |
| 4793 | ;} |
| 4794 | break; |
| 4795 | |
| 4796 | case 204: |
| 4797 | #line 2081 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4798 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4799 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4800 | char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true); |
| 4801 | std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr); |
| 4802 | free((yyvsp[(1) - (1)].StrVal)); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4803 | |
| 4804 | if (AsmSoFar.empty()) |
| 4805 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 4806 | else |
| 4807 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4808 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4809 | ;} |
| 4810 | break; |
| 4811 | |
| 4812 | case 205: |
| 4813 | #line 2094 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4814 | { |
| 4815 | CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal)); |
| 4816 | free((yyvsp[(3) - (3)].StrVal)); |
| 4817 | ;} |
| 4818 | break; |
| 4819 | |
| 4820 | case 206: |
| 4821 | #line 2098 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4822 | { |
| 4823 | CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal)); |
| 4824 | free((yyvsp[(3) - (3)].StrVal)); |
| 4825 | ;} |
| 4826 | break; |
| 4827 | |
| 4828 | case 208: |
| 4829 | #line 2105 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4830 | { |
| 4831 | CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal)); |
| 4832 | free((yyvsp[(3) - (3)].StrVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4833 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4834 | ;} |
| 4835 | break; |
| 4836 | |
| 4837 | case 209: |
| 4838 | #line 2110 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4839 | { |
| 4840 | CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal)); |
| 4841 | free((yyvsp[(1) - (1)].StrVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4842 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4843 | ;} |
| 4844 | break; |
| 4845 | |
| 4846 | case 210: |
| 4847 | #line 2115 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4848 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4849 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4850 | ;} |
| 4851 | break; |
| 4852 | |
| 4853 | case 211: |
| 4854 | #line 2124 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4855 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4856 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4857 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription()); |
| 4858 | if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4859 | GEN_ERROR("void typed arguments are invalid"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4860 | ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal); |
| 4861 | (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList); |
| 4862 | (yyvsp[(1) - (5)].ArgList)->push_back(E); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4863 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4864 | ;} |
| 4865 | break; |
| 4866 | |
| 4867 | case 212: |
| 4868 | #line 2134 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4869 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4870 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4871 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription()); |
| 4872 | if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4873 | GEN_ERROR("void typed arguments are invalid"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4874 | ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal); |
| 4875 | (yyval.ArgList) = new ArgListType; |
| 4876 | (yyval.ArgList)->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4877 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4878 | ;} |
| 4879 | break; |
| 4880 | |
| 4881 | case 213: |
| 4882 | #line 2145 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4883 | { |
| 4884 | (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4885 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4886 | ;} |
| 4887 | break; |
| 4888 | |
| 4889 | case 214: |
| 4890 | #line 2149 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4891 | { |
| 4892 | (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4893 | struct ArgListEntry E; |
| 4894 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 4895 | E.Name = 0; |
| 4896 | E.Attrs = ParamAttr::None; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4897 | (yyval.ArgList)->push_back(E); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 4898 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4899 | ;} |
| 4900 | break; |
| 4901 | |
| 4902 | case 215: |
| 4903 | #line 2158 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4904 | { |
| 4905 | (yyval.ArgList) = new ArgListType; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4906 | struct ArgListEntry E; |
| 4907 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 4908 | E.Name = 0; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 4909 | E.Attrs = ParamAttr::None; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4910 | (yyval.ArgList)->push_back(E); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4911 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4912 | ;} |
| 4913 | break; |
| 4914 | |
| 4915 | case 216: |
| 4916 | #line 2167 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4917 | { |
| 4918 | (yyval.ArgList) = 0; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4919 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4920 | ;} |
| 4921 | break; |
| 4922 | |
| 4923 | case 217: |
| 4924 | #line 2173 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 4925 | { |
| 4926 | UnEscapeLexed((yyvsp[(3) - (9)].StrVal)); |
| 4927 | std::string FunctionName((yyvsp[(3) - (9)].StrVal)); |
| 4928 | free((yyvsp[(3) - (9)].StrVal)); // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4929 | |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 4930 | // Check the function result for abstractness if this is a define. We should |
| 4931 | // have no abstract types at this point |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4932 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (9)].TypeVal))) |
| 4933 | GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (9)].TypeVal)->get()->getDescription()); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 4934 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4935 | std::vector<const Type*> ParamTypeList; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4936 | ParamAttrsVector Attrs; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4937 | if ((yyvsp[(7) - (9)].ParamAttrs) != ParamAttr::None) { |
| 4938 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(7) - (9)].ParamAttrs); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4939 | Attrs.push_back(PAWI); |
| 4940 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4941 | if ((yyvsp[(5) - (9)].ArgList)) { // If there are arguments... |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4942 | unsigned index = 1; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4943 | for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin(); I != (yyvsp[(5) - (9)].ArgList)->end(); ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4944 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 4945 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty)) |
| 4946 | GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4947 | ParamTypeList.push_back(Ty); |
| 4948 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4949 | if (I->Attrs != ParamAttr::None) { |
| 4950 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 4951 | Attrs.push_back(PAWI); |
| 4952 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4953 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4954 | } |
| 4955 | |
| 4956 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 4957 | if (isVarArg) ParamTypeList.pop_back(); |
| 4958 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 4959 | ParamAttrsList *PAL = 0; |
| 4960 | if (!Attrs.empty()) |
| 4961 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 4962 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4963 | FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (9)].TypeVal), ParamTypeList, isVarArg, PAL); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4964 | const PointerType *PFT = PointerType::get(FT); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4965 | delete (yyvsp[(2) - (9)].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4966 | |
| 4967 | ValID ID; |
| 4968 | if (!FunctionName.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4969 | ID = ValID::createGlobalName((char*)FunctionName.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4970 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 4971 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4972 | } |
| 4973 | |
| 4974 | Function *Fn = 0; |
| 4975 | // See if this function was forward referenced. If so, recycle the object. |
| 4976 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 4977 | // Move the function to the end of the list, from whereever it was |
| 4978 | // previously inserted. |
| 4979 | Fn = cast<Function>(FWRef); |
| 4980 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 4981 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 4982 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4983 | (Fn = CurModule.CurrentModule->getFunction(FunctionName))) { |
| 4984 | if (Fn->getFunctionType() != FT ) { |
| 4985 | // The existing function doesn't have the same type. This is an overload |
| 4986 | // error. |
| 4987 | GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); |
| 4988 | } else if (!CurFun.isDeclare && !Fn->isDeclaration()) { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 4989 | // Neither the existing or the current function is a declaration and they |
| 4990 | // have the same name and same type. Clearly this is a redefinition. |
| 4991 | GEN_ERROR("Redefinition of function '" + FunctionName + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4992 | } if (Fn->isDeclaration()) { |
| 4993 | // Make sure to strip off any argument names so we can't get conflicts. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4994 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 4995 | AI != AE; ++AI) |
| 4996 | AI->setName(""); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4997 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4998 | } else { // Not already defined? |
| 4999 | Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, |
| 5000 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 5001 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5002 | InsertValue(Fn, CurModule.Values); |
| 5003 | } |
| 5004 | |
| 5005 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 5006 | |
| 5007 | if (CurFun.isDeclare) { |
| 5008 | // If we have declaration, always overwrite linkage. This will allow us to |
| 5009 | // correctly handle cases, when pointer to function is passed as argument to |
| 5010 | // another function. |
| 5011 | Fn->setLinkage(CurFun.Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 5012 | Fn->setVisibility(CurFun.Visibility); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 5013 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5014 | Fn->setCallingConv((yyvsp[(1) - (9)].UIntVal)); |
| 5015 | Fn->setAlignment((yyvsp[(9) - (9)].UIntVal)); |
| 5016 | if ((yyvsp[(8) - (9)].StrVal)) { |
| 5017 | Fn->setSection((yyvsp[(8) - (9)].StrVal)); |
| 5018 | free((yyvsp[(8) - (9)].StrVal)); |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 5019 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5020 | |
| 5021 | // Add all of the arguments we parsed to the function... |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5022 | if ((yyvsp[(5) - (9)].ArgList)) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5023 | if (isVarArg) { // Nuke the last entry |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5024 | assert((yyvsp[(5) - (9)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (9)].ArgList)->back().Name == 0 && |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 5025 | "Not a varargs marker!"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5026 | delete (yyvsp[(5) - (9)].ArgList)->back().Ty; |
| 5027 | (yyvsp[(5) - (9)].ArgList)->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5028 | } |
| 5029 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5030 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5031 | unsigned Idx = 1; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5032 | for (ArgListType::iterator I = (yyvsp[(5) - (9)].ArgList)->begin(); |
| 5033 | I != (yyvsp[(5) - (9)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5034 | delete I->Ty; // Delete the typeholder... |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5035 | setValueName(ArgIt, I->Name); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5036 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5037 | InsertValue(ArgIt); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5038 | Idx++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5039 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 5040 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5041 | delete (yyvsp[(5) - (9)].ArgList); // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5042 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5043 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5044 | ;} |
| 5045 | break; |
| 5046 | |
| 5047 | case 220: |
| 5048 | #line 2296 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5049 | { |
| 5050 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5051 | |
| 5052 | // Make sure that we keep track of the linkage type even if there was a |
| 5053 | // previous "declare". |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5054 | (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage)); |
| 5055 | (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility)); |
| 5056 | ;} |
| 5057 | break; |
| 5058 | |
| 5059 | case 223: |
| 5060 | #line 2307 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5061 | { |
| 5062 | (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5063 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5064 | ;} |
| 5065 | break; |
| 5066 | |
| 5067 | case 224: |
| 5068 | #line 2312 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5069 | { |
| 5070 | CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage)); |
| 5071 | CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility)); |
| 5072 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5073 | CurFun.FunctionDone(); |
| 5074 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5075 | ;} |
| 5076 | break; |
| 5077 | |
| 5078 | case 225: |
| 5079 | #line 2324 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5080 | { |
| 5081 | (yyval.BoolVal) = false; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5082 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5083 | ;} |
| 5084 | break; |
| 5085 | |
| 5086 | case 226: |
| 5087 | #line 2328 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5088 | { |
| 5089 | (yyval.BoolVal) = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5090 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5091 | ;} |
| 5092 | break; |
| 5093 | |
| 5094 | case 227: |
| 5095 | #line 2333 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5096 | { // A reference to a direct constant |
| 5097 | (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5098 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5099 | ;} |
| 5100 | break; |
| 5101 | |
| 5102 | case 228: |
| 5103 | #line 2337 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5104 | { |
| 5105 | (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5106 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5107 | ;} |
| 5108 | break; |
| 5109 | |
| 5110 | case 229: |
| 5111 | #line 2341 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5112 | { // Perhaps it's an FP constant? |
| 5113 | (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5114 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5115 | ;} |
| 5116 | break; |
| 5117 | |
| 5118 | case 230: |
| 5119 | #line 2345 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5120 | { |
| 5121 | (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5122 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5123 | ;} |
| 5124 | break; |
| 5125 | |
| 5126 | case 231: |
| 5127 | #line 2349 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5128 | { |
| 5129 | (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5130 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5131 | ;} |
| 5132 | break; |
| 5133 | |
| 5134 | case 232: |
| 5135 | #line 2353 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5136 | { |
| 5137 | (yyval.ValIDVal) = ValID::createNull(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 5138 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5139 | ;} |
| 5140 | break; |
| 5141 | |
| 5142 | case 233: |
| 5143 | #line 2357 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5144 | { |
| 5145 | (yyval.ValIDVal) = ValID::createUndef(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 5146 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5147 | ;} |
| 5148 | break; |
| 5149 | |
| 5150 | case 234: |
| 5151 | #line 2361 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5152 | { // A vector zero constant. |
| 5153 | (yyval.ValIDVal) = ValID::createZeroInit(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5154 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5155 | ;} |
| 5156 | break; |
| 5157 | |
| 5158 | case 235: |
| 5159 | #line 2365 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5160 | { // Nonempty unsized packed vector |
| 5161 | const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType(); |
| 5162 | int NumElements = (yyvsp[(2) - (3)].ConstVector)->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5163 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5164 | VectorType* pt = VectorType::get(ETy, NumElements); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5165 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 5166 | HandleUpRefs( |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5167 | VectorType::get( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 5168 | ETy, |
| 5169 | NumElements) |
| 5170 | ) |
| 5171 | ); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5172 | |
| 5173 | // Verify all elements are correct type! |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5174 | for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) { |
| 5175 | if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5176 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5177 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5178 | (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5179 | } |
| 5180 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5181 | (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector))); |
| 5182 | delete PTy; delete (yyvsp[(2) - (3)].ConstVector); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5183 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5184 | ;} |
| 5185 | break; |
| 5186 | |
| 5187 | case 236: |
| 5188 | #line 2390 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5189 | { |
| 5190 | (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5191 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5192 | ;} |
| 5193 | break; |
| 5194 | |
| 5195 | case 237: |
| 5196 | #line 2394 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5197 | { |
| 5198 | char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true); |
| 5199 | std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End); |
| 5200 | End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true); |
| 5201 | std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End); |
| 5202 | (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal)); |
| 5203 | free((yyvsp[(3) - (5)].StrVal)); |
| 5204 | free((yyvsp[(5) - (5)].StrVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5205 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5206 | ;} |
| 5207 | break; |
| 5208 | |
| 5209 | case 238: |
| 5210 | #line 2408 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5211 | { // Is it an integer reference...? |
| 5212 | (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5213 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5214 | ;} |
| 5215 | break; |
| 5216 | |
| 5217 | case 239: |
| 5218 | #line 2412 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5219 | { |
| 5220 | (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5221 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5222 | ;} |
| 5223 | break; |
| 5224 | |
| 5225 | case 240: |
| 5226 | #line 2416 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5227 | { // Is it a named reference...? |
| 5228 | (yyval.ValIDVal) = ValID::createLocalName((yyvsp[(1) - (1)].StrVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5229 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5230 | ;} |
| 5231 | break; |
| 5232 | |
| 5233 | case 241: |
| 5234 | #line 2420 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5235 | { // Is it a named reference...? |
| 5236 | (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[(1) - (1)].StrVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5237 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5238 | ;} |
| 5239 | break; |
| 5240 | |
| 5241 | case 244: |
| 5242 | #line 2432 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5243 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5244 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5245 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); |
| 5246 | (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal)); |
| 5247 | delete (yyvsp[(1) - (2)].TypeVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5248 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5249 | ;} |
| 5250 | break; |
| 5251 | |
| 5252 | case 245: |
| 5253 | #line 2441 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5254 | { |
| 5255 | (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5256 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5257 | ;} |
| 5258 | break; |
| 5259 | |
| 5260 | case 246: |
| 5261 | #line 2445 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5262 | { // Do not allow functions with 0 basic blocks |
| 5263 | (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5264 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5265 | ;} |
| 5266 | break; |
| 5267 | |
| 5268 | case 247: |
| 5269 | #line 2454 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5270 | { |
| 5271 | setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5272 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5273 | InsertValue((yyvsp[(3) - (3)].TermInstVal)); |
| 5274 | (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal)); |
| 5275 | (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5276 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5277 | ;} |
| 5278 | break; |
| 5279 | |
| 5280 | case 248: |
| 5281 | #line 2463 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5282 | { |
| 5283 | if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal))) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5284 | if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0))) |
| 5285 | if (CI2->getParent() == 0) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5286 | (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2); |
| 5287 | (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal)); |
| 5288 | (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5289 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5290 | ;} |
| 5291 | break; |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5292 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5293 | case 249: |
| 5294 | #line 2472 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5295 | { // Empty space between instruction lists |
| 5296 | (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum)); |
| 5297 | CHECK_FOR_ERROR |
| 5298 | ;} |
| 5299 | break; |
| 5300 | |
| 5301 | case 250: |
| 5302 | #line 2476 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5303 | { // Labelled (named) basic block |
| 5304 | (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName((yyvsp[(1) - (1)].StrVal))); |
| 5305 | CHECK_FOR_ERROR |
| 5306 | ;} |
| 5307 | break; |
| 5308 | |
| 5309 | case 251: |
| 5310 | #line 2481 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5311 | { // Return with a result... |
| 5312 | (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal)); |
| 5313 | CHECK_FOR_ERROR |
| 5314 | ;} |
| 5315 | break; |
| 5316 | |
| 5317 | case 252: |
| 5318 | #line 2485 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5319 | { // Return with no result... |
| 5320 | (yyval.TermInstVal) = new ReturnInst(); |
| 5321 | CHECK_FOR_ERROR |
| 5322 | ;} |
| 5323 | break; |
| 5324 | |
| 5325 | case 253: |
| 5326 | #line 2489 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5327 | { // Unconditional Branch... |
| 5328 | BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal)); |
| 5329 | CHECK_FOR_ERROR |
| 5330 | (yyval.TermInstVal) = new BranchInst(tmpBB); |
| 5331 | ;} |
| 5332 | break; |
| 5333 | |
| 5334 | case 254: |
| 5335 | #line 2494 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5336 | { |
| 5337 | assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 5338 | BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal)); |
| 5339 | CHECK_FOR_ERROR |
| 5340 | BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal)); |
| 5341 | CHECK_FOR_ERROR |
| 5342 | Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal)); |
| 5343 | CHECK_FOR_ERROR |
| 5344 | (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 5345 | ;} |
| 5346 | break; |
| 5347 | |
| 5348 | case 255: |
| 5349 | #line 2504 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5350 | { |
| 5351 | Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal)); |
| 5352 | CHECK_FOR_ERROR |
| 5353 | BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal)); |
| 5354 | CHECK_FOR_ERROR |
| 5355 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size()); |
| 5356 | (yyval.TermInstVal) = S; |
| 5357 | |
| 5358 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(), |
| 5359 | E = (yyvsp[(8) - (9)].JumpTable)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5360 | for (; I != E; ++I) { |
| 5361 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 5362 | S->addCase(CI, I->second); |
| 5363 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5364 | GEN_ERROR("Switch case is constant, but not a simple integer"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5365 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5366 | delete (yyvsp[(8) - (9)].JumpTable); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5367 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5368 | ;} |
| 5369 | break; |
| 5370 | |
| 5371 | case 256: |
| 5372 | #line 2523 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5373 | { |
| 5374 | Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5375 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5376 | BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5377 | CHECK_FOR_ERROR |
| 5378 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5379 | (yyval.TermInstVal) = S; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5380 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5381 | ;} |
| 5382 | break; |
| 5383 | |
| 5384 | case 257: |
| 5385 | #line 2533 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5386 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5387 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5388 | // Handle the short syntax |
| 5389 | const PointerType *PFTy = 0; |
| 5390 | const FunctionType *Ty = 0; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5391 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5392 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5393 | // Pull out the types of all of the arguments... |
| 5394 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5395 | ParamAttrsVector Attrs; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5396 | if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None) { |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5397 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = 8; |
| 5398 | Attrs.push_back(PAWI); |
| 5399 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5400 | ValueRefList::iterator I = (yyvsp[(6) - (14)].ValueRefList)->begin(), E = (yyvsp[(6) - (14)].ValueRefList)->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5401 | unsigned index = 1; |
| 5402 | for (; I != E; ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5403 | const Type *Ty = I->Val->getType(); |
| 5404 | if (Ty == Type::VoidTy) |
| 5405 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 5406 | ParamTypes.push_back(Ty); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5407 | if (I->Attrs != ParamAttr::None) { |
| 5408 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 5409 | Attrs.push_back(PAWI); |
| 5410 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5411 | } |
| 5412 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5413 | ParamAttrsList *PAL = 0; |
| 5414 | if (!Attrs.empty()) |
| 5415 | PAL = ParamAttrsList::get(Attrs); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5416 | Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false, PAL); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5417 | PFTy = PointerType::get(Ty); |
| 5418 | } |
| 5419 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5420 | delete (yyvsp[(3) - (14)].TypeVal); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 5421 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5422 | Value *V = getVal(PFTy, (yyvsp[(4) - (14)].ValIDVal)); // Get the function we're calling... |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5423 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5424 | BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5425 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5426 | BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5427 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5428 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5429 | // Check the arguments |
| 5430 | ValueList Args; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5431 | if ((yyvsp[(6) - (14)].ValueRefList)->empty()) { // Has no arguments? |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5432 | // Make sure no arguments is a good thing! |
| 5433 | if (Ty->getNumParams() != 0) |
| 5434 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5435 | "expects arguments"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5436 | } else { // Has arguments? |
| 5437 | // Loop through FunctionType's arguments and ensure they are specified |
| 5438 | // correctly! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5439 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5440 | FunctionType::param_iterator E = Ty->param_end(); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5441 | ValueRefList::iterator ArgI = (yyvsp[(6) - (14)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (14)].ValueRefList)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5442 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5443 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5444 | if (ArgI->Val->getType() != *I) |
| 5445 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5446 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5447 | Args.push_back(ArgI->Val); |
| 5448 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5449 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5450 | if (Ty->isVarArg()) { |
| 5451 | if (I == E) |
| 5452 | for (; ArgI != ArgE; ++ArgI) |
| 5453 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 5454 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5455 | GEN_ERROR("Invalid number of parameters detected"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5456 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5457 | |
| 5458 | // Create the InvokeInst |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5459 | InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5460 | II->setCallingConv((yyvsp[(2) - (14)].UIntVal)); |
| 5461 | (yyval.TermInstVal) = II; |
| 5462 | delete (yyvsp[(6) - (14)].ValueRefList); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5463 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5464 | ;} |
| 5465 | break; |
| 5466 | |
| 5467 | case 258: |
| 5468 | #line 2612 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5469 | { |
| 5470 | (yyval.TermInstVal) = new UnwindInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5471 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5472 | ;} |
| 5473 | break; |
| 5474 | |
| 5475 | case 259: |
| 5476 | #line 2616 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5477 | { |
| 5478 | (yyval.TermInstVal) = new UnreachableInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5479 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5480 | ;} |
| 5481 | break; |
| 5482 | |
| 5483 | case 260: |
| 5484 | #line 2623 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5485 | { |
| 5486 | (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable); |
| 5487 | Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal))); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5488 | CHECK_FOR_ERROR |
| 5489 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5490 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5491 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5492 | BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5493 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5494 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5495 | ;} |
| 5496 | break; |
| 5497 | |
| 5498 | case 261: |
| 5499 | #line 2634 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5500 | { |
| 5501 | (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 5502 | Constant *V = cast<Constant>(getExistingVal((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal))); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5503 | CHECK_FOR_ERROR |
| 5504 | |
| 5505 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5506 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5507 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5508 | BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5509 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5510 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5511 | ;} |
| 5512 | break; |
| 5513 | |
| 5514 | case 262: |
| 5515 | #line 2647 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5516 | { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5517 | // Is this definition named?? if so, assign the name... |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5518 | setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal)); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5519 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5520 | InsertValue((yyvsp[(2) - (2)].InstVal)); |
| 5521 | (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5522 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5523 | ;} |
| 5524 | break; |
| 5525 | |
| 5526 | case 263: |
| 5527 | #line 2657 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5528 | { // Used for PHI nodes |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5529 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5530 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription()); |
| 5531 | (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 5532 | Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5533 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5534 | BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5535 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5536 | (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5537 | delete (yyvsp[(1) - (6)].TypeVal); |
| 5538 | ;} |
| 5539 | break; |
| 5540 | |
| 5541 | case 264: |
| 5542 | #line 2668 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5543 | { |
| 5544 | (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList); |
| 5545 | Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5546 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5547 | BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5548 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5549 | (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5550 | ;} |
| 5551 | break; |
| 5552 | |
| 5553 | case 265: |
| 5554 | #line 2678 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5555 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5556 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5557 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription()); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5558 | // Used for call and invoke instructions |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5559 | (yyval.ValueRefList) = new ValueRefList(); |
| 5560 | ValueRefListEntry E; E.Attrs = (yyvsp[(3) - (3)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (3)].TypeVal)->get(), (yyvsp[(2) - (3)].ValIDVal)); |
| 5561 | (yyval.ValueRefList)->push_back(E); |
| 5562 | delete (yyvsp[(1) - (3)].TypeVal); |
| 5563 | ;} |
| 5564 | break; |
| 5565 | |
| 5566 | case 266: |
| 5567 | #line 2687 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5568 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5569 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5570 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription()); |
| 5571 | (yyval.ValueRefList) = (yyvsp[(1) - (5)].ValueRefList); |
| 5572 | ValueRefListEntry E; E.Attrs = (yyvsp[(5) - (5)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (5)].TypeVal)->get(), (yyvsp[(4) - (5)].ValIDVal)); |
| 5573 | (yyval.ValueRefList)->push_back(E); |
| 5574 | delete (yyvsp[(3) - (5)].TypeVal); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5575 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5576 | ;} |
| 5577 | break; |
| 5578 | |
| 5579 | case 267: |
| 5580 | #line 2696 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5581 | { (yyval.ValueRefList) = new ValueRefList(); ;} |
| 5582 | break; |
| 5583 | |
| 5584 | case 268: |
| 5585 | #line 2699 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5586 | { (yyval.ValueList) = new std::vector<Value*>(); ;} |
| 5587 | break; |
| 5588 | |
| 5589 | case 269: |
| 5590 | #line 2700 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5591 | { |
| 5592 | (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList); |
| 5593 | (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5594 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5595 | ;} |
| 5596 | break; |
| 5597 | |
| 5598 | case 270: |
| 5599 | #line 2707 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5600 | { |
| 5601 | (yyval.BoolVal) = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5602 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5603 | ;} |
| 5604 | break; |
| 5605 | |
| 5606 | case 271: |
| 5607 | #line 2711 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5608 | { |
| 5609 | (yyval.BoolVal) = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5610 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5611 | ;} |
| 5612 | break; |
| 5613 | |
| 5614 | case 272: |
| 5615 | #line 2716 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5616 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5617 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5618 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription()); |
| 5619 | if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() && |
| 5620 | !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get())) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5621 | GEN_ERROR( |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5622 | "Arithmetic operator requires integer, FP, or packed operands"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5623 | if (isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get()) && |
| 5624 | ((yyvsp[(1) - (5)].BinaryOpVal) == Instruction::URem || |
| 5625 | (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::SRem || |
| 5626 | (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::FRem)) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 5627 | GEN_ERROR("Remainder not supported on vector types"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5628 | Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5629 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5630 | Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5631 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5632 | (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2); |
| 5633 | if ((yyval.InstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5634 | GEN_ERROR("binary operator returned null"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5635 | delete (yyvsp[(2) - (5)].TypeVal); |
| 5636 | ;} |
| 5637 | break; |
| 5638 | |
| 5639 | case 273: |
| 5640 | #line 2737 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5641 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5642 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5643 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription()); |
| 5644 | if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) { |
| 5645 | if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) || |
| 5646 | !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger()) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5647 | GEN_ERROR("Logical operator requires integral operands"); |
| 5648 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5649 | Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5650 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5651 | Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5652 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5653 | (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2); |
| 5654 | if ((yyval.InstVal) == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5655 | GEN_ERROR("binary operator returned null"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5656 | delete (yyvsp[(2) - (5)].TypeVal); |
| 5657 | ;} |
| 5658 | break; |
| 5659 | |
| 5660 | case 274: |
| 5661 | #line 2754 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5662 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5663 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5664 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription()); |
| 5665 | if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get())) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5666 | GEN_ERROR("Vector types not supported by icmp instruction"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5667 | Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5668 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5669 | Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5670 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5671 | (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2); |
| 5672 | if ((yyval.InstVal) == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5673 | GEN_ERROR("icmp operator returned null"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5674 | delete (yyvsp[(3) - (6)].TypeVal); |
| 5675 | ;} |
| 5676 | break; |
| 5677 | |
| 5678 | case 275: |
| 5679 | #line 2768 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5680 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5681 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5682 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription()); |
| 5683 | if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get())) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5684 | GEN_ERROR("Vector types not supported by fcmp instruction"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5685 | Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5686 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5687 | Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5688 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5689 | (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2); |
| 5690 | if ((yyval.InstVal) == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5691 | GEN_ERROR("fcmp operator returned null"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5692 | delete (yyvsp[(3) - (6)].TypeVal); |
| 5693 | ;} |
| 5694 | break; |
| 5695 | |
| 5696 | case 276: |
| 5697 | #line 2782 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5698 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5699 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5700 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription()); |
| 5701 | Value* Val = (yyvsp[(2) - (4)].ValueVal); |
| 5702 | const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get(); |
| 5703 | if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy)) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5704 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 5705 | Val->getType()->getDescription() + "' to '" + |
| 5706 | DestTy->getDescription() + "'"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5707 | (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy); |
| 5708 | delete (yyvsp[(4) - (4)].TypeVal); |
| 5709 | ;} |
| 5710 | break; |
| 5711 | |
| 5712 | case 277: |
| 5713 | #line 2794 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5714 | { |
| 5715 | if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5716 | GEN_ERROR("select condition must be boolean"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5717 | if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType()) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5718 | GEN_ERROR("select value types should match"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5719 | (yyval.InstVal) = new SelectInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5720 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5721 | ;} |
| 5722 | break; |
| 5723 | |
| 5724 | case 278: |
| 5725 | #line 2802 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5726 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5727 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5728 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription()); |
| 5729 | (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal)); |
| 5730 | delete (yyvsp[(4) - (4)].TypeVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5731 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5732 | ;} |
| 5733 | break; |
| 5734 | |
| 5735 | case 279: |
| 5736 | #line 2809 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5737 | { |
| 5738 | if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal))) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5739 | GEN_ERROR("Invalid extractelement operands"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5740 | (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5741 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5742 | ;} |
| 5743 | break; |
| 5744 | |
| 5745 | case 280: |
| 5746 | #line 2815 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5747 | { |
| 5748 | if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal))) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5749 | GEN_ERROR("Invalid insertelement operands"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5750 | (yyval.InstVal) = new InsertElementInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5751 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5752 | ;} |
| 5753 | break; |
| 5754 | |
| 5755 | case 281: |
| 5756 | #line 2821 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5757 | { |
| 5758 | if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal))) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5759 | GEN_ERROR("Invalid shufflevector operands"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5760 | (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5761 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5762 | ;} |
| 5763 | break; |
| 5764 | |
| 5765 | case 282: |
| 5766 | #line 2827 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5767 | { |
| 5768 | const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType(); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5769 | if (!Ty->isFirstClassType()) |
| 5770 | GEN_ERROR("PHI node operands must be of first class type"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5771 | (yyval.InstVal) = new PHINode(Ty); |
| 5772 | ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size()); |
| 5773 | while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) { |
| 5774 | if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5775 | GEN_ERROR("All elements of a PHI node must be of the same type"); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5776 | cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second); |
| 5777 | (yyvsp[(2) - (2)].PHIList)->pop_front(); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5778 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5779 | delete (yyvsp[(2) - (2)].PHIList); // Free the list... |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5780 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5781 | ;} |
| 5782 | break; |
| 5783 | |
| 5784 | case 283: |
| 5785 | #line 2843 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5786 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5787 | |
| 5788 | // Handle the short syntax |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5789 | const PointerType *PFTy = 0; |
| 5790 | const FunctionType *Ty = 0; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5791 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) || |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5792 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5793 | // Pull out the types of all of the arguments... |
| 5794 | std::vector<const Type*> ParamTypes; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5795 | ParamAttrsVector Attrs; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5796 | if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None) { |
| 5797 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (8)].ParamAttrs); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5798 | Attrs.push_back(PAWI); |
| 5799 | } |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5800 | unsigned index = 1; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5801 | ValueRefList::iterator I = (yyvsp[(6) - (8)].ValueRefList)->begin(), E = (yyvsp[(6) - (8)].ValueRefList)->end(); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5802 | for (; I != E; ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5803 | const Type *Ty = I->Val->getType(); |
| 5804 | if (Ty == Type::VoidTy) |
| 5805 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 5806 | ParamTypes.push_back(Ty); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5807 | if (I->Attrs != ParamAttr::None) { |
| 5808 | ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; |
| 5809 | Attrs.push_back(PAWI); |
| 5810 | } |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5811 | } |
| 5812 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5813 | ParamAttrsList *PAL = 0; |
| 5814 | if (!Attrs.empty()) |
| 5815 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5816 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5817 | Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false, PAL); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5818 | PFTy = PointerType::get(Ty); |
| 5819 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5820 | |
| 5821 | Value *V = getVal(PFTy, (yyvsp[(4) - (8)].ValIDVal)); // Get the function we're calling... |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5822 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5823 | |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 5824 | // Check for call to invalid intrinsic to avoid crashing later. |
| 5825 | if (Function *theF = dyn_cast<Function>(V)) { |
Reid Spencer | ed48de2 | 2007-04-16 22:02:23 +0000 | [diff] [blame] | 5826 | if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) && |
Reid Spencer | 36fdde1 | 2007-04-16 20:35:38 +0000 | [diff] [blame] | 5827 | (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) && |
| 5828 | !theF->getIntrinsicID(true)) |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 5829 | GEN_ERROR("Call to invalid LLVM intrinsic function '" + |
| 5830 | theF->getName() + "'"); |
| 5831 | } |
| 5832 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5833 | // Check the arguments |
| 5834 | ValueList Args; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5835 | if ((yyvsp[(6) - (8)].ValueRefList)->empty()) { // Has no arguments? |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5836 | // Make sure no arguments is a good thing! |
| 5837 | if (Ty->getNumParams() != 0) |
| 5838 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5839 | "expects arguments"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5840 | } else { // Has arguments? |
| 5841 | // Loop through FunctionType's arguments and ensure they are specified |
| 5842 | // correctly! |
| 5843 | // |
| 5844 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5845 | FunctionType::param_iterator E = Ty->param_end(); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5846 | ValueRefList::iterator ArgI = (yyvsp[(6) - (8)].ValueRefList)->begin(), ArgE = (yyvsp[(6) - (8)].ValueRefList)->end(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5847 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5848 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5849 | if (ArgI->Val->getType() != *I) |
| 5850 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5851 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5852 | Args.push_back(ArgI->Val); |
| 5853 | } |
| 5854 | if (Ty->isVarArg()) { |
| 5855 | if (I == E) |
| 5856 | for (; ArgI != ArgE; ++ArgI) |
| 5857 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 5858 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5859 | GEN_ERROR("Invalid number of parameters detected"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5860 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5861 | // Create the call node |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5862 | CallInst *CI = new CallInst(V, &Args[0], Args.size()); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5863 | CI->setTailCall((yyvsp[(1) - (8)].BoolVal)); |
| 5864 | CI->setCallingConv((yyvsp[(2) - (8)].UIntVal)); |
| 5865 | (yyval.InstVal) = CI; |
| 5866 | delete (yyvsp[(6) - (8)].ValueRefList); |
| 5867 | delete (yyvsp[(3) - (8)].TypeVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5868 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5869 | ;} |
| 5870 | break; |
| 5871 | |
| 5872 | case 284: |
| 5873 | #line 2927 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5874 | { |
| 5875 | (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5876 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5877 | ;} |
| 5878 | break; |
| 5879 | |
| 5880 | case 285: |
| 5881 | #line 2932 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5882 | { |
| 5883 | (yyval.BoolVal) = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5884 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5885 | ;} |
| 5886 | break; |
| 5887 | |
| 5888 | case 286: |
| 5889 | #line 2936 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5890 | { |
| 5891 | (yyval.BoolVal) = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5892 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5893 | ;} |
| 5894 | break; |
| 5895 | |
| 5896 | case 287: |
| 5897 | #line 2943 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5898 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5899 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5900 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription()); |
| 5901 | (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal)); |
| 5902 | delete (yyvsp[(2) - (3)].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5903 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5904 | ;} |
| 5905 | break; |
| 5906 | |
| 5907 | case 288: |
| 5908 | #line 2950 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5909 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5910 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5911 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription()); |
| 5912 | Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5913 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5914 | (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal)); |
| 5915 | delete (yyvsp[(2) - (6)].TypeVal); |
| 5916 | ;} |
| 5917 | break; |
| 5918 | |
| 5919 | case 289: |
| 5920 | #line 2958 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5921 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5922 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5923 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription()); |
| 5924 | (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal)); |
| 5925 | delete (yyvsp[(2) - (3)].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5926 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5927 | ;} |
| 5928 | break; |
| 5929 | |
| 5930 | case 290: |
| 5931 | #line 2965 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5932 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5933 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5934 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription()); |
| 5935 | Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5936 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5937 | (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal)); |
| 5938 | delete (yyvsp[(2) - (6)].TypeVal); |
| 5939 | ;} |
| 5940 | break; |
| 5941 | |
| 5942 | case 291: |
| 5943 | #line 2973 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5944 | { |
| 5945 | if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType())) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5946 | GEN_ERROR("Trying to free nonpointer type " + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5947 | (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + ""); |
| 5948 | (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5949 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5950 | ;} |
| 5951 | break; |
| 5952 | |
| 5953 | case 292: |
| 5954 | #line 2981 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5955 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5956 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5957 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription()); |
| 5958 | if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5959 | GEN_ERROR("Can't load from nonpointer type: " + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5960 | (*(yyvsp[(3) - (5)].TypeVal))->getDescription()); |
| 5961 | if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType()) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5962 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5963 | (*(yyvsp[(3) - (5)].TypeVal))->getDescription()); |
| 5964 | Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5965 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5966 | (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal)); |
| 5967 | delete (yyvsp[(3) - (5)].TypeVal); |
| 5968 | ;} |
| 5969 | break; |
| 5970 | |
| 5971 | case 293: |
| 5972 | #line 2995 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5973 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5974 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5975 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription()); |
| 5976 | const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get()); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5977 | if (!PT) |
| 5978 | GEN_ERROR("Can't store to a nonpointer type: " + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5979 | (*(yyvsp[(5) - (7)].TypeVal))->getDescription()); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5980 | const Type *ElTy = PT->getElementType(); |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5981 | if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType()) |
| 5982 | GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() + |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5983 | "' into space of type '" + ElTy->getDescription() + "'"); |
| 5984 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5985 | Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5986 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5987 | (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal)); |
| 5988 | delete (yyvsp[(5) - (7)].TypeVal); |
| 5989 | ;} |
| 5990 | break; |
| 5991 | |
| 5992 | case 294: |
| 5993 | #line 3012 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
| 5994 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5995 | if (!UpRefs.empty()) |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5996 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription()); |
| 5997 | if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5998 | GEN_ERROR("getelementptr insn requires pointer operand"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5999 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6000 | if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), &(*(yyvsp[(4) - (4)].ValueList))[0], (yyvsp[(4) - (4)].ValueList)->size(), true)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6001 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6002 | (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'"); |
| 6003 | Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6004 | CHECK_FOR_ERROR |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6005 | (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[(4) - (4)].ValueList))[0], (yyvsp[(4) - (4)].ValueList)->size()); |
| 6006 | delete (yyvsp[(2) - (4)].TypeVal); |
| 6007 | delete (yyvsp[(4) - (4)].ValueList); |
| 6008 | ;} |
| 6009 | break; |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 6010 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6011 | |
| 6012 | /* Line 1267 of yacc.c. */ |
| 6013 | #line 6014 "llvmAsmParser.tab.c" |
| 6014 | default: break; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 6015 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6016 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); |
| 6017 | |
| 6018 | YYPOPSTACK (yylen); |
| 6019 | yylen = 0; |
| 6020 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6021 | |
| 6022 | *++yyvsp = yyval; |
| 6023 | |
| 6024 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6025 | /* Now `shift' the result of the reduction. Determine what state |
| 6026 | that goes to, based on the state we popped back to and the rule |
| 6027 | number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6028 | |
| 6029 | yyn = yyr1[yyn]; |
| 6030 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6031 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 6032 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6033 | yystate = yytable[yystate]; |
| 6034 | else |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6035 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6036 | |
| 6037 | goto yynewstate; |
| 6038 | |
| 6039 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6040 | /*------------------------------------. |
| 6041 | | yyerrlab -- here on detecting error | |
| 6042 | `------------------------------------*/ |
| 6043 | yyerrlab: |
| 6044 | /* If not already recovering from an error, report this error. */ |
| 6045 | if (!yyerrstatus) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6046 | { |
| 6047 | ++yynerrs; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6048 | #if ! YYERROR_VERBOSE |
| 6049 | yyerror (YY_("syntax error")); |
| 6050 | #else |
| 6051 | { |
| 6052 | YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); |
| 6053 | if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) |
| 6054 | { |
| 6055 | YYSIZE_T yyalloc = 2 * yysize; |
| 6056 | if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) |
| 6057 | yyalloc = YYSTACK_ALLOC_MAXIMUM; |
| 6058 | if (yymsg != yymsgbuf) |
| 6059 | YYSTACK_FREE (yymsg); |
| 6060 | yymsg = (char *) YYSTACK_ALLOC (yyalloc); |
| 6061 | if (yymsg) |
| 6062 | yymsg_alloc = yyalloc; |
| 6063 | else |
| 6064 | { |
| 6065 | yymsg = yymsgbuf; |
| 6066 | yymsg_alloc = sizeof yymsgbuf; |
| 6067 | } |
| 6068 | } |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 6069 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6070 | if (0 < yysize && yysize <= yymsg_alloc) |
| 6071 | { |
| 6072 | (void) yysyntax_error (yymsg, yystate, yychar); |
| 6073 | yyerror (yymsg); |
| 6074 | } |
| 6075 | else |
| 6076 | { |
| 6077 | yyerror (YY_("syntax error")); |
| 6078 | if (yysize != 0) |
| 6079 | goto yyexhaustedlab; |
| 6080 | } |
| 6081 | } |
| 6082 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6083 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 6084 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6085 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 6086 | |
| 6087 | if (yyerrstatus == 3) |
| 6088 | { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6089 | /* If just tried and failed to reuse look-ahead token after an |
| 6090 | error, discard it. */ |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 6091 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6092 | if (yychar <= YYEOF) |
| 6093 | { |
| 6094 | /* Return failure if at end of input. */ |
| 6095 | if (yychar == YYEOF) |
| 6096 | YYABORT; |
| 6097 | } |
| 6098 | else |
| 6099 | { |
| 6100 | yydestruct ("Error: discarding", |
| 6101 | yytoken, &yylval); |
| 6102 | yychar = YYEMPTY; |
| 6103 | } |
| 6104 | } |
| 6105 | |
| 6106 | /* Else will try to reuse look-ahead token after shifting the error |
| 6107 | token. */ |
| 6108 | goto yyerrlab1; |
| 6109 | |
| 6110 | |
| 6111 | /*---------------------------------------------------. |
| 6112 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 6113 | `---------------------------------------------------*/ |
| 6114 | yyerrorlab: |
| 6115 | |
| 6116 | /* Pacify compilers like GCC when the user code never invokes |
| 6117 | YYERROR and the label yyerrorlab therefore never appears in user |
| 6118 | code. */ |
| 6119 | if (/*CONSTCOND*/ 0) |
| 6120 | goto yyerrorlab; |
| 6121 | |
| 6122 | /* Do not reclaim the symbols of the rule which action triggered |
| 6123 | this YYERROR. */ |
| 6124 | YYPOPSTACK (yylen); |
| 6125 | yylen = 0; |
| 6126 | YY_STACK_PRINT (yyss, yyssp); |
| 6127 | yystate = *yyssp; |
| 6128 | goto yyerrlab1; |
| 6129 | |
| 6130 | |
| 6131 | /*-------------------------------------------------------------. |
| 6132 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 6133 | `-------------------------------------------------------------*/ |
| 6134 | yyerrlab1: |
| 6135 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 6136 | |
| 6137 | for (;;) |
| 6138 | { |
| 6139 | yyn = yypact[yystate]; |
| 6140 | if (yyn != YYPACT_NINF) |
| 6141 | { |
| 6142 | yyn += YYTERROR; |
| 6143 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 6144 | { |
| 6145 | yyn = yytable[yyn]; |
| 6146 | if (0 < yyn) |
| 6147 | break; |
| 6148 | } |
| 6149 | } |
| 6150 | |
| 6151 | /* Pop the current state because it cannot handle the error token. */ |
| 6152 | if (yyssp == yyss) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6153 | YYABORT; |
| 6154 | |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 6155 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6156 | yydestruct ("Error: popping", |
| 6157 | yystos[yystate], yyvsp); |
| 6158 | YYPOPSTACK (1); |
| 6159 | yystate = *yyssp; |
| 6160 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6161 | } |
| 6162 | |
| 6163 | if (yyn == YYFINAL) |
| 6164 | YYACCEPT; |
| 6165 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6166 | *++yyvsp = yylval; |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6167 | |
| 6168 | |
| 6169 | /* Shift the error token. */ |
| 6170 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 6171 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6172 | yystate = yyn; |
| 6173 | goto yynewstate; |
| 6174 | |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 6175 | |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6176 | /*-------------------------------------. |
| 6177 | | yyacceptlab -- YYACCEPT comes here. | |
| 6178 | `-------------------------------------*/ |
| 6179 | yyacceptlab: |
| 6180 | yyresult = 0; |
| 6181 | goto yyreturn; |
| 6182 | |
| 6183 | /*-----------------------------------. |
| 6184 | | yyabortlab -- YYABORT comes here. | |
| 6185 | `-----------------------------------*/ |
| 6186 | yyabortlab: |
| 6187 | yyresult = 1; |
| 6188 | goto yyreturn; |
| 6189 | |
| 6190 | #ifndef yyoverflow |
| 6191 | /*-------------------------------------------------. |
| 6192 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 6193 | `-------------------------------------------------*/ |
| 6194 | yyexhaustedlab: |
| 6195 | yyerror (YY_("memory exhausted")); |
| 6196 | yyresult = 2; |
| 6197 | /* Fall through. */ |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 6198 | #endif |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6199 | |
| 6200 | yyreturn: |
| 6201 | if (yychar != YYEOF && yychar != YYEMPTY) |
| 6202 | yydestruct ("Cleanup: discarding lookahead", |
| 6203 | yytoken, &yylval); |
| 6204 | /* Do not reclaim the symbols of the rule which action triggered |
| 6205 | this YYABORT or YYACCEPT. */ |
| 6206 | YYPOPSTACK (yylen); |
| 6207 | YY_STACK_PRINT (yyss, yyssp); |
| 6208 | while (yyssp != yyss) |
| 6209 | { |
| 6210 | yydestruct ("Cleanup: popping", |
| 6211 | yystos[*yyssp], yyvsp); |
| 6212 | YYPOPSTACK (1); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 6213 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6214 | #ifndef yyoverflow |
| 6215 | if (yyss != yyssa) |
| 6216 | YYSTACK_FREE (yyss); |
| 6217 | #endif |
| 6218 | #if YYERROR_VERBOSE |
| 6219 | if (yymsg != yymsgbuf) |
| 6220 | YYSTACK_FREE (yymsg); |
| 6221 | #endif |
| 6222 | /* Make sure YYID is used. */ |
| 6223 | return YYID (yyresult); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6224 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6225 | |
| 6226 | |
| 6227 | #line 3029 "/home/asl/proj/llvm/src/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6228 | |
| 6229 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6230 | // common code from the two 'RunVMAsmParser' functions |
| 6231 | static Module* RunParser(Module * M) { |
| 6232 | |
| 6233 | llvmAsmlineno = 1; // Reset the current line number... |
| 6234 | CurModule.CurrentModule = M; |
| 6235 | #if YYDEBUG |
| 6236 | yydebug = Debug; |
| 6237 | #endif |
| 6238 | |
| 6239 | // Check to make sure the parser succeeded |
| 6240 | if (yyparse()) { |
| 6241 | if (ParserResult) |
| 6242 | delete ParserResult; |
| 6243 | return 0; |
| 6244 | } |
| 6245 | |
Reid Spencer | 0d60b5a | 2007-03-30 01:37:39 +0000 | [diff] [blame] | 6246 | // Emit an error if there are any unresolved types left. |
| 6247 | if (!CurModule.LateResolveTypes.empty()) { |
| 6248 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 6249 | if (DID.Type == ValID::LocalName) { |
| 6250 | GenerateError("Undefined type remains at eof: '"+DID.getName() + "'"); |
| 6251 | } else { |
| 6252 | GenerateError("Undefined type remains at eof: #" + itostr(DID.Num)); |
| 6253 | } |
| 6254 | if (ParserResult) |
| 6255 | delete ParserResult; |
| 6256 | return 0; |
| 6257 | } |
| 6258 | |
| 6259 | // Emit an error if there are any unresolved values left. |
| 6260 | if (!CurModule.LateResolveValues.empty()) { |
| 6261 | Value *V = CurModule.LateResolveValues.back(); |
| 6262 | std::map<Value*, std::pair<ValID, int> >::iterator I = |
| 6263 | CurModule.PlaceHolderInfo.find(V); |
| 6264 | |
| 6265 | if (I != CurModule.PlaceHolderInfo.end()) { |
| 6266 | ValID &DID = I->second.first; |
| 6267 | if (DID.Type == ValID::LocalName) { |
| 6268 | GenerateError("Undefined value remains at eof: "+DID.getName() + "'"); |
| 6269 | } else { |
| 6270 | GenerateError("Undefined value remains at eof: #" + itostr(DID.Num)); |
| 6271 | } |
| 6272 | if (ParserResult) |
| 6273 | delete ParserResult; |
| 6274 | return 0; |
| 6275 | } |
| 6276 | } |
| 6277 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6278 | // Check to make sure that parsing produced a result |
| 6279 | if (!ParserResult) |
| 6280 | return 0; |
| 6281 | |
| 6282 | // Reset ParserResult variable while saving its value for the result. |
| 6283 | Module *Result = ParserResult; |
| 6284 | ParserResult = 0; |
| 6285 | |
| 6286 | return Result; |
| 6287 | } |
| 6288 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6289 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 6290 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 6291 | // TODO: column number in exception |
| 6292 | if (TheParseError) |
| 6293 | TheParseError->setError(CurFilename, message, LineNo); |
| 6294 | TriggerError = 1; |
| 6295 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6296 | |
| 6297 | int yyerror(const char *ErrorMsg) { |
| 6298 | std::string where |
| 6299 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 6300 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 6301 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 6302 | if (yychar != YYEMPTY && yychar != 0) |
| 6303 | errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+ |
| 6304 | "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6305 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6306 | return 0; |
| 6307 | } |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 6308 | |