Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +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 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3 | /* Skeleton implementation for Bison's Yacc-like parsers in C |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +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 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +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 |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 63 | #define yylex llvmAsmlex |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 64 | #define yyerror llvmAsmerror |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +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 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +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 | X86_FP80 = 269, |
| 89 | FP128 = 270, |
| 90 | PPC_FP128 = 271, |
| 91 | LABEL = 272, |
| 92 | TYPE = 273, |
| 93 | LOCALVAR = 274, |
| 94 | GLOBALVAR = 275, |
| 95 | LABELSTR = 276, |
| 96 | STRINGCONSTANT = 277, |
| 97 | ATSTRINGCONSTANT = 278, |
| 98 | PCTSTRINGCONSTANT = 279, |
| 99 | ZEROINITIALIZER = 280, |
| 100 | TRUETOK = 281, |
| 101 | FALSETOK = 282, |
| 102 | BEGINTOK = 283, |
| 103 | ENDTOK = 284, |
| 104 | DECLARE = 285, |
| 105 | DEFINE = 286, |
| 106 | GLOBAL = 287, |
| 107 | CONSTANT = 288, |
| 108 | SECTION = 289, |
| 109 | ALIAS = 290, |
| 110 | VOLATILE = 291, |
| 111 | THREAD_LOCAL = 292, |
| 112 | TO = 293, |
| 113 | DOTDOTDOT = 294, |
| 114 | NULL_TOK = 295, |
| 115 | UNDEF = 296, |
| 116 | INTERNAL = 297, |
| 117 | LINKONCE = 298, |
| 118 | WEAK = 299, |
| 119 | APPENDING = 300, |
| 120 | DLLIMPORT = 301, |
| 121 | DLLEXPORT = 302, |
| 122 | EXTERN_WEAK = 303, |
| 123 | OPAQUE = 304, |
| 124 | EXTERNAL = 305, |
| 125 | TARGET = 306, |
| 126 | TRIPLE = 307, |
| 127 | ALIGN = 308, |
| 128 | ADDRSPACE = 309, |
| 129 | DEPLIBS = 310, |
| 130 | CALL = 311, |
| 131 | TAIL = 312, |
| 132 | ASM_TOK = 313, |
| 133 | MODULE = 314, |
| 134 | SIDEEFFECT = 315, |
| 135 | CC_TOK = 316, |
| 136 | CCC_TOK = 317, |
| 137 | FASTCC_TOK = 318, |
| 138 | COLDCC_TOK = 319, |
| 139 | X86_STDCALLCC_TOK = 320, |
| 140 | X86_FASTCALLCC_TOK = 321, |
| 141 | DATALAYOUT = 322, |
| 142 | RET = 323, |
| 143 | BR = 324, |
| 144 | SWITCH = 325, |
| 145 | INVOKE = 326, |
| 146 | UNWIND = 327, |
| 147 | UNREACHABLE = 328, |
| 148 | ADD = 329, |
| 149 | SUB = 330, |
| 150 | MUL = 331, |
| 151 | UDIV = 332, |
| 152 | SDIV = 333, |
| 153 | FDIV = 334, |
| 154 | UREM = 335, |
| 155 | SREM = 336, |
| 156 | FREM = 337, |
| 157 | AND = 338, |
| 158 | OR = 339, |
| 159 | XOR = 340, |
| 160 | SHL = 341, |
| 161 | LSHR = 342, |
| 162 | ASHR = 343, |
| 163 | ICMP = 344, |
| 164 | FCMP = 345, |
| 165 | EQ = 346, |
| 166 | NE = 347, |
| 167 | SLT = 348, |
| 168 | SGT = 349, |
| 169 | SLE = 350, |
| 170 | SGE = 351, |
| 171 | ULT = 352, |
| 172 | UGT = 353, |
| 173 | ULE = 354, |
| 174 | UGE = 355, |
| 175 | OEQ = 356, |
| 176 | ONE = 357, |
| 177 | OLT = 358, |
| 178 | OGT = 359, |
| 179 | OLE = 360, |
| 180 | OGE = 361, |
| 181 | ORD = 362, |
| 182 | UNO = 363, |
| 183 | UEQ = 364, |
| 184 | UNE = 365, |
| 185 | MALLOC = 366, |
| 186 | ALLOCA = 367, |
| 187 | FREE = 368, |
| 188 | LOAD = 369, |
| 189 | STORE = 370, |
| 190 | GETELEMENTPTR = 371, |
| 191 | TRUNC = 372, |
| 192 | ZEXT = 373, |
| 193 | SEXT = 374, |
| 194 | FPTRUNC = 375, |
| 195 | FPEXT = 376, |
| 196 | BITCAST = 377, |
| 197 | UITOFP = 378, |
| 198 | SITOFP = 379, |
| 199 | FPTOUI = 380, |
| 200 | FPTOSI = 381, |
| 201 | INTTOPTR = 382, |
| 202 | PTRTOINT = 383, |
| 203 | PHI_TOK = 384, |
| 204 | SELECT = 385, |
| 205 | VAARG = 386, |
| 206 | EXTRACTELEMENT = 387, |
| 207 | INSERTELEMENT = 388, |
| 208 | SHUFFLEVECTOR = 389, |
| 209 | SIGNEXT = 390, |
| 210 | ZEROEXT = 391, |
| 211 | NORETURN = 392, |
| 212 | INREG = 393, |
| 213 | SRET = 394, |
| 214 | NOUNWIND = 395, |
| 215 | NOALIAS = 396, |
| 216 | BYVAL = 397, |
| 217 | NEST = 398, |
| 218 | READNONE = 399, |
| 219 | READONLY = 400, |
| 220 | GC = 401, |
| 221 | DEFAULT = 402, |
| 222 | HIDDEN = 403, |
| 223 | PROTECTED = 404 |
| 224 | }; |
| 225 | #endif |
| 226 | /* Tokens. */ |
| 227 | #define ESINT64VAL 258 |
| 228 | #define EUINT64VAL 259 |
| 229 | #define ESAPINTVAL 260 |
| 230 | #define EUAPINTVAL 261 |
| 231 | #define LOCALVAL_ID 262 |
| 232 | #define GLOBALVAL_ID 263 |
| 233 | #define FPVAL 264 |
| 234 | #define VOID 265 |
| 235 | #define INTTYPE 266 |
| 236 | #define FLOAT 267 |
| 237 | #define DOUBLE 268 |
| 238 | #define X86_FP80 269 |
| 239 | #define FP128 270 |
| 240 | #define PPC_FP128 271 |
| 241 | #define LABEL 272 |
| 242 | #define TYPE 273 |
| 243 | #define LOCALVAR 274 |
| 244 | #define GLOBALVAR 275 |
| 245 | #define LABELSTR 276 |
| 246 | #define STRINGCONSTANT 277 |
| 247 | #define ATSTRINGCONSTANT 278 |
| 248 | #define PCTSTRINGCONSTANT 279 |
| 249 | #define ZEROINITIALIZER 280 |
| 250 | #define TRUETOK 281 |
| 251 | #define FALSETOK 282 |
| 252 | #define BEGINTOK 283 |
| 253 | #define ENDTOK 284 |
| 254 | #define DECLARE 285 |
| 255 | #define DEFINE 286 |
| 256 | #define GLOBAL 287 |
| 257 | #define CONSTANT 288 |
| 258 | #define SECTION 289 |
| 259 | #define ALIAS 290 |
| 260 | #define VOLATILE 291 |
| 261 | #define THREAD_LOCAL 292 |
| 262 | #define TO 293 |
| 263 | #define DOTDOTDOT 294 |
| 264 | #define NULL_TOK 295 |
| 265 | #define UNDEF 296 |
| 266 | #define INTERNAL 297 |
| 267 | #define LINKONCE 298 |
| 268 | #define WEAK 299 |
| 269 | #define APPENDING 300 |
| 270 | #define DLLIMPORT 301 |
| 271 | #define DLLEXPORT 302 |
| 272 | #define EXTERN_WEAK 303 |
| 273 | #define OPAQUE 304 |
| 274 | #define EXTERNAL 305 |
| 275 | #define TARGET 306 |
| 276 | #define TRIPLE 307 |
| 277 | #define ALIGN 308 |
| 278 | #define ADDRSPACE 309 |
| 279 | #define DEPLIBS 310 |
| 280 | #define CALL 311 |
| 281 | #define TAIL 312 |
| 282 | #define ASM_TOK 313 |
| 283 | #define MODULE 314 |
| 284 | #define SIDEEFFECT 315 |
| 285 | #define CC_TOK 316 |
| 286 | #define CCC_TOK 317 |
| 287 | #define FASTCC_TOK 318 |
| 288 | #define COLDCC_TOK 319 |
| 289 | #define X86_STDCALLCC_TOK 320 |
| 290 | #define X86_FASTCALLCC_TOK 321 |
| 291 | #define DATALAYOUT 322 |
| 292 | #define RET 323 |
| 293 | #define BR 324 |
| 294 | #define SWITCH 325 |
| 295 | #define INVOKE 326 |
| 296 | #define UNWIND 327 |
| 297 | #define UNREACHABLE 328 |
| 298 | #define ADD 329 |
| 299 | #define SUB 330 |
| 300 | #define MUL 331 |
| 301 | #define UDIV 332 |
| 302 | #define SDIV 333 |
| 303 | #define FDIV 334 |
| 304 | #define UREM 335 |
| 305 | #define SREM 336 |
| 306 | #define FREM 337 |
| 307 | #define AND 338 |
| 308 | #define OR 339 |
| 309 | #define XOR 340 |
| 310 | #define SHL 341 |
| 311 | #define LSHR 342 |
| 312 | #define ASHR 343 |
| 313 | #define ICMP 344 |
| 314 | #define FCMP 345 |
| 315 | #define EQ 346 |
| 316 | #define NE 347 |
| 317 | #define SLT 348 |
| 318 | #define SGT 349 |
| 319 | #define SLE 350 |
| 320 | #define SGE 351 |
| 321 | #define ULT 352 |
| 322 | #define UGT 353 |
| 323 | #define ULE 354 |
| 324 | #define UGE 355 |
| 325 | #define OEQ 356 |
| 326 | #define ONE 357 |
| 327 | #define OLT 358 |
| 328 | #define OGT 359 |
| 329 | #define OLE 360 |
| 330 | #define OGE 361 |
| 331 | #define ORD 362 |
| 332 | #define UNO 363 |
| 333 | #define UEQ 364 |
| 334 | #define UNE 365 |
| 335 | #define MALLOC 366 |
| 336 | #define ALLOCA 367 |
| 337 | #define FREE 368 |
| 338 | #define LOAD 369 |
| 339 | #define STORE 370 |
| 340 | #define GETELEMENTPTR 371 |
| 341 | #define TRUNC 372 |
| 342 | #define ZEXT 373 |
| 343 | #define SEXT 374 |
| 344 | #define FPTRUNC 375 |
| 345 | #define FPEXT 376 |
| 346 | #define BITCAST 377 |
| 347 | #define UITOFP 378 |
| 348 | #define SITOFP 379 |
| 349 | #define FPTOUI 380 |
| 350 | #define FPTOSI 381 |
| 351 | #define INTTOPTR 382 |
| 352 | #define PTRTOINT 383 |
| 353 | #define PHI_TOK 384 |
| 354 | #define SELECT 385 |
| 355 | #define VAARG 386 |
| 356 | #define EXTRACTELEMENT 387 |
| 357 | #define INSERTELEMENT 388 |
| 358 | #define SHUFFLEVECTOR 389 |
| 359 | #define SIGNEXT 390 |
| 360 | #define ZEROEXT 391 |
| 361 | #define NORETURN 392 |
| 362 | #define INREG 393 |
| 363 | #define SRET 394 |
| 364 | #define NOUNWIND 395 |
| 365 | #define NOALIAS 396 |
| 366 | #define BYVAL 397 |
| 367 | #define NEST 398 |
| 368 | #define READNONE 399 |
| 369 | #define READONLY 400 |
| 370 | #define GC 401 |
| 371 | #define DEFAULT 402 |
| 372 | #define HIDDEN 403 |
| 373 | #define PROTECTED 404 |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | /* Copy the first part of user declarations. */ |
| 379 | #line 14 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 380 | |
| 381 | #include "ParserInternals.h" |
| 382 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 383 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 384 | #include "llvm/Instructions.h" |
| 385 | #include "llvm/Module.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 386 | #include "llvm/ValueSymbolTable.h" |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 387 | #include "llvm/AutoUpgrade.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 388 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 389 | #include "llvm/Support/CommandLine.h" |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 390 | #include "llvm/ADT/SmallVector.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 391 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 392 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 481169e | 2006-12-01 00:33:46 +0000 | [diff] [blame] | 393 | #include "llvm/Support/Streams.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 394 | #include <algorithm> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 395 | #include <list> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 396 | #include <map> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 397 | #include <utility> |
| 398 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 399 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 400 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 401 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 402 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 403 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 404 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 405 | // GenerateError are made from inside productions and they must simulate the |
| 406 | // previous exception behavior by exiting the production immediately. We have |
| 407 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 408 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 409 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 410 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 411 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 412 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 413 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 414 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 415 | int yylex(); // declaration" of xxx warnings. |
| 416 | int yyparse(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 417 | using namespace llvm; |
| 418 | |
| 419 | static Module *ParserResult; |
| 420 | |
| 421 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 422 | // relating to upreferences in the input stream. |
| 423 | // |
| 424 | //#define DEBUG_UPREFS 1 |
| 425 | #ifdef DEBUG_UPREFS |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 426 | #define UR_OUT(X) cerr << X |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 427 | #else |
| 428 | #define UR_OUT(X) |
| 429 | #endif |
| 430 | |
| 431 | #define YYERROR_VERBOSE 1 |
| 432 | |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 433 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 434 | |
| 435 | |
| 436 | // This contains info used when building the body of a function. It is |
| 437 | // destroyed when the function is completed. |
| 438 | // |
| 439 | typedef std::vector<Value *> ValueList; // Numbered defs |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 440 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 441 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 442 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 443 | |
| 444 | static struct PerModuleInfo { |
| 445 | Module *CurrentModule; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 446 | ValueList Values; // Module level numbered definitions |
| 447 | ValueList LateResolveValues; |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 448 | std::vector<PATypeHolder> Types; |
| 449 | std::map<ValID, PATypeHolder> LateResolveTypes; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 450 | |
| 451 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 452 | /// 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] | 453 | /// that we can resolve them later and print error messages as appropriate. |
| 454 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 455 | |
| 456 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 457 | // references to global values. Global values may be referenced before they |
| 458 | // are defined, and if so, the temporary object that they represent is held |
| 459 | // here. This is used for forward references of GlobalValues. |
| 460 | // |
| 461 | typedef std::map<std::pair<const PointerType *, |
| 462 | ValID>, GlobalValue*> GlobalRefsType; |
| 463 | GlobalRefsType GlobalRefs; |
| 464 | |
| 465 | void ModuleDone() { |
| 466 | // If we could not resolve some functions at function compilation time |
| 467 | // (calls to functions before they are defined), resolve them now... Types |
| 468 | // are resolved when the constant pool has been completely parsed. |
| 469 | // |
| 470 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 471 | if (TriggerError) |
| 472 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 473 | |
| 474 | // Check to make sure that all global value forward references have been |
| 475 | // resolved! |
| 476 | // |
| 477 | if (!GlobalRefs.empty()) { |
| 478 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 479 | |
| 480 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 481 | I != E; ++I) { |
| 482 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 483 | I->first.second.getName() + "\n"; |
| 484 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 485 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 486 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 487 | } |
| 488 | |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 489 | // Look for intrinsic functions and CallInst that need to be upgraded |
| 490 | for (Module::iterator FI = CurrentModule->begin(), |
| 491 | FE = CurrentModule->end(); FI != FE; ) |
| 492 | UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove |
| 493 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 494 | Values.clear(); // Clear out function local definitions |
| 495 | Types.clear(); |
| 496 | CurrentModule = 0; |
| 497 | } |
| 498 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 499 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 500 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 501 | // If not, just return null. |
| 502 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 503 | // Check to see if there is a forward reference to this global variable... |
| 504 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 505 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 506 | GlobalValue *Ret = 0; |
| 507 | if (I != GlobalRefs.end()) { |
| 508 | Ret = I->second; |
| 509 | GlobalRefs.erase(I); |
| 510 | } |
| 511 | return Ret; |
| 512 | } |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 513 | |
| 514 | bool TypeIsUnresolved(PATypeHolder* PATy) { |
| 515 | // If it isn't abstract, its resolved |
| 516 | const Type* Ty = PATy->get(); |
| 517 | if (!Ty->isAbstract()) |
| 518 | return false; |
| 519 | // Traverse the type looking for abstract types. If it isn't abstract then |
| 520 | // we don't need to traverse that leg of the type. |
| 521 | std::vector<const Type*> WorkList, SeenList; |
| 522 | WorkList.push_back(Ty); |
| 523 | while (!WorkList.empty()) { |
| 524 | const Type* Ty = WorkList.back(); |
| 525 | SeenList.push_back(Ty); |
| 526 | WorkList.pop_back(); |
| 527 | if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) { |
| 528 | // Check to see if this is an unresolved type |
| 529 | std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin(); |
| 530 | std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end(); |
| 531 | for ( ; I != E; ++I) { |
| 532 | if (I->second.get() == OpTy) |
| 533 | return true; |
| 534 | } |
| 535 | } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) { |
| 536 | const Type* TheTy = SeqTy->getElementType(); |
| 537 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 538 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 539 | E = SeenList.end(); |
| 540 | for ( ; I != E; ++I) |
| 541 | if (*I == TheTy) |
| 542 | break; |
| 543 | if (I == E) |
| 544 | WorkList.push_back(TheTy); |
| 545 | } |
| 546 | } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) { |
| 547 | for (unsigned i = 0; i < StrTy->getNumElements(); ++i) { |
| 548 | const Type* TheTy = StrTy->getElementType(i); |
| 549 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 550 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 551 | E = SeenList.end(); |
| 552 | for ( ; I != E; ++I) |
| 553 | if (*I == TheTy) |
| 554 | break; |
| 555 | if (I == E) |
| 556 | WorkList.push_back(TheTy); |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | } |
| 561 | return false; |
| 562 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 563 | } CurModule; |
| 564 | |
| 565 | static struct PerFunctionInfo { |
| 566 | Function *CurrentFunction; // Pointer to current function being created |
| 567 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 568 | ValueList Values; // Keep track of #'d definitions |
| 569 | unsigned NextValNum; |
| 570 | ValueList LateResolveValues; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 571 | bool isDeclare; // Is this function a forward declararation? |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 572 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 573 | GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 574 | |
| 575 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 576 | /// track of them here. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 577 | std::map<ValID, BasicBlock*> BBForwardRefs; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 578 | |
| 579 | inline PerFunctionInfo() { |
| 580 | CurrentFunction = 0; |
| 581 | isDeclare = false; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 582 | Linkage = GlobalValue::ExternalLinkage; |
| 583 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | inline void FunctionStart(Function *M) { |
| 587 | CurrentFunction = M; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 588 | NextValNum = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | void FunctionDone() { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 592 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 593 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 594 | GenerateError("Undefined reference to label " + |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 595 | BBForwardRefs.begin()->second->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 596 | return; |
| 597 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 598 | |
| 599 | // Resolve all forward references now. |
| 600 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 601 | |
| 602 | Values.clear(); // Clear out function local definitions |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 603 | BBForwardRefs.clear(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 604 | CurrentFunction = 0; |
| 605 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 606 | Linkage = GlobalValue::ExternalLinkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 607 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 608 | } |
| 609 | } CurFun; // Info for the current function... |
| 610 | |
| 611 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 612 | |
| 613 | |
| 614 | //===----------------------------------------------------------------------===// |
| 615 | // Code to handle definitions of all the types |
| 616 | //===----------------------------------------------------------------------===// |
| 617 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 618 | static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) { |
| 619 | // Things that have names or are void typed don't get slot numbers |
| 620 | if (V->hasName() || (V->getType() == Type::VoidTy)) |
| 621 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 622 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 623 | // In the case of function values, we have to allow for the forward reference |
| 624 | // of basic blocks, which are included in the numbering. Consequently, we keep |
| 625 | // track of the next insertion location with NextValNum. When a BB gets |
| 626 | // inserted, it could change the size of the CurFun.Values vector. |
| 627 | if (&ValueTab == &CurFun.Values) { |
| 628 | if (ValueTab.size() <= CurFun.NextValNum) |
| 629 | ValueTab.resize(CurFun.NextValNum+1); |
| 630 | ValueTab[CurFun.NextValNum++] = V; |
| 631 | return; |
| 632 | } |
| 633 | // For all other lists, its okay to just tack it on the back of the vector. |
| 634 | ValueTab.push_back(V); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 638 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 639 | case ValID::LocalID: // Is it a numbered definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 640 | // Module constants occupy the lowest numbered slots... |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 641 | if (D.Num < CurModule.Types.size()) |
| 642 | return CurModule.Types[D.Num]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 643 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 644 | case ValID::LocalName: // Is it a named definition? |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 645 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 646 | D.destroy(); // Free old strdup'd memory... |
| 647 | return N; |
| 648 | } |
| 649 | break; |
| 650 | default: |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 651 | GenerateError("Internal parser error: Invalid symbol type reference"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 652 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | // If we reached here, we referenced either a symbol that we don't know about |
| 656 | // or an id number that hasn't been read yet. We may be referencing something |
| 657 | // forward, so just create an entry to be resolved later and get to it... |
| 658 | // |
| 659 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 660 | |
| 661 | |
| 662 | if (inFunctionScope()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 663 | if (D.Type == ValID::LocalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 664 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 665 | return 0; |
| 666 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 667 | GenerateError("Reference to an undefined type: #" + utostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 668 | return 0; |
| 669 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 670 | } |
| 671 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 672 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 673 | if (I != CurModule.LateResolveTypes.end()) |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 674 | return I->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 675 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 676 | Type *Typ = OpaqueType::get(); |
| 677 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 678 | return Typ; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 679 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 680 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 681 | // getExistingVal - Look up the value specified by the provided type and |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 682 | // the provided ValID. If the value exists and has already been defined, return |
| 683 | // it. Otherwise return null. |
| 684 | // |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 685 | static Value *getExistingVal(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 686 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 687 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 688 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 689 | return 0; |
| 690 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 691 | |
| 692 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 693 | case ValID::LocalID: { // Is it a numbered definition? |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 694 | // Check that the number is within bounds. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 695 | if (D.Num >= CurFun.Values.size()) |
| 696 | return 0; |
| 697 | Value *Result = CurFun.Values[D.Num]; |
| 698 | if (Ty != Result->getType()) { |
| 699 | GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" + |
| 700 | Result->getType()->getDescription() + "' does not match " |
| 701 | "expected type, '" + Ty->getDescription() + "'"); |
| 702 | return 0; |
| 703 | } |
| 704 | return Result; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 705 | } |
| 706 | case ValID::GlobalID: { // Is it a numbered definition? |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 707 | if (D.Num >= CurModule.Values.size()) |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 708 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 709 | Value *Result = CurModule.Values[D.Num]; |
| 710 | if (Ty != Result->getType()) { |
| 711 | GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" + |
| 712 | Result->getType()->getDescription() + "' does not match " |
| 713 | "expected type, '" + Ty->getDescription() + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 714 | return 0; |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 715 | } |
| 716 | return Result; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 717 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 718 | |
| 719 | case ValID::LocalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 720 | if (!inFunctionScope()) |
| 721 | return 0; |
| 722 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 723 | Value *N = SymTab.lookup(D.getName()); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 724 | if (N == 0) |
| 725 | return 0; |
| 726 | if (N->getType() != Ty) |
| 727 | return 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 728 | |
| 729 | D.destroy(); // Free old strdup'd memory... |
| 730 | return N; |
| 731 | } |
| 732 | case ValID::GlobalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 733 | ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable(); |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 734 | Value *N = SymTab.lookup(D.getName()); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 735 | if (N == 0) |
| 736 | return 0; |
| 737 | if (N->getType() != Ty) |
| 738 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 739 | |
| 740 | D.destroy(); // Free old strdup'd memory... |
| 741 | return N; |
| 742 | } |
| 743 | |
| 744 | // Check to make sure that "Ty" is an integral type, and that our |
| 745 | // value will fit into the specified type... |
| 746 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 747 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 748 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 749 | itostr(D.ConstPool64) + "' is invalid for type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 750 | Ty->getDescription() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 751 | return 0; |
| 752 | } |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 753 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 754 | |
| 755 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 756 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 757 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 758 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 759 | "' is invalid or out of range"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 760 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 761 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | 49d273e | 2007-03-19 20:40:51 +0000 | [diff] [blame] | 762 | return ConstantInt::get(Ty, D.ConstPool64, true); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 763 | } |
| 764 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 765 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 769 | if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 770 | GenerateError("FP constant invalid for type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 771 | return 0; |
| 772 | } |
Dale Johannesen | c72cd7e | 2007-09-11 18:33:39 +0000 | [diff] [blame] | 773 | // Lexer has no type info, so builds all float and double FP constants |
| 774 | // as double. Fix this here. Long double does not need this. |
| 775 | if (&D.ConstPoolFP->getSemantics() == &APFloat::IEEEdouble && |
| 776 | Ty==Type::FloatTy) |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 777 | D.ConstPoolFP->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); |
| 778 | return ConstantFP::get(Ty, *D.ConstPoolFP); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 779 | |
| 780 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 781 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 782 | GenerateError("Cannot create a a non pointer null"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 783 | return 0; |
| 784 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 785 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 786 | |
| 787 | case ValID::ConstUndefVal: // Is it an undef value? |
| 788 | return UndefValue::get(Ty); |
| 789 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 790 | case ValID::ConstZeroVal: // Is it a zero value? |
| 791 | return Constant::getNullValue(Ty); |
| 792 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 793 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 794 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 795 | GenerateError("Constant expression type different from required type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 796 | return 0; |
| 797 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 798 | return D.ConstantValue; |
| 799 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 800 | case ValID::InlineAsmVal: { // Inline asm expression |
| 801 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 802 | const FunctionType *FTy = |
| 803 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 804 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 805 | GenerateError("Invalid type for asm constraint string"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 806 | return 0; |
| 807 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 808 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 809 | D.IAD->HasSideEffects); |
| 810 | D.destroy(); // Free InlineAsmDescriptor. |
| 811 | return IA; |
| 812 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 813 | default: |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 814 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 815 | return 0; |
| 816 | } // End of switch |
| 817 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 818 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 819 | return 0; |
| 820 | } |
| 821 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 822 | // getVal - This function is identical to getExistingVal, except that if a |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 823 | // value is not already defined, it "improvises" by creating a placeholder var |
| 824 | // that looks and acts just like the requested variable. When the value is |
| 825 | // defined later, all uses of the placeholder variable are replaced with the |
| 826 | // real thing. |
| 827 | // |
| 828 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 829 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 830 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 831 | return 0; |
| 832 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 833 | |
| 834 | // See if the value has already been defined. |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 835 | Value *V = getExistingVal(Ty, ID); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 836 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 837 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 838 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 839 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 840 | GenerateError("Invalid use of a composite type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 841 | return 0; |
| 842 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 843 | |
| 844 | // If we reached here, we referenced either a symbol that we don't know about |
| 845 | // or an id number that hasn't been read yet. We may be referencing something |
| 846 | // forward, so just create an entry to be resolved later and get to it... |
| 847 | // |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 848 | switch (ID.Type) { |
| 849 | case ValID::GlobalName: |
Reid Spencer | 9c9b63a | 2007-04-28 16:07:31 +0000 | [diff] [blame] | 850 | case ValID::GlobalID: { |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 851 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 852 | if (!PTy) { |
| 853 | GenerateError("Invalid type for reference to global" ); |
| 854 | return 0; |
| 855 | } |
| 856 | const Type* ElTy = PTy->getElementType(); |
| 857 | if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy)) |
| 858 | V = new Function(FTy, GlobalValue::ExternalLinkage); |
| 859 | else |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 860 | V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage, 0, "", |
| 861 | (Module*)0, false, PTy->getAddressSpace()); |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 862 | break; |
Reid Spencer | 9c9b63a | 2007-04-28 16:07:31 +0000 | [diff] [blame] | 863 | } |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 864 | default: |
| 865 | V = new Argument(Ty); |
| 866 | } |
| 867 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 868 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 869 | // to recycle these things?? |
| 870 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 871 | LLLgetLineNo()))); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 872 | |
| 873 | if (inFunctionScope()) |
| 874 | InsertValue(V, CurFun.LateResolveValues); |
| 875 | else |
| 876 | InsertValue(V, CurModule.LateResolveValues); |
| 877 | return V; |
| 878 | } |
| 879 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 880 | /// defineBBVal - This is a definition of a new basic block with the specified |
| 881 | /// identifier which must be the same as CurFun.NextValNum, if its numeric. |
| 882 | static BasicBlock *defineBBVal(const ValID &ID) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 883 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 884 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 885 | BasicBlock *BB = 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 886 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 887 | // First, see if this was forward referenced |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 888 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 889 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 890 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 891 | BB = BBI->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 892 | // The forward declaration could have been inserted anywhere in the |
| 893 | // function: insert it into the correct place now. |
| 894 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 895 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 896 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 897 | // We're about to erase the entry, save the key so we can clean it up. |
| 898 | ValID Tmp = BBI->first; |
| 899 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 900 | // Erase the forward ref from the map as its no longer "forward" |
| 901 | CurFun.BBForwardRefs.erase(ID); |
| 902 | |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 903 | // The key has been removed from the map but so we don't want to leave |
| 904 | // strdup'd memory around so destroy it too. |
| 905 | Tmp.destroy(); |
| 906 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 907 | // If its a numbered definition, bump the number and set the BB value. |
| 908 | if (ID.Type == ValID::LocalID) { |
| 909 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 910 | InsertValue(BB); |
| 911 | } |
| 912 | |
| 913 | ID.destroy(); |
| 914 | return BB; |
| 915 | } |
| 916 | |
| 917 | // We haven't seen this BB before and its first mention is a definition. |
| 918 | // Just create it and return it. |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 919 | std::string Name (ID.Type == ValID::LocalName ? ID.getName() : ""); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 920 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 921 | if (ID.Type == ValID::LocalID) { |
| 922 | assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); |
| 923 | InsertValue(BB); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 924 | } |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 925 | |
| 926 | ID.destroy(); // Free strdup'd memory |
| 927 | return BB; |
| 928 | } |
| 929 | |
| 930 | /// getBBVal - get an existing BB value or create a forward reference for it. |
| 931 | /// |
| 932 | static BasicBlock *getBBVal(const ValID &ID) { |
| 933 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 934 | |
| 935 | BasicBlock *BB = 0; |
| 936 | |
| 937 | std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID); |
| 938 | if (BBI != CurFun.BBForwardRefs.end()) { |
| 939 | BB = BBI->second; |
| 940 | } if (ID.Type == ValID::LocalName) { |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 941 | std::string Name = ID.getName(); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 942 | Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name); |
| 943 | if (N) |
| 944 | if (N->getType()->getTypeID() == Type::LabelTyID) |
| 945 | BB = cast<BasicBlock>(N); |
| 946 | else |
| 947 | GenerateError("Reference to label '" + Name + "' is actually of type '"+ |
| 948 | N->getType()->getDescription() + "'"); |
| 949 | } else if (ID.Type == ValID::LocalID) { |
| 950 | if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) { |
| 951 | if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID) |
| 952 | BB = cast<BasicBlock>(CurFun.Values[ID.Num]); |
| 953 | else |
| 954 | GenerateError("Reference to label '%" + utostr(ID.Num) + |
| 955 | "' is actually of type '"+ |
| 956 | CurFun.Values[ID.Num]->getType()->getDescription() + "'"); |
| 957 | } |
| 958 | } else { |
| 959 | GenerateError("Illegal label reference " + ID.getName()); |
| 960 | return 0; |
| 961 | } |
| 962 | |
| 963 | // If its already been defined, return it now. |
| 964 | if (BB) { |
| 965 | ID.destroy(); // Free strdup'd memory. |
| 966 | return BB; |
| 967 | } |
| 968 | |
| 969 | // Otherwise, this block has not been seen before, create it. |
| 970 | std::string Name; |
| 971 | if (ID.Type == ValID::LocalName) |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 972 | Name = ID.getName(); |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 973 | BB = new BasicBlock(Name, CurFun.CurrentFunction); |
| 974 | |
| 975 | // Insert it in the forward refs map. |
| 976 | CurFun.BBForwardRefs[ID] = BB; |
| 977 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 978 | return BB; |
| 979 | } |
| 980 | |
| 981 | |
| 982 | //===----------------------------------------------------------------------===// |
| 983 | // Code to handle forward references in instructions |
| 984 | //===----------------------------------------------------------------------===// |
| 985 | // |
| 986 | // This code handles the late binding needed with statements that reference |
| 987 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 988 | // a loop body. |
| 989 | // |
| 990 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 991 | // and back patchs after we are done. |
| 992 | // |
| 993 | |
| 994 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 995 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 996 | // defs now... |
| 997 | // |
| 998 | static void |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 999 | ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1000 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 1001 | while (!LateResolvers.empty()) { |
| 1002 | Value *V = LateResolvers.back(); |
| 1003 | LateResolvers.pop_back(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1004 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 1005 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 1006 | CurModule.PlaceHolderInfo.find(V); |
| 1007 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1008 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 1009 | ValID &DID = PHI->second.first; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1010 | |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 1011 | Value *TheRealValue = getExistingVal(V->getType(), DID); |
| 1012 | if (TriggerError) |
| 1013 | return; |
| 1014 | if (TheRealValue) { |
| 1015 | V->replaceAllUsesWith(TheRealValue); |
| 1016 | delete V; |
| 1017 | CurModule.PlaceHolderInfo.erase(PHI); |
| 1018 | } else if (FutureLateResolvers) { |
| 1019 | // Functions have their unresolved items forwarded to the module late |
| 1020 | // resolver table |
| 1021 | InsertValue(V, *FutureLateResolvers); |
| 1022 | } else { |
| 1023 | if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) { |
| 1024 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
| 1025 | "' of type '" + V->getType()->getDescription() + "'", |
| 1026 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1027 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1028 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 1029 | GenerateError("Reference to an invalid definition: #" + |
| 1030 | itostr(DID.Num) + " of type '" + |
| 1031 | V->getType()->getDescription() + "'", |
| 1032 | PHI->second.second); |
| 1033 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1034 | } |
| 1035 | } |
| 1036 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1037 | LateResolvers.clear(); |
| 1038 | } |
| 1039 | |
| 1040 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 1041 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 1042 | // refering to the number can be resolved. Do this now. |
| 1043 | // |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1044 | static void ResolveTypeTo(std::string *Name, const Type *ToTy) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1045 | ValID D; |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1046 | if (Name) |
| 1047 | D = ValID::createLocalName(*Name); |
| 1048 | else |
| 1049 | D = ValID::createLocalID(CurModule.Types.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1050 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 1051 | std::map<ValID, PATypeHolder>::iterator I = |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1052 | CurModule.LateResolveTypes.find(D); |
| 1053 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 1054 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1055 | CurModule.LateResolveTypes.erase(I); |
| 1056 | } |
| 1057 | } |
| 1058 | |
| 1059 | // setValueName - Set the specified value to the name given. The name may be |
| 1060 | // null potentially, in which case this is a noop. The string passed in is |
| 1061 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 1062 | // |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1063 | static void setValueName(Value *V, std::string *NameStr) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1064 | if (!NameStr) return; |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1065 | std::string Name(*NameStr); // Copy string |
| 1066 | delete NameStr; // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1067 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1068 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1069 | GenerateError("Can't assign name '" + Name+"' to value with void type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1070 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1071 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1072 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 1073 | assert(inFunctionScope() && "Must be in function scope!"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 1074 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 1075 | if (ST.lookup(Name)) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1076 | GenerateError("Redefinition of value '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1077 | V->getType()->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1078 | return; |
| 1079 | } |
| 1080 | |
| 1081 | // Set the name. |
| 1082 | V->setName(Name); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 1086 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1087 | static GlobalVariable * |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1088 | ParseGlobalVariable(std::string *NameStr, |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1089 | GlobalValue::LinkageTypes Linkage, |
| 1090 | GlobalValue::VisibilityTypes Visibility, |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1091 | bool isConstantGlobal, const Type *Ty, |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 1092 | Constant *Initializer, bool IsThreadLocal, |
| 1093 | unsigned AddressSpace = 0) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1094 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1095 | GenerateError("Cannot declare global vars of function type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1096 | return 0; |
| 1097 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1098 | |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 1099 | const PointerType *PTy = PointerType::get(Ty, AddressSpace); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1100 | |
| 1101 | std::string Name; |
| 1102 | if (NameStr) { |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1103 | Name = *NameStr; // Copy string |
| 1104 | delete NameStr; // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1105 | } |
| 1106 | |
| 1107 | // See if this global value was forward referenced. If so, recycle the |
| 1108 | // object. |
| 1109 | ValID ID; |
| 1110 | if (!Name.empty()) { |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1111 | ID = ValID::createGlobalName(Name); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1112 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 1113 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1114 | } |
| 1115 | |
| 1116 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 1117 | // Move the global to the end of the list, from whereever it was |
| 1118 | // previously inserted. |
| 1119 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 1120 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 1121 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 1122 | GV->setInitializer(Initializer); |
| 1123 | GV->setLinkage(Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1124 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1125 | GV->setConstant(isConstantGlobal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 1126 | GV->setThreadLocal(IsThreadLocal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1127 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1128 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1129 | } |
| 1130 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 1131 | // If this global has a name |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1132 | if (!Name.empty()) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 1133 | // if the global we're parsing has an initializer (is a definition) and |
| 1134 | // has external linkage. |
| 1135 | if (Initializer && Linkage != GlobalValue::InternalLinkage) |
| 1136 | // If there is already a global with external linkage with this name |
| 1137 | if (CurModule.CurrentModule->getGlobalVariable(Name, false)) { |
| 1138 | // If we allow this GVar to get created, it will be renamed in the |
| 1139 | // symbol table because it conflicts with an existing GVar. We can't |
| 1140 | // allow redefinition of GVars whose linking indicates that their name |
| 1141 | // must stay the same. Issue the error. |
| 1142 | GenerateError("Redefinition of global variable named '" + Name + |
| 1143 | "' of type '" + Ty->getDescription() + "'"); |
| 1144 | return 0; |
| 1145 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1146 | } |
| 1147 | |
| 1148 | // Otherwise there is no existing GV to use, create one now. |
| 1149 | GlobalVariable *GV = |
| 1150 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 1151 | CurModule.CurrentModule, IsThreadLocal, AddressSpace); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1152 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1153 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1154 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1155 | } |
| 1156 | |
| 1157 | // setTypeName - Set the specified type to the name given. The name may be |
| 1158 | // null potentially, in which case this is a noop. The string passed in is |
| 1159 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 1160 | // |
| 1161 | // This function returns true if the type has already been defined, but is |
| 1162 | // allowed to be redefined in the specified context. If the name is a new name |
| 1163 | // for the type plane, it is inserted and false is returned. |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1164 | static bool setTypeName(const Type *T, std::string *NameStr) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 1165 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1166 | if (NameStr == 0) return false; |
| 1167 | |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1168 | std::string Name(*NameStr); // Copy string |
| 1169 | delete NameStr; // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1170 | |
| 1171 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1172 | if (T == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1173 | GenerateError("Can't assign name '" + Name + "' to the void type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1174 | return false; |
| 1175 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1176 | |
| 1177 | // Set the type name, checking for conflicts as we do so. |
| 1178 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 1179 | |
| 1180 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1181 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 1182 | assert(Existing && "Conflict but no matching type?!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1183 | |
| 1184 | // There is only one case where this is allowed: when we are refining an |
| 1185 | // opaque type. In this case, Existing will be an opaque type. |
| 1186 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1187 | // We ARE replacing an opaque type! |
| 1188 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 1189 | return true; |
| 1190 | } |
| 1191 | |
| 1192 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1193 | // the redefinition is identical to the original. This will be so if |
| 1194 | // Existing and T point to the same Type object. In this one case we |
| 1195 | // allow the equivalent redefinition. |
| 1196 | if (Existing == T) return true; // Yes, it's equal. |
| 1197 | |
| 1198 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 1199 | GenerateError("Redefinition of type named '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1200 | T->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1201 | } |
| 1202 | |
| 1203 | return false; |
| 1204 | } |
| 1205 | |
| 1206 | //===----------------------------------------------------------------------===// |
| 1207 | // Code for handling upreferences in type names... |
| 1208 | // |
| 1209 | |
| 1210 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1211 | // |
| 1212 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1213 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1214 | E) != Ty->subtype_end(); |
| 1215 | } |
| 1216 | |
| 1217 | namespace { |
| 1218 | struct UpRefRecord { |
| 1219 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1220 | // this type is resolved. |
| 1221 | unsigned NestingLevel; |
| 1222 | |
| 1223 | // LastContainedTy - This is the type at the current binding level for the |
| 1224 | // type. Every time we reduce the nesting level, this gets updated. |
| 1225 | const Type *LastContainedTy; |
| 1226 | |
| 1227 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1228 | // represented with. |
| 1229 | OpaqueType *UpRefTy; |
| 1230 | |
| 1231 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 1232 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 1233 | }; |
| 1234 | } |
| 1235 | |
| 1236 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1237 | static std::vector<UpRefRecord> UpRefs; |
| 1238 | |
| 1239 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1240 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1241 | /// currently active types. For each type, if the up reference is contained in |
| 1242 | /// the newly completed type, we decrement the level count. When the level |
| 1243 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1244 | /// thus we can complete the cycle. |
| 1245 | /// |
| 1246 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 1247 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1248 | // nothing to resolve here. |
| 1249 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1250 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1251 | PATypeHolder Ty(ty); |
| 1252 | UR_OUT("Type '" << Ty->getDescription() << |
| 1253 | "' newly formed. Resolving upreferences.\n" << |
| 1254 | UpRefs.size() << " upreferences active!\n"); |
| 1255 | |
| 1256 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1257 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1258 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1259 | // this variable. |
| 1260 | OpaqueType *TypeToResolve = 0; |
| 1261 | |
| 1262 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1263 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1264 | << UpRefs[i].second->getDescription() << ") = " |
| 1265 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1266 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1267 | // Decrement level of upreference |
| 1268 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1269 | UpRefs[i].LastContainedTy = Ty; |
| 1270 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1271 | if (Level == 0) { // Upreference should be resolved! |
| 1272 | if (!TypeToResolve) { |
| 1273 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1274 | } else { |
| 1275 | UR_OUT(" * Resolving upreference for " |
| 1276 | << UpRefs[i].second->getDescription() << "\n"; |
| 1277 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1278 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1279 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1280 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1281 | } |
| 1282 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1283 | --i; // Do not skip the next element... |
| 1284 | } |
| 1285 | } |
| 1286 | } |
| 1287 | |
| 1288 | if (TypeToResolve) { |
| 1289 | UR_OUT(" * Resolving upreference for " |
| 1290 | << UpRefs[i].second->getDescription() << "\n"; |
| 1291 | std::string OldName = TypeToResolve->getDescription()); |
| 1292 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1293 | } |
| 1294 | |
| 1295 | return Ty; |
| 1296 | } |
| 1297 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1298 | //===----------------------------------------------------------------------===// |
| 1299 | // RunVMAsmParser - Define an interface to this parser |
| 1300 | //===----------------------------------------------------------------------===// |
| 1301 | // |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1302 | static Module* RunParser(Module * M); |
| 1303 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 1304 | Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) { |
| 1305 | InitLLLexer(MB); |
| 1306 | Module *M = RunParser(new Module(LLLgetFilename())); |
| 1307 | FreeLexer(); |
| 1308 | return M; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1309 | } |
| 1310 | |
| 1311 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 1312 | |
| 1313 | /* Enabling traces. */ |
| 1314 | #ifndef YYDEBUG |
| 1315 | # define YYDEBUG 0 |
| 1316 | #endif |
| 1317 | |
| 1318 | /* Enabling verbose error messages. */ |
| 1319 | #ifdef YYERROR_VERBOSE |
| 1320 | # undef YYERROR_VERBOSE |
| 1321 | # define YYERROR_VERBOSE 1 |
| 1322 | #else |
| 1323 | # define YYERROR_VERBOSE 0 |
| 1324 | #endif |
| 1325 | |
| 1326 | /* Enabling the token table. */ |
| 1327 | #ifndef YYTOKEN_TABLE |
| 1328 | # define YYTOKEN_TABLE 0 |
| 1329 | #endif |
| 1330 | |
| 1331 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
| 1332 | typedef union YYSTYPE |
| 1333 | #line 947 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 1334 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1335 | llvm::Module *ModuleVal; |
| 1336 | llvm::Function *FunctionVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1337 | llvm::BasicBlock *BasicBlockVal; |
| 1338 | llvm::TerminatorInst *TermInstVal; |
| 1339 | llvm::Instruction *InstVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1340 | llvm::Constant *ConstVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1341 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1342 | const llvm::Type *PrimType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1343 | std::list<llvm::PATypeHolder> *TypeList; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1344 | llvm::PATypeHolder *TypeVal; |
| 1345 | llvm::Value *ValueVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1346 | std::vector<llvm::Value*> *ValueList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1347 | llvm::ArgListType *ArgList; |
| 1348 | llvm::TypeWithAttrs TypeWithAttrs; |
| 1349 | llvm::TypeWithAttrsList *TypeWithAttrsList; |
Dale Johannesen | eb57ea7 | 2007-11-05 21:20:28 +0000 | [diff] [blame] | 1350 | llvm::ParamList *ParamList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1351 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1352 | // Represent the RHS of PHI node |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1353 | std::list<std::pair<llvm::Value*, |
| 1354 | llvm::BasicBlock*> > *PHIList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1355 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1356 | std::vector<llvm::Constant*> *ConstVector; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1357 | |
| 1358 | llvm::GlobalValue::LinkageTypes Linkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1359 | llvm::GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 1360 | uint16_t ParamAttrs; |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 1361 | llvm::APInt *APIntVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1362 | int64_t SInt64Val; |
| 1363 | uint64_t UInt64Val; |
| 1364 | int SIntVal; |
| 1365 | unsigned UIntVal; |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 1366 | llvm::APFloat *FPVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1367 | bool BoolVal; |
| 1368 | |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 1369 | std::string *StrVal; // This memory must be deleted |
| 1370 | llvm::ValID ValIDVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1371 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1372 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1373 | llvm::Instruction::TermOps TermOpVal; |
| 1374 | llvm::Instruction::MemoryOps MemOpVal; |
| 1375 | llvm::Instruction::CastOps CastOpVal; |
| 1376 | llvm::Instruction::OtherOps OtherOpVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1377 | llvm::ICmpInst::Predicate IPredicate; |
| 1378 | llvm::FCmpInst::Predicate FPredicate; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 1379 | } |
| 1380 | /* Line 187 of yacc.c. */ |
| 1381 | #line 1382 "llvmAsmParser.tab.c" |
| 1382 | YYSTYPE; |
| 1383 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 1384 | # define YYSTYPE_IS_DECLARED 1 |
| 1385 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1386 | #endif |
| 1387 | |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1388 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1389 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 1390 | /* Copy the second part of user declarations. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1391 | |
| 1392 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 1393 | /* Line 216 of yacc.c. */ |
| 1394 | #line 1395 "llvmAsmParser.tab.c" |
Reid Spencer | b8f8505 | 2007-07-31 03:50:36 +0000 | [diff] [blame] | 1395 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 1396 | #ifdef short |
| 1397 | # undef short |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1398 | #endif |
| 1399 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 1400 | #ifdef YYTYPE_UINT8 |
| 1401 | typedef YYTYPE_UINT8 yytype_uint8; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1402 | #else |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 1403 | typedef unsigned char yytype_uint8; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 1404 | #endif |
| 1405 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 1406 | #ifdef YYTYPE_INT8 |
| 1407 | typedef YYTYPE_INT8 yytype_int8; |
| 1408 | #elif (defined __STDC__ || defined __C99__FUNC__ \ |
| 1409 | || defined __cplusplus || defined _MSC_VER) |
| 1410 | typedef signed char yytype_int8; |
| 1411 | #else |
| 1412 | typedef short int yytype_int8; |
| 1413 | #endif |
| 1414 | |
| 1415 | #ifdef YYTYPE_UINT16 |
| 1416 | typedef YYTYPE_UINT16 yytype_uint16; |
| 1417 | #else |
| 1418 | typedef unsigned short int yytype_uint16; |
| 1419 | #endif |
| 1420 | |
| 1421 | #ifdef YYTYPE_INT16 |
| 1422 | typedef YYTYPE_INT16 yytype_int16; |
| 1423 | #else |
| 1424 | typedef short int yytype_int16; |
| 1425 | #endif |
| 1426 | |
| 1427 | #ifndef YYSIZE_T |
| 1428 | # ifdef __SIZE_TYPE__ |
| 1429 | # define YYSIZE_T __SIZE_TYPE__ |
| 1430 | # elif defined size_t |
| 1431 | # define YYSIZE_T size_t |
| 1432 | # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ |
| 1433 | || defined __cplusplus || defined _MSC_VER) |
| 1434 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 1435 | # define YYSIZE_T size_t |
| 1436 | # else |
| 1437 | # define YYSIZE_T unsigned int |
| 1438 | # endif |
| 1439 | #endif |
| 1440 | |
| 1441 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
| 1442 | |
| 1443 | #ifndef YY_ |
| 1444 | # if YYENABLE_NLS |
| 1445 | # if ENABLE_NLS |
| 1446 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 1447 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
| 1448 | # endif |
| 1449 | # endif |
| 1450 | # ifndef YY_ |
| 1451 | # define YY_(msgid) msgid |
| 1452 | # endif |
| 1453 | #endif |
| 1454 | |
| 1455 | /* Suppress unused-variable warnings by "using" E. */ |
| 1456 | #if ! defined lint || defined __GNUC__ |
| 1457 | # define YYUSE(e) ((void) (e)) |
| 1458 | #else |
| 1459 | # define YYUSE(e) /* empty */ |
| 1460 | #endif |
| 1461 | |
| 1462 | /* Identity function, used to suppress warnings about constant conditions. */ |
| 1463 | #ifndef lint |
| 1464 | # define YYID(n) (n) |
| 1465 | #else |
| 1466 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 1467 | || defined __cplusplus || defined _MSC_VER) |
| 1468 | static int |
| 1469 | YYID (int i) |
| 1470 | #else |
| 1471 | static int |
| 1472 | YYID (i) |
| 1473 | int i; |
| 1474 | #endif |
| 1475 | { |
| 1476 | return i; |
| 1477 | } |
| 1478 | #endif |
| 1479 | |
| 1480 | #if ! defined yyoverflow || YYERROR_VERBOSE |
| 1481 | |
| 1482 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 1483 | |
| 1484 | # ifdef YYSTACK_USE_ALLOCA |
| 1485 | # if YYSTACK_USE_ALLOCA |
| 1486 | # ifdef __GNUC__ |
| 1487 | # define YYSTACK_ALLOC __builtin_alloca |
| 1488 | # elif defined __BUILTIN_VA_ARG_INCR |
| 1489 | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ |
| 1490 | # elif defined _AIX |
| 1491 | # define YYSTACK_ALLOC __alloca |
| 1492 | # elif defined _MSC_VER |
| 1493 | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ |
| 1494 | # define alloca _alloca |
| 1495 | # else |
| 1496 | # define YYSTACK_ALLOC alloca |
| 1497 | # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ |
| 1498 | || defined __cplusplus || defined _MSC_VER) |
| 1499 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 1500 | # ifndef _STDLIB_H |
| 1501 | # define _STDLIB_H 1 |
| 1502 | # endif |
| 1503 | # endif |
| 1504 | # endif |
| 1505 | # endif |
| 1506 | # endif |
| 1507 | |
| 1508 | # ifdef YYSTACK_ALLOC |
| 1509 | /* Pacify GCC's `empty if-body' warning. */ |
| 1510 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) |
| 1511 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1512 | /* The OS might guarantee only one guard page at the bottom of the stack, |
| 1513 | and a page size can be as small as 4096 bytes. So we cannot safely |
| 1514 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
| 1515 | to allow for a few compiler-allocated temporary stack slots. */ |
| 1516 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ |
| 1517 | # endif |
| 1518 | # else |
| 1519 | # define YYSTACK_ALLOC YYMALLOC |
| 1520 | # define YYSTACK_FREE YYFREE |
| 1521 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1522 | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
| 1523 | # endif |
| 1524 | # if (defined __cplusplus && ! defined _STDLIB_H \ |
| 1525 | && ! ((defined YYMALLOC || defined malloc) \ |
| 1526 | && (defined YYFREE || defined free))) |
| 1527 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 1528 | # ifndef _STDLIB_H |
| 1529 | # define _STDLIB_H 1 |
| 1530 | # endif |
| 1531 | # endif |
| 1532 | # ifndef YYMALLOC |
| 1533 | # define YYMALLOC malloc |
| 1534 | # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ |
| 1535 | || defined __cplusplus || defined _MSC_VER) |
| 1536 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 1537 | # endif |
| 1538 | # endif |
| 1539 | # ifndef YYFREE |
| 1540 | # define YYFREE free |
| 1541 | # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ |
| 1542 | || defined __cplusplus || defined _MSC_VER) |
| 1543 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 1544 | # endif |
| 1545 | # endif |
| 1546 | # endif |
| 1547 | #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ |
| 1548 | |
| 1549 | |
| 1550 | #if (! defined yyoverflow \ |
| 1551 | && (! defined __cplusplus \ |
| 1552 | || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) |
| 1553 | |
| 1554 | /* A type that is properly aligned for any stack member. */ |
| 1555 | union yyalloc |
| 1556 | { |
| 1557 | yytype_int16 yyss; |
| 1558 | YYSTYPE yyvs; |
| 1559 | }; |
| 1560 | |
| 1561 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 1562 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 1563 | |
| 1564 | /* The size of an array large to enough to hold all stacks, each with |
| 1565 | N elements. */ |
| 1566 | # define YYSTACK_BYTES(N) \ |
| 1567 | ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ |
| 1568 | + YYSTACK_GAP_MAXIMUM) |
| 1569 | |
| 1570 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 1571 | not overlap. */ |
| 1572 | # ifndef YYCOPY |
| 1573 | # if defined __GNUC__ && 1 < __GNUC__ |
| 1574 | # define YYCOPY(To, From, Count) \ |
| 1575 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 1576 | # else |
| 1577 | # define YYCOPY(To, From, Count) \ |
| 1578 | do \ |
| 1579 | { \ |
| 1580 | YYSIZE_T yyi; \ |
| 1581 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 1582 | (To)[yyi] = (From)[yyi]; \ |
| 1583 | } \ |
| 1584 | while (YYID (0)) |
| 1585 | # endif |
| 1586 | # endif |
| 1587 | |
| 1588 | /* Relocate STACK from its old location to the new one. The |
| 1589 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 1590 | elements in the stack, and YYPTR gives the new location of the |
| 1591 | stack. Advance YYPTR to a properly aligned location for the next |
| 1592 | stack. */ |
| 1593 | # define YYSTACK_RELOCATE(Stack) \ |
| 1594 | do \ |
| 1595 | { \ |
| 1596 | YYSIZE_T yynewbytes; \ |
| 1597 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 1598 | Stack = &yyptr->Stack; \ |
| 1599 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 1600 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 1601 | } \ |
| 1602 | while (YYID (0)) |
| 1603 | |
| 1604 | #endif |
| 1605 | |
| 1606 | /* YYFINAL -- State number of the termination state. */ |
| 1607 | #define YYFINAL 43 |
| 1608 | /* YYLAST -- Last index in YYTABLE. */ |
| 1609 | #define YYLAST 1988 |
| 1610 | |
| 1611 | /* YYNTOKENS -- Number of terminals. */ |
| 1612 | #define YYNTOKENS 164 |
| 1613 | /* YYNNTS -- Number of nonterminals. */ |
| 1614 | #define YYNNTS 84 |
| 1615 | /* YYNRULES -- Number of rules. */ |
| 1616 | #define YYNRULES 318 |
| 1617 | /* YYNRULES -- Number of states. */ |
| 1618 | #define YYNSTATES 619 |
| 1619 | |
| 1620 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 1621 | #define YYUNDEFTOK 2 |
| 1622 | #define YYMAXUTOK 404 |
| 1623 | |
| 1624 | #define YYTRANSLATE(YYX) \ |
| 1625 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 1626 | |
| 1627 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 1628 | static const yytype_uint8 yytranslate[] = |
| 1629 | { |
| 1630 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1631 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1632 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1633 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1634 | 150, 151, 154, 2, 153, 2, 2, 2, 2, 2, |
| 1635 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1636 | 159, 152, 160, 2, 2, 2, 2, 2, 2, 2, |
| 1637 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1638 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1639 | 2, 156, 155, 158, 2, 2, 2, 2, 2, 163, |
| 1640 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1641 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1642 | 157, 2, 2, 161, 2, 162, 2, 2, 2, 2, |
| 1643 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1644 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1645 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1646 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1647 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1648 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1649 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1650 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1651 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1652 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1653 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1654 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1655 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 1656 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 1657 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 1658 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 1659 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 1660 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 1661 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 1662 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 1663 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 1664 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1665 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 1666 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 1667 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 1668 | 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, |
| 1669 | 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, |
| 1670 | 145, 146, 147, 148, 149 |
| 1671 | }; |
| 1672 | |
| 1673 | #if YYDEBUG |
| 1674 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 1675 | YYRHS. */ |
| 1676 | static const yytype_uint16 yyprhs[] = |
| 1677 | { |
| 1678 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 1679 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 1680 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 1681 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, |
| 1682 | 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, |
| 1683 | 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, |
| 1684 | 119, 121, 123, 125, 127, 129, 130, 135, 136, 139, |
| 1685 | 140, 142, 144, 146, 147, 150, 152, 154, 156, 158, |
| 1686 | 160, 162, 164, 166, 167, 169, 171, 173, 174, 176, |
| 1687 | 178, 179, 181, 183, 185, 187, 188, 190, 192, 193, |
| 1688 | 195, 197, 199, 201, 203, 206, 208, 210, 212, 214, |
| 1689 | 216, 218, 220, 222, 224, 225, 228, 230, 232, 234, |
| 1690 | 236, 238, 240, 241, 244, 245, 248, 249, 252, 253, |
| 1691 | 257, 260, 261, 263, 264, 268, 270, 273, 275, 277, |
| 1692 | 279, 281, 283, 285, 287, 289, 291, 295, 297, 300, |
| 1693 | 306, 312, 318, 324, 328, 331, 337, 342, 345, 347, |
| 1694 | 349, 351, 355, 357, 361, 363, 364, 366, 370, 375, |
| 1695 | 379, 383, 388, 393, 397, 404, 410, 413, 416, 419, |
| 1696 | 422, 425, 428, 431, 434, 437, 440, 443, 446, 453, |
| 1697 | 459, 468, 475, 482, 490, 498, 505, 514, 523, 527, |
| 1698 | 529, 531, 533, 535, 536, 539, 546, 548, 549, 551, |
| 1699 | 554, 555, 559, 560, 564, 568, 572, 576, 577, 586, |
| 1700 | 587, 597, 598, 608, 614, 617, 621, 623, 627, 631, |
| 1701 | 635, 639, 641, 642, 648, 652, 654, 658, 660, 661, |
| 1702 | 672, 674, 676, 681, 683, 685, 688, 692, 693, 695, |
| 1703 | 697, 699, 701, 703, 705, 707, 709, 711, 715, 717, |
| 1704 | 723, 725, 727, 729, 731, 733, 735, 738, 741, 744, |
| 1705 | 748, 751, 752, 754, 757, 760, 764, 774, 784, 793, |
| 1706 | 808, 810, 812, 819, 825, 828, 835, 843, 848, 853, |
| 1707 | 860, 867, 868, 869, 873, 876, 878, 884, 890, 897, |
| 1708 | 904, 909, 916, 921, 926, 933, 940, 943, 952, 954, |
| 1709 | 956, 957, 961, 968, 972, 979, 982, 988, 996 |
| 1710 | }; |
| 1711 | |
| 1712 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 1713 | static const yytype_int16 yyrhs[] = |
| 1714 | { |
| 1715 | 210, 0, -1, 74, -1, 75, -1, 76, -1, 77, |
| 1716 | -1, 78, -1, 79, -1, 80, -1, 81, -1, 82, |
| 1717 | -1, 86, -1, 87, -1, 88, -1, 83, -1, 84, |
| 1718 | -1, 85, -1, 117, -1, 118, -1, 119, -1, 120, |
| 1719 | -1, 121, -1, 122, -1, 123, -1, 124, -1, 125, |
| 1720 | -1, 126, -1, 127, -1, 128, -1, 91, -1, 92, |
| 1721 | -1, 93, -1, 94, -1, 95, -1, 96, -1, 97, |
| 1722 | -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, |
| 1723 | -1, 103, -1, 104, -1, 105, -1, 106, -1, 107, |
| 1724 | -1, 108, -1, 109, -1, 110, -1, 97, -1, 98, |
| 1725 | -1, 99, -1, 100, -1, 26, -1, 27, -1, 11, |
| 1726 | -1, 12, -1, 13, -1, 16, -1, 15, -1, 14, |
| 1727 | -1, 19, -1, 22, -1, 24, -1, 172, -1, -1, |
| 1728 | 54, 150, 4, 151, -1, -1, 172, 152, -1, -1, |
| 1729 | 20, -1, 23, -1, 178, -1, -1, 176, 152, -1, |
| 1730 | 42, -1, 44, -1, 43, -1, 45, -1, 47, -1, |
| 1731 | 46, -1, 48, -1, 50, -1, -1, 147, -1, 148, |
| 1732 | -1, 149, -1, -1, 46, -1, 48, -1, -1, 42, |
| 1733 | -1, 43, -1, 44, -1, 47, -1, -1, 44, -1, |
| 1734 | 42, -1, -1, 62, -1, 63, -1, 64, -1, 65, |
| 1735 | -1, 66, -1, 61, 4, -1, 136, -1, 118, -1, |
| 1736 | 135, -1, 119, -1, 138, -1, 139, -1, 141, -1, |
| 1737 | 142, -1, 143, -1, -1, 187, 186, -1, 137, -1, |
| 1738 | 140, -1, 136, -1, 135, -1, 144, -1, 145, -1, |
| 1739 | -1, 189, 188, -1, -1, 146, 22, -1, -1, 53, |
| 1740 | 4, -1, -1, 153, 53, 4, -1, 34, 22, -1, |
| 1741 | -1, 193, -1, -1, 153, 196, 195, -1, 193, -1, |
| 1742 | 53, 4, -1, 11, -1, 12, -1, 13, -1, 16, |
| 1743 | -1, 15, -1, 14, -1, 17, -1, 49, -1, 197, |
| 1744 | -1, 198, 174, 154, -1, 232, -1, 155, 4, -1, |
| 1745 | 198, 150, 202, 151, 189, -1, 10, 150, 202, 151, |
| 1746 | 189, -1, 156, 4, 157, 198, 158, -1, 159, 4, |
| 1747 | 157, 198, 160, -1, 161, 203, 162, -1, 161, 162, |
| 1748 | -1, 159, 161, 203, 162, 160, -1, 159, 161, 162, |
| 1749 | 160, -1, 198, 187, -1, 198, -1, 10, -1, 199, |
| 1750 | -1, 201, 153, 199, -1, 201, -1, 201, 153, 39, |
| 1751 | -1, 39, -1, -1, 198, -1, 203, 153, 198, -1, |
| 1752 | 198, 156, 206, 158, -1, 198, 156, 158, -1, 198, |
| 1753 | 163, 22, -1, 198, 159, 206, 160, -1, 198, 161, |
| 1754 | 206, 162, -1, 198, 161, 162, -1, 198, 159, 161, |
| 1755 | 206, 162, 160, -1, 198, 159, 161, 162, 160, -1, |
| 1756 | 198, 40, -1, 198, 41, -1, 198, 232, -1, 198, |
| 1757 | 205, -1, 198, 25, -1, 170, 3, -1, 170, 5, |
| 1758 | -1, 170, 4, -1, 170, 6, -1, 11, 26, -1, |
| 1759 | 11, 27, -1, 171, 9, -1, 167, 150, 204, 38, |
| 1760 | 198, 151, -1, 116, 150, 204, 243, 151, -1, 130, |
| 1761 | 150, 204, 153, 204, 153, 204, 151, -1, 165, 150, |
| 1762 | 204, 153, 204, 151, -1, 166, 150, 204, 153, 204, |
| 1763 | 151, -1, 89, 168, 150, 204, 153, 204, 151, -1, |
| 1764 | 90, 169, 150, 204, 153, 204, 151, -1, 132, 150, |
| 1765 | 204, 153, 204, 151, -1, 133, 150, 204, 153, 204, |
| 1766 | 153, 204, 151, -1, 134, 150, 204, 153, 204, 153, |
| 1767 | 204, 151, -1, 206, 153, 204, -1, 204, -1, 32, |
| 1768 | -1, 33, -1, 37, -1, -1, 200, 232, -1, 122, |
| 1769 | 150, 209, 38, 198, 151, -1, 211, -1, -1, 212, |
| 1770 | -1, 211, 212, -1, -1, 31, 213, 228, -1, -1, |
| 1771 | 30, 214, 229, -1, 59, 58, 218, -1, 175, 18, |
| 1772 | 198, -1, 175, 18, 10, -1, -1, 177, 181, 208, |
| 1773 | 207, 204, 174, 215, 195, -1, -1, 177, 179, 181, |
| 1774 | 208, 207, 204, 174, 216, 195, -1, -1, 177, 180, |
| 1775 | 181, 208, 207, 198, 174, 217, 195, -1, 177, 181, |
| 1776 | 35, 184, 209, -1, 51, 219, -1, 55, 152, 220, |
| 1777 | -1, 22, -1, 52, 152, 22, -1, 67, 152, 22, |
| 1778 | -1, 156, 221, 158, -1, 221, 153, 22, -1, 22, |
| 1779 | -1, -1, 222, 153, 198, 187, 173, -1, 198, 187, |
| 1780 | 173, -1, 222, -1, 222, 153, 39, -1, 39, -1, |
| 1781 | -1, 185, 200, 176, 150, 223, 151, 189, 194, 191, |
| 1782 | 190, -1, 28, -1, 161, -1, 183, 181, 224, 225, |
| 1783 | -1, 29, -1, 162, -1, 235, 227, -1, 182, 181, |
| 1784 | 224, -1, -1, 60, -1, 3, -1, 4, -1, 9, |
| 1785 | -1, 26, -1, 27, -1, 40, -1, 41, -1, 25, |
| 1786 | -1, 159, 206, 160, -1, 205, -1, 58, 230, 22, |
| 1787 | 153, 22, -1, 7, -1, 8, -1, 172, -1, 176, |
| 1788 | -1, 232, -1, 231, -1, 198, 233, -1, 235, 236, |
| 1789 | -1, 226, 236, -1, 237, 175, 238, -1, 237, 240, |
| 1790 | -1, -1, 21, -1, 68, 234, -1, 68, 10, -1, |
| 1791 | 69, 17, 233, -1, 69, 11, 233, 153, 17, 233, |
| 1792 | 153, 17, 233, -1, 70, 170, 233, 153, 17, 233, |
| 1793 | 156, 239, 158, -1, 70, 170, 233, 153, 17, 233, |
| 1794 | 156, 158, -1, 71, 185, 200, 233, 150, 242, 151, |
| 1795 | 189, 38, 17, 233, 72, 17, 233, -1, 72, -1, |
| 1796 | 73, -1, 239, 170, 231, 153, 17, 233, -1, 170, |
| 1797 | 231, 153, 17, 233, -1, 175, 245, -1, 198, 156, |
| 1798 | 233, 153, 233, 158, -1, 241, 153, 156, 233, 153, |
| 1799 | 233, 158, -1, 198, 187, 233, 187, -1, 17, 187, |
| 1800 | 233, 187, -1, 242, 153, 198, 187, 233, 187, -1, |
| 1801 | 242, 153, 17, 187, 233, 187, -1, -1, -1, 243, |
| 1802 | 153, 234, -1, 57, 56, -1, 56, -1, 165, 198, |
| 1803 | 233, 153, 233, -1, 166, 198, 233, 153, 233, -1, |
| 1804 | 89, 168, 198, 233, 153, 233, -1, 90, 169, 198, |
| 1805 | 233, 153, 233, -1, 167, 234, 38, 198, -1, 130, |
| 1806 | 234, 153, 234, 153, 234, -1, 131, 234, 153, 198, |
| 1807 | -1, 132, 234, 153, 234, -1, 133, 234, 153, 234, |
| 1808 | 153, 234, -1, 134, 234, 153, 234, 153, 234, -1, |
| 1809 | 129, 241, -1, 244, 185, 200, 233, 150, 242, 151, |
| 1810 | 189, -1, 247, -1, 36, -1, -1, 111, 198, 192, |
| 1811 | -1, 111, 198, 153, 11, 233, 192, -1, 112, 198, |
| 1812 | 192, -1, 112, 198, 153, 11, 233, 192, -1, 113, |
| 1813 | 234, -1, 246, 114, 198, 233, 192, -1, 246, 115, |
| 1814 | 234, 153, 198, 233, 192, -1, 116, 198, 233, 243, |
| 1815 | -1 |
| 1816 | }; |
| 1817 | |
| 1818 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 1819 | static const yytype_uint16 yyrline[] = |
| 1820 | { |
| 1821 | 0, 1107, 1107, 1107, 1107, 1107, 1107, 1107, 1107, 1107, |
| 1822 | 1107, 1108, 1108, 1108, 1108, 1108, 1108, 1109, 1109, 1109, |
| 1823 | 1109, 1109, 1109, 1110, 1110, 1110, 1110, 1110, 1110, 1113, |
| 1824 | 1113, 1114, 1114, 1115, 1115, 1116, 1116, 1117, 1117, 1121, |
| 1825 | 1121, 1122, 1122, 1123, 1123, 1124, 1124, 1125, 1125, 1126, |
| 1826 | 1126, 1127, 1127, 1128, 1129, 1134, 1135, 1135, 1135, 1135, |
| 1827 | 1135, 1137, 1137, 1137, 1138, 1138, 1140, 1141, 1145, 1149, |
| 1828 | 1154, 1154, 1156, 1157, 1162, 1168, 1169, 1170, 1171, 1172, |
| 1829 | 1176, 1177, 1178, 1182, 1183, 1184, 1185, 1189, 1190, 1191, |
| 1830 | 1195, 1196, 1197, 1198, 1199, 1203, 1204, 1205, 1208, 1209, |
| 1831 | 1210, 1211, 1212, 1213, 1214, 1221, 1222, 1223, 1224, 1225, |
| 1832 | 1226, 1227, 1228, 1229, 1232, 1233, 1238, 1239, 1240, 1241, |
| 1833 | 1242, 1243, 1246, 1247, 1252, 1253, 1260, 1261, 1267, 1268, |
| 1834 | 1277, 1285, 1286, 1291, 1292, 1293, 1298, 1311, 1311, 1311, |
| 1835 | 1311, 1311, 1311, 1311, 1314, 1318, 1322, 1329, 1334, 1342, |
| 1836 | 1372, 1397, 1402, 1412, 1422, 1426, 1436, 1443, 1452, 1459, |
| 1837 | 1464, 1469, 1476, 1477, 1484, 1491, 1499, 1505, 1517, 1545, |
| 1838 | 1561, 1588, 1616, 1642, 1662, 1688, 1708, 1720, 1727, 1793, |
| 1839 | 1803, 1813, 1819, 1829, 1835, 1845, 1850, 1855, 1868, 1880, |
| 1840 | 1902, 1910, 1916, 1927, 1932, 1937, 1943, 1949, 1958, 1962, |
| 1841 | 1970, 1970, 1973, 1973, 1976, 1988, 2009, 2014, 2022, 2023, |
| 1842 | 2027, 2027, 2031, 2031, 2034, 2037, 2061, 2073, 2072, 2084, |
| 1843 | 2083, 2093, 2092, 2103, 2143, 2146, 2152, 2162, 2166, 2171, |
| 1844 | 2173, 2178, 2183, 2192, 2202, 2213, 2217, 2226, 2235, 2240, |
| 1845 | 2374, 2374, 2376, 2385, 2385, 2387, 2392, 2404, 2408, 2413, |
| 1846 | 2417, 2421, 2425, 2429, 2433, 2437, 2441, 2445, 2470, 2474, |
| 1847 | 2484, 2488, 2492, 2497, 2504, 2504, 2510, 2519, 2523, 2532, |
| 1848 | 2541, 2550, 2554, 2561, 2565, 2569, 2574, 2584, 2603, 2612, |
| 1849 | 2703, 2707, 2714, 2725, 2738, 2748, 2759, 2769, 2780, 2788, |
| 1850 | 2798, 2805, 2808, 2809, 2816, 2820, 2825, 2841, 2858, 2872, |
| 1851 | 2886, 2898, 2906, 2913, 2919, 2925, 2931, 2946, 3044, 3049, |
| 1852 | 3053, 3060, 3067, 3075, 3082, 3090, 3098, 3112, 3129 |
| 1853 | }; |
| 1854 | #endif |
| 1855 | |
| 1856 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
| 1857 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 1858 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 1859 | static const char *const yytname[] = |
| 1860 | { |
| 1861 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "ESAPINTVAL", |
| 1862 | "EUAPINTVAL", "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE", |
| 1863 | "FLOAT", "DOUBLE", "X86_FP80", "FP128", "PPC_FP128", "LABEL", "TYPE", |
| 1864 | "LOCALVAR", "GLOBALVAR", "LABELSTR", "STRINGCONSTANT", |
| 1865 | "ATSTRINGCONSTANT", "PCTSTRINGCONSTANT", "ZEROINITIALIZER", "TRUETOK", |
| 1866 | "FALSETOK", "BEGINTOK", "ENDTOK", "DECLARE", "DEFINE", "GLOBAL", |
| 1867 | "CONSTANT", "SECTION", "ALIAS", "VOLATILE", "THREAD_LOCAL", "TO", |
| 1868 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK", |
| 1869 | "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 1870 | "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "ADDRSPACE", "DEPLIBS", "CALL", |
| 1871 | "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", |
| 1872 | "FASTCC_TOK", "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", |
| 1873 | "DATALAYOUT", "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", |
| 1874 | "ADD", "SUB", "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", |
| 1875 | "AND", "OR", "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", |
| 1876 | "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", |
| 1877 | "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", |
| 1878 | "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", |
| 1879 | "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", |
| 1880 | "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", |
| 1881 | "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR", "SIGNEXT", "ZEROEXT", |
| 1882 | "NORETURN", "INREG", "SRET", "NOUNWIND", "NOALIAS", "BYVAL", "NEST", |
| 1883 | "READNONE", "READONLY", "GC", "DEFAULT", "HIDDEN", "PROTECTED", "'('", |
| 1884 | "')'", "'='", "','", "'*'", "'\\\\'", "'['", "'x'", "']'", "'<'", "'>'", |
| 1885 | "'{'", "'}'", "'c'", "$accept", "ArithmeticOps", "LogicalOps", "CastOps", |
| 1886 | "IPredicates", "FPredicates", "IntType", "FPType", "LocalName", |
| 1887 | "OptLocalName", "OptAddrSpace", "OptLocalAssign", "GlobalName", |
| 1888 | "OptGlobalAssign", "GlobalAssign", "GVInternalLinkage", |
| 1889 | "GVExternalLinkage", "GVVisibilityStyle", "FunctionDeclareLinkage", |
| 1890 | "FunctionDefineLinkage", "AliasLinkage", "OptCallingConv", "ParamAttr", |
| 1891 | "OptParamAttrs", "FuncAttr", "OptFuncAttrs", "OptGC", "OptAlign", |
| 1892 | "OptCAlign", "SectionString", "OptSection", "GlobalVarAttributes", |
| 1893 | "GlobalVarAttribute", "PrimType", "Types", "ArgType", "ResultTypes", |
| 1894 | "ArgTypeList", "ArgTypeListI", "TypeListI", "ConstVal", "ConstExpr", |
| 1895 | "ConstVector", "GlobalType", "ThreadLocal", "AliaseeRef", "Module", |
| 1896 | "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock", |
| 1897 | "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH", |
| 1898 | "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", |
| 1899 | "Function", "FunctionProto", "OptSideEffect", "ConstValueRef", |
| 1900 | "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList", |
| 1901 | "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst", |
| 1902 | "PHIList", "ParamList", "IndexList", "OptTailCall", "InstVal", |
| 1903 | "OptVolatile", "MemoryInst", 0 |
| 1904 | }; |
| 1905 | #endif |
| 1906 | |
| 1907 | # ifdef YYPRINT |
| 1908 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 1909 | token YYLEX-NUM. */ |
| 1910 | static const yytype_uint16 yytoknum[] = |
| 1911 | { |
| 1912 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 1913 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 1914 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 1915 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 1916 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 1917 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 1918 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 1919 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 1920 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 1921 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
| 1922 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
| 1923 | 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, |
| 1924 | 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, |
| 1925 | 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, |
| 1926 | 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, |
| 1927 | 40, 41, 61, 44, 42, 92, 91, 120, 93, 60, |
| 1928 | 62, 123, 125, 99 |
| 1929 | }; |
| 1930 | # endif |
| 1931 | |
| 1932 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 1933 | static const yytype_uint8 yyr1[] = |
| 1934 | { |
| 1935 | 0, 164, 165, 165, 165, 165, 165, 165, 165, 165, |
| 1936 | 165, 166, 166, 166, 166, 166, 166, 167, 167, 167, |
| 1937 | 167, 167, 167, 167, 167, 167, 167, 167, 167, 168, |
| 1938 | 168, 168, 168, 168, 168, 168, 168, 168, 168, 169, |
| 1939 | 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, |
| 1940 | 169, 169, 169, 169, 169, 170, 171, 171, 171, 171, |
| 1941 | 171, 172, 172, 172, 173, 173, 174, 174, 175, 175, |
| 1942 | 176, 176, 177, 177, 178, 179, 179, 179, 179, 179, |
| 1943 | 180, 180, 180, 181, 181, 181, 181, 182, 182, 182, |
| 1944 | 183, 183, 183, 183, 183, 184, 184, 184, 185, 185, |
| 1945 | 185, 185, 185, 185, 185, 186, 186, 186, 186, 186, |
| 1946 | 186, 186, 186, 186, 187, 187, 188, 188, 188, 188, |
| 1947 | 188, 188, 189, 189, 190, 190, 191, 191, 192, 192, |
| 1948 | 193, 194, 194, 195, 195, 196, 196, 197, 197, 197, |
| 1949 | 197, 197, 197, 197, 198, 198, 198, 198, 198, 198, |
| 1950 | 198, 198, 198, 198, 198, 198, 198, 199, 200, 200, |
| 1951 | 201, 201, 202, 202, 202, 202, 203, 203, 204, 204, |
| 1952 | 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, |
| 1953 | 204, 204, 204, 204, 204, 204, 204, 204, 205, 205, |
| 1954 | 205, 205, 205, 205, 205, 205, 205, 205, 206, 206, |
| 1955 | 207, 207, 208, 208, 209, 209, 210, 210, 211, 211, |
| 1956 | 213, 212, 214, 212, 212, 212, 212, 215, 212, 216, |
| 1957 | 212, 217, 212, 212, 212, 212, 218, 219, 219, 220, |
| 1958 | 221, 221, 221, 222, 222, 223, 223, 223, 223, 224, |
| 1959 | 225, 225, 226, 227, 227, 228, 229, 230, 230, 231, |
| 1960 | 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, |
| 1961 | 232, 232, 232, 232, 233, 233, 234, 235, 235, 236, |
| 1962 | 237, 237, 237, 238, 238, 238, 238, 238, 238, 238, |
| 1963 | 238, 238, 239, 239, 240, 241, 241, 242, 242, 242, |
| 1964 | 242, 242, 243, 243, 244, 244, 245, 245, 245, 245, |
| 1965 | 245, 245, 245, 245, 245, 245, 245, 245, 245, 246, |
| 1966 | 246, 247, 247, 247, 247, 247, 247, 247, 247 |
| 1967 | }; |
| 1968 | |
| 1969 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 1970 | static const yytype_uint8 yyr2[] = |
| 1971 | { |
| 1972 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1973 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1974 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1975 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1976 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1977 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1978 | 1, 1, 1, 1, 1, 0, 4, 0, 2, 0, |
| 1979 | 1, 1, 1, 0, 2, 1, 1, 1, 1, 1, |
| 1980 | 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, |
| 1981 | 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, |
| 1982 | 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, |
| 1983 | 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, |
| 1984 | 1, 1, 0, 2, 0, 2, 0, 2, 0, 3, |
| 1985 | 2, 0, 1, 0, 3, 1, 2, 1, 1, 1, |
| 1986 | 1, 1, 1, 1, 1, 1, 3, 1, 2, 5, |
| 1987 | 5, 5, 5, 3, 2, 5, 4, 2, 1, 1, |
| 1988 | 1, 3, 1, 3, 1, 0, 1, 3, 4, 3, |
| 1989 | 3, 4, 4, 3, 6, 5, 2, 2, 2, 2, |
| 1990 | 2, 2, 2, 2, 2, 2, 2, 2, 6, 5, |
| 1991 | 8, 6, 6, 7, 7, 6, 8, 8, 3, 1, |
| 1992 | 1, 1, 1, 0, 2, 6, 1, 0, 1, 2, |
| 1993 | 0, 3, 0, 3, 3, 3, 3, 0, 8, 0, |
| 1994 | 9, 0, 9, 5, 2, 3, 1, 3, 3, 3, |
| 1995 | 3, 1, 0, 5, 3, 1, 3, 1, 0, 10, |
| 1996 | 1, 1, 4, 1, 1, 2, 3, 0, 1, 1, |
| 1997 | 1, 1, 1, 1, 1, 1, 1, 3, 1, 5, |
| 1998 | 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, |
| 1999 | 2, 0, 1, 2, 2, 3, 9, 9, 8, 14, |
| 2000 | 1, 1, 6, 5, 2, 6, 7, 4, 4, 6, |
| 2001 | 6, 0, 0, 3, 2, 1, 5, 5, 6, 6, |
| 2002 | 4, 6, 4, 4, 6, 6, 2, 8, 1, 1, |
| 2003 | 0, 3, 6, 3, 6, 2, 5, 7, 4 |
| 2004 | }; |
| 2005 | |
| 2006 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 2007 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 2008 | means the default is an error. */ |
| 2009 | static const yytype_uint16 yydefact[] = |
| 2010 | { |
| 2011 | 73, 61, 70, 62, 71, 63, 212, 210, 0, 0, |
| 2012 | 0, 0, 0, 0, 83, 72, 0, 73, 208, 87, |
| 2013 | 90, 0, 0, 224, 0, 0, 68, 0, 74, 75, |
| 2014 | 77, 76, 78, 80, 79, 81, 82, 84, 85, 86, |
| 2015 | 83, 83, 203, 1, 209, 88, 89, 83, 213, 91, |
| 2016 | 92, 93, 94, 83, 271, 211, 271, 0, 0, 232, |
| 2017 | 225, 226, 214, 260, 261, 216, 137, 138, 139, 142, |
| 2018 | 141, 140, 143, 144, 0, 0, 0, 0, 262, 263, |
| 2019 | 145, 215, 147, 203, 203, 95, 202, 0, 98, 98, |
| 2020 | 272, 268, 69, 243, 244, 245, 267, 227, 228, 231, |
| 2021 | 0, 165, 148, 0, 0, 0, 0, 154, 166, 0, |
| 2022 | 0, 165, 0, 0, 0, 97, 96, 0, 200, 201, |
| 2023 | 0, 0, 99, 100, 101, 102, 103, 0, 246, 0, |
| 2024 | 310, 270, 0, 229, 164, 114, 160, 162, 0, 0, |
| 2025 | 0, 0, 0, 0, 153, 0, 0, 146, 0, 0, |
| 2026 | 159, 0, 158, 0, 223, 137, 138, 139, 142, 141, |
| 2027 | 140, 0, 0, 67, 67, 104, 0, 240, 241, 242, |
| 2028 | 309, 295, 0, 0, 0, 0, 98, 280, 281, 2, |
| 2029 | 3, 4, 5, 6, 7, 8, 9, 10, 14, 15, |
| 2030 | 16, 11, 12, 13, 0, 0, 0, 0, 0, 0, |
| 2031 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
| 2032 | 27, 28, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2033 | 0, 269, 98, 284, 0, 308, 230, 157, 0, 122, |
| 2034 | 67, 67, 156, 0, 167, 0, 122, 67, 67, 0, |
| 2035 | 204, 185, 186, 181, 183, 182, 184, 187, 180, 176, |
| 2036 | 177, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2037 | 0, 0, 0, 0, 0, 179, 178, 217, 0, 294, |
| 2038 | 274, 67, 273, 0, 0, 55, 0, 0, 29, 30, |
| 2039 | 31, 32, 33, 34, 35, 36, 37, 38, 0, 53, |
| 2040 | 54, 49, 50, 51, 52, 39, 40, 41, 42, 43, |
| 2041 | 44, 45, 46, 47, 48, 0, 128, 128, 315, 67, |
| 2042 | 67, 306, 0, 0, 0, 0, 0, 67, 67, 0, |
| 2043 | 0, 0, 0, 106, 108, 107, 105, 109, 110, 111, |
| 2044 | 112, 113, 115, 163, 161, 150, 151, 152, 155, 66, |
| 2045 | 149, 219, 221, 0, 0, 0, 0, 0, 0, 0, |
| 2046 | 0, 169, 199, 0, 0, 0, 173, 0, 170, 0, |
| 2047 | 0, 0, 133, 238, 249, 250, 251, 256, 252, 253, |
| 2048 | 254, 255, 247, 0, 258, 265, 264, 266, 0, 275, |
| 2049 | 0, 0, 67, 67, 0, 311, 0, 313, 292, 0, |
| 2050 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2051 | 67, 0, 119, 118, 116, 117, 120, 121, 123, 133, |
| 2052 | 133, 0, 0, 0, 292, 0, 0, 0, 0, 0, |
| 2053 | 168, 154, 166, 0, 171, 172, 0, 0, 0, 0, |
| 2054 | 218, 237, 114, 235, 0, 248, 0, 0, 0, 0, |
| 2055 | 0, 0, 0, 0, 0, 0, 318, 0, 0, 0, |
| 2056 | 302, 303, 0, 0, 0, 0, 300, 0, 128, 0, |
| 2057 | 220, 222, 67, 0, 0, 0, 0, 0, 0, 0, |
| 2058 | 198, 175, 0, 0, 0, 0, 0, 0, 135, 133, |
| 2059 | 65, 0, 122, 0, 257, 0, 0, 291, 0, 0, |
| 2060 | 128, 129, 128, 0, 0, 0, 0, 0, 0, 296, |
| 2061 | 297, 291, 0, 316, 67, 205, 0, 0, 189, 0, |
| 2062 | 0, 0, 0, 174, 0, 0, 67, 130, 136, 134, |
| 2063 | 64, 234, 236, 114, 131, 0, 0, 0, 114, 114, |
| 2064 | 0, 298, 299, 312, 314, 293, 0, 0, 301, 304, |
| 2065 | 305, 0, 128, 0, 0, 0, 195, 0, 0, 191, |
| 2066 | 192, 188, 65, 132, 126, 259, 0, 0, 0, 0, |
| 2067 | 122, 0, 285, 0, 122, 317, 193, 194, 0, 0, |
| 2068 | 0, 233, 0, 124, 0, 278, 0, 0, 106, 108, |
| 2069 | 114, 114, 0, 114, 114, 286, 307, 190, 196, 197, |
| 2070 | 127, 0, 239, 276, 0, 277, 0, 288, 287, 0, |
| 2071 | 0, 0, 125, 0, 0, 0, 114, 114, 0, 0, |
| 2072 | 0, 290, 289, 283, 0, 0, 282, 0, 279 |
| 2073 | }; |
| 2074 | |
| 2075 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 2076 | static const yytype_int16 yydefgoto[] = |
| 2077 | { |
| 2078 | -1, 262, 263, 264, 288, 305, 161, 162, 78, 521, |
| 2079 | 112, 12, 79, 14, 15, 40, 41, 42, 47, 53, |
| 2080 | 117, 127, 332, 227, 408, 335, 592, 573, 385, 478, |
| 2081 | 554, 430, 479, 80, 163, 136, 153, 137, 138, 109, |
| 2082 | 352, 374, 353, 120, 87, 154, 16, 17, 18, 20, |
| 2083 | 19, 362, 409, 410, 62, 23, 60, 100, 433, 434, |
| 2084 | 128, 169, 54, 95, 55, 48, 436, 375, 82, 377, |
| 2085 | 272, 56, 91, 92, 221, 577, 131, 311, 530, 446, |
| 2086 | 222, 223, 224, 225 |
| 2087 | }; |
| 2088 | |
| 2089 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 2090 | STATE-NUM. */ |
| 2091 | #define YYPACT_NINF -544 |
| 2092 | static const yytype_int16 yypact[] = |
| 2093 | { |
| 2094 | 291, -544, -544, -544, -544, -544, -544, -544, -9, -121, |
| 2095 | -14, -80, 72, -50, 19, -544, 110, 423, -544, 113, |
| 2096 | 13, -37, -33, -544, -16, 121, -544, 1532, -544, -544, |
| 2097 | -544, -544, -544, -544, -544, -544, -544, -544, -544, -544, |
| 2098 | 128, 128, 160, -544, -544, -544, -544, 128, -544, -544, |
| 2099 | -544, -544, -544, 128, 133, -544, 3, 183, 189, 192, |
| 2100 | -544, -544, -544, -544, -544, 32, -544, -544, -544, -544, |
| 2101 | -544, -544, -544, -544, 215, 218, 1, 509, -544, -544, |
| 2102 | -544, -18, -544, 190, 190, 184, -544, 260, 219, 219, |
| 2103 | -544, -544, 199, -544, -544, -544, -544, -544, -544, -544, |
| 2104 | -53, 1055, -544, 86, 102, 748, 32, -544, -18, -108, |
| 2105 | 118, 1055, 109, 260, 260, -544, -544, 1298, -544, -544, |
| 2106 | 1572, 267, -544, -544, -544, -544, -544, 1630, -544, -17, |
| 2107 | 1854, -544, 256, -544, -544, -18, -544, 136, 135, 1648, |
| 2108 | 1648, 137, -85, 1648, -544, 300, 157, -544, 1572, 1648, |
| 2109 | 32, 162, -18, 74, -544, 44, 307, 311, 324, 334, |
| 2110 | 335, 236, 336, 1110, 293, -544, 101, -544, -544, -544, |
| 2111 | -544, -544, 292, 1688, 63, 338, 219, -544, -544, -544, |
| 2112 | -544, -544, -544, -544, -544, -544, -544, -544, -544, -544, |
| 2113 | -544, -544, -544, -544, 392, 1194, 1648, 1648, 1648, 1648, |
| 2114 | -544, -544, -544, -544, -544, -544, -544, -544, -544, -544, |
| 2115 | -544, -544, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, |
| 2116 | 1648, -544, 219, -544, 49, -544, -544, 269, 1377, -544, |
| 2117 | -42, -38, -544, 197, -18, 200, -544, 293, -13, 1298, |
| 2118 | -544, -544, -544, -544, -544, -544, -544, -544, -544, -544, |
| 2119 | -544, 392, 1194, 202, 209, 212, 213, 214, 1417, 1728, |
| 2120 | 788, 348, 221, 223, 224, -544, -544, -544, 226, -544, |
| 2121 | 32, 699, -544, 837, 837, -544, 837, 1630, -544, -544, |
| 2122 | -544, -544, -544, -544, -544, -544, -544, -544, 1648, -544, |
| 2123 | -544, -544, -544, -544, -544, -544, -544, -544, -544, -544, |
| 2124 | -544, -544, -544, -544, -544, 1648, -8, -2, -544, 699, |
| 2125 | -15, 222, 227, 229, 230, 239, 245, 699, 699, 339, |
| 2126 | 1630, 1648, 1648, -544, -544, -544, -544, -544, -544, -544, |
| 2127 | -544, -544, -544, -544, -544, 120, -544, -544, -544, -544, |
| 2128 | 120, -544, 109, 340, 249, 250, 1572, 1572, 1572, 1572, |
| 2129 | 1572, -544, -544, -47, 1010, -4, -544, -75, -544, 1572, |
| 2130 | 1572, 1572, 248, 1457, -544, -544, -544, -544, -544, -544, |
| 2131 | -544, -544, 329, 1572, -544, -544, -544, -544, 262, -544, |
| 2132 | 263, 837, 699, 699, 23, -544, 31, -544, -544, 837, |
| 2133 | 246, 1648, 1648, 1648, 1648, 1648, 264, 265, 1648, 837, |
| 2134 | 699, 266, -544, -544, -544, -544, -544, -544, -544, 248, |
| 2135 | 248, 1648, 1572, 1572, -544, 273, 274, 275, 276, 1572, |
| 2136 | -544, 271, 965, -67, -544, -544, 283, 284, 371, 6, |
| 2137 | -544, -544, -18, 285, 288, -544, 398, 16, 427, 431, |
| 2138 | 301, 297, 299, 837, 452, 837, 305, 310, 837, 312, |
| 2139 | -18, -544, 313, 323, 837, 837, -18, 314, 326, 1648, |
| 2140 | -544, -544, 34, 328, 343, 154, 1572, 1572, 1572, 1572, |
| 2141 | -544, -544, 317, 1572, 1572, 1648, 438, 489, -544, 248, |
| 2142 | 131, 1475, -544, 344, -544, 837, 837, 1746, 837, 837, |
| 2143 | 326, -544, 326, 1648, 837, 345, 1648, 1648, 1648, -544, |
| 2144 | -544, 1746, 448, -544, 699, -544, 1572, 1572, -544, 351, |
| 2145 | 354, 353, 356, -544, 360, 361, 79, -544, -544, -544, |
| 2146 | -544, -544, -544, -18, -6, 485, 362, 357, 29, -18, |
| 2147 | 173, -544, -544, -544, -544, -544, 369, 837, -544, -544, |
| 2148 | -544, 176, 326, 363, 379, 1572, -544, 1572, 1572, -544, |
| 2149 | -544, -544, 131, -544, 481, -544, 521, -1, 558, 558, |
| 2150 | -544, 1803, -544, 381, -544, -544, -544, -544, 389, 391, |
| 2151 | 394, -544, 539, 400, 837, -544, 1249, 2, 397, 399, |
| 2152 | -544, -544, 80, 29, -18, -544, 120, -544, -544, -544, |
| 2153 | -544, 526, -544, -544, 401, -544, 1249, 269, 269, 538, |
| 2154 | 558, 558, -544, 540, 403, 837, -544, -544, 837, 542, |
| 2155 | 488, 269, 269, -544, 837, 546, -544, 837, -544 |
| 2156 | }; |
| 2157 | |
| 2158 | /* YYPGOTO[NTERM-NUM]. */ |
| 2159 | static const yytype_int16 yypgoto[] = |
| 2160 | { |
| 2161 | -544, 434, 439, 440, 320, 316, -171, -544, 0, 22, |
| 2162 | -134, 483, 9, -544, -544, -544, -544, 191, -544, -544, |
| 2163 | -544, -149, -544, -403, -544, -230, -544, -544, -284, 52, |
| 2164 | -544, -372, -544, -544, -26, 358, -119, -544, 468, 482, |
| 2165 | -113, -161, -245, 225, 257, 350, -544, -544, 573, -544, |
| 2166 | -544, -544, -544, -544, -544, -544, -544, -544, -544, -544, |
| 2167 | 502, -544, -544, -544, -544, -544, -544, -543, -64, 14, |
| 2168 | -195, -544, 536, -544, -544, -544, -544, -544, 92, 180, |
| 2169 | -544, -544, -544, -544 |
| 2170 | }; |
| 2171 | |
| 2172 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 2173 | positive, shift that token. If negative, reduce the rule which |
| 2174 | number is the opposite. If zero, do what YYDEFACT says. |
| 2175 | If YYTABLE_NINF, syntax error. */ |
| 2176 | #define YYTABLE_NINF -208 |
| 2177 | static const yytype_int16 yytable[] = |
| 2178 | { |
| 2179 | 11, 81, 265, 308, 276, 104, 340, 164, 166, 13, |
| 2180 | 275, 167, 110, 275, 355, 357, 110, 11, 312, 313, |
| 2181 | 314, 315, 316, 387, 90, 319, 13, 277, 476, 480, |
| 2182 | 267, 24, 93, 594, 443, 237, 110, 460, 461, 110, |
| 2183 | 476, 110, 445, 21, 25, 143, 110, -55, -55, -55, |
| 2184 | -55, 108, 110, 604, 144, 49, 50, 51, 22, 477, |
| 2185 | 52, 29, 30, 31, 32, 33, 34, 35, 143, 36, |
| 2186 | 241, 242, 26, 320, 273, 135, 444, 233, 419, 108, |
| 2187 | 274, 63, 64, -143, 444, 135, 419, 425, 110, 240, |
| 2188 | 27, 152, 11, 1, 2, 472, 3, 4, 5, 266, |
| 2189 | 132, 152, 28, 341, 342, 133, 419, 519, 111, 423, |
| 2190 | 43, 420, 111, 230, 231, 57, 336, 234, 599, 58, |
| 2191 | 552, 2, 337, 238, 4, 558, 559, 401, 437, 402, |
| 2192 | 403, 404, 111, 110, 405, 111, -67, 111, 406, 407, |
| 2193 | 59, 389, 111, 61, 168, 384, -67, 271, 111, 419, |
| 2194 | 1, 386, -67, 3, 90, 5, 424, 575, 381, 45, |
| 2195 | 595, 46, 105, 321, 322, 94, 37, 38, 39, 419, |
| 2196 | 306, 307, 271, 309, 503, 268, 484, 597, 598, -143, |
| 2197 | 600, 601, 101, -143, 111, 505, 310, 271, 271, 271, |
| 2198 | 271, 271, 317, 318, 271, 85, 449, 86, 451, 452, |
| 2199 | 453, 399, 135, 611, 612, 97, 533, 376, 534, 376, |
| 2200 | 376, 98, 376, 152, 99, 402, 403, 404, 1, 102, |
| 2201 | 405, 3, 103, 5, 406, 407, 115, 86, 116, 111, |
| 2202 | 551, 83, 84, 414, 415, 416, 417, 418, 88, 243, |
| 2203 | 244, 245, 246, 139, 89, 376, 426, 427, 428, 323, |
| 2204 | 324, 152, 524, 376, 376, 402, 403, 404, 565, 140, |
| 2205 | 405, 265, 382, 147, 406, 407, 325, 326, 145, 327, |
| 2206 | 328, 165, 329, 330, 331, 37, 38, 39, 226, 383, |
| 2207 | 121, 122, 123, 124, 125, 126, 229, 378, 379, 228, |
| 2208 | 380, -207, 118, 119, 152, 400, 271, 232, 535, 463, |
| 2209 | 464, 538, 539, 540, 235, 508, 470, 493, 236, -69, |
| 2210 | 1, 2, 239, 3, 4, 5, -56, 376, 376, 376, |
| 2211 | -57, 6, 7, 388, 560, 376, 561, 564, 422, 561, |
| 2212 | 582, 396, 397, -60, 586, 376, 376, 432, 148, 149, |
| 2213 | 113, 114, 8, -59, -58, 247, 9, 110, 269, 275, |
| 2214 | 10, 339, 346, 509, 510, 511, 512, 338, 266, 347, |
| 2215 | 514, 515, 348, 349, 350, 271, 450, 271, 271, 271, |
| 2216 | 358, 359, 456, 360, 361, 390, 363, 398, 411, 376, |
| 2217 | 391, 376, 392, 393, 376, 462, 576, 323, 324, 435, |
| 2218 | 376, 376, 394, 543, 544, 440, 441, 442, 395, 412, |
| 2219 | 413, 429, 448, 447, 325, 326, 596, 327, 328, 475, |
| 2220 | 329, 330, 331, 457, 458, 438, 439, 454, 455, 459, |
| 2221 | 483, 376, 376, -206, 376, 376, 466, 467, 468, 469, |
| 2222 | 376, 471, 568, 504, 569, 570, 473, 474, 481, 482, |
| 2223 | 376, -69, 1, 2, 485, 3, 4, 5, 486, 516, |
| 2224 | 488, 487, 489, 6, 7, 523, 491, 490, 493, 492, |
| 2225 | 517, 529, 495, 494, 501, 496, 497, 271, 499, 500, |
| 2226 | 271, 271, 271, 376, 8, 529, 498, 513, 9, 502, |
| 2227 | 520, 506, 10, 278, 279, 280, 281, 282, 283, 284, |
| 2228 | 285, 286, 287, 518, 376, 376, 507, 525, 537, 526, |
| 2229 | 527, 444, 531, 532, 545, 546, 547, 555, 536, 548, |
| 2230 | 376, 549, 550, 557, 566, 556, 63, 64, 542, 106, |
| 2231 | 66, 67, 68, 69, 70, 71, 72, 562, 1, 2, |
| 2232 | 567, 3, 4, 5, 572, 584, 376, 376, 574, 585, |
| 2233 | 587, 376, 588, 590, 376, 589, 591, -18, 602, -19, |
| 2234 | 376, 563, 520, 376, 603, 605, 609, 608, 73, 614, |
| 2235 | 615, 364, 365, 617, 218, 63, 64, 366, 345, 219, |
| 2236 | 220, 344, 580, 581, 571, 130, 553, 1, 2, 146, |
| 2237 | 3, 4, 5, 367, 368, 369, 334, 142, 593, 343, |
| 2238 | 44, 129, 96, 541, 465, 0, 0, 0, 370, 371, |
| 2239 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2240 | 0, 0, 0, 0, 606, 607, 372, 0, 0, 610, |
| 2241 | 0, 0, 613, 0, 0, 0, 0, 0, 616, 0, |
| 2242 | 0, 618, 179, 180, 181, 182, 183, 184, 185, 186, |
| 2243 | 187, 188, 189, 190, 191, 192, 193, 251, 252, 0, |
| 2244 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2245 | 0, 0, 0, 0, 74, 75, 0, 0, 76, 0, |
| 2246 | 77, 107, 0, 0, 253, 200, 578, 579, 203, 204, |
| 2247 | 205, 206, 207, 208, 209, 210, 211, 0, 254, 0, |
| 2248 | 255, 256, 257, 325, 326, 0, 327, 328, 0, 329, |
| 2249 | 330, 331, 364, 365, 0, 0, 63, 64, 366, 0, |
| 2250 | 0, 0, 0, 0, 0, 0, 0, 373, 1, 2, |
| 2251 | 0, 3, 4, 5, 367, 368, 369, 0, 0, 0, |
| 2252 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 370, |
| 2253 | 371, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2254 | 0, 0, 0, 110, 0, 63, 64, 372, 106, 66, |
| 2255 | 67, 68, 69, 70, 71, 72, 0, 1, 2, 0, |
| 2256 | 3, 4, 5, 179, 180, 181, 182, 183, 184, 185, |
| 2257 | 186, 187, 188, 189, 190, 191, 192, 193, 251, 252, |
| 2258 | 0, 0, 0, 0, 0, 63, 64, 73, 106, 155, |
| 2259 | 156, 157, 158, 159, 160, 72, 0, 1, 2, 0, |
| 2260 | 3, 4, 5, 0, 0, 253, 200, 201, 202, 203, |
| 2261 | 204, 205, 206, 207, 208, 209, 210, 211, 0, 254, |
| 2262 | 0, 255, 256, 257, 0, 0, 0, 73, 0, 0, |
| 2263 | 364, 365, 0, 0, 63, 64, 366, 0, 0, 111, |
| 2264 | 0, 0, 0, 0, 0, 0, 1, 2, 373, 3, |
| 2265 | 4, 5, 367, 368, 369, 0, 0, 0, 0, 0, |
| 2266 | 0, 0, 0, 0, 0, 0, 0, 370, 371, 0, |
| 2267 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2268 | 0, 0, 0, 0, 0, 372, 0, 0, 0, 0, |
| 2269 | 0, 0, 0, 74, 75, 0, 0, 76, 0, 77, |
| 2270 | 141, 179, 180, 181, 182, 183, 184, 185, 186, 187, |
| 2271 | 188, 189, 190, 191, 192, 193, 251, 252, 0, 0, |
| 2272 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2273 | 0, 0, 0, 74, 75, 0, 0, 76, 0, 77, |
| 2274 | 356, 0, 0, 253, 200, 201, 202, 203, 204, 205, |
| 2275 | 206, 207, 208, 209, 210, 211, 0, 254, 0, 255, |
| 2276 | 256, 257, 63, 64, 0, 0, 0, 0, 0, 0, |
| 2277 | 0, 0, 0, 0, 1, 2, 0, 3, 4, 5, |
| 2278 | 248, 0, 0, 0, 0, 0, 373, 0, 0, 0, |
| 2279 | 0, 0, 0, 0, 0, 249, 250, 0, 0, 0, |
| 2280 | 0, 0, 0, 0, 0, 0, 0, 63, 64, 110, |
| 2281 | 106, 155, 156, 157, 158, 159, 160, 72, 0, 1, |
| 2282 | 2, 0, 3, 4, 5, 0, 0, 0, 0, 179, |
| 2283 | 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, |
| 2284 | 190, 191, 192, 193, 251, 252, 0, 0, 0, 73, |
| 2285 | 0, 0, 63, 64, 0, 106, 66, 67, 68, 69, |
| 2286 | 70, 71, 72, 0, 1, 2, 0, 3, 4, 5, |
| 2287 | 0, 253, 200, 201, 202, 203, 204, 205, 206, 207, |
| 2288 | 208, 209, 210, 211, 134, 254, 0, 255, 256, 257, |
| 2289 | 0, 0, 0, 0, 73, 0, 0, 0, 0, 0, |
| 2290 | 0, 0, 0, 0, 0, 111, 0, 63, 64, -67, |
| 2291 | 0, 258, 0, 0, 259, 0, 260, 0, 261, 1, |
| 2292 | 2, 0, 3, 4, 5, 248, 0, 0, 0, 0, |
| 2293 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2294 | 249, 250, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2295 | 0, 0, 0, 0, 110, 74, 75, 0, 0, 76, |
| 2296 | 0, 77, 421, 0, 0, 0, 0, 0, 0, 0, |
| 2297 | 0, 0, 0, 0, 179, 180, 181, 182, 183, 184, |
| 2298 | 185, 186, 187, 188, 189, 190, 191, 192, 193, 251, |
| 2299 | 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2300 | 74, 75, 0, 0, 76, 0, 77, 0, 0, 0, |
| 2301 | 289, 290, 0, 0, 0, 0, 253, 200, 201, 202, |
| 2302 | 203, 204, 205, 206, 207, 208, 209, 210, 211, 0, |
| 2303 | 254, 0, 255, 256, 257, 0, 0, 0, 0, 0, |
| 2304 | 0, 0, 364, 365, 0, 0, 0, 0, 366, 0, |
| 2305 | 111, 0, 0, 0, 0, 0, 258, 0, 0, 259, |
| 2306 | 0, 260, 0, 261, 367, 368, 369, 0, 0, 0, |
| 2307 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 370, |
| 2308 | 371, 291, 292, 293, 294, 295, 296, 297, 298, 299, |
| 2309 | 300, 301, 302, 303, 304, 63, 64, 372, 150, 66, |
| 2310 | 67, 68, 69, 70, 71, 72, 0, 1, 2, 0, |
| 2311 | 3, 4, 5, 179, 180, 181, 182, 183, 184, 185, |
| 2312 | 186, 187, 188, 189, 190, 191, 192, 193, 251, 252, |
| 2313 | 0, 0, 0, 0, 0, 0, 0, 73, 0, 0, |
| 2314 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2315 | 0, 0, 0, 0, 0, 253, 200, 201, 202, 203, |
| 2316 | 204, 205, 206, 207, 208, 209, 210, 211, 0, 254, |
| 2317 | 0, 255, 256, 257, 63, 64, 0, 106, 66, 67, |
| 2318 | 68, 69, 70, 71, 72, 0, 1, 2, 0, 3, |
| 2319 | 4, 5, 0, 0, 0, 0, 0, 0, 373, 0, |
| 2320 | 0, 0, 0, 0, 0, 0, 333, 0, 0, 0, |
| 2321 | 151, 0, 0, 0, 63, 64, 73, 106, 155, 156, |
| 2322 | 157, 158, 159, 160, 72, 0, 1, 2, 0, 3, |
| 2323 | 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2324 | 0, 0, 0, 74, 75, 0, 0, 76, 0, 77, |
| 2325 | 0, 0, 0, 0, 63, 64, 73, 106, 66, 67, |
| 2326 | 68, 69, 70, 71, 72, 0, 1, 2, 0, 3, |
| 2327 | 4, 5, 63, 64, 0, 106, 66, 67, 68, 69, |
| 2328 | 70, 71, 72, 0, 1, 2, 431, 3, 4, 5, |
| 2329 | 0, 0, 0, 0, 0, 0, 73, 0, 0, 0, |
| 2330 | 0, 0, 0, 0, 522, 0, 0, 0, 0, 0, |
| 2331 | 0, 0, 0, 0, 73, 0, 0, 0, 0, 0, |
| 2332 | 0, 0, 74, 75, 0, 0, 76, 0, 77, 63, |
| 2333 | 64, 0, 65, 66, 67, 68, 69, 70, 71, 72, |
| 2334 | 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, |
| 2335 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2336 | 0, 0, 74, 75, 0, 351, 76, 0, 77, 63, |
| 2337 | 64, 73, 106, 155, 156, 157, 158, 159, 160, 72, |
| 2338 | 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, |
| 2339 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2340 | 0, 0, 74, 75, 0, 0, 76, 0, 77, 0, |
| 2341 | 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2342 | 74, 75, 0, 0, 76, 0, 77, 63, 64, 0, |
| 2343 | 150, 66, 67, 68, 69, 70, 71, 72, 0, 1, |
| 2344 | 2, 0, 3, 4, 5, 63, 64, 0, 106, 66, |
| 2345 | 67, 68, 69, 70, 71, 72, 0, 1, 2, 0, |
| 2346 | 3, 4, 5, 0, 0, 0, 0, 0, 0, 73, |
| 2347 | 0, 0, 0, 0, 0, 0, 0, 74, 75, 0, |
| 2348 | 0, 76, 0, 77, 0, 63, 64, 73, 270, 66, |
| 2349 | 67, 68, 69, 70, 71, 72, 0, 1, 2, 0, |
| 2350 | 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, |
| 2351 | 0, 0, 0, 0, 0, 0, 0, 74, 75, 0, |
| 2352 | 0, 76, 0, 77, 0, 63, 64, 73, 106, 155, |
| 2353 | 156, 157, 158, 159, 160, 72, 0, 1, 2, 0, |
| 2354 | 3, 4, 5, 63, 64, 0, 106, 66, 67, 68, |
| 2355 | 69, 70, 71, 528, 0, 1, 2, 0, 3, 4, |
| 2356 | 5, 0, 0, 0, 0, 0, 0, 73, 0, 0, |
| 2357 | 0, 0, 0, 0, 0, 74, 75, 0, 0, 76, |
| 2358 | 0, 77, 0, 0, 0, 73, 0, 0, 0, 0, |
| 2359 | 0, 0, 0, 74, 75, 0, 0, 76, 0, 77, |
| 2360 | 63, 64, 0, 106, 66, 67, 68, 69, 70, 71, |
| 2361 | 583, 0, 1, 2, 0, 3, 4, 5, 0, 0, |
| 2362 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2363 | 0, 0, 0, 74, 75, 0, 0, 76, 0, 77, |
| 2364 | 0, 0, 73, 0, 0, 0, 0, 0, 0, 0, |
| 2365 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2366 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2367 | 0, 0, 0, 74, 75, 0, 0, 76, 0, 354, |
| 2368 | 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2369 | 0, 74, 75, 0, 0, 76, 0, 77, 0, 0, |
| 2370 | 171, 172, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2371 | 0, 0, 173, 174, 175, 176, 177, 178, 179, 180, |
| 2372 | 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, |
| 2373 | 191, 192, 193, 194, 195, 0, 0, 0, 0, 0, |
| 2374 | 0, 0, 0, 0, 0, 0, 0, 0, 74, 75, |
| 2375 | 0, 0, 76, 0, 77, 196, 197, 198, 0, 0, |
| 2376 | 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, |
| 2377 | 209, 210, 211, 212, 213, 214, 215, 216, 217 |
| 2378 | }; |
| 2379 | |
| 2380 | static const yytype_int16 yycheck[] = |
| 2381 | { |
| 2382 | 0, 27, 163, 198, 175, 4, 236, 120, 127, 0, |
| 2383 | 11, 28, 54, 11, 259, 260, 54, 17, 213, 214, |
| 2384 | 215, 216, 217, 307, 21, 220, 17, 176, 34, 432, |
| 2385 | 164, 152, 29, 576, 11, 148, 54, 409, 410, 54, |
| 2386 | 34, 54, 11, 52, 58, 153, 54, 3, 4, 5, |
| 2387 | 6, 77, 54, 596, 162, 42, 43, 44, 67, 53, |
| 2388 | 47, 42, 43, 44, 45, 46, 47, 48, 153, 50, |
| 2389 | 26, 27, 152, 222, 11, 101, 53, 162, 153, 105, |
| 2390 | 17, 7, 8, 54, 53, 111, 153, 162, 54, 153, |
| 2391 | 18, 117, 92, 19, 20, 162, 22, 23, 24, 163, |
| 2392 | 153, 127, 152, 237, 238, 158, 153, 479, 150, 354, |
| 2393 | 0, 158, 150, 139, 140, 152, 158, 143, 38, 152, |
| 2394 | 523, 20, 160, 149, 23, 528, 529, 322, 373, 135, |
| 2395 | 136, 137, 150, 54, 140, 150, 154, 150, 144, 145, |
| 2396 | 156, 156, 150, 22, 161, 153, 154, 173, 150, 153, |
| 2397 | 19, 153, 154, 22, 21, 24, 160, 158, 277, 46, |
| 2398 | 158, 48, 161, 114, 115, 162, 147, 148, 149, 153, |
| 2399 | 196, 197, 198, 199, 458, 166, 160, 580, 581, 150, |
| 2400 | 583, 584, 150, 154, 150, 151, 212, 213, 214, 215, |
| 2401 | 216, 217, 218, 219, 220, 35, 391, 37, 393, 394, |
| 2402 | 395, 320, 228, 606, 607, 22, 490, 271, 492, 273, |
| 2403 | 274, 22, 276, 239, 22, 135, 136, 137, 19, 4, |
| 2404 | 140, 22, 4, 24, 144, 145, 42, 37, 44, 150, |
| 2405 | 151, 40, 41, 346, 347, 348, 349, 350, 47, 3, |
| 2406 | 4, 5, 6, 157, 53, 309, 359, 360, 361, 118, |
| 2407 | 119, 277, 482, 317, 318, 135, 136, 137, 542, 157, |
| 2408 | 140, 422, 288, 154, 144, 145, 135, 136, 150, 138, |
| 2409 | 139, 4, 141, 142, 143, 147, 148, 149, 22, 305, |
| 2410 | 61, 62, 63, 64, 65, 66, 151, 273, 274, 153, |
| 2411 | 276, 0, 32, 33, 320, 321, 322, 160, 493, 412, |
| 2412 | 413, 496, 497, 498, 4, 151, 419, 153, 151, 18, |
| 2413 | 19, 20, 150, 22, 23, 24, 9, 381, 382, 383, |
| 2414 | 9, 30, 31, 309, 151, 389, 153, 151, 354, 153, |
| 2415 | 560, 317, 318, 9, 564, 399, 400, 363, 113, 114, |
| 2416 | 83, 84, 51, 9, 9, 9, 55, 54, 56, 11, |
| 2417 | 59, 151, 150, 466, 467, 468, 469, 160, 422, 150, |
| 2418 | 473, 474, 150, 150, 150, 391, 392, 393, 394, 395, |
| 2419 | 22, 150, 398, 150, 150, 153, 150, 38, 38, 443, |
| 2420 | 153, 445, 153, 153, 448, 411, 557, 118, 119, 60, |
| 2421 | 454, 455, 153, 506, 507, 381, 382, 383, 153, 150, |
| 2422 | 150, 153, 156, 389, 135, 136, 577, 138, 139, 38, |
| 2423 | 141, 142, 143, 399, 400, 153, 153, 153, 153, 153, |
| 2424 | 22, 485, 486, 0, 488, 489, 153, 153, 153, 153, |
| 2425 | 494, 160, 545, 459, 547, 548, 153, 153, 153, 151, |
| 2426 | 504, 18, 19, 20, 17, 22, 23, 24, 17, 475, |
| 2427 | 153, 150, 153, 30, 31, 481, 4, 443, 153, 445, |
| 2428 | 22, 487, 448, 153, 150, 153, 153, 493, 454, 455, |
| 2429 | 496, 497, 498, 537, 51, 501, 153, 160, 55, 153, |
| 2430 | 480, 153, 59, 91, 92, 93, 94, 95, 96, 97, |
| 2431 | 98, 99, 100, 4, 558, 559, 153, 153, 153, 485, |
| 2432 | 486, 53, 488, 489, 153, 151, 153, 22, 494, 153, |
| 2433 | 574, 151, 151, 156, 151, 153, 7, 8, 504, 10, |
| 2434 | 11, 12, 13, 14, 15, 16, 17, 158, 19, 20, |
| 2435 | 151, 22, 23, 24, 53, 561, 600, 601, 17, 158, |
| 2436 | 151, 605, 151, 4, 608, 151, 146, 150, 22, 150, |
| 2437 | 614, 537, 552, 617, 153, 17, 153, 17, 49, 17, |
| 2438 | 72, 3, 4, 17, 130, 7, 8, 9, 252, 130, |
| 2439 | 130, 251, 558, 559, 552, 92, 524, 19, 20, 111, |
| 2440 | 22, 23, 24, 25, 26, 27, 228, 105, 574, 239, |
| 2441 | 17, 89, 56, 501, 414, -1, -1, -1, 40, 41, |
| 2442 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2443 | -1, -1, -1, -1, 600, 601, 58, -1, -1, 605, |
| 2444 | -1, -1, 608, -1, -1, -1, -1, -1, 614, -1, |
| 2445 | -1, 617, 74, 75, 76, 77, 78, 79, 80, 81, |
| 2446 | 82, 83, 84, 85, 86, 87, 88, 89, 90, -1, |
| 2447 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2448 | -1, -1, -1, -1, 155, 156, -1, -1, 159, -1, |
| 2449 | 161, 162, -1, -1, 116, 117, 118, 119, 120, 121, |
| 2450 | 122, 123, 124, 125, 126, 127, 128, -1, 130, -1, |
| 2451 | 132, 133, 134, 135, 136, -1, 138, 139, -1, 141, |
| 2452 | 142, 143, 3, 4, -1, -1, 7, 8, 9, -1, |
| 2453 | -1, -1, -1, -1, -1, -1, -1, 159, 19, 20, |
| 2454 | -1, 22, 23, 24, 25, 26, 27, -1, -1, -1, |
| 2455 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 40, |
| 2456 | 41, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2457 | -1, -1, -1, 54, -1, 7, 8, 58, 10, 11, |
| 2458 | 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, |
| 2459 | 22, 23, 24, 74, 75, 76, 77, 78, 79, 80, |
| 2460 | 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 2461 | -1, -1, -1, -1, -1, 7, 8, 49, 10, 11, |
| 2462 | 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, |
| 2463 | 22, 23, 24, -1, -1, 116, 117, 118, 119, 120, |
| 2464 | 121, 122, 123, 124, 125, 126, 127, 128, -1, 130, |
| 2465 | -1, 132, 133, 134, -1, -1, -1, 49, -1, -1, |
| 2466 | 3, 4, -1, -1, 7, 8, 9, -1, -1, 150, |
| 2467 | -1, -1, -1, -1, -1, -1, 19, 20, 159, 22, |
| 2468 | 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, |
| 2469 | -1, -1, -1, -1, -1, -1, -1, 40, 41, -1, |
| 2470 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2471 | -1, -1, -1, -1, -1, 58, -1, -1, -1, -1, |
| 2472 | -1, -1, -1, 155, 156, -1, -1, 159, -1, 161, |
| 2473 | 162, 74, 75, 76, 77, 78, 79, 80, 81, 82, |
| 2474 | 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, |
| 2475 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2476 | -1, -1, -1, 155, 156, -1, -1, 159, -1, 161, |
| 2477 | 162, -1, -1, 116, 117, 118, 119, 120, 121, 122, |
| 2478 | 123, 124, 125, 126, 127, 128, -1, 130, -1, 132, |
| 2479 | 133, 134, 7, 8, -1, -1, -1, -1, -1, -1, |
| 2480 | -1, -1, -1, -1, 19, 20, -1, 22, 23, 24, |
| 2481 | 25, -1, -1, -1, -1, -1, 159, -1, -1, -1, |
| 2482 | -1, -1, -1, -1, -1, 40, 41, -1, -1, -1, |
| 2483 | -1, -1, -1, -1, -1, -1, -1, 7, 8, 54, |
| 2484 | 10, 11, 12, 13, 14, 15, 16, 17, -1, 19, |
| 2485 | 20, -1, 22, 23, 24, -1, -1, -1, -1, 74, |
| 2486 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 2487 | 85, 86, 87, 88, 89, 90, -1, -1, -1, 49, |
| 2488 | -1, -1, 7, 8, -1, 10, 11, 12, 13, 14, |
| 2489 | 15, 16, 17, -1, 19, 20, -1, 22, 23, 24, |
| 2490 | -1, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 2491 | 125, 126, 127, 128, 39, 130, -1, 132, 133, 134, |
| 2492 | -1, -1, -1, -1, 49, -1, -1, -1, -1, -1, |
| 2493 | -1, -1, -1, -1, -1, 150, -1, 7, 8, 154, |
| 2494 | -1, 156, -1, -1, 159, -1, 161, -1, 163, 19, |
| 2495 | 20, -1, 22, 23, 24, 25, -1, -1, -1, -1, |
| 2496 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2497 | 40, 41, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2498 | -1, -1, -1, -1, 54, 155, 156, -1, -1, 159, |
| 2499 | -1, 161, 162, -1, -1, -1, -1, -1, -1, -1, |
| 2500 | -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, |
| 2501 | 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, |
| 2502 | 90, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2503 | 155, 156, -1, -1, 159, -1, 161, -1, -1, -1, |
| 2504 | 26, 27, -1, -1, -1, -1, 116, 117, 118, 119, |
| 2505 | 120, 121, 122, 123, 124, 125, 126, 127, 128, -1, |
| 2506 | 130, -1, 132, 133, 134, -1, -1, -1, -1, -1, |
| 2507 | -1, -1, 3, 4, -1, -1, -1, -1, 9, -1, |
| 2508 | 150, -1, -1, -1, -1, -1, 156, -1, -1, 159, |
| 2509 | -1, 161, -1, 163, 25, 26, 27, -1, -1, -1, |
| 2510 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 40, |
| 2511 | 41, 97, 98, 99, 100, 101, 102, 103, 104, 105, |
| 2512 | 106, 107, 108, 109, 110, 7, 8, 58, 10, 11, |
| 2513 | 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, |
| 2514 | 22, 23, 24, 74, 75, 76, 77, 78, 79, 80, |
| 2515 | 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 2516 | -1, -1, -1, -1, -1, -1, -1, 49, -1, -1, |
| 2517 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2518 | -1, -1, -1, -1, -1, 116, 117, 118, 119, 120, |
| 2519 | 121, 122, 123, 124, 125, 126, 127, 128, -1, 130, |
| 2520 | -1, 132, 133, 134, 7, 8, -1, 10, 11, 12, |
| 2521 | 13, 14, 15, 16, 17, -1, 19, 20, -1, 22, |
| 2522 | 23, 24, -1, -1, -1, -1, -1, -1, 159, -1, |
| 2523 | -1, -1, -1, -1, -1, -1, 39, -1, -1, -1, |
| 2524 | 122, -1, -1, -1, 7, 8, 49, 10, 11, 12, |
| 2525 | 13, 14, 15, 16, 17, -1, 19, 20, -1, 22, |
| 2526 | 23, 24, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2527 | -1, -1, -1, 155, 156, -1, -1, 159, -1, 161, |
| 2528 | -1, -1, -1, -1, 7, 8, 49, 10, 11, 12, |
| 2529 | 13, 14, 15, 16, 17, -1, 19, 20, -1, 22, |
| 2530 | 23, 24, 7, 8, -1, 10, 11, 12, 13, 14, |
| 2531 | 15, 16, 17, -1, 19, 20, 39, 22, 23, 24, |
| 2532 | -1, -1, -1, -1, -1, -1, 49, -1, -1, -1, |
| 2533 | -1, -1, -1, -1, 39, -1, -1, -1, -1, -1, |
| 2534 | -1, -1, -1, -1, 49, -1, -1, -1, -1, -1, |
| 2535 | -1, -1, 155, 156, -1, -1, 159, -1, 161, 7, |
| 2536 | 8, -1, 10, 11, 12, 13, 14, 15, 16, 17, |
| 2537 | -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, |
| 2538 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2539 | -1, -1, 155, 156, -1, 158, 159, -1, 161, 7, |
| 2540 | 8, 49, 10, 11, 12, 13, 14, 15, 16, 17, |
| 2541 | -1, 19, 20, -1, 22, 23, 24, -1, -1, -1, |
| 2542 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2543 | -1, -1, 155, 156, -1, -1, 159, -1, 161, -1, |
| 2544 | -1, 49, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2545 | 155, 156, -1, -1, 159, -1, 161, 7, 8, -1, |
| 2546 | 10, 11, 12, 13, 14, 15, 16, 17, -1, 19, |
| 2547 | 20, -1, 22, 23, 24, 7, 8, -1, 10, 11, |
| 2548 | 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, |
| 2549 | 22, 23, 24, -1, -1, -1, -1, -1, -1, 49, |
| 2550 | -1, -1, -1, -1, -1, -1, -1, 155, 156, -1, |
| 2551 | -1, 159, -1, 161, -1, 7, 8, 49, 10, 11, |
| 2552 | 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, |
| 2553 | 22, 23, 24, -1, -1, -1, -1, -1, -1, -1, |
| 2554 | -1, -1, -1, -1, -1, -1, -1, 155, 156, -1, |
| 2555 | -1, 159, -1, 161, -1, 7, 8, 49, 10, 11, |
| 2556 | 12, 13, 14, 15, 16, 17, -1, 19, 20, -1, |
| 2557 | 22, 23, 24, 7, 8, -1, 10, 11, 12, 13, |
| 2558 | 14, 15, 16, 17, -1, 19, 20, -1, 22, 23, |
| 2559 | 24, -1, -1, -1, -1, -1, -1, 49, -1, -1, |
| 2560 | -1, -1, -1, -1, -1, 155, 156, -1, -1, 159, |
| 2561 | -1, 161, -1, -1, -1, 49, -1, -1, -1, -1, |
| 2562 | -1, -1, -1, 155, 156, -1, -1, 159, -1, 161, |
| 2563 | 7, 8, -1, 10, 11, 12, 13, 14, 15, 16, |
| 2564 | 17, -1, 19, 20, -1, 22, 23, 24, -1, -1, |
| 2565 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2566 | -1, -1, -1, 155, 156, -1, -1, 159, -1, 161, |
| 2567 | -1, -1, 49, -1, -1, -1, -1, -1, -1, -1, |
| 2568 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2569 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2570 | -1, -1, -1, 155, 156, -1, -1, 159, -1, 161, |
| 2571 | 36, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2572 | -1, 155, 156, -1, -1, 159, -1, 161, -1, -1, |
| 2573 | 56, 57, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2574 | -1, -1, 68, 69, 70, 71, 72, 73, 74, 75, |
| 2575 | 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, |
| 2576 | 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, |
| 2577 | -1, -1, -1, -1, -1, -1, -1, -1, 155, 156, |
| 2578 | -1, -1, 159, -1, 161, 111, 112, 113, -1, -1, |
| 2579 | 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, |
| 2580 | 126, 127, 128, 129, 130, 131, 132, 133, 134 |
| 2581 | }; |
| 2582 | |
| 2583 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 2584 | symbol of state STATE-NUM. */ |
| 2585 | static const yytype_uint8 yystos[] = |
| 2586 | { |
| 2587 | 0, 19, 20, 22, 23, 24, 30, 31, 51, 55, |
| 2588 | 59, 172, 175, 176, 177, 178, 210, 211, 212, 214, |
| 2589 | 213, 52, 67, 219, 152, 58, 152, 18, 152, 42, |
| 2590 | 43, 44, 45, 46, 47, 48, 50, 147, 148, 149, |
| 2591 | 179, 180, 181, 0, 212, 46, 48, 182, 229, 42, |
| 2592 | 43, 44, 47, 183, 226, 228, 235, 152, 152, 156, |
| 2593 | 220, 22, 218, 7, 8, 10, 11, 12, 13, 14, |
| 2594 | 15, 16, 17, 49, 155, 156, 159, 161, 172, 176, |
| 2595 | 197, 198, 232, 181, 181, 35, 37, 208, 181, 181, |
| 2596 | 21, 236, 237, 29, 162, 227, 236, 22, 22, 22, |
| 2597 | 221, 150, 4, 4, 4, 161, 10, 162, 198, 203, |
| 2598 | 54, 150, 174, 208, 208, 42, 44, 184, 32, 33, |
| 2599 | 207, 61, 62, 63, 64, 65, 66, 185, 224, 224, |
| 2600 | 175, 240, 153, 158, 39, 198, 199, 201, 202, 157, |
| 2601 | 157, 162, 203, 153, 162, 150, 202, 154, 207, 207, |
| 2602 | 10, 122, 198, 200, 209, 11, 12, 13, 14, 15, |
| 2603 | 16, 170, 171, 198, 204, 4, 200, 28, 161, 225, |
| 2604 | 36, 56, 57, 68, 69, 70, 71, 72, 73, 74, |
| 2605 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 2606 | 85, 86, 87, 88, 89, 90, 111, 112, 113, 116, |
| 2607 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 2608 | 127, 128, 129, 130, 131, 132, 133, 134, 165, 166, |
| 2609 | 167, 238, 244, 245, 246, 247, 22, 187, 153, 151, |
| 2610 | 198, 198, 160, 162, 198, 4, 151, 204, 198, 150, |
| 2611 | 232, 26, 27, 3, 4, 5, 6, 9, 25, 40, |
| 2612 | 41, 89, 90, 116, 130, 132, 133, 134, 156, 159, |
| 2613 | 161, 163, 165, 166, 167, 205, 232, 174, 176, 56, |
| 2614 | 10, 198, 234, 11, 17, 11, 170, 185, 91, 92, |
| 2615 | 93, 94, 95, 96, 97, 98, 99, 100, 168, 26, |
| 2616 | 27, 97, 98, 99, 100, 101, 102, 103, 104, 105, |
| 2617 | 106, 107, 108, 109, 110, 169, 198, 198, 234, 198, |
| 2618 | 198, 241, 234, 234, 234, 234, 234, 198, 198, 234, |
| 2619 | 185, 114, 115, 118, 119, 135, 136, 138, 139, 141, |
| 2620 | 142, 143, 186, 39, 199, 189, 158, 160, 160, 151, |
| 2621 | 189, 174, 174, 209, 168, 169, 150, 150, 150, 150, |
| 2622 | 150, 158, 204, 206, 161, 206, 162, 206, 22, 150, |
| 2623 | 150, 150, 215, 150, 3, 4, 9, 25, 26, 27, |
| 2624 | 40, 41, 58, 159, 205, 231, 232, 233, 233, 233, |
| 2625 | 233, 200, 198, 198, 153, 192, 153, 192, 233, 156, |
| 2626 | 153, 153, 153, 153, 153, 153, 233, 233, 38, 200, |
| 2627 | 198, 234, 135, 136, 137, 140, 144, 145, 188, 216, |
| 2628 | 217, 38, 150, 150, 204, 204, 204, 204, 204, 153, |
| 2629 | 158, 162, 198, 206, 160, 162, 204, 204, 204, 153, |
| 2630 | 195, 39, 198, 222, 223, 60, 230, 206, 153, 153, |
| 2631 | 233, 233, 233, 11, 53, 11, 243, 233, 156, 234, |
| 2632 | 198, 234, 234, 234, 153, 153, 198, 233, 233, 153, |
| 2633 | 195, 195, 198, 204, 204, 243, 153, 153, 153, 153, |
| 2634 | 204, 160, 162, 153, 153, 38, 34, 53, 193, 196, |
| 2635 | 187, 153, 151, 22, 160, 17, 17, 150, 153, 153, |
| 2636 | 233, 4, 233, 153, 153, 233, 153, 153, 153, 233, |
| 2637 | 233, 150, 153, 192, 198, 151, 153, 153, 151, 204, |
| 2638 | 204, 204, 204, 160, 204, 204, 198, 22, 4, 195, |
| 2639 | 172, 173, 39, 198, 189, 153, 233, 233, 17, 198, |
| 2640 | 242, 233, 233, 192, 192, 234, 233, 153, 234, 234, |
| 2641 | 234, 242, 233, 204, 204, 153, 151, 153, 153, 151, |
| 2642 | 151, 151, 187, 193, 194, 22, 153, 156, 187, 187, |
| 2643 | 151, 153, 158, 233, 151, 192, 151, 151, 204, 204, |
| 2644 | 204, 173, 53, 191, 17, 158, 170, 239, 118, 119, |
| 2645 | 233, 233, 189, 17, 198, 158, 189, 151, 151, 151, |
| 2646 | 4, 146, 190, 233, 231, 158, 170, 187, 187, 38, |
| 2647 | 187, 187, 22, 153, 231, 17, 233, 233, 17, 153, |
| 2648 | 233, 187, 187, 233, 17, 72, 233, 17, 233 |
| 2649 | }; |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 2650 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2651 | #define yyerrok (yyerrstatus = 0) |
| 2652 | #define yyclearin (yychar = YYEMPTY) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2653 | #define YYEMPTY (-2) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2654 | #define YYEOF 0 |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2655 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2656 | #define YYACCEPT goto yyacceptlab |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2657 | #define YYABORT goto yyabortlab |
| 2658 | #define YYERROR goto yyerrorlab |
| 2659 | |
| 2660 | |
| 2661 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 2662 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2663 | Once GCC version 2 has supplanted version 1, this can go. */ |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2664 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2665 | #define YYFAIL goto yyerrlab |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2666 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2667 | #define YYRECOVERING() (!!yyerrstatus) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2668 | |
| 2669 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2670 | do \ |
| 2671 | if (yychar == YYEMPTY && yylen == 1) \ |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2672 | { \ |
| 2673 | yychar = (Token); \ |
| 2674 | yylval = (Value); \ |
| 2675 | yytoken = YYTRANSLATE (yychar); \ |
| 2676 | YYPOPSTACK (1); \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2677 | goto yybackup; \ |
| 2678 | } \ |
| 2679 | else \ |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2680 | { \ |
| 2681 | yyerror (YY_("syntax error: cannot back up")); \ |
| 2682 | YYERROR; \ |
| 2683 | } \ |
| 2684 | while (YYID (0)) |
| 2685 | |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 2686 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2687 | #define YYTERROR 1 |
| 2688 | #define YYERRCODE 256 |
| 2689 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2690 | |
| 2691 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
| 2692 | If N is 0, then set CURRENT to the empty location which ends |
| 2693 | the previous symbol: RHS[0] (always defined). */ |
| 2694 | |
| 2695 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| 2696 | #ifndef YYLLOC_DEFAULT |
| 2697 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 2698 | do \ |
| 2699 | if (YYID (N)) \ |
| 2700 | { \ |
| 2701 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
| 2702 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
| 2703 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
| 2704 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
| 2705 | } \ |
| 2706 | else \ |
| 2707 | { \ |
| 2708 | (Current).first_line = (Current).last_line = \ |
| 2709 | YYRHSLOC (Rhs, 0).last_line; \ |
| 2710 | (Current).first_column = (Current).last_column = \ |
| 2711 | YYRHSLOC (Rhs, 0).last_column; \ |
| 2712 | } \ |
| 2713 | while (YYID (0)) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2714 | #endif |
| 2715 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2716 | |
| 2717 | /* YY_LOCATION_PRINT -- Print the location on the stream. |
| 2718 | This macro was not mandated originally: define only if we know |
| 2719 | we won't break user code: when these are the locations we know. */ |
| 2720 | |
| 2721 | #ifndef YY_LOCATION_PRINT |
| 2722 | # if YYLTYPE_IS_TRIVIAL |
| 2723 | # define YY_LOCATION_PRINT(File, Loc) \ |
| 2724 | fprintf (File, "%d.%d-%d.%d", \ |
| 2725 | (Loc).first_line, (Loc).first_column, \ |
| 2726 | (Loc).last_line, (Loc).last_column) |
| 2727 | # else |
| 2728 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 2729 | # endif |
| 2730 | #endif |
| 2731 | |
| 2732 | |
| 2733 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 2734 | |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2735 | #ifdef YYLEX_PARAM |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2736 | # define YYLEX yylex (YYLEX_PARAM) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 2737 | #else |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2738 | # define YYLEX yylex () |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 2739 | #endif |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2740 | |
| 2741 | /* Enable debugging if requested. */ |
| 2742 | #if YYDEBUG |
| 2743 | |
| 2744 | # ifndef YYFPRINTF |
| 2745 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 2746 | # define YYFPRINTF fprintf |
| 2747 | # endif |
| 2748 | |
| 2749 | # define YYDPRINTF(Args) \ |
| 2750 | do { \ |
| 2751 | if (yydebug) \ |
| 2752 | YYFPRINTF Args; \ |
| 2753 | } while (YYID (0)) |
| 2754 | |
| 2755 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 2756 | do { \ |
| 2757 | if (yydebug) \ |
| 2758 | { \ |
| 2759 | YYFPRINTF (stderr, "%s ", Title); \ |
| 2760 | yy_symbol_print (stderr, \ |
| 2761 | Type, Value); \ |
| 2762 | YYFPRINTF (stderr, "\n"); \ |
| 2763 | } \ |
| 2764 | } while (YYID (0)) |
| 2765 | |
| 2766 | |
| 2767 | /*--------------------------------. |
| 2768 | | Print this symbol on YYOUTPUT. | |
| 2769 | `--------------------------------*/ |
| 2770 | |
| 2771 | /*ARGSUSED*/ |
| 2772 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2773 | || defined __cplusplus || defined _MSC_VER) |
| 2774 | static void |
| 2775 | yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 2776 | #else |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2777 | static void |
| 2778 | yy_symbol_value_print (yyoutput, yytype, yyvaluep) |
| 2779 | FILE *yyoutput; |
| 2780 | int yytype; |
| 2781 | YYSTYPE const * const yyvaluep; |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 2782 | #endif |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2783 | { |
| 2784 | if (!yyvaluep) |
| 2785 | return; |
| 2786 | # ifdef YYPRINT |
| 2787 | if (yytype < YYNTOKENS) |
| 2788 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 2789 | # else |
| 2790 | YYUSE (yyoutput); |
| 2791 | # endif |
| 2792 | switch (yytype) |
| 2793 | { |
| 2794 | default: |
| 2795 | break; |
| 2796 | } |
| 2797 | } |
| 2798 | |
| 2799 | |
| 2800 | /*--------------------------------. |
| 2801 | | Print this symbol on YYOUTPUT. | |
| 2802 | `--------------------------------*/ |
| 2803 | |
| 2804 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2805 | || defined __cplusplus || defined _MSC_VER) |
| 2806 | static void |
| 2807 | yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) |
| 2808 | #else |
| 2809 | static void |
| 2810 | yy_symbol_print (yyoutput, yytype, yyvaluep) |
| 2811 | FILE *yyoutput; |
| 2812 | int yytype; |
| 2813 | YYSTYPE const * const yyvaluep; |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 2814 | #endif |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2815 | { |
| 2816 | if (yytype < YYNTOKENS) |
| 2817 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 2818 | else |
| 2819 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
Anton Korobeynikov | b9b977d | 2007-11-14 09:53:48 +0000 | [diff] [blame] | 2820 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2821 | yy_symbol_value_print (yyoutput, yytype, yyvaluep); |
| 2822 | YYFPRINTF (yyoutput, ")"); |
| 2823 | } |
Anton Korobeynikov | b9b977d | 2007-11-14 09:53:48 +0000 | [diff] [blame] | 2824 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2825 | /*------------------------------------------------------------------. |
| 2826 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 2827 | | TOP (included). | |
| 2828 | `------------------------------------------------------------------*/ |
Anton Korobeynikov | b9b977d | 2007-11-14 09:53:48 +0000 | [diff] [blame] | 2829 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2830 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2831 | || defined __cplusplus || defined _MSC_VER) |
| 2832 | static void |
| 2833 | yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) |
| 2834 | #else |
| 2835 | static void |
| 2836 | yy_stack_print (bottom, top) |
| 2837 | yytype_int16 *bottom; |
| 2838 | yytype_int16 *top; |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 2839 | #endif |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2840 | { |
| 2841 | YYFPRINTF (stderr, "Stack now"); |
| 2842 | for (; bottom <= top; ++bottom) |
| 2843 | YYFPRINTF (stderr, " %d", *bottom); |
| 2844 | YYFPRINTF (stderr, "\n"); |
| 2845 | } |
Anton Korobeynikov | b9b977d | 2007-11-14 09:53:48 +0000 | [diff] [blame] | 2846 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2847 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 2848 | do { \ |
| 2849 | if (yydebug) \ |
| 2850 | yy_stack_print ((Bottom), (Top)); \ |
| 2851 | } while (YYID (0)) |
Anton Korobeynikov | b9b977d | 2007-11-14 09:53:48 +0000 | [diff] [blame] | 2852 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2853 | |
| 2854 | /*------------------------------------------------. |
| 2855 | | Report that the YYRULE is going to be reduced. | |
| 2856 | `------------------------------------------------*/ |
| 2857 | |
| 2858 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2859 | || defined __cplusplus || defined _MSC_VER) |
| 2860 | static void |
| 2861 | yy_reduce_print (YYSTYPE *yyvsp, int yyrule) |
| 2862 | #else |
| 2863 | static void |
| 2864 | yy_reduce_print (yyvsp, yyrule) |
| 2865 | YYSTYPE *yyvsp; |
| 2866 | int yyrule; |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 2867 | #endif |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2868 | { |
| 2869 | int yynrhs = yyr2[yyrule]; |
| 2870 | int yyi; |
| 2871 | unsigned long int yylno = yyrline[yyrule]; |
| 2872 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", |
| 2873 | yyrule - 1, yylno); |
| 2874 | /* The symbols being reduced. */ |
| 2875 | for (yyi = 0; yyi < yynrhs; yyi++) |
| 2876 | { |
| 2877 | fprintf (stderr, " $%d = ", yyi + 1); |
| 2878 | yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], |
| 2879 | &(yyvsp[(yyi + 1) - (yynrhs)]) |
| 2880 | ); |
| 2881 | fprintf (stderr, "\n"); |
| 2882 | } |
| 2883 | } |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2884 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2885 | # define YY_REDUCE_PRINT(Rule) \ |
| 2886 | do { \ |
| 2887 | if (yydebug) \ |
| 2888 | yy_reduce_print (yyvsp, Rule); \ |
| 2889 | } while (YYID (0)) |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 2890 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2891 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 2892 | multiple parsers can coexist. */ |
| 2893 | int yydebug; |
| 2894 | #else /* !YYDEBUG */ |
| 2895 | # define YYDPRINTF(Args) |
| 2896 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
| 2897 | # define YY_STACK_PRINT(Bottom, Top) |
| 2898 | # define YY_REDUCE_PRINT(Rule) |
| 2899 | #endif /* !YYDEBUG */ |
| 2900 | |
| 2901 | |
| 2902 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2903 | #ifndef YYINITDEPTH |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2904 | # define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2905 | #endif |
| 2906 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2907 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 2908 | if the built-in stack extension method is used). |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2909 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2910 | Do not make this value too large; the results are undefined if |
| 2911 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
| 2912 | evaluated with infinite-precision integer arithmetic. */ |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 2913 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2914 | #ifndef YYMAXDEPTH |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2915 | # define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2916 | #endif |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2917 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2918 | |
| 2919 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2920 | #if YYERROR_VERBOSE |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2921 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2922 | # ifndef yystrlen |
| 2923 | # if defined __GLIBC__ && defined _STRING_H |
| 2924 | # define yystrlen strlen |
| 2925 | # else |
| 2926 | /* Return the length of YYSTR. */ |
| 2927 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2928 | || defined __cplusplus || defined _MSC_VER) |
| 2929 | static YYSIZE_T |
| 2930 | yystrlen (const char *yystr) |
Anton Korobeynikov | b9b977d | 2007-11-14 09:53:48 +0000 | [diff] [blame] | 2931 | #else |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 2932 | static YYSIZE_T |
| 2933 | yystrlen (yystr) |
| 2934 | const char *yystr; |
| 2935 | #endif |
| 2936 | { |
| 2937 | YYSIZE_T yylen; |
| 2938 | for (yylen = 0; yystr[yylen]; yylen++) |
| 2939 | continue; |
| 2940 | return yylen; |
| 2941 | } |
| 2942 | # endif |
| 2943 | # endif |
| 2944 | |
| 2945 | # ifndef yystpcpy |
| 2946 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE |
| 2947 | # define yystpcpy stpcpy |
| 2948 | # else |
| 2949 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 2950 | YYDEST. */ |
| 2951 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 2952 | || defined __cplusplus || defined _MSC_VER) |
| 2953 | static char * |
| 2954 | yystpcpy (char *yydest, const char *yysrc) |
| 2955 | #else |
| 2956 | static char * |
| 2957 | yystpcpy (yydest, yysrc) |
| 2958 | char *yydest; |
| 2959 | const char *yysrc; |
| 2960 | #endif |
| 2961 | { |
| 2962 | char *yyd = yydest; |
| 2963 | const char *yys = yysrc; |
| 2964 | |
| 2965 | while ((*yyd++ = *yys++) != '\0') |
| 2966 | continue; |
| 2967 | |
| 2968 | return yyd - 1; |
| 2969 | } |
| 2970 | # endif |
| 2971 | # endif |
| 2972 | |
| 2973 | # ifndef yytnamerr |
| 2974 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
| 2975 | quotes and backslashes, so that it's suitable for yyerror. The |
| 2976 | heuristic is that double-quoting is unnecessary unless the string |
| 2977 | contains an apostrophe, a comma, or backslash (other than |
| 2978 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
| 2979 | null, do not copy; instead, return the length of what the result |
| 2980 | would have been. */ |
| 2981 | static YYSIZE_T |
| 2982 | yytnamerr (char *yyres, const char *yystr) |
| 2983 | { |
| 2984 | if (*yystr == '"') |
| 2985 | { |
| 2986 | YYSIZE_T yyn = 0; |
| 2987 | char const *yyp = yystr; |
| 2988 | |
| 2989 | for (;;) |
| 2990 | switch (*++yyp) |
| 2991 | { |
| 2992 | case '\'': |
| 2993 | case ',': |
| 2994 | goto do_not_strip_quotes; |
| 2995 | |
| 2996 | case '\\': |
| 2997 | if (*++yyp != '\\') |
| 2998 | goto do_not_strip_quotes; |
| 2999 | /* Fall through. */ |
| 3000 | default: |
| 3001 | if (yyres) |
| 3002 | yyres[yyn] = *yyp; |
| 3003 | yyn++; |
| 3004 | break; |
| 3005 | |
| 3006 | case '"': |
| 3007 | if (yyres) |
| 3008 | yyres[yyn] = '\0'; |
| 3009 | return yyn; |
| 3010 | } |
| 3011 | do_not_strip_quotes: ; |
| 3012 | } |
| 3013 | |
| 3014 | if (! yyres) |
| 3015 | return yystrlen (yystr); |
| 3016 | |
| 3017 | return yystpcpy (yyres, yystr) - yyres; |
| 3018 | } |
| 3019 | # endif |
| 3020 | |
| 3021 | /* Copy into YYRESULT an error message about the unexpected token |
| 3022 | YYCHAR while in state YYSTATE. Return the number of bytes copied, |
| 3023 | including the terminating null byte. If YYRESULT is null, do not |
| 3024 | copy anything; just return the number of bytes that would be |
| 3025 | copied. As a special case, return 0 if an ordinary "syntax error" |
| 3026 | message will do. Return YYSIZE_MAXIMUM if overflow occurs during |
| 3027 | size calculation. */ |
| 3028 | static YYSIZE_T |
| 3029 | yysyntax_error (char *yyresult, int yystate, int yychar) |
| 3030 | { |
| 3031 | int yyn = yypact[yystate]; |
| 3032 | |
| 3033 | if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) |
| 3034 | return 0; |
| 3035 | else |
| 3036 | { |
| 3037 | int yytype = YYTRANSLATE (yychar); |
| 3038 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); |
| 3039 | YYSIZE_T yysize = yysize0; |
| 3040 | YYSIZE_T yysize1; |
| 3041 | int yysize_overflow = 0; |
| 3042 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; |
| 3043 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 3044 | int yyx; |
| 3045 | |
| 3046 | # if 0 |
| 3047 | /* This is so xgettext sees the translatable formats that are |
| 3048 | constructed on the fly. */ |
| 3049 | YY_("syntax error, unexpected %s"); |
| 3050 | YY_("syntax error, unexpected %s, expecting %s"); |
| 3051 | YY_("syntax error, unexpected %s, expecting %s or %s"); |
| 3052 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); |
| 3053 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); |
| 3054 | # endif |
| 3055 | char *yyfmt; |
| 3056 | char const *yyf; |
| 3057 | static char const yyunexpected[] = "syntax error, unexpected %s"; |
| 3058 | static char const yyexpecting[] = ", expecting %s"; |
| 3059 | static char const yyor[] = " or %s"; |
| 3060 | char yyformat[sizeof yyunexpected |
| 3061 | + sizeof yyexpecting - 1 |
| 3062 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) |
| 3063 | * (sizeof yyor - 1))]; |
| 3064 | char const *yyprefix = yyexpecting; |
| 3065 | |
| 3066 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 3067 | YYCHECK. */ |
| 3068 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 3069 | |
| 3070 | /* Stay within bounds of both yycheck and yytname. */ |
| 3071 | int yychecklim = YYLAST - yyn + 1; |
| 3072 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 3073 | int yycount = 1; |
| 3074 | |
| 3075 | yyarg[0] = yytname[yytype]; |
| 3076 | yyfmt = yystpcpy (yyformat, yyunexpected); |
| 3077 | |
| 3078 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 3079 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 3080 | { |
| 3081 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 3082 | { |
| 3083 | yycount = 1; |
| 3084 | yysize = yysize0; |
| 3085 | yyformat[sizeof yyunexpected - 1] = '\0'; |
| 3086 | break; |
| 3087 | } |
| 3088 | yyarg[yycount++] = yytname[yyx]; |
| 3089 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); |
| 3090 | yysize_overflow |= (yysize1 < yysize); |
| 3091 | yysize = yysize1; |
| 3092 | yyfmt = yystpcpy (yyfmt, yyprefix); |
| 3093 | yyprefix = yyor; |
| 3094 | } |
| 3095 | |
| 3096 | yyf = YY_(yyformat); |
| 3097 | yysize1 = yysize + yystrlen (yyf); |
| 3098 | yysize_overflow |= (yysize1 < yysize); |
| 3099 | yysize = yysize1; |
| 3100 | |
| 3101 | if (yysize_overflow) |
| 3102 | return YYSIZE_MAXIMUM; |
| 3103 | |
| 3104 | if (yyresult) |
| 3105 | { |
| 3106 | /* Avoid sprintf, as that infringes on the user's name space. |
| 3107 | Don't have undefined behavior even if the translation |
| 3108 | produced a string with the wrong number of "%s"s. */ |
| 3109 | char *yyp = yyresult; |
| 3110 | int yyi = 0; |
| 3111 | while ((*yyp = *yyf) != '\0') |
| 3112 | { |
| 3113 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) |
| 3114 | { |
| 3115 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
| 3116 | yyf += 2; |
| 3117 | } |
| 3118 | else |
| 3119 | { |
| 3120 | yyp++; |
| 3121 | yyf++; |
| 3122 | } |
| 3123 | } |
| 3124 | } |
| 3125 | return yysize; |
| 3126 | } |
| 3127 | } |
| 3128 | #endif /* YYERROR_VERBOSE */ |
| 3129 | |
| 3130 | |
| 3131 | /*-----------------------------------------------. |
| 3132 | | Release the memory associated to this symbol. | |
| 3133 | `-----------------------------------------------*/ |
| 3134 | |
| 3135 | /*ARGSUSED*/ |
| 3136 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3137 | || defined __cplusplus || defined _MSC_VER) |
| 3138 | static void |
| 3139 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
| 3140 | #else |
| 3141 | static void |
| 3142 | yydestruct (yymsg, yytype, yyvaluep) |
| 3143 | const char *yymsg; |
| 3144 | int yytype; |
| 3145 | YYSTYPE *yyvaluep; |
| 3146 | #endif |
| 3147 | { |
| 3148 | YYUSE (yyvaluep); |
| 3149 | |
| 3150 | if (!yymsg) |
| 3151 | yymsg = "Deleting"; |
| 3152 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 3153 | |
| 3154 | switch (yytype) |
| 3155 | { |
| 3156 | |
| 3157 | default: |
| 3158 | break; |
| 3159 | } |
| 3160 | } |
| 3161 | |
| 3162 | |
| 3163 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 3164 | |
| 3165 | #ifdef YYPARSE_PARAM |
| 3166 | #if defined __STDC__ || defined __cplusplus |
| 3167 | int yyparse (void *YYPARSE_PARAM); |
| 3168 | #else |
| 3169 | int yyparse (); |
| 3170 | #endif |
| 3171 | #else /* ! YYPARSE_PARAM */ |
| 3172 | #if defined __STDC__ || defined __cplusplus |
David Greene | 5fd22a8 | 2007-09-04 18:46:50 +0000 | [diff] [blame] | 3173 | int yyparse (void); |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 3174 | #else |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3175 | int yyparse (); |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 3176 | #endif |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3177 | #endif /* ! YYPARSE_PARAM */ |
Chandler Carruth | 0220219 | 2007-08-04 01:56:21 +0000 | [diff] [blame] | 3178 | |
Anton Korobeynikov | b9b977d | 2007-11-14 09:53:48 +0000 | [diff] [blame] | 3179 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3180 | |
| 3181 | /* The look-ahead symbol. */ |
| 3182 | int yychar; |
| 3183 | |
| 3184 | /* The semantic value of the look-ahead symbol. */ |
| 3185 | YYSTYPE yylval; |
| 3186 | |
| 3187 | /* Number of syntax errors so far. */ |
| 3188 | int yynerrs; |
| 3189 | |
| 3190 | |
| 3191 | |
| 3192 | /*----------. |
| 3193 | | yyparse. | |
| 3194 | `----------*/ |
| 3195 | |
| 3196 | #ifdef YYPARSE_PARAM |
| 3197 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3198 | || defined __cplusplus || defined _MSC_VER) |
| 3199 | int |
| 3200 | yyparse (void *YYPARSE_PARAM) |
| 3201 | #else |
| 3202 | int |
| 3203 | yyparse (YYPARSE_PARAM) |
| 3204 | void *YYPARSE_PARAM; |
| 3205 | #endif |
| 3206 | #else /* ! YYPARSE_PARAM */ |
| 3207 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
| 3208 | || defined __cplusplus || defined _MSC_VER) |
| 3209 | int |
| 3210 | yyparse (void) |
| 3211 | #else |
| 3212 | int |
| 3213 | yyparse () |
| 3214 | |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 3215 | #endif |
| 3216 | #endif |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3217 | { |
| 3218 | |
| 3219 | int yystate; |
| 3220 | int yyn; |
| 3221 | int yyresult; |
| 3222 | /* Number of tokens to shift before error messages enabled. */ |
| 3223 | int yyerrstatus; |
| 3224 | /* Look-ahead token as an internal (translated) token number. */ |
| 3225 | int yytoken = 0; |
| 3226 | #if YYERROR_VERBOSE |
| 3227 | /* Buffer for error messages, and its allocated size. */ |
| 3228 | char yymsgbuf[128]; |
| 3229 | char *yymsg = yymsgbuf; |
| 3230 | YYSIZE_T yymsg_alloc = sizeof yymsgbuf; |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 3231 | #endif |
Anton Korobeynikov | b9b977d | 2007-11-14 09:53:48 +0000 | [diff] [blame] | 3232 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3233 | /* Three stacks and their tools: |
| 3234 | `yyss': related to states, |
| 3235 | `yyvs': related to semantic values, |
| 3236 | `yyls': related to locations. |
| 3237 | |
| 3238 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 3239 | to reallocate them elsewhere. */ |
| 3240 | |
| 3241 | /* The state stack. */ |
| 3242 | yytype_int16 yyssa[YYINITDEPTH]; |
| 3243 | yytype_int16 *yyss = yyssa; |
| 3244 | yytype_int16 *yyssp; |
| 3245 | |
| 3246 | /* The semantic value stack. */ |
| 3247 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 3248 | YYSTYPE *yyvs = yyvsa; |
| 3249 | YYSTYPE *yyvsp; |
| 3250 | |
| 3251 | |
| 3252 | |
| 3253 | #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) |
| 3254 | |
| 3255 | YYSIZE_T yystacksize = YYINITDEPTH; |
| 3256 | |
| 3257 | /* The variables used to return semantic value and location from the |
| 3258 | action routines. */ |
| 3259 | YYSTYPE yyval; |
| 3260 | |
| 3261 | |
| 3262 | /* The number of symbols on the RHS of the reduced rule. |
| 3263 | Keep to zero when no symbol should be popped. */ |
| 3264 | int yylen = 0; |
| 3265 | |
| 3266 | YYDPRINTF ((stderr, "Starting parse\n")); |
| 3267 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3268 | yystate = 0; |
| 3269 | yyerrstatus = 0; |
| 3270 | yynerrs = 0; |
| 3271 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 3272 | |
| 3273 | /* Initialize stack pointers. |
| 3274 | Waste one element of value and location stack |
| 3275 | so that they stay on the same level as the state stack. |
| 3276 | The wasted elements are never initialized. */ |
| 3277 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3278 | yyssp = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3279 | yyvsp = yyvs; |
| 3280 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3281 | goto yysetstate; |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 3282 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3283 | /*------------------------------------------------------------. |
| 3284 | | yynewstate -- Push a new state, which is found in yystate. | |
| 3285 | `------------------------------------------------------------*/ |
| 3286 | yynewstate: |
| 3287 | /* In all cases, when you get here, the value and location stacks |
| 3288 | have just been pushed. So pushing a state here evens the stacks. */ |
| 3289 | yyssp++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3290 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3291 | yysetstate: |
| 3292 | *yyssp = yystate; |
| 3293 | |
| 3294 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3295 | { |
| 3296 | /* Get the current used size of the three stacks, in elements. */ |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3297 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3298 | |
| 3299 | #ifdef yyoverflow |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3300 | { |
| 3301 | /* Give user a chance to reallocate the stack. Use copies of |
| 3302 | these so that the &'s don't force the real ones into |
| 3303 | memory. */ |
| 3304 | YYSTYPE *yyvs1 = yyvs; |
| 3305 | yytype_int16 *yyss1 = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3306 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3307 | |
| 3308 | /* Each stack pointer address is followed by the size of the |
| 3309 | data in use in that stack, in bytes. This used to be a |
| 3310 | conditional around just the two extra args, but that might |
| 3311 | be undefined if yyoverflow is a macro. */ |
| 3312 | yyoverflow (YY_("memory exhausted"), |
| 3313 | &yyss1, yysize * sizeof (*yyssp), |
| 3314 | &yyvs1, yysize * sizeof (*yyvsp), |
| 3315 | |
| 3316 | &yystacksize); |
| 3317 | |
| 3318 | yyss = yyss1; |
| 3319 | yyvs = yyvs1; |
| 3320 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3321 | #else /* no yyoverflow */ |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3322 | # ifndef YYSTACK_RELOCATE |
| 3323 | goto yyexhaustedlab; |
| 3324 | # else |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3325 | /* Extend the stack our own way. */ |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3326 | if (YYMAXDEPTH <= yystacksize) |
| 3327 | goto yyexhaustedlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3328 | yystacksize *= 2; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3329 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3330 | yystacksize = YYMAXDEPTH; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3331 | |
| 3332 | { |
| 3333 | yytype_int16 *yyss1 = yyss; |
| 3334 | union yyalloc *yyptr = |
| 3335 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 3336 | if (! yyptr) |
| 3337 | goto yyexhaustedlab; |
| 3338 | YYSTACK_RELOCATE (yyss); |
| 3339 | YYSTACK_RELOCATE (yyvs); |
| 3340 | |
| 3341 | # undef YYSTACK_RELOCATE |
| 3342 | if (yyss1 != yyssa) |
| 3343 | YYSTACK_FREE (yyss1); |
| 3344 | } |
| 3345 | # endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3346 | #endif /* no yyoverflow */ |
| 3347 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3348 | yyssp = yyss + yysize - 1; |
| 3349 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3350 | |
| 3351 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3352 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 3353 | (unsigned long int) yystacksize)); |
| 3354 | |
| 3355 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3356 | YYABORT; |
| 3357 | } |
| 3358 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3359 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3360 | |
| 3361 | goto yybackup; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3362 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3363 | /*-----------. |
| 3364 | | yybackup. | |
| 3365 | `-----------*/ |
| 3366 | yybackup: |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3367 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3368 | /* Do appropriate processing given the current state. Read a |
| 3369 | 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] | 3370 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3371 | /* 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] | 3372 | yyn = yypact[yystate]; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3373 | if (yyn == YYPACT_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3374 | goto yydefault; |
| 3375 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3376 | /* 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] | 3377 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3378 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3379 | if (yychar == YYEMPTY) |
| 3380 | { |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3381 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3382 | yychar = YYLEX; |
| 3383 | } |
| 3384 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3385 | if (yychar <= YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3386 | { |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3387 | yychar = yytoken = YYEOF; |
| 3388 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3389 | } |
| 3390 | else |
| 3391 | { |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3392 | yytoken = YYTRANSLATE (yychar); |
| 3393 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3394 | } |
| 3395 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3396 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 3397 | detect an error, take that action. */ |
| 3398 | yyn += yytoken; |
| 3399 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3400 | goto yydefault; |
| 3401 | yyn = yytable[yyn]; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3402 | if (yyn <= 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3403 | { |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3404 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3405 | goto yyerrlab; |
| 3406 | yyn = -yyn; |
| 3407 | goto yyreduce; |
| 3408 | } |
| 3409 | |
| 3410 | if (yyn == YYFINAL) |
| 3411 | YYACCEPT; |
| 3412 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3413 | /* Count tokens shifted since error; after three, turn off error |
| 3414 | status. */ |
| 3415 | if (yyerrstatus) |
| 3416 | yyerrstatus--; |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 3417 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3418 | /* Shift the look-ahead token. */ |
| 3419 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3420 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3421 | /* Discard the shifted token unless it is eof. */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3422 | if (yychar != YYEOF) |
| 3423 | yychar = YYEMPTY; |
| 3424 | |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 3425 | yystate = yyn; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3426 | *++yyvsp = yylval; |
| 3427 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3428 | goto yynewstate; |
| 3429 | |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 3430 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3431 | /*-----------------------------------------------------------. |
| 3432 | | yydefault -- do the default action for the current state. | |
| 3433 | `-----------------------------------------------------------*/ |
| 3434 | yydefault: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3435 | yyn = yydefact[yystate]; |
| 3436 | if (yyn == 0) |
| 3437 | goto yyerrlab; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3438 | goto yyreduce; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3439 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3440 | |
| 3441 | /*-----------------------------. |
| 3442 | | yyreduce -- Do a reduction. | |
| 3443 | `-----------------------------*/ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3444 | yyreduce: |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3445 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3446 | yylen = yyr2[yyn]; |
| 3447 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3448 | /* If YYLEN is nonzero, implement the default value of the action: |
| 3449 | `$$ = $1'. |
| 3450 | |
| 3451 | Otherwise, the following line sets YYVAL to garbage. |
| 3452 | This behavior is undocumented and Bison |
| 3453 | users should not rely upon it. Assigning to YYVAL |
| 3454 | unconditionally makes the parser a bit smaller, and it avoids a |
| 3455 | GCC warning that YYVAL may be used uninitialized. */ |
| 3456 | yyval = yyvsp[1-yylen]; |
| 3457 | |
| 3458 | |
| 3459 | YY_REDUCE_PRINT (yyn); |
| 3460 | switch (yyn) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3461 | { |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3462 | case 29: |
| 3463 | #line 1113 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3464 | { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;} |
| 3465 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3466 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3467 | case 30: |
| 3468 | #line 1113 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3469 | { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;} |
| 3470 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3471 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3472 | case 31: |
| 3473 | #line 1114 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3474 | { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;} |
| 3475 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3476 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3477 | case 32: |
| 3478 | #line 1114 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3479 | { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;} |
| 3480 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3481 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3482 | case 33: |
| 3483 | #line 1115 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3484 | { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;} |
| 3485 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3486 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3487 | case 34: |
| 3488 | #line 1115 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3489 | { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;} |
| 3490 | break; |
| 3491 | |
| 3492 | case 35: |
| 3493 | #line 1116 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3494 | { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;} |
| 3495 | break; |
| 3496 | |
| 3497 | case 36: |
| 3498 | #line 1116 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3499 | { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;} |
| 3500 | break; |
| 3501 | |
| 3502 | case 37: |
| 3503 | #line 1117 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3504 | { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;} |
| 3505 | break; |
| 3506 | |
| 3507 | case 38: |
| 3508 | #line 1117 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3509 | { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;} |
| 3510 | break; |
| 3511 | |
| 3512 | case 39: |
| 3513 | #line 1121 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3514 | { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;} |
| 3515 | break; |
| 3516 | |
| 3517 | case 40: |
| 3518 | #line 1121 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3519 | { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;} |
| 3520 | break; |
| 3521 | |
| 3522 | case 41: |
| 3523 | #line 1122 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3524 | { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;} |
| 3525 | break; |
| 3526 | |
| 3527 | case 42: |
| 3528 | #line 1122 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3529 | { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;} |
| 3530 | break; |
| 3531 | |
| 3532 | case 43: |
| 3533 | #line 1123 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3534 | { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;} |
| 3535 | break; |
| 3536 | |
| 3537 | case 44: |
| 3538 | #line 1123 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3539 | { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;} |
| 3540 | break; |
| 3541 | |
| 3542 | case 45: |
| 3543 | #line 1124 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3544 | { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;} |
| 3545 | break; |
| 3546 | |
| 3547 | case 46: |
| 3548 | #line 1124 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3549 | { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;} |
| 3550 | break; |
| 3551 | |
| 3552 | case 47: |
| 3553 | #line 1125 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3554 | { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;} |
| 3555 | break; |
| 3556 | |
| 3557 | case 48: |
| 3558 | #line 1125 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3559 | { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;} |
| 3560 | break; |
| 3561 | |
| 3562 | case 49: |
| 3563 | #line 1126 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3564 | { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;} |
| 3565 | break; |
| 3566 | |
| 3567 | case 50: |
| 3568 | #line 1126 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3569 | { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;} |
| 3570 | break; |
| 3571 | |
| 3572 | case 51: |
| 3573 | #line 1127 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3574 | { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;} |
| 3575 | break; |
| 3576 | |
| 3577 | case 52: |
| 3578 | #line 1127 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3579 | { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;} |
| 3580 | break; |
| 3581 | |
| 3582 | case 53: |
| 3583 | #line 1128 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3584 | { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;} |
| 3585 | break; |
| 3586 | |
| 3587 | case 54: |
| 3588 | #line 1129 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3589 | { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;} |
| 3590 | break; |
| 3591 | |
| 3592 | case 65: |
| 3593 | #line 1138 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3594 | { (yyval.StrVal) = 0; ;} |
| 3595 | break; |
| 3596 | |
| 3597 | case 66: |
| 3598 | #line 1140 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3599 | { (yyval.UIntVal)=(yyvsp[(3) - (4)].UInt64Val); ;} |
| 3600 | break; |
| 3601 | |
| 3602 | case 67: |
| 3603 | #line 1141 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3604 | { (yyval.UIntVal)=0; ;} |
| 3605 | break; |
| 3606 | |
| 3607 | case 68: |
| 3608 | #line 1145 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3609 | { |
| 3610 | (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3611 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3612 | ;} |
| 3613 | break; |
| 3614 | |
| 3615 | case 69: |
| 3616 | #line 1149 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3617 | { |
| 3618 | (yyval.StrVal) = 0; |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 3619 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3620 | ;} |
| 3621 | break; |
| 3622 | |
| 3623 | case 73: |
| 3624 | #line 1157 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3625 | { |
| 3626 | (yyval.StrVal) = 0; |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 3627 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3628 | ;} |
| 3629 | break; |
| 3630 | |
| 3631 | case 74: |
| 3632 | #line 1162 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3633 | { |
| 3634 | (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal); |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 3635 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3636 | ;} |
| 3637 | break; |
| 3638 | |
| 3639 | case 75: |
| 3640 | #line 1168 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3641 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3642 | break; |
| 3643 | |
| 3644 | case 76: |
| 3645 | #line 1169 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3646 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3647 | break; |
| 3648 | |
| 3649 | case 77: |
| 3650 | #line 1170 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3651 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 3652 | break; |
| 3653 | |
| 3654 | case 78: |
| 3655 | #line 1171 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3656 | { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} |
| 3657 | break; |
| 3658 | |
| 3659 | case 79: |
| 3660 | #line 1172 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3661 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 3662 | break; |
| 3663 | |
| 3664 | case 80: |
| 3665 | #line 1176 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3666 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 3667 | break; |
| 3668 | |
| 3669 | case 81: |
| 3670 | #line 1177 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3671 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 3672 | break; |
| 3673 | |
| 3674 | case 82: |
| 3675 | #line 1178 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3676 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3677 | break; |
| 3678 | |
| 3679 | case 83: |
| 3680 | #line 1182 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3681 | { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;} |
| 3682 | break; |
| 3683 | |
| 3684 | case 84: |
| 3685 | #line 1183 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3686 | { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;} |
| 3687 | break; |
| 3688 | |
| 3689 | case 85: |
| 3690 | #line 1184 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3691 | { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;} |
| 3692 | break; |
| 3693 | |
| 3694 | case 86: |
| 3695 | #line 1185 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3696 | { (yyval.Visibility) = GlobalValue::ProtectedVisibility; ;} |
| 3697 | break; |
| 3698 | |
| 3699 | case 87: |
| 3700 | #line 1189 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3701 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3702 | break; |
| 3703 | |
| 3704 | case 88: |
| 3705 | #line 1190 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3706 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 3707 | break; |
| 3708 | |
| 3709 | case 89: |
| 3710 | #line 1191 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3711 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 3712 | break; |
| 3713 | |
| 3714 | case 90: |
| 3715 | #line 1195 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3716 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3717 | break; |
| 3718 | |
| 3719 | case 91: |
| 3720 | #line 1196 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3721 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3722 | break; |
| 3723 | |
| 3724 | case 92: |
| 3725 | #line 1197 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3726 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 3727 | break; |
| 3728 | |
| 3729 | case 93: |
| 3730 | #line 1198 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3731 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3732 | break; |
| 3733 | |
| 3734 | case 94: |
| 3735 | #line 1199 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3736 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 3737 | break; |
| 3738 | |
| 3739 | case 95: |
| 3740 | #line 1203 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3741 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3742 | break; |
| 3743 | |
| 3744 | case 96: |
| 3745 | #line 1204 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3746 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3747 | break; |
| 3748 | |
| 3749 | case 97: |
| 3750 | #line 1205 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3751 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3752 | break; |
| 3753 | |
| 3754 | case 98: |
| 3755 | #line 1208 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3756 | { (yyval.UIntVal) = CallingConv::C; ;} |
| 3757 | break; |
| 3758 | |
| 3759 | case 99: |
| 3760 | #line 1209 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3761 | { (yyval.UIntVal) = CallingConv::C; ;} |
| 3762 | break; |
| 3763 | |
| 3764 | case 100: |
| 3765 | #line 1210 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3766 | { (yyval.UIntVal) = CallingConv::Fast; ;} |
| 3767 | break; |
| 3768 | |
| 3769 | case 101: |
| 3770 | #line 1211 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3771 | { (yyval.UIntVal) = CallingConv::Cold; ;} |
| 3772 | break; |
| 3773 | |
| 3774 | case 102: |
| 3775 | #line 1212 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3776 | { (yyval.UIntVal) = CallingConv::X86_StdCall; ;} |
| 3777 | break; |
| 3778 | |
| 3779 | case 103: |
| 3780 | #line 1213 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3781 | { (yyval.UIntVal) = CallingConv::X86_FastCall; ;} |
| 3782 | break; |
| 3783 | |
| 3784 | case 104: |
| 3785 | #line 1214 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3786 | { |
| 3787 | if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3788 | GEN_ERROR("Calling conv too large"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3789 | (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3790 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3791 | ;} |
| 3792 | break; |
| 3793 | |
| 3794 | case 105: |
| 3795 | #line 1221 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3796 | { (yyval.ParamAttrs) = ParamAttr::ZExt; ;} |
| 3797 | break; |
| 3798 | |
| 3799 | case 106: |
| 3800 | #line 1222 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3801 | { (yyval.ParamAttrs) = ParamAttr::ZExt; ;} |
| 3802 | break; |
| 3803 | |
| 3804 | case 107: |
| 3805 | #line 1223 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3806 | { (yyval.ParamAttrs) = ParamAttr::SExt; ;} |
| 3807 | break; |
| 3808 | |
| 3809 | case 108: |
| 3810 | #line 1224 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3811 | { (yyval.ParamAttrs) = ParamAttr::SExt; ;} |
| 3812 | break; |
| 3813 | |
| 3814 | case 109: |
| 3815 | #line 1225 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3816 | { (yyval.ParamAttrs) = ParamAttr::InReg; ;} |
| 3817 | break; |
| 3818 | |
| 3819 | case 110: |
| 3820 | #line 1226 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3821 | { (yyval.ParamAttrs) = ParamAttr::StructRet; ;} |
| 3822 | break; |
| 3823 | |
| 3824 | case 111: |
| 3825 | #line 1227 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3826 | { (yyval.ParamAttrs) = ParamAttr::NoAlias; ;} |
| 3827 | break; |
| 3828 | |
| 3829 | case 112: |
| 3830 | #line 1228 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3831 | { (yyval.ParamAttrs) = ParamAttr::ByVal; ;} |
| 3832 | break; |
| 3833 | |
| 3834 | case 113: |
| 3835 | #line 1229 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3836 | { (yyval.ParamAttrs) = ParamAttr::Nest; ;} |
| 3837 | break; |
| 3838 | |
| 3839 | case 114: |
| 3840 | #line 1232 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3841 | { (yyval.ParamAttrs) = ParamAttr::None; ;} |
| 3842 | break; |
| 3843 | |
| 3844 | case 115: |
| 3845 | #line 1233 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3846 | { |
| 3847 | (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs); |
| 3848 | ;} |
| 3849 | break; |
| 3850 | |
| 3851 | case 116: |
| 3852 | #line 1238 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3853 | { (yyval.ParamAttrs) = ParamAttr::NoReturn; ;} |
| 3854 | break; |
| 3855 | |
| 3856 | case 117: |
| 3857 | #line 1239 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3858 | { (yyval.ParamAttrs) = ParamAttr::NoUnwind; ;} |
| 3859 | break; |
| 3860 | |
| 3861 | case 118: |
| 3862 | #line 1240 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3863 | { (yyval.ParamAttrs) = ParamAttr::ZExt; ;} |
| 3864 | break; |
| 3865 | |
| 3866 | case 119: |
| 3867 | #line 1241 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3868 | { (yyval.ParamAttrs) = ParamAttr::SExt; ;} |
| 3869 | break; |
| 3870 | |
| 3871 | case 120: |
| 3872 | #line 1242 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3873 | { (yyval.ParamAttrs) = ParamAttr::ReadNone; ;} |
| 3874 | break; |
| 3875 | |
| 3876 | case 121: |
| 3877 | #line 1243 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3878 | { (yyval.ParamAttrs) = ParamAttr::ReadOnly; ;} |
| 3879 | break; |
| 3880 | |
| 3881 | case 122: |
| 3882 | #line 1246 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3883 | { (yyval.ParamAttrs) = ParamAttr::None; ;} |
| 3884 | break; |
| 3885 | |
| 3886 | case 123: |
| 3887 | #line 1247 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3888 | { |
| 3889 | (yyval.ParamAttrs) = (yyvsp[(1) - (2)].ParamAttrs) | (yyvsp[(2) - (2)].ParamAttrs); |
| 3890 | ;} |
| 3891 | break; |
| 3892 | |
| 3893 | case 124: |
| 3894 | #line 1252 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3895 | { (yyval.StrVal) = 0; ;} |
| 3896 | break; |
| 3897 | |
| 3898 | case 125: |
| 3899 | #line 1253 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3900 | { |
| 3901 | (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal); |
| 3902 | ;} |
| 3903 | break; |
| 3904 | |
| 3905 | case 126: |
| 3906 | #line 1260 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3907 | { (yyval.UIntVal) = 0; ;} |
| 3908 | break; |
| 3909 | |
| 3910 | case 127: |
| 3911 | #line 1261 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3912 | { |
| 3913 | (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val); |
| 3914 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3915 | GEN_ERROR("Alignment must be a power of two"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3916 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3917 | ;} |
| 3918 | break; |
| 3919 | |
| 3920 | case 128: |
| 3921 | #line 1267 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3922 | { (yyval.UIntVal) = 0; ;} |
| 3923 | break; |
| 3924 | |
| 3925 | case 129: |
| 3926 | #line 1268 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3927 | { |
| 3928 | (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val); |
| 3929 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 3930 | GEN_ERROR("Alignment must be a power of two"); |
| 3931 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3932 | ;} |
| 3933 | break; |
| 3934 | |
| 3935 | case 130: |
| 3936 | #line 1277 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3937 | { |
| 3938 | for (unsigned i = 0, e = (yyvsp[(2) - (2)].StrVal)->length(); i != e; ++i) |
| 3939 | if ((*(yyvsp[(2) - (2)].StrVal))[i] == '"' || (*(yyvsp[(2) - (2)].StrVal))[i] == '\\') |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3940 | GEN_ERROR("Invalid character in section name"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3941 | (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3942 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3943 | ;} |
| 3944 | break; |
| 3945 | |
| 3946 | case 131: |
| 3947 | #line 1285 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3948 | { (yyval.StrVal) = 0; ;} |
| 3949 | break; |
| 3950 | |
| 3951 | case 132: |
| 3952 | #line 1286 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3953 | { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;} |
| 3954 | break; |
| 3955 | |
| 3956 | case 133: |
| 3957 | #line 1291 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3958 | {;} |
| 3959 | break; |
| 3960 | |
| 3961 | case 134: |
| 3962 | #line 1292 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3963 | {;} |
| 3964 | break; |
| 3965 | |
| 3966 | case 135: |
| 3967 | #line 1293 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3968 | { |
| 3969 | CurGV->setSection(*(yyvsp[(1) - (1)].StrVal)); |
| 3970 | delete (yyvsp[(1) - (1)].StrVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3971 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3972 | ;} |
| 3973 | break; |
| 3974 | |
| 3975 | case 136: |
| 3976 | #line 1298 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3977 | { |
| 3978 | if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val))) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 3979 | GEN_ERROR("Alignment must be a power of two"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3980 | CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3981 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3982 | ;} |
| 3983 | break; |
| 3984 | |
| 3985 | case 144: |
| 3986 | #line 1314 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3987 | { |
| 3988 | (yyval.TypeVal) = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3989 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3990 | ;} |
| 3991 | break; |
| 3992 | |
| 3993 | case 145: |
| 3994 | #line 1318 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 3995 | { |
| 3996 | (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3997 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 3998 | ;} |
| 3999 | break; |
| 4000 | |
| 4001 | case 146: |
| 4002 | #line 1322 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4003 | { // Pointer type? |
| 4004 | if (*(yyvsp[(1) - (3)].TypeVal) == Type::LabelTy) |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 4005 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4006 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (3)].TypeVal), (yyvsp[(2) - (3)].UIntVal)))); |
| 4007 | delete (yyvsp[(1) - (3)].TypeVal); |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 4008 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4009 | ;} |
| 4010 | break; |
| 4011 | |
| 4012 | case 147: |
| 4013 | #line 1329 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4014 | { // Named types are also simple types... |
| 4015 | const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal)); |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 4016 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4017 | (yyval.TypeVal) = new PATypeHolder(tmp); |
| 4018 | ;} |
| 4019 | break; |
| 4020 | |
| 4021 | case 148: |
| 4022 | #line 1334 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4023 | { // Type UpReference |
| 4024 | if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4025 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4026 | UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector... |
| 4027 | (yyval.TypeVal) = new PATypeHolder(OT); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4028 | UR_OUT("New Upreference!\n"); |
| 4029 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4030 | ;} |
| 4031 | break; |
| 4032 | |
| 4033 | case 149: |
| 4034 | #line 1342 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4035 | { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4036 | // Allow but ignore attributes on function types; this permits auto-upgrade. |
| 4037 | // FIXME: remove in LLVM 3.0. |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4038 | const Type* RetTy = *(yyvsp[(1) - (5)].TypeVal); |
Anton Korobeynikov | 05e5a74 | 2007-12-03 21:01:29 +0000 | [diff] [blame] | 4039 | if (!(RetTy->isFirstClassType() || RetTy == Type::VoidTy || |
| 4040 | isa<OpaqueType>(RetTy))) |
Anton Korobeynikov | c36284e | 2007-12-03 19:17:47 +0000 | [diff] [blame] | 4041 | GEN_ERROR("LLVM Functions cannot return aggregates"); |
Anton Korobeynikov | 05e5a74 | 2007-12-03 21:01:29 +0000 | [diff] [blame] | 4042 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4043 | std::vector<const Type*> Params; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4044 | TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4045 | for (; I != E; ++I ) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 4046 | const Type *Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 4047 | Params.push_back(Ty); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4048 | } |
Anton Korobeynikov | 05e5a74 | 2007-12-03 21:01:29 +0000 | [diff] [blame] | 4049 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4050 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 4051 | if (isVarArg) Params.pop_back(); |
| 4052 | |
Anton Korobeynikov | 05e5a74 | 2007-12-03 21:01:29 +0000 | [diff] [blame] | 4053 | for (unsigned i = 0; i != Params.size(); ++i) |
| 4054 | if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i]))) |
| 4055 | GEN_ERROR("Function arguments must be value types!"); |
| 4056 | |
| 4057 | CHECK_FOR_ERROR |
| 4058 | |
Anton Korobeynikov | c36284e | 2007-12-03 19:17:47 +0000 | [diff] [blame] | 4059 | FunctionType *FT = FunctionType::get(RetTy, Params, isVarArg); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4060 | delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list |
| 4061 | delete (yyvsp[(1) - (5)].TypeVal); // Delete the return type handle |
| 4062 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4063 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4064 | ;} |
| 4065 | break; |
| 4066 | |
| 4067 | case 150: |
| 4068 | #line 1372 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4069 | { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4070 | // Allow but ignore attributes on function types; this permits auto-upgrade. |
| 4071 | // FIXME: remove in LLVM 3.0. |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4072 | std::vector<const Type*> Params; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4073 | TypeWithAttrsList::iterator I = (yyvsp[(3) - (5)].TypeWithAttrsList)->begin(), E = (yyvsp[(3) - (5)].TypeWithAttrsList)->end(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4074 | for ( ; I != E; ++I ) { |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 4075 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 4076 | Params.push_back(Ty); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4077 | } |
Anton Korobeynikov | 05e5a74 | 2007-12-03 21:01:29 +0000 | [diff] [blame] | 4078 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4079 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 4080 | if (isVarArg) Params.pop_back(); |
| 4081 | |
Anton Korobeynikov | 05e5a74 | 2007-12-03 21:01:29 +0000 | [diff] [blame] | 4082 | for (unsigned i = 0; i != Params.size(); ++i) |
| 4083 | if (!(Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i]))) |
| 4084 | GEN_ERROR("Function arguments must be value types!"); |
| 4085 | |
| 4086 | CHECK_FOR_ERROR |
| 4087 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4088 | FunctionType *FT = FunctionType::get((yyvsp[(1) - (5)].PrimType), Params, isVarArg); |
| 4089 | delete (yyvsp[(3) - (5)].TypeWithAttrsList); // Delete the argument list |
| 4090 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4091 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4092 | ;} |
| 4093 | break; |
| 4094 | |
| 4095 | case 151: |
| 4096 | #line 1397 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4097 | { // Sized array type? |
| 4098 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val)))); |
| 4099 | delete (yyvsp[(4) - (5)].TypeVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4100 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4101 | ;} |
| 4102 | break; |
| 4103 | |
| 4104 | case 152: |
| 4105 | #line 1402 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4106 | { // Vector type? |
| 4107 | const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get(); |
| 4108 | if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4109 | GEN_ERROR("Unsigned result not equal to signed result"); |
| 4110 | if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) |
| 4111 | GEN_ERROR("Element type of a VectorType must be primitive"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4112 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val)))); |
| 4113 | delete (yyvsp[(4) - (5)].TypeVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4114 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4115 | ;} |
| 4116 | break; |
| 4117 | |
| 4118 | case 153: |
| 4119 | #line 1412 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4120 | { // Structure type? |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4121 | std::vector<const Type*> Elements; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4122 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(), |
| 4123 | E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4124 | Elements.push_back(*I); |
| 4125 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4126 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 4127 | delete (yyvsp[(2) - (3)].TypeList); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4128 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4129 | ;} |
| 4130 | break; |
| 4131 | |
| 4132 | case 154: |
| 4133 | #line 1422 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4134 | { // Empty structure type? |
| 4135 | (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4136 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4137 | ;} |
| 4138 | break; |
| 4139 | |
| 4140 | case 155: |
| 4141 | #line 1426 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4142 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4143 | std::vector<const Type*> Elements; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4144 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[(3) - (5)].TypeList)->begin(), |
| 4145 | E = (yyvsp[(3) - (5)].TypeList)->end(); I != E; ++I) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4146 | Elements.push_back(*I); |
| 4147 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4148 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); |
| 4149 | delete (yyvsp[(3) - (5)].TypeList); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4150 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4151 | ;} |
| 4152 | break; |
| 4153 | |
| 4154 | case 156: |
| 4155 | #line 1436 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4156 | { // Empty structure type? |
| 4157 | (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4158 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4159 | ;} |
| 4160 | break; |
| 4161 | |
| 4162 | case 157: |
| 4163 | #line 1443 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4164 | { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 4165 | // Allow but ignore attributes on function types; this permits auto-upgrade. |
| 4166 | // FIXME: remove in LLVM 3.0. |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4167 | (yyval.TypeWithAttrs).Ty = (yyvsp[(1) - (2)].TypeVal); |
| 4168 | (yyval.TypeWithAttrs).Attrs = ParamAttr::None; |
| 4169 | ;} |
| 4170 | break; |
| 4171 | |
| 4172 | case 158: |
| 4173 | #line 1452 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4174 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4175 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4176 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription()); |
| 4177 | if (!(*(yyvsp[(1) - (1)].TypeVal))->isFirstClassType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4178 | GEN_ERROR("LLVM functions cannot return aggregate types"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4179 | (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal); |
| 4180 | ;} |
| 4181 | break; |
| 4182 | |
| 4183 | case 159: |
| 4184 | #line 1459 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4185 | { |
| 4186 | (yyval.TypeVal) = new PATypeHolder(Type::VoidTy); |
| 4187 | ;} |
| 4188 | break; |
| 4189 | |
| 4190 | case 160: |
| 4191 | #line 1464 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4192 | { |
| 4193 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); |
| 4194 | (yyval.TypeWithAttrsList)->push_back((yyvsp[(1) - (1)].TypeWithAttrs)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 4195 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4196 | ;} |
| 4197 | break; |
| 4198 | |
| 4199 | case 161: |
| 4200 | #line 1469 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4201 | { |
| 4202 | ((yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList))->push_back((yyvsp[(3) - (3)].TypeWithAttrs)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4203 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4204 | ;} |
| 4205 | break; |
| 4206 | |
| 4207 | case 163: |
| 4208 | #line 1477 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4209 | { |
| 4210 | (yyval.TypeWithAttrsList)=(yyvsp[(1) - (3)].TypeWithAttrsList); |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 4211 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4212 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4213 | (yyval.TypeWithAttrsList)->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4214 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4215 | ;} |
| 4216 | break; |
| 4217 | |
| 4218 | case 164: |
| 4219 | #line 1484 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4220 | { |
| 4221 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4222 | TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None; |
| 4223 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4224 | (yyval.TypeWithAttrsList)->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4225 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4226 | ;} |
| 4227 | break; |
| 4228 | |
| 4229 | case 165: |
| 4230 | #line 1491 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4231 | { |
| 4232 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4233 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4234 | ;} |
| 4235 | break; |
| 4236 | |
| 4237 | case 166: |
| 4238 | #line 1499 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4239 | { |
| 4240 | (yyval.TypeList) = new std::list<PATypeHolder>(); |
| 4241 | (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal)); |
| 4242 | delete (yyvsp[(1) - (1)].TypeVal); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 4243 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4244 | ;} |
| 4245 | break; |
| 4246 | |
| 4247 | case 167: |
| 4248 | #line 1505 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4249 | { |
| 4250 | ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal)); |
| 4251 | delete (yyvsp[(3) - (3)].TypeVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4252 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4253 | ;} |
| 4254 | break; |
| 4255 | |
| 4256 | case 168: |
| 4257 | #line 1517 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4258 | { // Nonempty unsized arr |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4259 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4260 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription()); |
| 4261 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (4)].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4262 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4263 | GEN_ERROR("Cannot make array constant with type: '" + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4264 | (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4265 | const Type *ETy = ATy->getElementType(); |
| 4266 | int NumElements = ATy->getNumElements(); |
| 4267 | |
| 4268 | // Verify that we have the correct size... |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4269 | if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4270 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4271 | utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4272 | itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4273 | |
| 4274 | // Verify all elements are correct type! |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4275 | for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) { |
| 4276 | if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4277 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 4278 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4279 | (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4280 | } |
| 4281 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4282 | (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector)); |
| 4283 | delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4284 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4285 | ;} |
| 4286 | break; |
| 4287 | |
| 4288 | case 169: |
| 4289 | #line 1545 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4290 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4291 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4292 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription()); |
| 4293 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4294 | if (ATy == 0) |
| 4295 | GEN_ERROR("Cannot make array constant with type: '" + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4296 | (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4297 | |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4298 | int NumElements = ATy->getNumElements(); |
| 4299 | if (NumElements != -1 && NumElements != 0) |
| 4300 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4301 | " arguments, but has size of " + itostr(NumElements) +""); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4302 | (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 4303 | delete (yyvsp[(1) - (3)].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4304 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4305 | ;} |
| 4306 | break; |
| 4307 | |
| 4308 | case 170: |
| 4309 | #line 1561 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4310 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4311 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4312 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription()); |
| 4313 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[(1) - (3)].TypeVal)->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4314 | if (ATy == 0) |
| 4315 | GEN_ERROR("Cannot make array constant with type: '" + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4316 | (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4317 | |
| 4318 | int NumElements = ATy->getNumElements(); |
| 4319 | const Type *ETy = ATy->getElementType(); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4320 | if (NumElements != -1 && NumElements != int((yyvsp[(3) - (3)].StrVal)->length())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4321 | GEN_ERROR("Can't build string constant of size " + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4322 | itostr((int)((yyvsp[(3) - (3)].StrVal)->length())) + |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4323 | " when array has size " + itostr(NumElements) + ""); |
| 4324 | std::vector<Constant*> Vals; |
| 4325 | if (ETy == Type::Int8Ty) { |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4326 | for (unsigned i = 0; i < (yyvsp[(3) - (3)].StrVal)->length(); ++i) |
| 4327 | Vals.push_back(ConstantInt::get(ETy, (*(yyvsp[(3) - (3)].StrVal))[i])); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4328 | } else { |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4329 | delete (yyvsp[(3) - (3)].StrVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4330 | GEN_ERROR("Cannot build string arrays of non byte sized elements"); |
| 4331 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4332 | delete (yyvsp[(3) - (3)].StrVal); |
| 4333 | (yyval.ConstVal) = ConstantArray::get(ATy, Vals); |
| 4334 | delete (yyvsp[(1) - (3)].TypeVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4335 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4336 | ;} |
| 4337 | break; |
| 4338 | |
| 4339 | case 171: |
| 4340 | #line 1588 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4341 | { // Nonempty unsized arr |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4342 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4343 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription()); |
| 4344 | const VectorType *PTy = dyn_cast<VectorType>((yyvsp[(1) - (4)].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4345 | if (PTy == 0) |
| 4346 | GEN_ERROR("Cannot make packed constant with type: '" + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4347 | (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4348 | const Type *ETy = PTy->getElementType(); |
| 4349 | int NumElements = PTy->getNumElements(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4350 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4351 | // Verify that we have the correct size... |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4352 | if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4353 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4354 | utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4355 | itostr(NumElements) + ""); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4356 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4357 | // Verify all elements are correct type! |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4358 | for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) { |
| 4359 | if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4360 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 4361 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4362 | (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4363 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4364 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4365 | (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[(3) - (4)].ConstVector)); |
| 4366 | delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4367 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4368 | ;} |
| 4369 | break; |
| 4370 | |
| 4371 | case 172: |
| 4372 | #line 1616 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4373 | { |
| 4374 | const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (4)].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4375 | if (STy == 0) |
| 4376 | GEN_ERROR("Cannot make struct constant with type: '" + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4377 | (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4378 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4379 | if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4380 | GEN_ERROR("Illegal number of initializers for structure type"); |
| 4381 | |
| 4382 | // Check to ensure that constants are compatible with the type initializer! |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4383 | for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i) |
| 4384 | if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4385 | GEN_ERROR("Expected type '" + |
| 4386 | STy->getElementType(i)->getDescription() + |
| 4387 | "' for element #" + utostr(i) + |
| 4388 | " of structure initializer"); |
| 4389 | |
| 4390 | // Check to ensure that Type is not packed |
| 4391 | if (STy->isPacked()) |
| 4392 | GEN_ERROR("Unpacked Initializer to vector type '" + |
| 4393 | STy->getDescription() + "'"); |
| 4394 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4395 | (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector)); |
| 4396 | delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4397 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4398 | ;} |
| 4399 | break; |
| 4400 | |
| 4401 | case 173: |
| 4402 | #line 1642 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4403 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4404 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4405 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription()); |
| 4406 | const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (3)].TypeVal)->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4407 | if (STy == 0) |
| 4408 | GEN_ERROR("Cannot make struct constant with type: '" + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4409 | (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4410 | |
| 4411 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4412 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4413 | |
| 4414 | // Check to ensure that Type is not packed |
| 4415 | if (STy->isPacked()) |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4416 | GEN_ERROR("Unpacked Initializer to vector type '" + |
| 4417 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4418 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4419 | (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 4420 | delete (yyvsp[(1) - (3)].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4421 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4422 | ;} |
| 4423 | break; |
| 4424 | |
| 4425 | case 174: |
| 4426 | #line 1662 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4427 | { |
| 4428 | const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (6)].TypeVal)->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4429 | if (STy == 0) |
| 4430 | GEN_ERROR("Cannot make struct constant with type: '" + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4431 | (*(yyvsp[(1) - (6)].TypeVal))->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4432 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4433 | if ((yyvsp[(4) - (6)].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4434 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4435 | |
| 4436 | // Check to ensure that constants are compatible with the type initializer! |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4437 | for (unsigned i = 0, e = (yyvsp[(4) - (6)].ConstVector)->size(); i != e; ++i) |
| 4438 | if ((*(yyvsp[(4) - (6)].ConstVector))[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4439 | GEN_ERROR("Expected type '" + |
| 4440 | STy->getElementType(i)->getDescription() + |
| 4441 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4442 | " of structure initializer"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4443 | |
| 4444 | // Check to ensure that Type is packed |
| 4445 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 4446 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 4447 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4448 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4449 | (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(4) - (6)].ConstVector)); |
| 4450 | delete (yyvsp[(1) - (6)].TypeVal); delete (yyvsp[(4) - (6)].ConstVector); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4451 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4452 | ;} |
| 4453 | break; |
| 4454 | |
| 4455 | case 175: |
| 4456 | #line 1688 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4457 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4458 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4459 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (5)].TypeVal))->getDescription()); |
| 4460 | const StructType *STy = dyn_cast<StructType>((yyvsp[(1) - (5)].TypeVal)->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4461 | if (STy == 0) |
| 4462 | GEN_ERROR("Cannot make struct constant with type: '" + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4463 | (*(yyvsp[(1) - (5)].TypeVal))->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4464 | |
| 4465 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4466 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4467 | |
| 4468 | // Check to ensure that Type is packed |
| 4469 | if (!STy->isPacked()) |
Chris Lattner | 3298069 | 2007-02-19 07:44:24 +0000 | [diff] [blame] | 4470 | GEN_ERROR("Vector initializer to non-vector type '" + |
| 4471 | STy->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4472 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4473 | (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 4474 | delete (yyvsp[(1) - (5)].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4475 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4476 | ;} |
| 4477 | break; |
| 4478 | |
| 4479 | case 176: |
| 4480 | #line 1708 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4481 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4482 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4483 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); |
| 4484 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4485 | if (PTy == 0) |
| 4486 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4487 | (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4488 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4489 | (yyval.ConstVal) = ConstantPointerNull::get(PTy); |
| 4490 | delete (yyvsp[(1) - (2)].TypeVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4491 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4492 | ;} |
| 4493 | break; |
| 4494 | |
| 4495 | case 177: |
| 4496 | #line 1720 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4497 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4498 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4499 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); |
| 4500 | (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get()); |
| 4501 | delete (yyvsp[(1) - (2)].TypeVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4502 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4503 | ;} |
| 4504 | break; |
| 4505 | |
| 4506 | case 178: |
| 4507 | #line 1727 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4508 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4509 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4510 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); |
| 4511 | const PointerType *Ty = dyn_cast<PointerType>((yyvsp[(1) - (2)].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4512 | if (Ty == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4513 | GEN_ERROR("Global const reference must be a pointer type"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4514 | |
| 4515 | // ConstExprs can exist in the body of a function, thus creating |
| 4516 | // GlobalValues whenever they refer to a variable. Because we are in |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 4517 | // the context of a function, getExistingVal will search the functions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4518 | // symbol table instead of the module symbol table for the global symbol, |
| 4519 | // which throws things all off. To get around this, we just tell |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 4520 | // getExistingVal that we are at global scope here. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4521 | // |
| 4522 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 4523 | CurFun.CurrentFunction = 0; |
| 4524 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4525 | Value *V = getExistingVal(Ty, (yyvsp[(2) - (2)].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4526 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4527 | |
| 4528 | CurFun.CurrentFunction = SavedCurFn; |
| 4529 | |
| 4530 | // If this is an initializer for a constant pointer, which is referencing a |
| 4531 | // (currently) undefined variable, create a stub now that shall be replaced |
| 4532 | // in the future with the right type of variable. |
| 4533 | // |
| 4534 | if (V == 0) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 4535 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4536 | const PointerType *PT = cast<PointerType>(Ty); |
| 4537 | |
| 4538 | // First check to see if the forward references value is already created! |
| 4539 | PerModuleInfo::GlobalRefsType::iterator I = |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4540 | CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal))); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4541 | |
| 4542 | if (I != CurModule.GlobalRefs.end()) { |
| 4543 | V = I->second; // Placeholder already exists, use it... |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4544 | (yyvsp[(2) - (2)].ValIDVal).destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4545 | } else { |
| 4546 | std::string Name; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4547 | if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::GlobalName) |
| 4548 | Name = (yyvsp[(2) - (2)].ValIDVal).getName(); |
| 4549 | else if ((yyvsp[(2) - (2)].ValIDVal).Type != ValID::GlobalID) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4550 | GEN_ERROR("Invalid reference to global"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4551 | |
| 4552 | // Create the forward referenced global. |
| 4553 | GlobalValue *GV; |
| 4554 | if (const FunctionType *FTy = |
| 4555 | dyn_cast<FunctionType>(PT->getElementType())) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4556 | GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4557 | CurModule.CurrentModule); |
| 4558 | } else { |
| 4559 | GV = new GlobalVariable(PT->getElementType(), false, |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 4560 | GlobalValue::ExternalWeakLinkage, 0, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4561 | Name, CurModule.CurrentModule); |
| 4562 | } |
| 4563 | |
| 4564 | // Keep track of the fact that we have a forward ref to recycle it |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4565 | 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] | 4566 | V = GV; |
| 4567 | } |
| 4568 | } |
| 4569 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4570 | (yyval.ConstVal) = cast<GlobalValue>(V); |
| 4571 | delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4572 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4573 | ;} |
| 4574 | break; |
| 4575 | |
| 4576 | case 179: |
| 4577 | #line 1793 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4578 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4579 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4580 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); |
| 4581 | if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4582 | GEN_ERROR("Mismatched types for constant expression: " + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4583 | (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + " and " + (yyvsp[(2) - (2)].ConstVal)->getType()->getDescription()); |
| 4584 | (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal); |
| 4585 | delete (yyvsp[(1) - (2)].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4586 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4587 | ;} |
| 4588 | break; |
| 4589 | |
| 4590 | case 180: |
| 4591 | #line 1803 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4592 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4593 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4594 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); |
| 4595 | const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4596 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 4597 | GEN_ERROR("Cannot create a null initialized value of this type"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4598 | (yyval.ConstVal) = Constant::getNullValue(Ty); |
| 4599 | delete (yyvsp[(1) - (2)].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4600 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4601 | ;} |
| 4602 | break; |
| 4603 | |
| 4604 | case 181: |
| 4605 | #line 1813 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4606 | { // integral constants |
| 4607 | if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val))) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4608 | GEN_ERROR("Constant value doesn't fit in type"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4609 | (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val), true); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 4610 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4611 | ;} |
| 4612 | break; |
| 4613 | |
| 4614 | case 182: |
| 4615 | #line 1819 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4616 | { // arbitrary precision integer constants |
| 4617 | uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth(); |
| 4618 | if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4619 | GEN_ERROR("Constant value does not fit in type"); |
| 4620 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4621 | (yyvsp[(2) - (2)].APIntVal)->sextOrTrunc(BitWidth); |
| 4622 | (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal)); |
| 4623 | delete (yyvsp[(2) - (2)].APIntVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4624 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4625 | ;} |
| 4626 | break; |
| 4627 | |
| 4628 | case 183: |
| 4629 | #line 1829 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4630 | { // integral constants |
| 4631 | if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val))) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4632 | GEN_ERROR("Constant value doesn't fit in type"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4633 | (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] | 4634 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4635 | ;} |
| 4636 | break; |
| 4637 | |
| 4638 | case 184: |
| 4639 | #line 1835 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4640 | { // arbitrary precision integer constants |
| 4641 | uint32_t BitWidth = cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth(); |
| 4642 | if ((yyvsp[(2) - (2)].APIntVal)->getBitWidth() > BitWidth) { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4643 | GEN_ERROR("Constant value does not fit in type"); |
| 4644 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4645 | (yyvsp[(2) - (2)].APIntVal)->zextOrTrunc(BitWidth); |
| 4646 | (yyval.ConstVal) = ConstantInt::get(*(yyvsp[(2) - (2)].APIntVal)); |
| 4647 | delete (yyvsp[(2) - (2)].APIntVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4648 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4649 | ;} |
| 4650 | break; |
| 4651 | |
| 4652 | case 185: |
| 4653 | #line 1845 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4654 | { // Boolean constants |
| 4655 | assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 4656 | (yyval.ConstVal) = ConstantInt::getTrue(); |
Reid Spencer | 38c91a9 | 2007-02-28 02:24:54 +0000 | [diff] [blame] | 4657 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4658 | ;} |
| 4659 | break; |
| 4660 | |
| 4661 | case 186: |
| 4662 | #line 1850 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4663 | { // Boolean constants |
| 4664 | assert(cast<IntegerType>((yyvsp[(1) - (2)].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 4665 | (yyval.ConstVal) = ConstantInt::getFalse(); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4666 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4667 | ;} |
| 4668 | break; |
| 4669 | |
| 4670 | case 187: |
| 4671 | #line 1855 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4672 | { // Floating point constants |
| 4673 | if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal))) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4674 | GEN_ERROR("Floating point constant invalid for type"); |
Dale Johannesen | c72cd7e | 2007-09-11 18:33:39 +0000 | [diff] [blame] | 4675 | // Lexer has no type info, so builds all float and double FP constants |
| 4676 | // as double. Fix this here. Long double is done right. |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4677 | if (&(yyvsp[(2) - (2)].FPVal)->getSemantics()==&APFloat::IEEEdouble && (yyvsp[(1) - (2)].PrimType)==Type::FloatTy) |
| 4678 | (yyvsp[(2) - (2)].FPVal)->convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven); |
| 4679 | (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), *(yyvsp[(2) - (2)].FPVal)); |
| 4680 | delete (yyvsp[(2) - (2)].FPVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4681 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4682 | ;} |
| 4683 | break; |
| 4684 | |
| 4685 | case 188: |
| 4686 | #line 1868 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4687 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4688 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4689 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (6)].TypeVal))->getDescription()); |
| 4690 | Constant *Val = (yyvsp[(3) - (6)].ConstVal); |
| 4691 | const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get(); |
| 4692 | if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4693 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 4694 | Val->getType()->getDescription() + "' to '" + |
| 4695 | DestTy->getDescription() + "'"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4696 | (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy); |
| 4697 | delete (yyvsp[(5) - (6)].TypeVal); |
| 4698 | ;} |
| 4699 | break; |
| 4700 | |
| 4701 | case 189: |
| 4702 | #line 1880 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4703 | { |
| 4704 | if (!isa<PointerType>((yyvsp[(3) - (5)].ConstVal)->getType())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4705 | GEN_ERROR("GetElementPtr requires a pointer operand"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4706 | |
| 4707 | const Type *IdxTy = |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4708 | GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), (yyvsp[(4) - (5)].ValueList)->begin(), (yyvsp[(4) - (5)].ValueList)->end(), |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 4709 | true); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4710 | if (!IdxTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4711 | GEN_ERROR("Index list invalid for constant getelementptr"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4712 | |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 4713 | SmallVector<Constant*, 8> IdxVec; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4714 | for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i) |
| 4715 | if (Constant *C = dyn_cast<Constant>((*(yyvsp[(4) - (5)].ValueList))[i])) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4716 | IdxVec.push_back(C); |
| 4717 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4718 | GEN_ERROR("Indices to constant getelementptr must be constants"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4719 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4720 | delete (yyvsp[(4) - (5)].ValueList); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4721 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4722 | (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), &IdxVec[0], IdxVec.size()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4723 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4724 | ;} |
| 4725 | break; |
| 4726 | |
| 4727 | case 190: |
| 4728 | #line 1902 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4729 | { |
| 4730 | if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::Int1Ty) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4731 | GEN_ERROR("Select condition must be of boolean type"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4732 | if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4733 | GEN_ERROR("Select operand types must match"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4734 | (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4735 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4736 | ;} |
| 4737 | break; |
| 4738 | |
| 4739 | case 191: |
| 4740 | #line 1910 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4741 | { |
| 4742 | if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4743 | GEN_ERROR("Binary operator types must match"); |
| 4744 | CHECK_FOR_ERROR; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4745 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)); |
| 4746 | ;} |
| 4747 | break; |
| 4748 | |
| 4749 | case 192: |
| 4750 | #line 1916 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4751 | { |
| 4752 | if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4753 | GEN_ERROR("Logical operator types must match"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4754 | if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) { |
| 4755 | if (Instruction::isShift((yyvsp[(1) - (6)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType()) || |
| 4756 | !cast<VectorType>((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isInteger()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4757 | GEN_ERROR("Logical operator requires integral operands"); |
| 4758 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4759 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4760 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4761 | ;} |
| 4762 | break; |
| 4763 | |
| 4764 | case 193: |
| 4765 | #line 1927 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4766 | { |
| 4767 | if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4768 | GEN_ERROR("icmp operand types must match"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4769 | (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal)); |
| 4770 | ;} |
| 4771 | break; |
| 4772 | |
| 4773 | case 194: |
| 4774 | #line 1932 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4775 | { |
| 4776 | if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4777 | GEN_ERROR("fcmp operand types must match"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4778 | (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal)); |
| 4779 | ;} |
| 4780 | break; |
| 4781 | |
| 4782 | case 195: |
| 4783 | #line 1937 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4784 | { |
| 4785 | if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal))) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4786 | GEN_ERROR("Invalid extractelement operands"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4787 | (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4788 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4789 | ;} |
| 4790 | break; |
| 4791 | |
| 4792 | case 196: |
| 4793 | #line 1943 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4794 | { |
| 4795 | if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal))) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4796 | GEN_ERROR("Invalid insertelement operands"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4797 | (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] | 4798 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4799 | ;} |
| 4800 | break; |
| 4801 | |
| 4802 | case 197: |
| 4803 | #line 1949 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4804 | { |
| 4805 | if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal))) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4806 | GEN_ERROR("Invalid shufflevector operands"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4807 | (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] | 4808 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4809 | ;} |
| 4810 | break; |
| 4811 | |
| 4812 | case 198: |
| 4813 | #line 1958 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4814 | { |
| 4815 | ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4816 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4817 | ;} |
| 4818 | break; |
| 4819 | |
| 4820 | case 199: |
| 4821 | #line 1962 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4822 | { |
| 4823 | (yyval.ConstVector) = new std::vector<Constant*>(); |
| 4824 | (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4825 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4826 | ;} |
| 4827 | break; |
| 4828 | |
| 4829 | case 200: |
| 4830 | #line 1970 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4831 | { (yyval.BoolVal) = false; ;} |
| 4832 | break; |
| 4833 | |
| 4834 | case 201: |
| 4835 | #line 1970 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4836 | { (yyval.BoolVal) = true; ;} |
| 4837 | break; |
| 4838 | |
| 4839 | case 202: |
| 4840 | #line 1973 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4841 | { (yyval.BoolVal) = true; ;} |
| 4842 | break; |
| 4843 | |
| 4844 | case 203: |
| 4845 | #line 1973 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4846 | { (yyval.BoolVal) = false; ;} |
| 4847 | break; |
| 4848 | |
| 4849 | case 204: |
| 4850 | #line 1976 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4851 | { |
| 4852 | const Type* VTy = (yyvsp[(1) - (2)].TypeVal)->get(); |
| 4853 | Value *V = getVal(VTy, (yyvsp[(2) - (2)].ValIDVal)); |
Chris Lattner | 0275cff | 2007-08-06 21:00:46 +0000 | [diff] [blame] | 4854 | CHECK_FOR_ERROR |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 4855 | GlobalValue* Aliasee = dyn_cast<GlobalValue>(V); |
| 4856 | if (!Aliasee) |
| 4857 | GEN_ERROR("Aliases can be created only to global values"); |
| 4858 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4859 | (yyval.ConstVal) = Aliasee; |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 4860 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4861 | delete (yyvsp[(1) - (2)].TypeVal); |
| 4862 | ;} |
| 4863 | break; |
| 4864 | |
| 4865 | case 205: |
| 4866 | #line 1988 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4867 | { |
| 4868 | Constant *Val = (yyvsp[(3) - (6)].ConstVal); |
| 4869 | const Type *DestTy = (yyvsp[(5) - (6)].TypeVal)->get(); |
| 4870 | if (!CastInst::castIsValid((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy)) |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 4871 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 4872 | Val->getType()->getDescription() + "' to '" + |
| 4873 | DestTy->getDescription() + "'"); |
| 4874 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4875 | (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), DestTy); |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 4876 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4877 | delete (yyvsp[(5) - (6)].TypeVal); |
| 4878 | ;} |
| 4879 | break; |
| 4880 | |
| 4881 | case 206: |
| 4882 | #line 2009 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4883 | { |
| 4884 | (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4885 | CurModule.ModuleDone(); |
| 4886 | CHECK_FOR_ERROR; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4887 | ;} |
| 4888 | break; |
| 4889 | |
| 4890 | case 207: |
| 4891 | #line 2014 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4892 | { |
| 4893 | (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 4894 | CurModule.ModuleDone(); |
| 4895 | CHECK_FOR_ERROR; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4896 | ;} |
| 4897 | break; |
| 4898 | |
| 4899 | case 210: |
| 4900 | #line 2027 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4901 | { CurFun.isDeclare = false; ;} |
| 4902 | break; |
| 4903 | |
| 4904 | case 211: |
| 4905 | #line 2027 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4906 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4907 | CurFun.FunctionDone(); |
| 4908 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4909 | ;} |
| 4910 | break; |
| 4911 | |
| 4912 | case 212: |
| 4913 | #line 2031 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4914 | { CurFun.isDeclare = true; ;} |
| 4915 | break; |
| 4916 | |
| 4917 | case 213: |
| 4918 | #line 2031 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4919 | { |
Gordon Henriksen | 80a75bf | 2007-12-10 03:18:06 +0000 | [diff] [blame] | 4920 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4921 | ;} |
| 4922 | break; |
| 4923 | |
| 4924 | case 214: |
| 4925 | #line 2034 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4926 | { |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 4927 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4928 | ;} |
| 4929 | break; |
| 4930 | |
| 4931 | case 215: |
| 4932 | #line 2037 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4933 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4934 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4935 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (3)].TypeVal))->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4936 | // Eagerly resolve types. This is not an optimization, this is a |
| 4937 | // requirement that is due to the fact that we could have this: |
| 4938 | // |
| 4939 | // %list = type { %list * } |
| 4940 | // %list = type { %list * } ; repeated type decl |
| 4941 | // |
| 4942 | // If types are not resolved eagerly, then the two types will not be |
| 4943 | // determined to be the same type! |
| 4944 | // |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4945 | ResolveTypeTo((yyvsp[(1) - (3)].StrVal), *(yyvsp[(3) - (3)].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4946 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4947 | 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] | 4948 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4949 | // If this is a named type that is not a redefinition, add it to the slot |
| 4950 | // table. |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4951 | CurModule.Types.push_back(*(yyvsp[(3) - (3)].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4952 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4953 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4954 | delete (yyvsp[(3) - (3)].TypeVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4955 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4956 | ;} |
| 4957 | break; |
Reid Spencer | b8f8505 | 2007-07-31 03:50:36 +0000 | [diff] [blame] | 4958 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4959 | case 216: |
| 4960 | #line 2061 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4961 | { |
| 4962 | ResolveTypeTo((yyvsp[(1) - (3)].StrVal), (yyvsp[(3) - (3)].PrimType)); |
| 4963 | |
| 4964 | if (!setTypeName((yyvsp[(3) - (3)].PrimType), (yyvsp[(1) - (3)].StrVal)) && !(yyvsp[(1) - (3)].StrVal)) { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4965 | CHECK_FOR_ERROR |
| 4966 | // If this is a named type that is not a redefinition, add it to the slot |
| 4967 | // table. |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4968 | CurModule.Types.push_back((yyvsp[(3) - (3)].PrimType)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4969 | } |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4970 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4971 | ;} |
| 4972 | break; |
| 4973 | |
| 4974 | case 217: |
| 4975 | #line 2073 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4976 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4977 | /* "Externally Visible" Linkage */ |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4978 | if ((yyvsp[(5) - (6)].ConstVal) == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4979 | GEN_ERROR("Global value initializer is not a constant"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4980 | CurGV = ParseGlobalVariable((yyvsp[(1) - (6)].StrVal), GlobalValue::ExternalLinkage, |
| 4981 | (yyvsp[(2) - (6)].Visibility), (yyvsp[(4) - (6)].BoolVal), (yyvsp[(5) - (6)].ConstVal)->getType(), (yyvsp[(5) - (6)].ConstVal), (yyvsp[(3) - (6)].BoolVal), (yyvsp[(6) - (6)].UIntVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 4982 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4983 | ;} |
| 4984 | break; |
| 4985 | |
| 4986 | case 218: |
| 4987 | #line 2080 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4988 | { |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 4989 | CurGV = 0; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4990 | ;} |
| 4991 | break; |
| 4992 | |
| 4993 | case 219: |
| 4994 | #line 2084 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 4995 | { |
| 4996 | if ((yyvsp[(6) - (7)].ConstVal) == 0) |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 4997 | GEN_ERROR("Global value initializer is not a constant"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 4998 | CurGV = ParseGlobalVariable((yyvsp[(1) - (7)].StrVal), (yyvsp[(2) - (7)].Linkage), (yyvsp[(3) - (7)].Visibility), (yyvsp[(5) - (7)].BoolVal), (yyvsp[(6) - (7)].ConstVal)->getType(), (yyvsp[(6) - (7)].ConstVal), (yyvsp[(4) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal)); |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 4999 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5000 | ;} |
| 5001 | break; |
| 5002 | |
| 5003 | case 220: |
| 5004 | #line 2089 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5005 | { |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 5006 | CurGV = 0; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5007 | ;} |
| 5008 | break; |
| 5009 | |
| 5010 | case 221: |
| 5011 | #line 2093 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5012 | { |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 5013 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5014 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(6) - (7)].TypeVal))->getDescription()); |
| 5015 | CurGV = ParseGlobalVariable((yyvsp[(1) - (7)].StrVal), (yyvsp[(2) - (7)].Linkage), (yyvsp[(3) - (7)].Visibility), (yyvsp[(5) - (7)].BoolVal), *(yyvsp[(6) - (7)].TypeVal), 0, (yyvsp[(4) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal)); |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 5016 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5017 | delete (yyvsp[(6) - (7)].TypeVal); |
| 5018 | ;} |
| 5019 | break; |
| 5020 | |
| 5021 | case 222: |
| 5022 | #line 2099 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5023 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5024 | CurGV = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5025 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5026 | ;} |
| 5027 | break; |
| 5028 | |
| 5029 | case 223: |
| 5030 | #line 2103 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5031 | { |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 5032 | std::string Name; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5033 | if ((yyvsp[(1) - (5)].StrVal)) { |
| 5034 | Name = *(yyvsp[(1) - (5)].StrVal); |
| 5035 | delete (yyvsp[(1) - (5)].StrVal); |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 5036 | } |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5037 | if (Name.empty()) |
| 5038 | GEN_ERROR("Alias name cannot be empty"); |
| 5039 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5040 | Constant* Aliasee = (yyvsp[(5) - (5)].ConstVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5041 | if (Aliasee == 0) |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 5042 | GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5043 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5044 | GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), (yyvsp[(4) - (5)].Linkage), Name, Aliasee, |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5045 | CurModule.CurrentModule); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5046 | GA->setVisibility((yyvsp[(2) - (5)].Visibility)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5047 | InsertValue(GA, CurModule.Values); |
Chris Lattner | 569f737 | 2007-09-10 23:24:14 +0000 | [diff] [blame] | 5048 | |
| 5049 | |
| 5050 | // If there was a forward reference of this alias, resolve it now. |
| 5051 | |
| 5052 | ValID ID; |
| 5053 | if (!Name.empty()) |
| 5054 | ID = ValID::createGlobalName(Name); |
| 5055 | else |
| 5056 | ID = ValID::createGlobalID(CurModule.Values.size()-1); |
| 5057 | |
| 5058 | if (GlobalValue *FWGV = |
| 5059 | CurModule.GetForwardRefForGlobal(GA->getType(), ID)) { |
| 5060 | // Replace uses of the fwdref with the actual alias. |
| 5061 | FWGV->replaceAllUsesWith(GA); |
| 5062 | if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV)) |
| 5063 | GV->eraseFromParent(); |
| 5064 | else |
| 5065 | cast<Function>(FWGV)->eraseFromParent(); |
| 5066 | } |
| 5067 | ID.destroy(); |
| 5068 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5069 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5070 | ;} |
| 5071 | break; |
| 5072 | |
| 5073 | case 224: |
| 5074 | #line 2143 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5075 | { |
Anton Korobeynikov | 77d0f97 | 2007-04-25 14:29:12 +0000 | [diff] [blame] | 5076 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5077 | ;} |
| 5078 | break; |
| 5079 | |
| 5080 | case 225: |
| 5081 | #line 2146 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5082 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5083 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5084 | ;} |
| 5085 | break; |
| 5086 | |
| 5087 | case 226: |
| 5088 | #line 2152 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5089 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 5090 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 5091 | if (AsmSoFar.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5092 | CurModule.CurrentModule->setModuleInlineAsm(*(yyvsp[(1) - (1)].StrVal)); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 5093 | else |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5094 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*(yyvsp[(1) - (1)].StrVal)); |
| 5095 | delete (yyvsp[(1) - (1)].StrVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5096 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5097 | ;} |
| 5098 | break; |
| 5099 | |
| 5100 | case 227: |
| 5101 | #line 2162 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5102 | { |
| 5103 | CurModule.CurrentModule->setTargetTriple(*(yyvsp[(3) - (3)].StrVal)); |
| 5104 | delete (yyvsp[(3) - (3)].StrVal); |
| 5105 | ;} |
| 5106 | break; |
| 5107 | |
| 5108 | case 228: |
| 5109 | #line 2166 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5110 | { |
| 5111 | CurModule.CurrentModule->setDataLayout(*(yyvsp[(3) - (3)].StrVal)); |
| 5112 | delete (yyvsp[(3) - (3)].StrVal); |
| 5113 | ;} |
| 5114 | break; |
| 5115 | |
| 5116 | case 230: |
| 5117 | #line 2173 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5118 | { |
| 5119 | CurModule.CurrentModule->addLibrary(*(yyvsp[(3) - (3)].StrVal)); |
| 5120 | delete (yyvsp[(3) - (3)].StrVal); |
Christopher Lamb | bf3348d | 2007-12-12 08:45:45 +0000 | [diff] [blame] | 5121 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5122 | ;} |
| 5123 | break; |
| 5124 | |
| 5125 | case 231: |
| 5126 | #line 2178 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5127 | { |
| 5128 | CurModule.CurrentModule->addLibrary(*(yyvsp[(1) - (1)].StrVal)); |
| 5129 | delete (yyvsp[(1) - (1)].StrVal); |
Reid Spencer | 1013b4d | 2007-07-31 14:41:17 +0000 | [diff] [blame] | 5130 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5131 | ;} |
| 5132 | break; |
| 5133 | |
| 5134 | case 232: |
| 5135 | #line 2183 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5136 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5137 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5138 | ;} |
| 5139 | break; |
| 5140 | |
| 5141 | case 233: |
| 5142 | #line 2192 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5143 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5144 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5145 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription()); |
| 5146 | if (*(yyvsp[(3) - (5)].TypeVal) == Type::VoidTy) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5147 | GEN_ERROR("void typed arguments are invalid"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5148 | ArgListEntry E; E.Attrs = (yyvsp[(4) - (5)].ParamAttrs); E.Ty = (yyvsp[(3) - (5)].TypeVal); E.Name = (yyvsp[(5) - (5)].StrVal); |
| 5149 | (yyval.ArgList) = (yyvsp[(1) - (5)].ArgList); |
| 5150 | (yyvsp[(1) - (5)].ArgList)->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5151 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5152 | ;} |
| 5153 | break; |
| 5154 | |
| 5155 | case 234: |
| 5156 | #line 2202 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5157 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5158 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5159 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (3)].TypeVal))->getDescription()); |
| 5160 | if (*(yyvsp[(1) - (3)].TypeVal) == Type::VoidTy) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5161 | GEN_ERROR("void typed arguments are invalid"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5162 | ArgListEntry E; E.Attrs = (yyvsp[(2) - (3)].ParamAttrs); E.Ty = (yyvsp[(1) - (3)].TypeVal); E.Name = (yyvsp[(3) - (3)].StrVal); |
| 5163 | (yyval.ArgList) = new ArgListType; |
| 5164 | (yyval.ArgList)->push_back(E); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5165 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5166 | ;} |
| 5167 | break; |
| 5168 | |
| 5169 | case 235: |
| 5170 | #line 2213 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5171 | { |
| 5172 | (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5173 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5174 | ;} |
| 5175 | break; |
| 5176 | |
| 5177 | case 236: |
| 5178 | #line 2217 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5179 | { |
| 5180 | (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5181 | struct ArgListEntry E; |
| 5182 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 5183 | E.Name = 0; |
Reid Spencer | 18da072 | 2007-04-11 02:44:20 +0000 | [diff] [blame] | 5184 | E.Attrs = ParamAttr::None; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5185 | (yyval.ArgList)->push_back(E); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5186 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5187 | ;} |
| 5188 | break; |
| 5189 | |
| 5190 | case 237: |
| 5191 | #line 2226 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5192 | { |
| 5193 | (yyval.ArgList) = new ArgListType; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5194 | struct ArgListEntry E; |
| 5195 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 5196 | E.Name = 0; |
| 5197 | E.Attrs = ParamAttr::None; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5198 | (yyval.ArgList)->push_back(E); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5199 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5200 | ;} |
| 5201 | break; |
| 5202 | |
| 5203 | case 238: |
| 5204 | #line 2235 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5205 | { |
| 5206 | (yyval.ArgList) = 0; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5207 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5208 | ;} |
| 5209 | break; |
| 5210 | |
| 5211 | case 239: |
| 5212 | #line 2241 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5213 | { |
| 5214 | std::string FunctionName(*(yyvsp[(3) - (10)].StrVal)); |
| 5215 | delete (yyvsp[(3) - (10)].StrVal); // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5216 | |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 5217 | // Check the function result for abstractness if this is a define. We should |
| 5218 | // have no abstract types at this point |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5219 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[(2) - (10)].TypeVal))) |
| 5220 | GEN_ERROR("Reference to abstract result: "+ (yyvsp[(2) - (10)].TypeVal)->get()->getDescription()); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 5221 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5222 | std::vector<const Type*> ParamTypeList; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5223 | ParamAttrsVector Attrs; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5224 | if ((yyvsp[(7) - (10)].ParamAttrs) != ParamAttr::None) { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5225 | ParamAttrsWithIndex PAWI; |
| 5226 | PAWI.index = 0; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5227 | PAWI.attrs = (yyvsp[(7) - (10)].ParamAttrs); |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5228 | Attrs.push_back(PAWI); |
| 5229 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5230 | if ((yyvsp[(5) - (10)].ArgList)) { // If there are arguments... |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5231 | unsigned index = 1; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5232 | for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin(); I != (yyvsp[(5) - (10)].ArgList)->end(); ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5233 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 5234 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty)) |
| 5235 | GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5236 | ParamTypeList.push_back(Ty); |
| 5237 | if (Ty != Type::VoidTy) |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5238 | if (I->Attrs != ParamAttr::None) { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5239 | ParamAttrsWithIndex PAWI; |
| 5240 | PAWI.index = index; |
| 5241 | PAWI.attrs = I->Attrs; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5242 | Attrs.push_back(PAWI); |
| 5243 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5244 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5245 | } |
| 5246 | |
| 5247 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 5248 | if (isVarArg) ParamTypeList.pop_back(); |
| 5249 | |
Duncan Sands | afa3b6d | 2007-11-28 17:07:01 +0000 | [diff] [blame] | 5250 | const ParamAttrsList *PAL = 0; |
Christopher Lamb | 5c10424 | 2007-04-22 20:09:11 +0000 | [diff] [blame] | 5251 | if (!Attrs.empty()) |
| 5252 | PAL = ParamAttrsList::get(Attrs); |
Reid Spencer | 7b5d466 | 2007-04-09 06:16:21 +0000 | [diff] [blame] | 5253 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5254 | FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (10)].TypeVal), ParamTypeList, isVarArg); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame] | 5255 | const PointerType *PFT = PointerType::getUnqual(FT); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5256 | delete (yyvsp[(2) - (10)].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5257 | |
| 5258 | ValID ID; |
| 5259 | if (!FunctionName.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5260 | ID = ValID::createGlobalName((char*)FunctionName.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5261 | } else { |
Reid Spencer | 93c4003 | 2007-03-19 18:40:50 +0000 | [diff] [blame] | 5262 | ID = ValID::createGlobalID(CurModule.Values.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5263 | } |
| 5264 | |
| 5265 | Function *Fn = 0; |
| 5266 | // See if this function was forward referenced. If so, recycle the object. |
| 5267 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 5268 | // Move the function to the end of the list, from whereever it was |
| 5269 | // previously inserted. |
| 5270 | Fn = cast<Function>(FWRef); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5271 | assert(!Fn->getParamAttrs() && "Forward reference has parameter attributes!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5272 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 5273 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 5274 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5275 | (Fn = CurModule.CurrentModule->getFunction(FunctionName))) { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5276 | if (Fn->getFunctionType() != FT ) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5277 | // The existing function doesn't have the same type. This is an overload |
| 5278 | // error. |
| 5279 | GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5280 | } else if (Fn->getParamAttrs() != PAL) { |
| 5281 | // The existing function doesn't have the same parameter attributes. |
| 5282 | // This is an overload error. |
| 5283 | GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5284 | } else if (!CurFun.isDeclare && !Fn->isDeclaration()) { |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5285 | // Neither the existing or the current function is a declaration and they |
| 5286 | // have the same name and same type. Clearly this is a redefinition. |
| 5287 | GEN_ERROR("Redefinition of function '" + FunctionName + "'"); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5288 | } else if (Fn->isDeclaration()) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5289 | // 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] | 5290 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 5291 | AI != AE; ++AI) |
| 5292 | AI->setName(""); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5293 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5294 | } else { // Not already defined? |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 5295 | Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName, |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5296 | CurModule.CurrentModule); |
| 5297 | InsertValue(Fn, CurModule.Values); |
| 5298 | } |
| 5299 | |
| 5300 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 5301 | |
| 5302 | if (CurFun.isDeclare) { |
| 5303 | // If we have declaration, always overwrite linkage. This will allow us to |
| 5304 | // correctly handle cases, when pointer to function is passed as argument to |
| 5305 | // another function. |
| 5306 | Fn->setLinkage(CurFun.Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 5307 | Fn->setVisibility(CurFun.Visibility); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 5308 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5309 | Fn->setCallingConv((yyvsp[(1) - (10)].UIntVal)); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5310 | Fn->setParamAttrs(PAL); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5311 | Fn->setAlignment((yyvsp[(9) - (10)].UIntVal)); |
| 5312 | if ((yyvsp[(8) - (10)].StrVal)) { |
| 5313 | Fn->setSection(*(yyvsp[(8) - (10)].StrVal)); |
| 5314 | delete (yyvsp[(8) - (10)].StrVal); |
Gordon Henriksen | 80a75bf | 2007-12-10 03:18:06 +0000 | [diff] [blame] | 5315 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5316 | if ((yyvsp[(10) - (10)].StrVal)) { |
| 5317 | Fn->setCollector((yyvsp[(10) - (10)].StrVal)->c_str()); |
| 5318 | delete (yyvsp[(10) - (10)].StrVal); |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 5319 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5320 | |
| 5321 | // Add all of the arguments we parsed to the function... |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5322 | if ((yyvsp[(5) - (10)].ArgList)) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5323 | if (isVarArg) { // Nuke the last entry |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5324 | assert((yyvsp[(5) - (10)].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[(5) - (10)].ArgList)->back().Name == 0 && |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 5325 | "Not a varargs marker!"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5326 | delete (yyvsp[(5) - (10)].ArgList)->back().Ty; |
| 5327 | (yyvsp[(5) - (10)].ArgList)->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5328 | } |
| 5329 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5330 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5331 | unsigned Idx = 1; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5332 | for (ArgListType::iterator I = (yyvsp[(5) - (10)].ArgList)->begin(); |
| 5333 | I != (yyvsp[(5) - (10)].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5334 | delete I->Ty; // Delete the typeholder... |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 5335 | setValueName(ArgIt, I->Name); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5336 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5337 | InsertValue(ArgIt); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5338 | Idx++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5339 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 5340 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5341 | delete (yyvsp[(5) - (10)].ArgList); // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5342 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5343 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5344 | ;} |
| 5345 | break; |
| 5346 | |
| 5347 | case 242: |
| 5348 | #line 2376 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5349 | { |
| 5350 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5351 | |
| 5352 | // Make sure that we keep track of the linkage type even if there was a |
| 5353 | // previous "declare". |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5354 | (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (4)].Linkage)); |
| 5355 | (yyval.FunctionVal)->setVisibility((yyvsp[(2) - (4)].Visibility)); |
| 5356 | ;} |
| 5357 | break; |
| 5358 | |
| 5359 | case 245: |
| 5360 | #line 2387 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5361 | { |
| 5362 | (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5363 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5364 | ;} |
| 5365 | break; |
| 5366 | |
| 5367 | case 246: |
| 5368 | #line 2392 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5369 | { |
| 5370 | CurFun.CurrentFunction->setLinkage((yyvsp[(1) - (3)].Linkage)); |
| 5371 | CurFun.CurrentFunction->setVisibility((yyvsp[(2) - (3)].Visibility)); |
| 5372 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5373 | CurFun.FunctionDone(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5374 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5375 | ;} |
| 5376 | break; |
| 5377 | |
| 5378 | case 247: |
| 5379 | #line 2404 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5380 | { |
| 5381 | (yyval.BoolVal) = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5382 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5383 | ;} |
| 5384 | break; |
| 5385 | |
| 5386 | case 248: |
| 5387 | #line 2408 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5388 | { |
| 5389 | (yyval.BoolVal) = true; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5390 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5391 | ;} |
| 5392 | break; |
| 5393 | |
| 5394 | case 249: |
| 5395 | #line 2413 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5396 | { // A reference to a direct constant |
| 5397 | (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5398 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5399 | ;} |
| 5400 | break; |
| 5401 | |
| 5402 | case 250: |
| 5403 | #line 2417 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5404 | { |
| 5405 | (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5406 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5407 | ;} |
| 5408 | break; |
| 5409 | |
| 5410 | case 251: |
| 5411 | #line 2421 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5412 | { // Perhaps it's an FP constant? |
| 5413 | (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5414 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5415 | ;} |
| 5416 | break; |
| 5417 | |
| 5418 | case 252: |
| 5419 | #line 2425 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5420 | { |
| 5421 | (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5422 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5423 | ;} |
| 5424 | break; |
| 5425 | |
| 5426 | case 253: |
| 5427 | #line 2429 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5428 | { |
| 5429 | (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse()); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 5430 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5431 | ;} |
| 5432 | break; |
| 5433 | |
| 5434 | case 254: |
| 5435 | #line 2433 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5436 | { |
| 5437 | (yyval.ValIDVal) = ValID::createNull(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 5438 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5439 | ;} |
| 5440 | break; |
| 5441 | |
| 5442 | case 255: |
| 5443 | #line 2437 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5444 | { |
| 5445 | (yyval.ValIDVal) = ValID::createUndef(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5446 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5447 | ;} |
| 5448 | break; |
| 5449 | |
| 5450 | case 256: |
| 5451 | #line 2441 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5452 | { // A vector zero constant. |
| 5453 | (yyval.ValIDVal) = ValID::createZeroInit(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5454 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5455 | ;} |
| 5456 | break; |
| 5457 | |
| 5458 | case 257: |
| 5459 | #line 2445 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5460 | { // Nonempty unsized packed vector |
| 5461 | const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType(); |
| 5462 | int NumElements = (yyvsp[(2) - (3)].ConstVector)->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5463 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5464 | VectorType* pt = VectorType::get(ETy, NumElements); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5465 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 5466 | HandleUpRefs( |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame] | 5467 | VectorType::get( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 5468 | ETy, |
| 5469 | NumElements) |
| 5470 | ) |
| 5471 | ); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5472 | |
| 5473 | // Verify all elements are correct type! |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5474 | for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) { |
| 5475 | if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5476 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5477 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5478 | (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5479 | } |
| 5480 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5481 | (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[(2) - (3)].ConstVector))); |
| 5482 | delete PTy; delete (yyvsp[(2) - (3)].ConstVector); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5483 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5484 | ;} |
| 5485 | break; |
| 5486 | |
| 5487 | case 258: |
| 5488 | #line 2470 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5489 | { |
| 5490 | (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5491 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5492 | ;} |
| 5493 | break; |
| 5494 | |
| 5495 | case 259: |
| 5496 | #line 2474 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5497 | { |
| 5498 | (yyval.ValIDVal) = ValID::createInlineAsm(*(yyvsp[(3) - (5)].StrVal), *(yyvsp[(5) - (5)].StrVal), (yyvsp[(2) - (5)].BoolVal)); |
| 5499 | delete (yyvsp[(3) - (5)].StrVal); |
| 5500 | delete (yyvsp[(5) - (5)].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5501 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5502 | ;} |
| 5503 | break; |
| 5504 | |
| 5505 | case 260: |
| 5506 | #line 2484 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5507 | { // Is it an integer reference...? |
| 5508 | (yyval.ValIDVal) = ValID::createLocalID((yyvsp[(1) - (1)].UIntVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5509 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5510 | ;} |
| 5511 | break; |
| 5512 | |
| 5513 | case 261: |
| 5514 | #line 2488 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5515 | { |
| 5516 | (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[(1) - (1)].UIntVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5517 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5518 | ;} |
| 5519 | break; |
| 5520 | |
| 5521 | case 262: |
| 5522 | #line 2492 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5523 | { // Is it a named reference...? |
| 5524 | (yyval.ValIDVal) = ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal)); |
| 5525 | delete (yyvsp[(1) - (1)].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5526 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5527 | ;} |
| 5528 | break; |
| 5529 | |
| 5530 | case 263: |
| 5531 | #line 2497 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5532 | { // Is it a named reference...? |
| 5533 | (yyval.ValIDVal) = ValID::createGlobalName(*(yyvsp[(1) - (1)].StrVal)); |
| 5534 | delete (yyvsp[(1) - (1)].StrVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5535 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5536 | ;} |
| 5537 | break; |
| 5538 | |
| 5539 | case 266: |
| 5540 | #line 2510 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5541 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5542 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5543 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (2)].TypeVal))->getDescription()); |
| 5544 | (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal)); |
| 5545 | delete (yyvsp[(1) - (2)].TypeVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5546 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5547 | ;} |
| 5548 | break; |
| 5549 | |
| 5550 | case 267: |
| 5551 | #line 2519 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5552 | { |
| 5553 | (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5554 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5555 | ;} |
| 5556 | break; |
| 5557 | |
| 5558 | case 268: |
| 5559 | #line 2523 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5560 | { // Do not allow functions with 0 basic blocks |
| 5561 | (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5562 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5563 | ;} |
| 5564 | break; |
| 5565 | |
| 5566 | case 269: |
| 5567 | #line 2532 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5568 | { |
| 5569 | setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5570 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5571 | InsertValue((yyvsp[(3) - (3)].TermInstVal)); |
| 5572 | (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal)); |
| 5573 | (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5574 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5575 | ;} |
| 5576 | break; |
| 5577 | |
| 5578 | case 270: |
| 5579 | #line 2541 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5580 | { |
| 5581 | if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[(2) - (2)].InstVal))) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5582 | if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0))) |
| 5583 | if (CI2->getParent() == 0) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5584 | (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2); |
| 5585 | (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal)); |
| 5586 | (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal); |
Anton Korobeynikov | 38e0980 | 2007-04-28 13:48:45 +0000 | [diff] [blame] | 5587 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5588 | ;} |
| 5589 | break; |
| 5590 | |
| 5591 | case 271: |
| 5592 | #line 2550 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5593 | { // Empty space between instruction lists |
| 5594 | (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalID(CurFun.NextValNum)); |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 5595 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5596 | ;} |
| 5597 | break; |
| 5598 | |
| 5599 | case 272: |
| 5600 | #line 2554 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5601 | { // Labelled (named) basic block |
| 5602 | (yyval.BasicBlockVal) = defineBBVal(ValID::createLocalName(*(yyvsp[(1) - (1)].StrVal))); |
| 5603 | delete (yyvsp[(1) - (1)].StrVal); |
Reid Spencer | ed951ea | 2007-05-19 07:22:10 +0000 | [diff] [blame] | 5604 | CHECK_FOR_ERROR |
Reid Spencer | 0a8a16b | 2007-05-22 18:52:55 +0000 | [diff] [blame] | 5605 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5606 | ;} |
| 5607 | break; |
Reid Spencer | b8f8505 | 2007-07-31 03:50:36 +0000 | [diff] [blame] | 5608 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5609 | case 273: |
| 5610 | #line 2561 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5611 | { // Return with a result... |
| 5612 | (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal)); |
| 5613 | CHECK_FOR_ERROR |
| 5614 | ;} |
| 5615 | break; |
| 5616 | |
| 5617 | case 274: |
| 5618 | #line 2565 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5619 | { // Return with no result... |
| 5620 | (yyval.TermInstVal) = new ReturnInst(); |
| 5621 | CHECK_FOR_ERROR |
| 5622 | ;} |
| 5623 | break; |
| 5624 | |
| 5625 | case 275: |
| 5626 | #line 2569 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5627 | { // Unconditional Branch... |
| 5628 | BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal)); |
| 5629 | CHECK_FOR_ERROR |
| 5630 | (yyval.TermInstVal) = new BranchInst(tmpBB); |
| 5631 | ;} |
| 5632 | break; |
| 5633 | |
| 5634 | case 276: |
| 5635 | #line 2574 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5636 | { |
| 5637 | assert(cast<IntegerType>((yyvsp[(2) - (9)].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 5638 | BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal)); |
| 5639 | CHECK_FOR_ERROR |
| 5640 | BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal)); |
| 5641 | CHECK_FOR_ERROR |
| 5642 | Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[(3) - (9)].ValIDVal)); |
| 5643 | CHECK_FOR_ERROR |
| 5644 | (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 5645 | ;} |
| 5646 | break; |
| 5647 | |
| 5648 | case 277: |
| 5649 | #line 2584 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5650 | { |
| 5651 | Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal)); |
| 5652 | CHECK_FOR_ERROR |
| 5653 | BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal)); |
| 5654 | CHECK_FOR_ERROR |
| 5655 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size()); |
| 5656 | (yyval.TermInstVal) = S; |
| 5657 | |
| 5658 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(), |
| 5659 | E = (yyvsp[(8) - (9)].JumpTable)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5660 | for (; I != E; ++I) { |
| 5661 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 5662 | S->addCase(CI, I->second); |
| 5663 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5664 | GEN_ERROR("Switch case is constant, but not a simple integer"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5665 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5666 | delete (yyvsp[(8) - (9)].JumpTable); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5667 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5668 | ;} |
| 5669 | break; |
| 5670 | |
| 5671 | case 278: |
| 5672 | #line 2603 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5673 | { |
| 5674 | Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5675 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5676 | BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5677 | CHECK_FOR_ERROR |
| 5678 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5679 | (yyval.TermInstVal) = S; |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5680 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5681 | ;} |
| 5682 | break; |
| 5683 | |
| 5684 | case 279: |
| 5685 | #line 2613 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5686 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 5687 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5688 | // Handle the short syntax |
| 5689 | const PointerType *PFTy = 0; |
| 5690 | const FunctionType *Ty = 0; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5691 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (14)].TypeVal)->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5692 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5693 | // Pull out the types of all of the arguments... |
| 5694 | std::vector<const Type*> ParamTypes; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5695 | ParamList::iterator I = (yyvsp[(6) - (14)].ParamList)->begin(), E = (yyvsp[(6) - (14)].ParamList)->end(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5696 | for (; I != E; ++I) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5697 | const Type *Ty = I->Val->getType(); |
| 5698 | if (Ty == Type::VoidTy) |
| 5699 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 5700 | ParamTypes.push_back(Ty); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5701 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5702 | Ty = FunctionType::get((yyvsp[(3) - (14)].TypeVal)->get(), ParamTypes, false); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame] | 5703 | PFTy = PointerType::getUnqual(Ty); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5704 | } |
| 5705 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5706 | delete (yyvsp[(3) - (14)].TypeVal); |
Reid Spencer | 66728ef | 2007-03-20 01:13:36 +0000 | [diff] [blame] | 5707 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5708 | 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] | 5709 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5710 | BasicBlock *Normal = getBBVal((yyvsp[(11) - (14)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5711 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5712 | BasicBlock *Except = getBBVal((yyvsp[(14) - (14)].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5713 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5714 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5715 | ParamAttrsVector Attrs; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5716 | if ((yyvsp[(8) - (14)].ParamAttrs) != ParamAttr::None) { |
| 5717 | ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = (yyvsp[(8) - (14)].ParamAttrs); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5718 | Attrs.push_back(PAWI); |
| 5719 | } |
| 5720 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5721 | // Check the arguments |
| 5722 | ValueList Args; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5723 | if ((yyvsp[(6) - (14)].ParamList)->empty()) { // Has no arguments? |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5724 | // Make sure no arguments is a good thing! |
| 5725 | if (Ty->getNumParams() != 0) |
| 5726 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5727 | "expects arguments"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5728 | } else { // Has arguments? |
| 5729 | // Loop through FunctionType's arguments and ensure they are specified |
| 5730 | // correctly! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5731 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5732 | FunctionType::param_iterator E = Ty->param_end(); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5733 | ParamList::iterator ArgI = (yyvsp[(6) - (14)].ParamList)->begin(), ArgE = (yyvsp[(6) - (14)].ParamList)->end(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5734 | unsigned index = 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5735 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5736 | for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5737 | if (ArgI->Val->getType() != *I) |
| 5738 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5739 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5740 | Args.push_back(ArgI->Val); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5741 | if (ArgI->Attrs != ParamAttr::None) { |
| 5742 | ParamAttrsWithIndex PAWI; |
| 5743 | PAWI.index = index; |
| 5744 | PAWI.attrs = ArgI->Attrs; |
| 5745 | Attrs.push_back(PAWI); |
| 5746 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5747 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5748 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5749 | if (Ty->isVarArg()) { |
| 5750 | if (I == E) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5751 | for (; ArgI != ArgE; ++ArgI, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5752 | Args.push_back(ArgI->Val); // push the remaining varargs |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5753 | if (ArgI->Attrs != ParamAttr::None) { |
| 5754 | ParamAttrsWithIndex PAWI; |
| 5755 | PAWI.index = index; |
| 5756 | PAWI.attrs = ArgI->Attrs; |
| 5757 | Attrs.push_back(PAWI); |
| 5758 | } |
| 5759 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5760 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5761 | GEN_ERROR("Invalid number of parameters detected"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5762 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5763 | |
Duncan Sands | afa3b6d | 2007-11-28 17:07:01 +0000 | [diff] [blame] | 5764 | const ParamAttrsList *PAL = 0; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5765 | if (!Attrs.empty()) |
| 5766 | PAL = ParamAttrsList::get(Attrs); |
| 5767 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5768 | // Create the InvokeInst |
Chris Lattner | d80fb8b | 2007-08-29 16:15:23 +0000 | [diff] [blame] | 5769 | InvokeInst *II = new InvokeInst(V, Normal, Except, Args.begin(), Args.end()); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5770 | II->setCallingConv((yyvsp[(2) - (14)].UIntVal)); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5771 | II->setParamAttrs(PAL); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5772 | (yyval.TermInstVal) = II; |
| 5773 | delete (yyvsp[(6) - (14)].ParamList); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5774 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5775 | ;} |
| 5776 | break; |
| 5777 | |
| 5778 | case 280: |
| 5779 | #line 2703 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5780 | { |
| 5781 | (yyval.TermInstVal) = new UnwindInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5782 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5783 | ;} |
| 5784 | break; |
| 5785 | |
| 5786 | case 281: |
| 5787 | #line 2707 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5788 | { |
| 5789 | (yyval.TermInstVal) = new UnreachableInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5790 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5791 | ;} |
| 5792 | break; |
| 5793 | |
| 5794 | case 282: |
| 5795 | #line 2714 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5796 | { |
| 5797 | (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable); |
| 5798 | Constant *V = cast<Constant>(getExistingVal((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal))); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5799 | CHECK_FOR_ERROR |
| 5800 | if (V == 0) |
| 5801 | GEN_ERROR("May only switch on a constant pool value"); |
| 5802 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5803 | BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5804 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5805 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5806 | ;} |
| 5807 | break; |
| 5808 | |
| 5809 | case 283: |
| 5810 | #line 2725 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5811 | { |
| 5812 | (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 5813 | 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] | 5814 | CHECK_FOR_ERROR |
| 5815 | |
| 5816 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5817 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5818 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5819 | BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5820 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5821 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5822 | ;} |
| 5823 | break; |
| 5824 | |
| 5825 | case 284: |
| 5826 | #line 2738 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5827 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5828 | // Is this definition named?? if so, assign the name... |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5829 | setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5830 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5831 | InsertValue((yyvsp[(2) - (2)].InstVal)); |
| 5832 | (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5833 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5834 | ;} |
| 5835 | break; |
| 5836 | |
| 5837 | case 285: |
| 5838 | #line 2748 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5839 | { // Used for PHI nodes |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5840 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5841 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (6)].TypeVal))->getDescription()); |
| 5842 | (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 5843 | Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5844 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5845 | BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5846 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5847 | (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5848 | delete (yyvsp[(1) - (6)].TypeVal); |
| 5849 | ;} |
| 5850 | break; |
| 5851 | |
| 5852 | case 286: |
| 5853 | #line 2759 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5854 | { |
| 5855 | (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList); |
| 5856 | Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5857 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5858 | BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5859 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5860 | (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5861 | ;} |
| 5862 | break; |
| 5863 | |
| 5864 | case 287: |
| 5865 | #line 2769 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5866 | { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5867 | // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0 |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5868 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5869 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (4)].TypeVal))->getDescription()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5870 | // Used for call and invoke instructions |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5871 | (yyval.ParamList) = new ParamList(); |
| 5872 | ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getVal((yyvsp[(1) - (4)].TypeVal)->get(), (yyvsp[(3) - (4)].ValIDVal)); |
| 5873 | (yyval.ParamList)->push_back(E); |
| 5874 | delete (yyvsp[(1) - (4)].TypeVal); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5875 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5876 | ;} |
| 5877 | break; |
| 5878 | |
| 5879 | case 288: |
| 5880 | #line 2780 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5881 | { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5882 | // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0 |
Dale Johannesen | eb57ea7 | 2007-11-05 21:20:28 +0000 | [diff] [blame] | 5883 | // Labels are only valid in ASMs |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5884 | (yyval.ParamList) = new ParamList(); |
| 5885 | ParamListEntry E; E.Attrs = (yyvsp[(2) - (4)].ParamAttrs) | (yyvsp[(4) - (4)].ParamAttrs); E.Val = getBBVal((yyvsp[(3) - (4)].ValIDVal)); |
| 5886 | (yyval.ParamList)->push_back(E); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5887 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5888 | ;} |
| 5889 | break; |
| 5890 | |
| 5891 | case 289: |
| 5892 | #line 2788 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5893 | { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5894 | // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0 |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5895 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5896 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription()); |
| 5897 | (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList); |
| 5898 | ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getVal((yyvsp[(3) - (6)].TypeVal)->get(), (yyvsp[(5) - (6)].ValIDVal)); |
| 5899 | (yyval.ParamList)->push_back(E); |
| 5900 | delete (yyvsp[(3) - (6)].TypeVal); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5901 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5902 | ;} |
| 5903 | break; |
| 5904 | |
| 5905 | case 290: |
| 5906 | #line 2798 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5907 | { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 5908 | // FIXME: Remove trailing OptParamAttrs in LLVM 3.0, it was a mistake in 2.0 |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5909 | (yyval.ParamList) = (yyvsp[(1) - (6)].ParamList); |
| 5910 | ParamListEntry E; E.Attrs = (yyvsp[(4) - (6)].ParamAttrs) | (yyvsp[(6) - (6)].ParamAttrs); E.Val = getBBVal((yyvsp[(5) - (6)].ValIDVal)); |
| 5911 | (yyval.ParamList)->push_back(E); |
Dale Johannesen | eb57ea7 | 2007-11-05 21:20:28 +0000 | [diff] [blame] | 5912 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5913 | ;} |
| 5914 | break; |
| 5915 | |
| 5916 | case 291: |
| 5917 | #line 2805 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5918 | { (yyval.ParamList) = new ParamList(); ;} |
| 5919 | break; |
| 5920 | |
| 5921 | case 292: |
| 5922 | #line 2808 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5923 | { (yyval.ValueList) = new std::vector<Value*>(); ;} |
| 5924 | break; |
| 5925 | |
| 5926 | case 293: |
| 5927 | #line 2809 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5928 | { |
| 5929 | (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList); |
| 5930 | (yyval.ValueList)->push_back((yyvsp[(3) - (3)].ValueVal)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5931 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5932 | ;} |
| 5933 | break; |
| 5934 | |
| 5935 | case 294: |
| 5936 | #line 2816 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5937 | { |
| 5938 | (yyval.BoolVal) = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5939 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5940 | ;} |
| 5941 | break; |
| 5942 | |
| 5943 | case 295: |
| 5944 | #line 2820 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5945 | { |
| 5946 | (yyval.BoolVal) = false; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5947 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5948 | ;} |
| 5949 | break; |
| 5950 | |
| 5951 | case 296: |
| 5952 | #line 2825 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5953 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5954 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5955 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription()); |
| 5956 | if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() && |
| 5957 | !isa<VectorType>((*(yyvsp[(2) - (5)].TypeVal)).get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5958 | GEN_ERROR( |
| 5959 | "Arithmetic operator requires integer, FP, or packed operands"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5960 | Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5961 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5962 | Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5963 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5964 | (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2); |
| 5965 | if ((yyval.InstVal) == 0) |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5966 | GEN_ERROR("binary operator returned null"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5967 | delete (yyvsp[(2) - (5)].TypeVal); |
| 5968 | ;} |
| 5969 | break; |
| 5970 | |
| 5971 | case 297: |
| 5972 | #line 2841 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5973 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5974 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5975 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (5)].TypeVal))->getDescription()); |
| 5976 | if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger()) { |
| 5977 | if (Instruction::isShift((yyvsp[(1) - (5)].BinaryOpVal)) || !isa<VectorType>((yyvsp[(2) - (5)].TypeVal)->get()) || |
| 5978 | !cast<VectorType>((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isInteger()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5979 | GEN_ERROR("Logical operator requires integral operands"); |
| 5980 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5981 | Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5982 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5983 | Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5984 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5985 | (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2); |
| 5986 | if ((yyval.InstVal) == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5987 | GEN_ERROR("binary operator returned null"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5988 | delete (yyvsp[(2) - (5)].TypeVal); |
| 5989 | ;} |
| 5990 | break; |
| 5991 | |
| 5992 | case 298: |
| 5993 | #line 2858 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 5994 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 5995 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5996 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription()); |
| 5997 | if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 5998 | GEN_ERROR("Vector types not supported by icmp instruction"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 5999 | Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 6000 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6001 | Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 6002 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6003 | (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2); |
| 6004 | if ((yyval.InstVal) == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6005 | GEN_ERROR("icmp operator returned null"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6006 | delete (yyvsp[(3) - (6)].TypeVal); |
| 6007 | ;} |
| 6008 | break; |
| 6009 | |
| 6010 | case 299: |
| 6011 | #line 2872 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6012 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 6013 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6014 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (6)].TypeVal))->getDescription()); |
| 6015 | if (isa<VectorType>((*(yyvsp[(3) - (6)].TypeVal)).get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6016 | GEN_ERROR("Vector types not supported by fcmp instruction"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6017 | Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6018 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6019 | Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6020 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6021 | (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2); |
| 6022 | if ((yyval.InstVal) == 0) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6023 | GEN_ERROR("fcmp operator returned null"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6024 | delete (yyvsp[(3) - (6)].TypeVal); |
| 6025 | ;} |
| 6026 | break; |
| 6027 | |
| 6028 | case 300: |
| 6029 | #line 2886 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6030 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6031 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6032 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription()); |
| 6033 | Value* Val = (yyvsp[(2) - (4)].ValueVal); |
| 6034 | const Type* DestTy = (yyvsp[(4) - (4)].TypeVal)->get(); |
| 6035 | if (!CastInst::castIsValid((yyvsp[(1) - (4)].CastOpVal), Val, DestTy)) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6036 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 6037 | Val->getType()->getDescription() + "' to '" + |
| 6038 | DestTy->getDescription() + "'"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6039 | (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), Val, DestTy); |
| 6040 | delete (yyvsp[(4) - (4)].TypeVal); |
| 6041 | ;} |
| 6042 | break; |
| 6043 | |
| 6044 | case 301: |
| 6045 | #line 2898 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6046 | { |
| 6047 | if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::Int1Ty) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6048 | GEN_ERROR("select condition must be boolean"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6049 | if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6050 | GEN_ERROR("select value types should match"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6051 | (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] | 6052 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6053 | ;} |
| 6054 | break; |
| 6055 | |
| 6056 | case 302: |
| 6057 | #line 2906 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6058 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6059 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6060 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(4) - (4)].TypeVal))->getDescription()); |
| 6061 | (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal)); |
| 6062 | delete (yyvsp[(4) - (4)].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6063 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6064 | ;} |
| 6065 | break; |
| 6066 | |
| 6067 | case 303: |
| 6068 | #line 2913 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6069 | { |
| 6070 | if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal))) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6071 | GEN_ERROR("Invalid extractelement operands"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6072 | (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 6073 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6074 | ;} |
| 6075 | break; |
| 6076 | |
| 6077 | case 304: |
| 6078 | #line 2919 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6079 | { |
| 6080 | if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal))) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6081 | GEN_ERROR("Invalid insertelement operands"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6082 | (yyval.InstVal) = new InsertElementInst((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] | 6083 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6084 | ;} |
| 6085 | break; |
| 6086 | |
| 6087 | case 305: |
| 6088 | #line 2925 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6089 | { |
| 6090 | if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal))) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6091 | GEN_ERROR("Invalid shufflevector operands"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6092 | (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] | 6093 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6094 | ;} |
| 6095 | break; |
| 6096 | |
| 6097 | case 306: |
| 6098 | #line 2931 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6099 | { |
| 6100 | const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6101 | if (!Ty->isFirstClassType()) |
| 6102 | GEN_ERROR("PHI node operands must be of first class type"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6103 | (yyval.InstVal) = new PHINode(Ty); |
| 6104 | ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size()); |
| 6105 | while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) { |
| 6106 | if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6107 | GEN_ERROR("All elements of a PHI node must be of the same type"); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6108 | cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second); |
| 6109 | (yyvsp[(2) - (2)].PHIList)->pop_front(); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6110 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6111 | delete (yyvsp[(2) - (2)].PHIList); // Free the list... |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6112 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6113 | ;} |
| 6114 | break; |
| 6115 | |
| 6116 | case 307: |
| 6117 | #line 2947 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6118 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6119 | |
| 6120 | // Handle the short syntax |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 6121 | const PointerType *PFTy = 0; |
| 6122 | const FunctionType *Ty = 0; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6123 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[(3) - (8)].TypeVal)->get())) || |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 6124 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 6125 | // Pull out the types of all of the arguments... |
| 6126 | std::vector<const Type*> ParamTypes; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6127 | ParamList::iterator I = (yyvsp[(6) - (8)].ParamList)->begin(), E = (yyvsp[(6) - (8)].ParamList)->end(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6128 | for (; I != E; ++I) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6129 | const Type *Ty = I->Val->getType(); |
| 6130 | if (Ty == Type::VoidTy) |
| 6131 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 6132 | ParamTypes.push_back(Ty); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 6133 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6134 | Ty = FunctionType::get((yyvsp[(3) - (8)].TypeVal)->get(), ParamTypes, false); |
Christopher Lamb | 4374f8e | 2007-12-17 01:17:35 +0000 | [diff] [blame] | 6135 | PFTy = PointerType::getUnqual(Ty); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 6136 | } |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 6137 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6138 | 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] | 6139 | CHECK_FOR_ERROR |
Chris Lattner | 6cdc682 | 2007-04-26 05:31:05 +0000 | [diff] [blame] | 6140 | |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 6141 | // Check for call to invalid intrinsic to avoid crashing later. |
| 6142 | if (Function *theF = dyn_cast<Function>(V)) { |
Reid Spencer | ed48de2 | 2007-04-16 22:02:23 +0000 | [diff] [blame] | 6143 | if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) && |
Reid Spencer | 36fdde1 | 2007-04-16 20:35:38 +0000 | [diff] [blame] | 6144 | (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) && |
| 6145 | !theF->getIntrinsicID(true)) |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 6146 | GEN_ERROR("Call to invalid LLVM intrinsic function '" + |
| 6147 | theF->getName() + "'"); |
| 6148 | } |
| 6149 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6150 | // Set up the ParamAttrs for the function |
| 6151 | ParamAttrsVector Attrs; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6152 | if ((yyvsp[(8) - (8)].ParamAttrs) != ParamAttr::None) { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6153 | ParamAttrsWithIndex PAWI; |
| 6154 | PAWI.index = 0; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6155 | PAWI.attrs = (yyvsp[(8) - (8)].ParamAttrs); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6156 | Attrs.push_back(PAWI); |
| 6157 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6158 | // Check the arguments |
| 6159 | ValueList Args; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6160 | if ((yyvsp[(6) - (8)].ParamList)->empty()) { // Has no arguments? |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 6161 | // Make sure no arguments is a good thing! |
| 6162 | if (Ty->getNumParams() != 0) |
| 6163 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 6164 | "expects arguments"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 6165 | } else { // Has arguments? |
| 6166 | // Loop through FunctionType's arguments and ensure they are specified |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6167 | // correctly. Also, gather any parameter attributes. |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 6168 | FunctionType::param_iterator I = Ty->param_begin(); |
| 6169 | FunctionType::param_iterator E = Ty->param_end(); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6170 | ParamList::iterator ArgI = (yyvsp[(6) - (8)].ParamList)->begin(), ArgE = (yyvsp[(6) - (8)].ParamList)->end(); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6171 | unsigned index = 1; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 6172 | |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6173 | for (; ArgI != ArgE && I != E; ++ArgI, ++I, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6174 | if (ArgI->Val->getType() != *I) |
| 6175 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 6176 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6177 | Args.push_back(ArgI->Val); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6178 | if (ArgI->Attrs != ParamAttr::None) { |
| 6179 | ParamAttrsWithIndex PAWI; |
| 6180 | PAWI.index = index; |
| 6181 | PAWI.attrs = ArgI->Attrs; |
| 6182 | Attrs.push_back(PAWI); |
| 6183 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6184 | } |
| 6185 | if (Ty->isVarArg()) { |
| 6186 | if (I == E) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6187 | for (; ArgI != ArgE; ++ArgI, ++index) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6188 | Args.push_back(ArgI->Val); // push the remaining varargs |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6189 | if (ArgI->Attrs != ParamAttr::None) { |
| 6190 | ParamAttrsWithIndex PAWI; |
| 6191 | PAWI.index = index; |
| 6192 | PAWI.attrs = ArgI->Attrs; |
| 6193 | Attrs.push_back(PAWI); |
| 6194 | } |
| 6195 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6196 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 6197 | GEN_ERROR("Invalid number of parameters detected"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 6198 | } |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6199 | |
| 6200 | // Finish off the ParamAttrs and check them |
Duncan Sands | afa3b6d | 2007-11-28 17:07:01 +0000 | [diff] [blame] | 6201 | const ParamAttrsList *PAL = 0; |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6202 | if (!Attrs.empty()) |
| 6203 | PAL = ParamAttrsList::get(Attrs); |
| 6204 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6205 | // Create the call node |
David Greene | 718fda3 | 2007-08-01 03:59:32 +0000 | [diff] [blame] | 6206 | CallInst *CI = new CallInst(V, Args.begin(), Args.end()); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6207 | CI->setTailCall((yyvsp[(1) - (8)].BoolVal)); |
| 6208 | CI->setCallingConv((yyvsp[(2) - (8)].UIntVal)); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6209 | CI->setParamAttrs(PAL); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6210 | (yyval.InstVal) = CI; |
| 6211 | delete (yyvsp[(6) - (8)].ParamList); |
| 6212 | delete (yyvsp[(3) - (8)].TypeVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 6213 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6214 | ;} |
| 6215 | break; |
| 6216 | |
| 6217 | case 308: |
| 6218 | #line 3044 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6219 | { |
| 6220 | (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 6221 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6222 | ;} |
| 6223 | break; |
| 6224 | |
| 6225 | case 309: |
| 6226 | #line 3049 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6227 | { |
| 6228 | (yyval.BoolVal) = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 6229 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6230 | ;} |
| 6231 | break; |
| 6232 | |
| 6233 | case 310: |
| 6234 | #line 3053 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6235 | { |
| 6236 | (yyval.BoolVal) = false; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6237 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6238 | ;} |
| 6239 | break; |
| 6240 | |
| 6241 | case 311: |
| 6242 | #line 3060 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6243 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 6244 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6245 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription()); |
| 6246 | (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal)); |
| 6247 | delete (yyvsp[(2) - (3)].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6248 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6249 | ;} |
| 6250 | break; |
| 6251 | |
| 6252 | case 312: |
| 6253 | #line 3067 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6254 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 6255 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6256 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription()); |
| 6257 | Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6258 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6259 | (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal)); |
| 6260 | delete (yyvsp[(2) - (6)].TypeVal); |
| 6261 | ;} |
| 6262 | break; |
| 6263 | |
| 6264 | case 313: |
| 6265 | #line 3075 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6266 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6267 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6268 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (3)].TypeVal))->getDescription()); |
| 6269 | (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal)); |
| 6270 | delete (yyvsp[(2) - (3)].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6271 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6272 | ;} |
| 6273 | break; |
| 6274 | |
| 6275 | case 314: |
| 6276 | #line 3082 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6277 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6278 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6279 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (6)].TypeVal))->getDescription()); |
| 6280 | Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 6281 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6282 | (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal)); |
| 6283 | delete (yyvsp[(2) - (6)].TypeVal); |
| 6284 | ;} |
| 6285 | break; |
| 6286 | |
| 6287 | case 315: |
| 6288 | #line 3090 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6289 | { |
| 6290 | if (!isa<PointerType>((yyvsp[(2) - (2)].ValueVal)->getType())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6291 | GEN_ERROR("Trying to free nonpointer type " + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6292 | (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + ""); |
| 6293 | (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 6294 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6295 | ;} |
| 6296 | break; |
| 6297 | |
| 6298 | case 316: |
| 6299 | #line 3098 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6300 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 6301 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6302 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(3) - (5)].TypeVal))->getDescription()); |
| 6303 | if (!isa<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6304 | GEN_ERROR("Can't load from nonpointer type: " + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6305 | (*(yyvsp[(3) - (5)].TypeVal))->getDescription()); |
| 6306 | if (!cast<PointerType>((yyvsp[(3) - (5)].TypeVal)->get())->getElementType()->isFirstClassType()) |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6307 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6308 | (*(yyvsp[(3) - (5)].TypeVal))->getDescription()); |
| 6309 | Value* tmpVal = getVal(*(yyvsp[(3) - (5)].TypeVal), (yyvsp[(4) - (5)].ValIDVal)); |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 6310 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6311 | (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (5)].BoolVal), (yyvsp[(5) - (5)].UIntVal)); |
| 6312 | delete (yyvsp[(3) - (5)].TypeVal); |
| 6313 | ;} |
| 6314 | break; |
| 6315 | |
| 6316 | case 317: |
| 6317 | #line 3112 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6318 | { |
Lauro Ramos Venancio | c763552 | 2007-04-12 18:32:50 +0000 | [diff] [blame] | 6319 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6320 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(5) - (7)].TypeVal))->getDescription()); |
| 6321 | const PointerType *PT = dyn_cast<PointerType>((yyvsp[(5) - (7)].TypeVal)->get()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6322 | if (!PT) |
| 6323 | GEN_ERROR("Can't store to a nonpointer type: " + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6324 | (*(yyvsp[(5) - (7)].TypeVal))->getDescription()); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6325 | const Type *ElTy = PT->getElementType(); |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6326 | if (ElTy != (yyvsp[(3) - (7)].ValueVal)->getType()) |
| 6327 | GEN_ERROR("Can't store '" + (yyvsp[(3) - (7)].ValueVal)->getType()->getDescription() + |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6328 | "' into space of type '" + ElTy->getDescription() + "'"); |
| 6329 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6330 | Value* tmpVal = getVal(*(yyvsp[(5) - (7)].TypeVal), (yyvsp[(6) - (7)].ValIDVal)); |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6331 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6332 | (yyval.InstVal) = new StoreInst((yyvsp[(3) - (7)].ValueVal), tmpVal, (yyvsp[(1) - (7)].BoolVal), (yyvsp[(7) - (7)].UIntVal)); |
| 6333 | delete (yyvsp[(5) - (7)].TypeVal); |
| 6334 | ;} |
| 6335 | break; |
| 6336 | |
| 6337 | case 318: |
| 6338 | #line 3129 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
| 6339 | { |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6340 | if (!UpRefs.empty()) |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6341 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(2) - (4)].TypeVal))->getDescription()); |
| 6342 | if (!isa<PointerType>((yyvsp[(2) - (4)].TypeVal)->get())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 6343 | GEN_ERROR("getelementptr insn requires pointer operand"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6344 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6345 | if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end(), true)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6346 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6347 | (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'"); |
| 6348 | Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6349 | CHECK_FOR_ERROR |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6350 | (yyval.InstVal) = new GetElementPtrInst(tmpVal, (yyvsp[(4) - (4)].ValueList)->begin(), (yyvsp[(4) - (4)].ValueList)->end()); |
| 6351 | delete (yyvsp[(2) - (4)].TypeVal); |
| 6352 | delete (yyvsp[(4) - (4)].ValueList); |
| 6353 | ;} |
| 6354 | break; |
Reid Spencer | 7780acb | 2007-04-16 06:56:07 +0000 | [diff] [blame] | 6355 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6356 | |
| 6357 | /* Line 1267 of yacc.c. */ |
| 6358 | #line 6359 "llvmAsmParser.tab.c" |
| 6359 | default: break; |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 6360 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6361 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); |
| 6362 | |
| 6363 | YYPOPSTACK (yylen); |
| 6364 | yylen = 0; |
| 6365 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6366 | |
| 6367 | *++yyvsp = yyval; |
| 6368 | |
| 6369 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6370 | /* Now `shift' the result of the reduction. Determine what state |
| 6371 | that goes to, based on the state we popped back to and the rule |
| 6372 | number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6373 | |
| 6374 | yyn = yyr1[yyn]; |
| 6375 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6376 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 6377 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6378 | yystate = yytable[yystate]; |
| 6379 | else |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6380 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6381 | |
| 6382 | goto yynewstate; |
| 6383 | |
| 6384 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6385 | /*------------------------------------. |
| 6386 | | yyerrlab -- here on detecting error | |
| 6387 | `------------------------------------*/ |
| 6388 | yyerrlab: |
| 6389 | /* If not already recovering from an error, report this error. */ |
| 6390 | if (!yyerrstatus) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6391 | { |
| 6392 | ++yynerrs; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6393 | #if ! YYERROR_VERBOSE |
| 6394 | yyerror (YY_("syntax error")); |
| 6395 | #else |
| 6396 | { |
| 6397 | YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); |
| 6398 | if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) |
| 6399 | { |
| 6400 | YYSIZE_T yyalloc = 2 * yysize; |
| 6401 | if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) |
| 6402 | yyalloc = YYSTACK_ALLOC_MAXIMUM; |
| 6403 | if (yymsg != yymsgbuf) |
| 6404 | YYSTACK_FREE (yymsg); |
| 6405 | yymsg = (char *) YYSTACK_ALLOC (yyalloc); |
| 6406 | if (yymsg) |
| 6407 | yymsg_alloc = yyalloc; |
| 6408 | else |
| 6409 | { |
| 6410 | yymsg = yymsgbuf; |
| 6411 | yymsg_alloc = sizeof yymsgbuf; |
| 6412 | } |
| 6413 | } |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 6414 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6415 | if (0 < yysize && yysize <= yymsg_alloc) |
| 6416 | { |
| 6417 | (void) yysyntax_error (yymsg, yystate, yychar); |
| 6418 | yyerror (yymsg); |
| 6419 | } |
| 6420 | else |
| 6421 | { |
| 6422 | yyerror (YY_("syntax error")); |
| 6423 | if (yysize != 0) |
| 6424 | goto yyexhaustedlab; |
| 6425 | } |
| 6426 | } |
| 6427 | #endif |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6428 | } |
| 6429 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6430 | |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6431 | |
| 6432 | if (yyerrstatus == 3) |
| 6433 | { |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6434 | /* If just tried and failed to reuse look-ahead token after an |
| 6435 | error, discard it. */ |
Anton Korobeynikov | f52e608 | 2007-04-29 18:38:24 +0000 | [diff] [blame] | 6436 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6437 | if (yychar <= YYEOF) |
| 6438 | { |
| 6439 | /* Return failure if at end of input. */ |
| 6440 | if (yychar == YYEOF) |
| 6441 | YYABORT; |
| 6442 | } |
| 6443 | else |
| 6444 | { |
| 6445 | yydestruct ("Error: discarding", |
| 6446 | yytoken, &yylval); |
| 6447 | yychar = YYEMPTY; |
| 6448 | } |
| 6449 | } |
| 6450 | |
| 6451 | /* Else will try to reuse look-ahead token after shifting the error |
| 6452 | token. */ |
| 6453 | goto yyerrlab1; |
| 6454 | |
| 6455 | |
| 6456 | /*---------------------------------------------------. |
| 6457 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 6458 | `---------------------------------------------------*/ |
| 6459 | yyerrorlab: |
| 6460 | |
| 6461 | /* Pacify compilers like GCC when the user code never invokes |
| 6462 | YYERROR and the label yyerrorlab therefore never appears in user |
| 6463 | code. */ |
| 6464 | if (/*CONSTCOND*/ 0) |
| 6465 | goto yyerrorlab; |
| 6466 | |
| 6467 | /* Do not reclaim the symbols of the rule which action triggered |
| 6468 | this YYERROR. */ |
| 6469 | YYPOPSTACK (yylen); |
| 6470 | yylen = 0; |
| 6471 | YY_STACK_PRINT (yyss, yyssp); |
| 6472 | yystate = *yyssp; |
| 6473 | goto yyerrlab1; |
| 6474 | |
| 6475 | |
| 6476 | /*-------------------------------------------------------------. |
| 6477 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 6478 | `-------------------------------------------------------------*/ |
| 6479 | yyerrlab1: |
| 6480 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 6481 | |
| 6482 | for (;;) |
| 6483 | { |
| 6484 | yyn = yypact[yystate]; |
| 6485 | if (yyn != YYPACT_NINF) |
| 6486 | { |
| 6487 | yyn += YYTERROR; |
| 6488 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 6489 | { |
| 6490 | yyn = yytable[yyn]; |
| 6491 | if (0 < yyn) |
| 6492 | break; |
| 6493 | } |
| 6494 | } |
| 6495 | |
| 6496 | /* Pop the current state because it cannot handle the error token. */ |
| 6497 | if (yyssp == yyss) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6498 | YYABORT; |
| 6499 | |
Dale Johannesen | cdd509a | 2007-09-07 21:07:57 +0000 | [diff] [blame] | 6500 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6501 | yydestruct ("Error: popping", |
| 6502 | yystos[yystate], yyvsp); |
| 6503 | YYPOPSTACK (1); |
| 6504 | yystate = *yyssp; |
| 6505 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6506 | } |
| 6507 | |
| 6508 | if (yyn == YYFINAL) |
| 6509 | YYACCEPT; |
| 6510 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6511 | *++yyvsp = yylval; |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6512 | |
| 6513 | |
| 6514 | /* Shift the error token. */ |
| 6515 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
Reid Spencer | b8f8505 | 2007-07-31 03:50:36 +0000 | [diff] [blame] | 6516 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6517 | yystate = yyn; |
| 6518 | goto yynewstate; |
| 6519 | |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 6520 | |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6521 | /*-------------------------------------. |
| 6522 | | yyacceptlab -- YYACCEPT comes here. | |
| 6523 | `-------------------------------------*/ |
| 6524 | yyacceptlab: |
| 6525 | yyresult = 0; |
| 6526 | goto yyreturn; |
| 6527 | |
| 6528 | /*-----------------------------------. |
| 6529 | | yyabortlab -- YYABORT comes here. | |
| 6530 | `-----------------------------------*/ |
| 6531 | yyabortlab: |
| 6532 | yyresult = 1; |
| 6533 | goto yyreturn; |
| 6534 | |
| 6535 | #ifndef yyoverflow |
| 6536 | /*-------------------------------------------------. |
| 6537 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 6538 | `-------------------------------------------------*/ |
| 6539 | yyexhaustedlab: |
| 6540 | yyerror (YY_("memory exhausted")); |
| 6541 | yyresult = 2; |
| 6542 | /* Fall through. */ |
Anton Korobeynikov | b9b977d | 2007-11-14 09:53:48 +0000 | [diff] [blame] | 6543 | #endif |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6544 | |
| 6545 | yyreturn: |
| 6546 | if (yychar != YYEOF && yychar != YYEMPTY) |
| 6547 | yydestruct ("Cleanup: discarding lookahead", |
| 6548 | yytoken, &yylval); |
| 6549 | /* Do not reclaim the symbols of the rule which action triggered |
| 6550 | this YYABORT or YYACCEPT. */ |
| 6551 | YYPOPSTACK (yylen); |
| 6552 | YY_STACK_PRINT (yyss, yyssp); |
| 6553 | while (yyssp != yyss) |
| 6554 | { |
| 6555 | yydestruct ("Cleanup: popping", |
| 6556 | yystos[*yyssp], yyvsp); |
| 6557 | YYPOPSTACK (1); |
Christopher Lamb | a8ed9bf | 2007-12-11 09:02:08 +0000 | [diff] [blame] | 6558 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6559 | #ifndef yyoverflow |
| 6560 | if (yyss != yyssa) |
| 6561 | YYSTACK_FREE (yyss); |
| 6562 | #endif |
| 6563 | #if YYERROR_VERBOSE |
| 6564 | if (yymsg != yymsgbuf) |
| 6565 | YYSTACK_FREE (yymsg); |
| 6566 | #endif |
| 6567 | /* Make sure YYID is used. */ |
| 6568 | return YYID (yyresult); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6569 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6570 | |
| 6571 | |
| 6572 | #line 3146 "/Users/scottm/play/llvm-trunk/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6573 | |
| 6574 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6575 | // common code from the two 'RunVMAsmParser' functions |
| 6576 | static Module* RunParser(Module * M) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6577 | CurModule.CurrentModule = M; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6578 | // Check to make sure the parser succeeded |
| 6579 | if (yyparse()) { |
| 6580 | if (ParserResult) |
| 6581 | delete ParserResult; |
| 6582 | return 0; |
| 6583 | } |
| 6584 | |
Reid Spencer | 0d60b5a | 2007-03-30 01:37:39 +0000 | [diff] [blame] | 6585 | // Emit an error if there are any unresolved types left. |
| 6586 | if (!CurModule.LateResolveTypes.empty()) { |
| 6587 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
| 6588 | if (DID.Type == ValID::LocalName) { |
| 6589 | GenerateError("Undefined type remains at eof: '"+DID.getName() + "'"); |
| 6590 | } else { |
| 6591 | GenerateError("Undefined type remains at eof: #" + itostr(DID.Num)); |
| 6592 | } |
| 6593 | if (ParserResult) |
| 6594 | delete ParserResult; |
| 6595 | return 0; |
| 6596 | } |
| 6597 | |
| 6598 | // Emit an error if there are any unresolved values left. |
| 6599 | if (!CurModule.LateResolveValues.empty()) { |
| 6600 | Value *V = CurModule.LateResolveValues.back(); |
| 6601 | std::map<Value*, std::pair<ValID, int> >::iterator I = |
| 6602 | CurModule.PlaceHolderInfo.find(V); |
| 6603 | |
| 6604 | if (I != CurModule.PlaceHolderInfo.end()) { |
| 6605 | ValID &DID = I->second.first; |
| 6606 | if (DID.Type == ValID::LocalName) { |
| 6607 | GenerateError("Undefined value remains at eof: "+DID.getName() + "'"); |
| 6608 | } else { |
| 6609 | GenerateError("Undefined value remains at eof: #" + itostr(DID.Num)); |
| 6610 | } |
| 6611 | if (ParserResult) |
| 6612 | delete ParserResult; |
| 6613 | return 0; |
| 6614 | } |
| 6615 | } |
| 6616 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 6617 | // Check to make sure that parsing produced a result |
| 6618 | if (!ParserResult) |
| 6619 | return 0; |
| 6620 | |
| 6621 | // Reset ParserResult variable while saving its value for the result. |
| 6622 | Module *Result = ParserResult; |
| 6623 | ParserResult = 0; |
| 6624 | |
| 6625 | return Result; |
| 6626 | } |
| 6627 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6628 | void llvm::GenerateError(const std::string &message, int LineNo) { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6629 | if (LineNo == -1) LineNo = LLLgetLineNo(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6630 | // TODO: column number in exception |
| 6631 | if (TheParseError) |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6632 | TheParseError->setError(LLLgetFilename(), message, LineNo); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6633 | TriggerError = 1; |
| 6634 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6635 | |
| 6636 | int yyerror(const char *ErrorMsg) { |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6637 | std::string where = LLLgetFilename() + ":" + utostr(LLLgetLineNo()) + ": "; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 6638 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
Duncan Sands | dc02467 | 2007-11-27 13:23:08 +0000 | [diff] [blame] | 6639 | if (yychar != YYEMPTY && yychar != 0) { |
| 6640 | errMsg += " while reading token: '"; |
| 6641 | errMsg += std::string(LLLgetTokenStart(), |
| 6642 | LLLgetTokenStart()+LLLgetTokenLength()) + "'"; |
| 6643 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 6644 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 6645 | return 0; |
| 6646 | } |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame^] | 6647 | |