Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 1 | /* A Bison parser, made by GNU Bison 2.1. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3 | /* Skeleton parser for Yacc-like parsing with Bison, |
| 4 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 5 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2, or (at your option) |
| 9 | any later version. |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 10 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 | Boston, MA 02110-1301, USA. */ |
| 20 | |
| 21 | /* As a special exception, when this file is copied by Bison into a |
| 22 | Bison output file, you may use that output file without restriction. |
| 23 | This special exception was added by the Free Software Foundation |
| 24 | in version 1.24 of Bison. */ |
| 25 | |
| 26 | /* Written by Richard Stallman by simplifying the original so called |
| 27 | ``semantic'' parser. */ |
| 28 | |
| 29 | /* All symbols defined below should begin with yy or YY, to avoid |
| 30 | infringing on user name space. This should be done even for local |
| 31 | variables, as they might otherwise be expanded by user macros. |
| 32 | There are some unavoidable exceptions within include files to |
| 33 | define necessary library symbols; they are noted "INFRINGES ON |
| 34 | USER NAME SPACE" below. */ |
| 35 | |
| 36 | /* Identify Bison output. */ |
| 37 | #define YYBISON 1 |
| 38 | |
| 39 | /* Bison version. */ |
| 40 | #define YYBISON_VERSION "2.1" |
| 41 | |
| 42 | /* Skeleton name. */ |
| 43 | #define YYSKELETON_NAME "yacc.c" |
| 44 | |
| 45 | /* Pure parsers. */ |
| 46 | #define YYPURE 0 |
| 47 | |
| 48 | /* Using locations. */ |
| 49 | #define YYLSP_NEEDED 0 |
| 50 | |
| 51 | /* Substitute the variable and function names. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 52 | #define yyparse llvmAsmparse |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 53 | #define yylex llvmAsmlex |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 54 | #define yyerror llvmAsmerror |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 55 | #define yylval llvmAsmlval |
| 56 | #define yychar llvmAsmchar |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 57 | #define yydebug llvmAsmdebug |
| 58 | #define yynerrs llvmAsmnerrs |
| 59 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 60 | |
| 61 | /* Tokens. */ |
| 62 | #ifndef YYTOKENTYPE |
| 63 | # define YYTOKENTYPE |
| 64 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
| 65 | know about them. */ |
| 66 | enum yytokentype { |
| 67 | ESINT64VAL = 258, |
| 68 | EUINT64VAL = 259, |
| 69 | LOCALVAL_ID = 260, |
| 70 | GLOBALVAL_ID = 261, |
| 71 | FPVAL = 262, |
| 72 | VOID = 263, |
| 73 | INTTYPE = 264, |
| 74 | FLOAT = 265, |
| 75 | DOUBLE = 266, |
| 76 | LABEL = 267, |
| 77 | TYPE = 268, |
| 78 | LOCALVAR = 269, |
| 79 | GLOBALVAR = 270, |
| 80 | LABELSTR = 271, |
| 81 | STRINGCONSTANT = 272, |
| 82 | ATSTRINGCONSTANT = 273, |
| 83 | IMPLEMENTATION = 274, |
| 84 | ZEROINITIALIZER = 275, |
| 85 | TRUETOK = 276, |
| 86 | FALSETOK = 277, |
| 87 | BEGINTOK = 278, |
| 88 | ENDTOK = 279, |
| 89 | DECLARE = 280, |
| 90 | DEFINE = 281, |
| 91 | GLOBAL = 282, |
| 92 | CONSTANT = 283, |
| 93 | SECTION = 284, |
| 94 | VOLATILE = 285, |
| 95 | TO = 286, |
| 96 | DOTDOTDOT = 287, |
| 97 | NULL_TOK = 288, |
| 98 | UNDEF = 289, |
| 99 | INTERNAL = 290, |
| 100 | LINKONCE = 291, |
| 101 | WEAK = 292, |
| 102 | APPENDING = 293, |
| 103 | DLLIMPORT = 294, |
| 104 | DLLEXPORT = 295, |
| 105 | EXTERN_WEAK = 296, |
| 106 | OPAQUE = 297, |
| 107 | EXTERNAL = 298, |
| 108 | TARGET = 299, |
| 109 | TRIPLE = 300, |
| 110 | ALIGN = 301, |
| 111 | DEPLIBS = 302, |
| 112 | CALL = 303, |
| 113 | TAIL = 304, |
| 114 | ASM_TOK = 305, |
| 115 | MODULE = 306, |
| 116 | SIDEEFFECT = 307, |
| 117 | CC_TOK = 308, |
| 118 | CCC_TOK = 309, |
| 119 | FASTCC_TOK = 310, |
| 120 | COLDCC_TOK = 311, |
| 121 | X86_STDCALLCC_TOK = 312, |
| 122 | X86_FASTCALLCC_TOK = 313, |
| 123 | DATALAYOUT = 314, |
| 124 | RET = 315, |
| 125 | BR = 316, |
| 126 | SWITCH = 317, |
| 127 | INVOKE = 318, |
| 128 | UNWIND = 319, |
| 129 | UNREACHABLE = 320, |
| 130 | ADD = 321, |
| 131 | SUB = 322, |
| 132 | MUL = 323, |
| 133 | UDIV = 324, |
| 134 | SDIV = 325, |
| 135 | FDIV = 326, |
| 136 | UREM = 327, |
| 137 | SREM = 328, |
| 138 | FREM = 329, |
| 139 | AND = 330, |
| 140 | OR = 331, |
| 141 | XOR = 332, |
| 142 | SHL = 333, |
| 143 | LSHR = 334, |
| 144 | ASHR = 335, |
| 145 | ICMP = 336, |
| 146 | FCMP = 337, |
| 147 | EQ = 338, |
| 148 | NE = 339, |
| 149 | SLT = 340, |
| 150 | SGT = 341, |
| 151 | SLE = 342, |
| 152 | SGE = 343, |
| 153 | ULT = 344, |
| 154 | UGT = 345, |
| 155 | ULE = 346, |
| 156 | UGE = 347, |
| 157 | OEQ = 348, |
| 158 | ONE = 349, |
| 159 | OLT = 350, |
| 160 | OGT = 351, |
| 161 | OLE = 352, |
| 162 | OGE = 353, |
| 163 | ORD = 354, |
| 164 | UNO = 355, |
| 165 | UEQ = 356, |
| 166 | UNE = 357, |
| 167 | MALLOC = 358, |
| 168 | ALLOCA = 359, |
| 169 | FREE = 360, |
| 170 | LOAD = 361, |
| 171 | STORE = 362, |
| 172 | GETELEMENTPTR = 363, |
| 173 | TRUNC = 364, |
| 174 | ZEXT = 365, |
| 175 | SEXT = 366, |
| 176 | FPTRUNC = 367, |
| 177 | FPEXT = 368, |
| 178 | BITCAST = 369, |
| 179 | UITOFP = 370, |
| 180 | SITOFP = 371, |
| 181 | FPTOUI = 372, |
| 182 | FPTOSI = 373, |
| 183 | INTTOPTR = 374, |
| 184 | PTRTOINT = 375, |
| 185 | PHI_TOK = 376, |
| 186 | SELECT = 377, |
| 187 | VAARG = 378, |
| 188 | EXTRACTELEMENT = 379, |
| 189 | INSERTELEMENT = 380, |
| 190 | SHUFFLEVECTOR = 381, |
| 191 | NORETURN = 382, |
| 192 | INREG = 383, |
| 193 | SRET = 384, |
| 194 | DEFAULT = 385, |
| 195 | HIDDEN = 386 |
| 196 | }; |
| 197 | #endif |
| 198 | /* Tokens. */ |
| 199 | #define ESINT64VAL 258 |
| 200 | #define EUINT64VAL 259 |
| 201 | #define LOCALVAL_ID 260 |
| 202 | #define GLOBALVAL_ID 261 |
| 203 | #define FPVAL 262 |
| 204 | #define VOID 263 |
| 205 | #define INTTYPE 264 |
| 206 | #define FLOAT 265 |
| 207 | #define DOUBLE 266 |
| 208 | #define LABEL 267 |
| 209 | #define TYPE 268 |
| 210 | #define LOCALVAR 269 |
| 211 | #define GLOBALVAR 270 |
| 212 | #define LABELSTR 271 |
| 213 | #define STRINGCONSTANT 272 |
| 214 | #define ATSTRINGCONSTANT 273 |
| 215 | #define IMPLEMENTATION 274 |
| 216 | #define ZEROINITIALIZER 275 |
| 217 | #define TRUETOK 276 |
| 218 | #define FALSETOK 277 |
| 219 | #define BEGINTOK 278 |
| 220 | #define ENDTOK 279 |
| 221 | #define DECLARE 280 |
| 222 | #define DEFINE 281 |
| 223 | #define GLOBAL 282 |
| 224 | #define CONSTANT 283 |
| 225 | #define SECTION 284 |
| 226 | #define VOLATILE 285 |
| 227 | #define TO 286 |
| 228 | #define DOTDOTDOT 287 |
| 229 | #define NULL_TOK 288 |
| 230 | #define UNDEF 289 |
| 231 | #define INTERNAL 290 |
| 232 | #define LINKONCE 291 |
| 233 | #define WEAK 292 |
| 234 | #define APPENDING 293 |
| 235 | #define DLLIMPORT 294 |
| 236 | #define DLLEXPORT 295 |
| 237 | #define EXTERN_WEAK 296 |
| 238 | #define OPAQUE 297 |
| 239 | #define EXTERNAL 298 |
| 240 | #define TARGET 299 |
| 241 | #define TRIPLE 300 |
| 242 | #define ALIGN 301 |
| 243 | #define DEPLIBS 302 |
| 244 | #define CALL 303 |
| 245 | #define TAIL 304 |
| 246 | #define ASM_TOK 305 |
| 247 | #define MODULE 306 |
| 248 | #define SIDEEFFECT 307 |
| 249 | #define CC_TOK 308 |
| 250 | #define CCC_TOK 309 |
| 251 | #define FASTCC_TOK 310 |
| 252 | #define COLDCC_TOK 311 |
| 253 | #define X86_STDCALLCC_TOK 312 |
| 254 | #define X86_FASTCALLCC_TOK 313 |
| 255 | #define DATALAYOUT 314 |
| 256 | #define RET 315 |
| 257 | #define BR 316 |
| 258 | #define SWITCH 317 |
| 259 | #define INVOKE 318 |
| 260 | #define UNWIND 319 |
| 261 | #define UNREACHABLE 320 |
| 262 | #define ADD 321 |
| 263 | #define SUB 322 |
| 264 | #define MUL 323 |
| 265 | #define UDIV 324 |
| 266 | #define SDIV 325 |
| 267 | #define FDIV 326 |
| 268 | #define UREM 327 |
| 269 | #define SREM 328 |
| 270 | #define FREM 329 |
| 271 | #define AND 330 |
| 272 | #define OR 331 |
| 273 | #define XOR 332 |
| 274 | #define SHL 333 |
| 275 | #define LSHR 334 |
| 276 | #define ASHR 335 |
| 277 | #define ICMP 336 |
| 278 | #define FCMP 337 |
| 279 | #define EQ 338 |
| 280 | #define NE 339 |
| 281 | #define SLT 340 |
| 282 | #define SGT 341 |
| 283 | #define SLE 342 |
| 284 | #define SGE 343 |
| 285 | #define ULT 344 |
| 286 | #define UGT 345 |
| 287 | #define ULE 346 |
| 288 | #define UGE 347 |
| 289 | #define OEQ 348 |
| 290 | #define ONE 349 |
| 291 | #define OLT 350 |
| 292 | #define OGT 351 |
| 293 | #define OLE 352 |
| 294 | #define OGE 353 |
| 295 | #define ORD 354 |
| 296 | #define UNO 355 |
| 297 | #define UEQ 356 |
| 298 | #define UNE 357 |
| 299 | #define MALLOC 358 |
| 300 | #define ALLOCA 359 |
| 301 | #define FREE 360 |
| 302 | #define LOAD 361 |
| 303 | #define STORE 362 |
| 304 | #define GETELEMENTPTR 363 |
| 305 | #define TRUNC 364 |
| 306 | #define ZEXT 365 |
| 307 | #define SEXT 366 |
| 308 | #define FPTRUNC 367 |
| 309 | #define FPEXT 368 |
| 310 | #define BITCAST 369 |
| 311 | #define UITOFP 370 |
| 312 | #define SITOFP 371 |
| 313 | #define FPTOUI 372 |
| 314 | #define FPTOSI 373 |
| 315 | #define INTTOPTR 374 |
| 316 | #define PTRTOINT 375 |
| 317 | #define PHI_TOK 376 |
| 318 | #define SELECT 377 |
| 319 | #define VAARG 378 |
| 320 | #define EXTRACTELEMENT 379 |
| 321 | #define INSERTELEMENT 380 |
| 322 | #define SHUFFLEVECTOR 381 |
| 323 | #define NORETURN 382 |
| 324 | #define INREG 383 |
| 325 | #define SRET 384 |
| 326 | #define DEFAULT 385 |
| 327 | #define HIDDEN 386 |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | /* Copy the first part of user declarations. */ |
| 333 | #line 14 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 334 | |
| 335 | #include "ParserInternals.h" |
| 336 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 337 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 338 | #include "llvm/Instructions.h" |
| 339 | #include "llvm/Module.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 340 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 341 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 342 | #include "llvm/Support/CommandLine.h" |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 343 | #include "llvm/ADT/SmallVector.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 344 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 345 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 481169e | 2006-12-01 00:33:46 +0000 | [diff] [blame] | 346 | #include "llvm/Support/Streams.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 347 | #include <algorithm> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 348 | #include <list> |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 349 | #include <map> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 350 | #include <utility> |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 351 | #ifndef NDEBUG |
| 352 | #define YYDEBUG 1 |
| 353 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 354 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 355 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 356 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 357 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 358 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 359 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 360 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 361 | // GenerateError are made from inside productions and they must simulate the |
| 362 | // previous exception behavior by exiting the production immediately. We have |
| 363 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 364 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 365 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 366 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 367 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 368 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 369 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 370 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 371 | int yylex(); // declaration" of xxx warnings. |
| 372 | int yyparse(); |
| 373 | |
| 374 | namespace llvm { |
| 375 | std::string CurFilename; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 376 | #if YYDEBUG |
| 377 | static cl::opt<bool> |
| 378 | Debug("debug-yacc", cl::desc("Print yacc debug state changes"), |
| 379 | cl::Hidden, cl::init(false)); |
| 380 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 381 | } |
| 382 | using namespace llvm; |
| 383 | |
| 384 | static Module *ParserResult; |
| 385 | |
| 386 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 387 | // relating to upreferences in the input stream. |
| 388 | // |
| 389 | //#define DEBUG_UPREFS 1 |
| 390 | #ifdef DEBUG_UPREFS |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 391 | #define UR_OUT(X) cerr << X |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 392 | #else |
| 393 | #define UR_OUT(X) |
| 394 | #endif |
| 395 | |
| 396 | #define YYERROR_VERBOSE 1 |
| 397 | |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 398 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 399 | |
| 400 | |
| 401 | // This contains info used when building the body of a function. It is |
| 402 | // destroyed when the function is completed. |
| 403 | // |
| 404 | typedef std::vector<Value *> ValueList; // Numbered defs |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 405 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 406 | static void |
| 407 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 408 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 409 | |
| 410 | static struct PerModuleInfo { |
| 411 | Module *CurrentModule; |
| 412 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 413 | std::map<const Type *,ValueList> LateResolveValues; |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 414 | std::vector<PATypeHolder> Types; |
| 415 | std::map<ValID, PATypeHolder> LateResolveTypes; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 416 | |
| 417 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 418 | /// 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] | 419 | /// that we can resolve them later and print error messages as appropriate. |
| 420 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 421 | |
| 422 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 423 | // references to global values. Global values may be referenced before they |
| 424 | // are defined, and if so, the temporary object that they represent is held |
| 425 | // here. This is used for forward references of GlobalValues. |
| 426 | // |
| 427 | typedef std::map<std::pair<const PointerType *, |
| 428 | ValID>, GlobalValue*> GlobalRefsType; |
| 429 | GlobalRefsType GlobalRefs; |
| 430 | |
| 431 | void ModuleDone() { |
| 432 | // If we could not resolve some functions at function compilation time |
| 433 | // (calls to functions before they are defined), resolve them now... Types |
| 434 | // are resolved when the constant pool has been completely parsed. |
| 435 | // |
| 436 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 437 | if (TriggerError) |
| 438 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 439 | |
| 440 | // Check to make sure that all global value forward references have been |
| 441 | // resolved! |
| 442 | // |
| 443 | if (!GlobalRefs.empty()) { |
| 444 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 445 | |
| 446 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 447 | I != E; ++I) { |
| 448 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 449 | I->first.second.getName() + "\n"; |
| 450 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 451 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 452 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | Values.clear(); // Clear out function local definitions |
| 456 | Types.clear(); |
| 457 | CurrentModule = 0; |
| 458 | } |
| 459 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 460 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 461 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 462 | // If not, just return null. |
| 463 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 464 | // Check to see if there is a forward reference to this global variable... |
| 465 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 466 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 467 | GlobalValue *Ret = 0; |
| 468 | if (I != GlobalRefs.end()) { |
| 469 | Ret = I->second; |
| 470 | GlobalRefs.erase(I); |
| 471 | } |
| 472 | return Ret; |
| 473 | } |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 474 | |
| 475 | bool TypeIsUnresolved(PATypeHolder* PATy) { |
| 476 | // If it isn't abstract, its resolved |
| 477 | const Type* Ty = PATy->get(); |
| 478 | if (!Ty->isAbstract()) |
| 479 | return false; |
| 480 | // Traverse the type looking for abstract types. If it isn't abstract then |
| 481 | // we don't need to traverse that leg of the type. |
| 482 | std::vector<const Type*> WorkList, SeenList; |
| 483 | WorkList.push_back(Ty); |
| 484 | while (!WorkList.empty()) { |
| 485 | const Type* Ty = WorkList.back(); |
| 486 | SeenList.push_back(Ty); |
| 487 | WorkList.pop_back(); |
| 488 | if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) { |
| 489 | // Check to see if this is an unresolved type |
| 490 | std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin(); |
| 491 | std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end(); |
| 492 | for ( ; I != E; ++I) { |
| 493 | if (I->second.get() == OpTy) |
| 494 | return true; |
| 495 | } |
| 496 | } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) { |
| 497 | const Type* TheTy = SeqTy->getElementType(); |
| 498 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 499 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 500 | E = SeenList.end(); |
| 501 | for ( ; I != E; ++I) |
| 502 | if (*I == TheTy) |
| 503 | break; |
| 504 | if (I == E) |
| 505 | WorkList.push_back(TheTy); |
| 506 | } |
| 507 | } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) { |
| 508 | for (unsigned i = 0; i < StrTy->getNumElements(); ++i) { |
| 509 | const Type* TheTy = StrTy->getElementType(i); |
| 510 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 511 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 512 | E = SeenList.end(); |
| 513 | for ( ; I != E; ++I) |
| 514 | if (*I == TheTy) |
| 515 | break; |
| 516 | if (I == E) |
| 517 | WorkList.push_back(TheTy); |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | } |
| 522 | return false; |
| 523 | } |
| 524 | |
| 525 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 526 | } CurModule; |
| 527 | |
| 528 | static struct PerFunctionInfo { |
| 529 | Function *CurrentFunction; // Pointer to current function being created |
| 530 | |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 531 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 532 | std::map<const Type*, ValueList> LateResolveValues; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 533 | bool isDeclare; // Is this function a forward declararation? |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 534 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 535 | GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 536 | |
| 537 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 538 | /// track of them here. |
| 539 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 540 | std::vector<BasicBlock*> NumberedBlocks; |
| 541 | unsigned NextBBNum; |
| 542 | |
| 543 | inline PerFunctionInfo() { |
| 544 | CurrentFunction = 0; |
| 545 | isDeclare = false; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 546 | Linkage = GlobalValue::ExternalLinkage; |
| 547 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | inline void FunctionStart(Function *M) { |
| 551 | CurrentFunction = M; |
| 552 | NextBBNum = 0; |
| 553 | } |
| 554 | |
| 555 | void FunctionDone() { |
| 556 | NumberedBlocks.clear(); |
| 557 | |
| 558 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 559 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 560 | GenerateError("Undefined reference to label " + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 561 | BBForwardRefs.begin()->first->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 562 | return; |
| 563 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 564 | |
| 565 | // Resolve all forward references now. |
| 566 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 567 | |
| 568 | Values.clear(); // Clear out function local definitions |
| 569 | CurrentFunction = 0; |
| 570 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 571 | Linkage = GlobalValue::ExternalLinkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 572 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 573 | } |
| 574 | } CurFun; // Info for the current function... |
| 575 | |
| 576 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 577 | |
| 578 | |
| 579 | //===----------------------------------------------------------------------===// |
| 580 | // Code to handle definitions of all the types |
| 581 | //===----------------------------------------------------------------------===// |
| 582 | |
| 583 | static int InsertValue(Value *V, |
| 584 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 585 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 586 | |
| 587 | // Yes, insert the value into the value table... |
| 588 | ValueList &List = ValueTab[V->getType()]; |
| 589 | List.push_back(V); |
| 590 | return List.size()-1; |
| 591 | } |
| 592 | |
| 593 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 594 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 595 | case ValID::LocalID: // Is it a numbered definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 596 | // Module constants occupy the lowest numbered slots... |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 597 | if (D.Num < CurModule.Types.size()) |
| 598 | return CurModule.Types[D.Num]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 599 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 600 | case ValID::LocalName: // Is it a named definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 601 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 602 | D.destroy(); // Free old strdup'd memory... |
| 603 | return N; |
| 604 | } |
| 605 | break; |
| 606 | default: |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 607 | GenerateError("Internal parser error: Invalid symbol type reference"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 608 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | // If we reached here, we referenced either a symbol that we don't know about |
| 612 | // or an id number that hasn't been read yet. We may be referencing something |
| 613 | // forward, so just create an entry to be resolved later and get to it... |
| 614 | // |
| 615 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 616 | |
| 617 | |
| 618 | if (inFunctionScope()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 619 | if (D.Type == ValID::LocalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 620 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 621 | return 0; |
| 622 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 623 | GenerateError("Reference to an undefined type: #" + utostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 624 | return 0; |
| 625 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 626 | } |
| 627 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 628 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 629 | if (I != CurModule.LateResolveTypes.end()) |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 630 | return I->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 631 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 632 | Type *Typ = OpaqueType::get(); |
| 633 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 634 | return Typ; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 635 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 636 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 637 | // getValNonImprovising - Look up the value specified by the provided type and |
| 638 | // the provided ValID. If the value exists and has already been defined, return |
| 639 | // it. Otherwise return null. |
| 640 | // |
| 641 | static Value *getValNonImprovising(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 642 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 643 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 644 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 645 | return 0; |
| 646 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 647 | |
| 648 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 649 | case ValID::LocalID: { // Is it a numbered definition? |
| 650 | // Module constants occupy the lowest numbered slots. |
| 651 | std::map<const Type*,ValueList>::iterator VI = CurFun.Values.find(Ty); |
| 652 | // Make sure that our type is within bounds. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 653 | if (VI == CurFun.Values.end()) return 0; |
| 654 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 655 | // Check that the number is within bounds. |
| 656 | if (D.Num >= VI->second.size()) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 657 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 658 | return VI->second[D.Num]; |
| 659 | } |
| 660 | case ValID::GlobalID: { // Is it a numbered definition? |
| 661 | unsigned Num = D.Num; |
| 662 | |
| 663 | // Module constants occupy the lowest numbered slots... |
| 664 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 665 | if (VI == CurModule.Values.end()) |
| 666 | return 0; |
| 667 | if (D.Num >= VI->second.size()) |
| 668 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 669 | return VI->second[Num]; |
| 670 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 671 | |
| 672 | case ValID::LocalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 673 | if (!inFunctionScope()) |
| 674 | return 0; |
| 675 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
| 676 | Value *N = SymTab.lookup(D.Name); |
| 677 | if (N == 0) |
| 678 | return 0; |
| 679 | if (N->getType() != Ty) |
| 680 | return 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 681 | |
| 682 | D.destroy(); // Free old strdup'd memory... |
| 683 | return N; |
| 684 | } |
| 685 | case ValID::GlobalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 686 | ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable(); |
| 687 | Value *N = SymTab.lookup(D.Name); |
| 688 | if (N == 0) |
| 689 | return 0; |
| 690 | if (N->getType() != Ty) |
| 691 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 692 | |
| 693 | D.destroy(); // Free old strdup'd memory... |
| 694 | return N; |
| 695 | } |
| 696 | |
| 697 | // Check to make sure that "Ty" is an integral type, and that our |
| 698 | // value will fit into the specified type... |
| 699 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 700 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 701 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 702 | itostr(D.ConstPool64) + "' is invalid for type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 703 | Ty->getDescription() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 704 | return 0; |
| 705 | } |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 706 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 707 | |
| 708 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 709 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 710 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 711 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 712 | "' is invalid or out of range"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 713 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 714 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 715 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 716 | } |
| 717 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 718 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 722 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 723 | GenerateError("FP constant invalid for type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 724 | return 0; |
| 725 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 726 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 727 | |
| 728 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 729 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 730 | GenerateError("Cannot create a a non pointer null"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 731 | return 0; |
| 732 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 733 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 734 | |
| 735 | case ValID::ConstUndefVal: // Is it an undef value? |
| 736 | return UndefValue::get(Ty); |
| 737 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 738 | case ValID::ConstZeroVal: // Is it a zero value? |
| 739 | return Constant::getNullValue(Ty); |
| 740 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 741 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 742 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 743 | GenerateError("Constant expression type different from required type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 744 | return 0; |
| 745 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 746 | return D.ConstantValue; |
| 747 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 748 | case ValID::InlineAsmVal: { // Inline asm expression |
| 749 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 750 | const FunctionType *FTy = |
| 751 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 752 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 753 | GenerateError("Invalid type for asm constraint string"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 754 | return 0; |
| 755 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 756 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 757 | D.IAD->HasSideEffects); |
| 758 | D.destroy(); // Free InlineAsmDescriptor. |
| 759 | return IA; |
| 760 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 761 | default: |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 762 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 763 | return 0; |
| 764 | } // End of switch |
| 765 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 766 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 767 | return 0; |
| 768 | } |
| 769 | |
| 770 | // getVal - This function is identical to getValNonImprovising, except that if a |
| 771 | // value is not already defined, it "improvises" by creating a placeholder var |
| 772 | // that looks and acts just like the requested variable. When the value is |
| 773 | // defined later, all uses of the placeholder variable are replaced with the |
| 774 | // real thing. |
| 775 | // |
| 776 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 777 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 778 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 779 | return 0; |
| 780 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 781 | |
| 782 | // See if the value has already been defined. |
| 783 | Value *V = getValNonImprovising(Ty, ID); |
| 784 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 785 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 786 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 787 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 788 | GenerateError("Invalid use of a composite type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 789 | return 0; |
| 790 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 791 | |
| 792 | // If we reached here, we referenced either a symbol that we don't know about |
| 793 | // or an id number that hasn't been read yet. We may be referencing something |
| 794 | // forward, so just create an entry to be resolved later and get to it... |
| 795 | // |
| 796 | V = new Argument(Ty); |
| 797 | |
| 798 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 799 | // to recycle these things?? |
| 800 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 801 | llvmAsmlineno))); |
| 802 | |
| 803 | if (inFunctionScope()) |
| 804 | InsertValue(V, CurFun.LateResolveValues); |
| 805 | else |
| 806 | InsertValue(V, CurModule.LateResolveValues); |
| 807 | return V; |
| 808 | } |
| 809 | |
| 810 | /// getBBVal - This is used for two purposes: |
| 811 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 812 | /// defined. |
| 813 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 814 | /// or may not be a forward reference. |
| 815 | /// |
| 816 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 817 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 818 | |
| 819 | std::string Name; |
| 820 | BasicBlock *BB = 0; |
| 821 | switch (ID.Type) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 822 | default: |
| 823 | GenerateError("Illegal label reference " + ID.getName()); |
| 824 | return 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 825 | case ValID::LocalID: // Is it a numbered definition? |
| 826 | if (ID.Num >= CurFun.NumberedBlocks.size()) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 827 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 828 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 829 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 830 | case ValID::LocalName: // Is it a named definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 831 | Name = ID.Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 832 | Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name); |
| 833 | if (N && N->getType()->getTypeID() == Type::LabelTyID) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 834 | BB = cast<BasicBlock>(N); |
| 835 | break; |
| 836 | } |
| 837 | |
| 838 | // See if the block has already been defined. |
| 839 | if (BB) { |
| 840 | // If this is the definition of the block, make sure the existing value was |
| 841 | // just a forward reference. If it was a forward reference, there will be |
| 842 | // an entry for it in the PlaceHolderInfo map. |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 843 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 844 | // The existing value was a definition, not a forward reference. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 845 | GenerateError("Redefinition of label " + ID.getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 846 | return 0; |
| 847 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 848 | |
| 849 | ID.destroy(); // Free strdup'd memory. |
| 850 | return BB; |
| 851 | } |
| 852 | |
| 853 | // Otherwise this block has not been seen before. |
| 854 | BB = new BasicBlock("", CurFun.CurrentFunction); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 855 | if (ID.Type == ValID::LocalName) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 856 | BB->setName(ID.Name); |
| 857 | } else { |
| 858 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 859 | } |
| 860 | |
| 861 | // If this is not a definition, keep track of it so we can use it as a forward |
| 862 | // reference. |
| 863 | if (!isDefinition) { |
| 864 | // Remember where this forward reference came from. |
| 865 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno); |
| 866 | } else { |
| 867 | // The forward declaration could have been inserted anywhere in the |
| 868 | // function: insert it into the correct place now. |
| 869 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 870 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 871 | } |
| 872 | ID.destroy(); |
| 873 | return BB; |
| 874 | } |
| 875 | |
| 876 | |
| 877 | //===----------------------------------------------------------------------===// |
| 878 | // Code to handle forward references in instructions |
| 879 | //===----------------------------------------------------------------------===// |
| 880 | // |
| 881 | // This code handles the late binding needed with statements that reference |
| 882 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 883 | // a loop body. |
| 884 | // |
| 885 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 886 | // and back patchs after we are done. |
| 887 | // |
| 888 | |
| 889 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 890 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 891 | // defs now... |
| 892 | // |
| 893 | static void |
| 894 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 895 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
| 896 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 897 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 898 | E = LateResolvers.end(); LRI != E; ++LRI) { |
| 899 | ValueList &List = LRI->second; |
| 900 | while (!List.empty()) { |
| 901 | Value *V = List.back(); |
| 902 | List.pop_back(); |
| 903 | |
| 904 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 905 | CurModule.PlaceHolderInfo.find(V); |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 906 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 907 | |
| 908 | ValID &DID = PHI->second.first; |
| 909 | |
| 910 | Value *TheRealValue = getValNonImprovising(LRI->first, DID); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 911 | if (TriggerError) |
| 912 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 913 | if (TheRealValue) { |
| 914 | V->replaceAllUsesWith(TheRealValue); |
| 915 | delete V; |
| 916 | CurModule.PlaceHolderInfo.erase(PHI); |
| 917 | } else if (FutureLateResolvers) { |
| 918 | // Functions have their unresolved items forwarded to the module late |
| 919 | // resolver table |
| 920 | InsertValue(V, *FutureLateResolvers); |
| 921 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 922 | if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 923 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 924 | "' of type '" + V->getType()->getDescription() + "'", |
| 925 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 926 | return; |
| 927 | } else { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 928 | GenerateError("Reference to an invalid definition: #" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 929 | itostr(DID.Num) + " of type '" + |
| 930 | V->getType()->getDescription() + "'", |
| 931 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 932 | return; |
| 933 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 934 | } |
| 935 | } |
| 936 | } |
| 937 | |
| 938 | LateResolvers.clear(); |
| 939 | } |
| 940 | |
| 941 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 942 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 943 | // refering to the number can be resolved. Do this now. |
| 944 | // |
| 945 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 946 | ValID D; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 947 | if (Name) D = ValID::createLocalName(Name); |
| 948 | else D = ValID::createLocalID(CurModule.Types.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 949 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 950 | std::map<ValID, PATypeHolder>::iterator I = |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 951 | CurModule.LateResolveTypes.find(D); |
| 952 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 953 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 954 | CurModule.LateResolveTypes.erase(I); |
| 955 | } |
| 956 | } |
| 957 | |
| 958 | // setValueName - Set the specified value to the name given. The name may be |
| 959 | // null potentially, in which case this is a noop. The string passed in is |
| 960 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 961 | // |
| 962 | static void setValueName(Value *V, char *NameStr) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 963 | if (!NameStr) return; |
| 964 | std::string Name(NameStr); // Copy string |
| 965 | free(NameStr); // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 966 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 967 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 968 | GenerateError("Can't assign name '" + Name+"' to value with void type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 969 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 970 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 971 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 972 | assert(inFunctionScope() && "Must be in function scope!"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 973 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 974 | if (ST.lookup(Name)) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 975 | GenerateError("Redefinition of value '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 976 | V->getType()->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 977 | return; |
| 978 | } |
| 979 | |
| 980 | // Set the name. |
| 981 | V->setName(Name); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 982 | } |
| 983 | |
| 984 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 985 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 986 | static GlobalVariable * |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 987 | ParseGlobalVariable(char *NameStr, |
| 988 | GlobalValue::LinkageTypes Linkage, |
| 989 | GlobalValue::VisibilityTypes Visibility, |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 990 | bool isConstantGlobal, const Type *Ty, |
| 991 | Constant *Initializer) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 992 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 993 | GenerateError("Cannot declare global vars of function type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 994 | return 0; |
| 995 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 996 | |
| 997 | const PointerType *PTy = PointerType::get(Ty); |
| 998 | |
| 999 | std::string Name; |
| 1000 | if (NameStr) { |
| 1001 | Name = NameStr; // Copy string |
| 1002 | free(NameStr); // Free old string |
| 1003 | } |
| 1004 | |
| 1005 | // See if this global value was forward referenced. If so, recycle the |
| 1006 | // object. |
| 1007 | ValID ID; |
| 1008 | if (!Name.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1009 | ID = ValID::createGlobalName((char*)Name.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1010 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1011 | ID = ValID::createGlobalID(CurModule.Values[PTy].size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 1015 | // Move the global to the end of the list, from whereever it was |
| 1016 | // previously inserted. |
| 1017 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 1018 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 1019 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 1020 | GV->setInitializer(Initializer); |
| 1021 | GV->setLinkage(Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1022 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1023 | GV->setConstant(isConstantGlobal); |
| 1024 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1025 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1026 | } |
| 1027 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 1028 | // If this global has a name |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1029 | if (!Name.empty()) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 1030 | // if the global we're parsing has an initializer (is a definition) and |
| 1031 | // has external linkage. |
| 1032 | if (Initializer && Linkage != GlobalValue::InternalLinkage) |
| 1033 | // If there is already a global with external linkage with this name |
| 1034 | if (CurModule.CurrentModule->getGlobalVariable(Name, false)) { |
| 1035 | // If we allow this GVar to get created, it will be renamed in the |
| 1036 | // symbol table because it conflicts with an existing GVar. We can't |
| 1037 | // allow redefinition of GVars whose linking indicates that their name |
| 1038 | // must stay the same. Issue the error. |
| 1039 | GenerateError("Redefinition of global variable named '" + Name + |
| 1040 | "' of type '" + Ty->getDescription() + "'"); |
| 1041 | return 0; |
| 1042 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1043 | } |
| 1044 | |
| 1045 | // Otherwise there is no existing GV to use, create one now. |
| 1046 | GlobalVariable *GV = |
| 1047 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 1048 | CurModule.CurrentModule); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1049 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1050 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1051 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1052 | } |
| 1053 | |
| 1054 | // setTypeName - Set the specified type to the name given. The name may be |
| 1055 | // null potentially, in which case this is a noop. The string passed in is |
| 1056 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 1057 | // |
| 1058 | // This function returns true if the type has already been defined, but is |
| 1059 | // allowed to be redefined in the specified context. If the name is a new name |
| 1060 | // for the type plane, it is inserted and false is returned. |
| 1061 | static bool setTypeName(const Type *T, char *NameStr) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 1062 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1063 | if (NameStr == 0) return false; |
| 1064 | |
| 1065 | std::string Name(NameStr); // Copy string |
| 1066 | free(NameStr); // Free old string |
| 1067 | |
| 1068 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1069 | if (T == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1070 | GenerateError("Can't assign name '" + Name + "' to the void type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1071 | return false; |
| 1072 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1073 | |
| 1074 | // Set the type name, checking for conflicts as we do so. |
| 1075 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 1076 | |
| 1077 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1078 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 1079 | assert(Existing && "Conflict but no matching type?!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1080 | |
| 1081 | // There is only one case where this is allowed: when we are refining an |
| 1082 | // opaque type. In this case, Existing will be an opaque type. |
| 1083 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1084 | // We ARE replacing an opaque type! |
| 1085 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 1086 | return true; |
| 1087 | } |
| 1088 | |
| 1089 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1090 | // the redefinition is identical to the original. This will be so if |
| 1091 | // Existing and T point to the same Type object. In this one case we |
| 1092 | // allow the equivalent redefinition. |
| 1093 | if (Existing == T) return true; // Yes, it's equal. |
| 1094 | |
| 1095 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 1096 | GenerateError("Redefinition of type named '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1097 | T->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1098 | } |
| 1099 | |
| 1100 | return false; |
| 1101 | } |
| 1102 | |
| 1103 | //===----------------------------------------------------------------------===// |
| 1104 | // Code for handling upreferences in type names... |
| 1105 | // |
| 1106 | |
| 1107 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1108 | // |
| 1109 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1110 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1111 | E) != Ty->subtype_end(); |
| 1112 | } |
| 1113 | |
| 1114 | namespace { |
| 1115 | struct UpRefRecord { |
| 1116 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1117 | // this type is resolved. |
| 1118 | unsigned NestingLevel; |
| 1119 | |
| 1120 | // LastContainedTy - This is the type at the current binding level for the |
| 1121 | // type. Every time we reduce the nesting level, this gets updated. |
| 1122 | const Type *LastContainedTy; |
| 1123 | |
| 1124 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1125 | // represented with. |
| 1126 | OpaqueType *UpRefTy; |
| 1127 | |
| 1128 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 1129 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 1130 | }; |
| 1131 | } |
| 1132 | |
| 1133 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1134 | static std::vector<UpRefRecord> UpRefs; |
| 1135 | |
| 1136 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1137 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1138 | /// currently active types. For each type, if the up reference is contained in |
| 1139 | /// the newly completed type, we decrement the level count. When the level |
| 1140 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1141 | /// thus we can complete the cycle. |
| 1142 | /// |
| 1143 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 1144 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1145 | // nothing to resolve here. |
| 1146 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1147 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1148 | PATypeHolder Ty(ty); |
| 1149 | UR_OUT("Type '" << Ty->getDescription() << |
| 1150 | "' newly formed. Resolving upreferences.\n" << |
| 1151 | UpRefs.size() << " upreferences active!\n"); |
| 1152 | |
| 1153 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1154 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1155 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1156 | // this variable. |
| 1157 | OpaqueType *TypeToResolve = 0; |
| 1158 | |
| 1159 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1160 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1161 | << UpRefs[i].second->getDescription() << ") = " |
| 1162 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1163 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1164 | // Decrement level of upreference |
| 1165 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1166 | UpRefs[i].LastContainedTy = Ty; |
| 1167 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1168 | if (Level == 0) { // Upreference should be resolved! |
| 1169 | if (!TypeToResolve) { |
| 1170 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1171 | } else { |
| 1172 | UR_OUT(" * Resolving upreference for " |
| 1173 | << UpRefs[i].second->getDescription() << "\n"; |
| 1174 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1175 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1176 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1177 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1178 | } |
| 1179 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1180 | --i; // Do not skip the next element... |
| 1181 | } |
| 1182 | } |
| 1183 | } |
| 1184 | |
| 1185 | if (TypeToResolve) { |
| 1186 | UR_OUT(" * Resolving upreference for " |
| 1187 | << UpRefs[i].second->getDescription() << "\n"; |
| 1188 | std::string OldName = TypeToResolve->getDescription()); |
| 1189 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1190 | } |
| 1191 | |
| 1192 | return Ty; |
| 1193 | } |
| 1194 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1195 | //===----------------------------------------------------------------------===// |
| 1196 | // RunVMAsmParser - Define an interface to this parser |
| 1197 | //===----------------------------------------------------------------------===// |
| 1198 | // |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1199 | static Module* RunParser(Module * M); |
| 1200 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1201 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1202 | set_scan_file(F); |
| 1203 | |
| 1204 | CurFilename = Filename; |
| 1205 | return RunParser(new Module(CurFilename)); |
| 1206 | } |
| 1207 | |
| 1208 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1209 | set_scan_string(AsmString); |
| 1210 | |
| 1211 | CurFilename = "from_memory"; |
| 1212 | if (M == NULL) { |
| 1213 | return RunParser(new Module (CurFilename)); |
| 1214 | } else { |
| 1215 | return RunParser(M); |
| 1216 | } |
| 1217 | } |
| 1218 | |
| 1219 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 1220 | |
| 1221 | /* Enabling traces. */ |
| 1222 | #ifndef YYDEBUG |
| 1223 | # define YYDEBUG 0 |
| 1224 | #endif |
| 1225 | |
| 1226 | /* Enabling verbose error messages. */ |
| 1227 | #ifdef YYERROR_VERBOSE |
| 1228 | # undef YYERROR_VERBOSE |
| 1229 | # define YYERROR_VERBOSE 1 |
| 1230 | #else |
| 1231 | # define YYERROR_VERBOSE 0 |
| 1232 | #endif |
| 1233 | |
| 1234 | /* Enabling the token table. */ |
| 1235 | #ifndef YYTOKEN_TABLE |
| 1236 | # define YYTOKEN_TABLE 0 |
| 1237 | #endif |
| 1238 | |
| 1239 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
| 1240 | #line 901 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 1241 | typedef union YYSTYPE { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1242 | llvm::Module *ModuleVal; |
| 1243 | llvm::Function *FunctionVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1244 | llvm::BasicBlock *BasicBlockVal; |
| 1245 | llvm::TerminatorInst *TermInstVal; |
| 1246 | llvm::Instruction *InstVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1247 | llvm::Constant *ConstVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1248 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1249 | const llvm::Type *PrimType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1250 | std::list<llvm::PATypeHolder> *TypeList; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1251 | llvm::PATypeHolder *TypeVal; |
| 1252 | llvm::Value *ValueVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1253 | std::vector<llvm::Value*> *ValueList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1254 | llvm::ArgListType *ArgList; |
| 1255 | llvm::TypeWithAttrs TypeWithAttrs; |
| 1256 | llvm::TypeWithAttrsList *TypeWithAttrsList; |
| 1257 | llvm::ValueRefList *ValueRefList; |
| 1258 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1259 | // Represent the RHS of PHI node |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1260 | std::list<std::pair<llvm::Value*, |
| 1261 | llvm::BasicBlock*> > *PHIList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1262 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1263 | std::vector<llvm::Constant*> *ConstVector; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1264 | |
| 1265 | llvm::GlobalValue::LinkageTypes Linkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1266 | llvm::GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1267 | llvm::FunctionType::ParameterAttributes ParamAttrs; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1268 | int64_t SInt64Val; |
| 1269 | uint64_t UInt64Val; |
| 1270 | int SIntVal; |
| 1271 | unsigned UIntVal; |
| 1272 | double FPVal; |
| 1273 | bool BoolVal; |
| 1274 | |
| 1275 | char *StrVal; // This memory is strdup'd! |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1276 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1277 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1278 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1279 | llvm::Instruction::TermOps TermOpVal; |
| 1280 | llvm::Instruction::MemoryOps MemOpVal; |
| 1281 | llvm::Instruction::CastOps CastOpVal; |
| 1282 | llvm::Instruction::OtherOps OtherOpVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1283 | llvm::ICmpInst::Predicate IPredicate; |
| 1284 | llvm::FCmpInst::Predicate FPredicate; |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 1285 | } YYSTYPE; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 1286 | /* Line 196 of yacc.c. */ |
| 1287 | #line 1288 "llvmAsmParser.tab.c" |
| 1288 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 1289 | # define YYSTYPE_IS_DECLARED 1 |
| 1290 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1291 | #endif |
| 1292 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1293 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1294 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 1295 | /* Copy the second part of user declarations. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1296 | |
| 1297 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 1298 | /* Line 219 of yacc.c. */ |
| 1299 | #line 1300 "llvmAsmParser.tab.c" |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1300 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 1301 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
| 1302 | # define YYSIZE_T __SIZE_TYPE__ |
| 1303 | #endif |
| 1304 | #if ! defined (YYSIZE_T) && defined (size_t) |
| 1305 | # define YYSIZE_T size_t |
| 1306 | #endif |
| 1307 | #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) |
| 1308 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 1309 | # define YYSIZE_T size_t |
| 1310 | #endif |
| 1311 | #if ! defined (YYSIZE_T) |
| 1312 | # define YYSIZE_T unsigned int |
| 1313 | #endif |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 1314 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 1315 | #ifndef YY_ |
| 1316 | # if YYENABLE_NLS |
| 1317 | # if ENABLE_NLS |
| 1318 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 1319 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
| 1320 | # endif |
| 1321 | # endif |
| 1322 | # ifndef YY_ |
| 1323 | # define YY_(msgid) msgid |
| 1324 | # endif |
| 1325 | #endif |
| 1326 | |
| 1327 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
| 1328 | |
| 1329 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 1330 | |
| 1331 | # ifdef YYSTACK_USE_ALLOCA |
| 1332 | # if YYSTACK_USE_ALLOCA |
| 1333 | # ifdef __GNUC__ |
| 1334 | # define YYSTACK_ALLOC __builtin_alloca |
| 1335 | # else |
| 1336 | # define YYSTACK_ALLOC alloca |
| 1337 | # if defined (__STDC__) || defined (__cplusplus) |
| 1338 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 1339 | # define YYINCLUDED_STDLIB_H |
| 1340 | # endif |
| 1341 | # endif |
| 1342 | # endif |
| 1343 | # endif |
| 1344 | |
| 1345 | # ifdef YYSTACK_ALLOC |
| 1346 | /* Pacify GCC's `empty if-body' warning. */ |
| 1347 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
| 1348 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1349 | /* The OS might guarantee only one guard page at the bottom of the stack, |
| 1350 | and a page size can be as small as 4096 bytes. So we cannot safely |
| 1351 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
| 1352 | to allow for a few compiler-allocated temporary stack slots. */ |
| 1353 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ |
| 1354 | # endif |
| 1355 | # else |
| 1356 | # define YYSTACK_ALLOC YYMALLOC |
| 1357 | # define YYSTACK_FREE YYFREE |
| 1358 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1359 | # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) |
| 1360 | # endif |
| 1361 | # ifdef __cplusplus |
| 1362 | extern "C" { |
| 1363 | # endif |
| 1364 | # ifndef YYMALLOC |
| 1365 | # define YYMALLOC malloc |
| 1366 | # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 1367 | && (defined (__STDC__) || defined (__cplusplus))) |
| 1368 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 1369 | # endif |
| 1370 | # endif |
| 1371 | # ifndef YYFREE |
| 1372 | # define YYFREE free |
| 1373 | # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 1374 | && (defined (__STDC__) || defined (__cplusplus))) |
| 1375 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 1376 | # endif |
| 1377 | # endif |
| 1378 | # ifdef __cplusplus |
| 1379 | } |
| 1380 | # endif |
| 1381 | # endif |
| 1382 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
| 1383 | |
| 1384 | |
| 1385 | #if (! defined (yyoverflow) \ |
| 1386 | && (! defined (__cplusplus) \ |
| 1387 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
| 1388 | |
| 1389 | /* A type that is properly aligned for any stack member. */ |
| 1390 | union yyalloc |
| 1391 | { |
| 1392 | short int yyss; |
| 1393 | YYSTYPE yyvs; |
| 1394 | }; |
| 1395 | |
| 1396 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 1397 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 1398 | |
| 1399 | /* The size of an array large to enough to hold all stacks, each with |
| 1400 | N elements. */ |
| 1401 | # define YYSTACK_BYTES(N) \ |
| 1402 | ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ |
| 1403 | + YYSTACK_GAP_MAXIMUM) |
| 1404 | |
| 1405 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 1406 | not overlap. */ |
| 1407 | # ifndef YYCOPY |
| 1408 | # if defined (__GNUC__) && 1 < __GNUC__ |
| 1409 | # define YYCOPY(To, From, Count) \ |
| 1410 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 1411 | # else |
| 1412 | # define YYCOPY(To, From, Count) \ |
| 1413 | do \ |
| 1414 | { \ |
| 1415 | YYSIZE_T yyi; \ |
| 1416 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 1417 | (To)[yyi] = (From)[yyi]; \ |
| 1418 | } \ |
| 1419 | while (0) |
| 1420 | # endif |
| 1421 | # endif |
| 1422 | |
| 1423 | /* Relocate STACK from its old location to the new one. The |
| 1424 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 1425 | elements in the stack, and YYPTR gives the new location of the |
| 1426 | stack. Advance YYPTR to a properly aligned location for the next |
| 1427 | stack. */ |
| 1428 | # define YYSTACK_RELOCATE(Stack) \ |
| 1429 | do \ |
| 1430 | { \ |
| 1431 | YYSIZE_T yynewbytes; \ |
| 1432 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 1433 | Stack = &yyptr->Stack; \ |
| 1434 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 1435 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 1436 | } \ |
| 1437 | while (0) |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 1438 | |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1439 | #endif |
| 1440 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 1441 | #if defined (__STDC__) || defined (__cplusplus) |
| 1442 | typedef signed char yysigned_char; |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 1443 | #else |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 1444 | typedef short int yysigned_char; |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 1445 | #endif |
| 1446 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 1447 | /* YYFINAL -- State number of the termination state. */ |
| 1448 | #define YYFINAL 40 |
| 1449 | /* YYLAST -- Last index in YYTABLE. */ |
| 1450 | #define YYLAST 1439 |
| 1451 | |
| 1452 | /* YYNTOKENS -- Number of terminals. */ |
| 1453 | #define YYNTOKENS 146 |
| 1454 | /* YYNNTS -- Number of nonterminals. */ |
| 1455 | #define YYNNTS 78 |
| 1456 | /* YYNRULES -- Number of rules. */ |
| 1457 | #define YYNRULES 284 |
| 1458 | /* YYNRULES -- Number of states. */ |
| 1459 | #define YYNSTATES 557 |
| 1460 | |
| 1461 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 1462 | #define YYUNDEFTOK 2 |
| 1463 | #define YYMAXUTOK 386 |
| 1464 | |
| 1465 | #define YYTRANSLATE(YYX) \ |
| 1466 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 1467 | |
| 1468 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 1469 | static const unsigned char yytranslate[] = |
| 1470 | { |
| 1471 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1472 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1473 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1474 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1475 | 136, 137, 134, 2, 133, 2, 2, 2, 2, 2, |
| 1476 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1477 | 141, 132, 142, 2, 2, 2, 2, 2, 2, 2, |
| 1478 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1479 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1480 | 2, 138, 135, 140, 2, 2, 2, 2, 2, 145, |
| 1481 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1482 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1483 | 139, 2, 2, 143, 2, 144, 2, 2, 2, 2, |
| 1484 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1485 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1486 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1487 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1488 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1489 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1490 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1491 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1492 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1493 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1494 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1495 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1496 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 1497 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 1498 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 1499 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 1500 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 1501 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 1502 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 1503 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 1504 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 1505 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1506 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 1507 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 1508 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 1509 | 125, 126, 127, 128, 129, 130, 131 |
| 1510 | }; |
| 1511 | |
| 1512 | #if YYDEBUG |
| 1513 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 1514 | YYRHS. */ |
| 1515 | static const unsigned short int yyprhs[] = |
| 1516 | { |
| 1517 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 1518 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 1519 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 1520 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, |
| 1521 | 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, |
| 1522 | 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, |
| 1523 | 119, 121, 122, 125, 126, 128, 130, 133, 134, 136, |
| 1524 | 138, 140, 142, 144, 146, 148, 150, 151, 153, 154, |
| 1525 | 156, 158, 159, 161, 163, 165, 167, 168, 170, 172, |
| 1526 | 174, 176, 178, 181, 183, 185, 187, 189, 190, 193, |
| 1527 | 195, 197, 198, 201, 202, 205, 206, 210, 213, 214, |
| 1528 | 216, 217, 221, 223, 226, 228, 230, 232, 234, 236, |
| 1529 | 238, 241, 243, 246, 252, 258, 264, 270, 274, 277, |
| 1530 | 283, 288, 291, 293, 295, 297, 301, 303, 307, 309, |
| 1531 | 310, 312, 316, 321, 325, 329, 334, 339, 343, 350, |
| 1532 | 356, 359, 362, 365, 368, 371, 374, 377, 380, 383, |
| 1533 | 386, 393, 399, 408, 415, 422, 430, 438, 445, 454, |
| 1534 | 463, 467, 469, 471, 473, 475, 476, 478, 481, 482, |
| 1535 | 486, 487, 491, 495, 497, 501, 505, 506, 513, 514, |
| 1536 | 522, 523, 531, 534, 538, 540, 544, 548, 552, 556, |
| 1537 | 558, 559, 565, 569, 571, 575, 577, 578, 588, 590, |
| 1538 | 592, 597, 599, 601, 604, 608, 609, 611, 613, 615, |
| 1539 | 617, 619, 621, 623, 625, 627, 631, 633, 639, 641, |
| 1540 | 643, 645, 647, 649, 651, 654, 657, 660, 664, 667, |
| 1541 | 668, 670, 673, 676, 680, 690, 700, 709, 724, 726, |
| 1542 | 728, 735, 741, 744, 751, 759, 763, 769, 770, 771, |
| 1543 | 775, 778, 780, 786, 792, 799, 806, 811, 818, 823, |
| 1544 | 828, 835, 842, 845, 854, 856, 858, 859, 863, 870, |
| 1545 | 874, 881, 884, 889, 896 |
| 1546 | }; |
| 1547 | |
| 1548 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 1549 | static const short int yyrhs[] = |
| 1550 | { |
| 1551 | 186, 0, -1, 66, -1, 67, -1, 68, -1, 69, |
| 1552 | -1, 70, -1, 71, -1, 72, -1, 73, -1, 74, |
| 1553 | -1, 78, -1, 79, -1, 80, -1, 75, -1, 76, |
| 1554 | -1, 77, -1, 109, -1, 110, -1, 111, -1, 112, |
| 1555 | -1, 113, -1, 114, -1, 115, -1, 116, -1, 117, |
| 1556 | -1, 118, -1, 119, -1, 120, -1, 83, -1, 84, |
| 1557 | -1, 85, -1, 86, -1, 87, -1, 88, -1, 89, |
| 1558 | -1, 90, -1, 91, -1, 92, -1, 93, -1, 94, |
| 1559 | -1, 95, -1, 96, -1, 97, -1, 98, -1, 99, |
| 1560 | -1, 100, -1, 101, -1, 102, -1, 89, -1, 90, |
| 1561 | -1, 91, -1, 92, -1, 21, -1, 22, -1, 9, |
| 1562 | -1, 10, -1, 11, -1, 14, -1, 17, -1, 154, |
| 1563 | -1, -1, 154, 132, -1, -1, 15, -1, 18, -1, |
| 1564 | 157, 132, -1, -1, 35, -1, 37, -1, 36, -1, |
| 1565 | 38, -1, 40, -1, 39, -1, 41, -1, 43, -1, |
| 1566 | -1, 131, -1, -1, 39, -1, 41, -1, -1, 35, |
| 1567 | -1, 36, -1, 37, -1, 40, -1, -1, 54, -1, |
| 1568 | 55, -1, 56, -1, 57, -1, 58, -1, 53, 4, |
| 1569 | -1, 110, -1, 111, -1, 128, -1, 129, -1, -1, |
| 1570 | 166, 165, -1, 127, -1, 165, -1, -1, 168, 167, |
| 1571 | -1, -1, 46, 4, -1, -1, 133, 46, 4, -1, |
| 1572 | 29, 17, -1, -1, 171, -1, -1, 133, 174, 173, |
| 1573 | -1, 171, -1, 46, 4, -1, 9, -1, 10, -1, |
| 1574 | 11, -1, 12, -1, 42, -1, 175, -1, 176, 134, |
| 1575 | -1, 208, -1, 135, 4, -1, 176, 136, 180, 137, |
| 1576 | 168, -1, 8, 136, 180, 137, 168, -1, 138, 4, |
| 1577 | 139, 176, 140, -1, 141, 4, 139, 176, 142, -1, |
| 1578 | 143, 181, 144, -1, 143, 144, -1, 141, 143, 181, |
| 1579 | 144, 142, -1, 141, 143, 144, 142, -1, 176, 166, |
| 1580 | -1, 176, -1, 8, -1, 177, -1, 179, 133, 177, |
| 1581 | -1, 179, -1, 179, 133, 32, -1, 32, -1, -1, |
| 1582 | 176, -1, 181, 133, 176, -1, 176, 138, 184, 140, |
| 1583 | -1, 176, 138, 140, -1, 176, 145, 17, -1, 176, |
| 1584 | 141, 184, 142, -1, 176, 143, 184, 144, -1, 176, |
| 1585 | 143, 144, -1, 176, 141, 143, 184, 144, 142, -1, |
| 1586 | 176, 141, 143, 144, 142, -1, 176, 33, -1, 176, |
| 1587 | 34, -1, 176, 208, -1, 176, 183, -1, 176, 20, |
| 1588 | -1, 152, 3, -1, 152, 4, -1, 9, 21, -1, |
| 1589 | 9, 22, -1, 153, 7, -1, 149, 136, 182, 31, |
| 1590 | 176, 137, -1, 108, 136, 182, 219, 137, -1, 122, |
| 1591 | 136, 182, 133, 182, 133, 182, 137, -1, 147, 136, |
| 1592 | 182, 133, 182, 137, -1, 148, 136, 182, 133, 182, |
| 1593 | 137, -1, 81, 150, 136, 182, 133, 182, 137, -1, |
| 1594 | 82, 151, 136, 182, 133, 182, 137, -1, 124, 136, |
| 1595 | 182, 133, 182, 137, -1, 125, 136, 182, 133, 182, |
| 1596 | 133, 182, 137, -1, 126, 136, 182, 133, 182, 133, |
| 1597 | 182, 137, -1, 184, 133, 182, -1, 182, -1, 27, |
| 1598 | -1, 28, -1, 187, -1, -1, 188, -1, 187, 188, |
| 1599 | -1, -1, 26, 189, 204, -1, -1, 25, 190, 205, |
| 1600 | -1, 51, 50, 194, -1, 19, -1, 156, 13, 176, |
| 1601 | -1, 156, 13, 8, -1, -1, 158, 161, 185, 182, |
| 1602 | 191, 173, -1, -1, 158, 159, 161, 185, 182, 192, |
| 1603 | 173, -1, -1, 158, 160, 161, 185, 176, 193, 173, |
| 1604 | -1, 44, 195, -1, 47, 132, 196, -1, 17, -1, |
| 1605 | 45, 132, 17, -1, 59, 132, 17, -1, 138, 197, |
| 1606 | 140, -1, 197, 133, 17, -1, 17, -1, -1, 198, |
| 1607 | 133, 176, 166, 155, -1, 176, 166, 155, -1, 198, |
| 1608 | -1, 198, 133, 32, -1, 32, -1, -1, 164, 178, |
| 1609 | 157, 136, 199, 137, 168, 172, 169, -1, 23, -1, |
| 1610 | 143, -1, 163, 161, 200, 201, -1, 24, -1, 144, |
| 1611 | -1, 211, 203, -1, 162, 161, 200, -1, -1, 52, |
| 1612 | -1, 3, -1, 4, -1, 7, -1, 21, -1, 22, |
| 1613 | -1, 33, -1, 34, -1, 20, -1, 141, 184, 142, |
| 1614 | -1, 183, -1, 50, 206, 17, 133, 17, -1, 5, |
| 1615 | -1, 6, -1, 154, -1, 157, -1, 208, -1, 207, |
| 1616 | -1, 176, 209, -1, 211, 212, -1, 202, 212, -1, |
| 1617 | 213, 156, 214, -1, 213, 216, -1, -1, 16, -1, |
| 1618 | 60, 210, -1, 60, 8, -1, 61, 12, 209, -1, |
| 1619 | 61, 9, 209, 133, 12, 209, 133, 12, 209, -1, |
| 1620 | 62, 152, 209, 133, 12, 209, 138, 215, 140, -1, |
| 1621 | 62, 152, 209, 133, 12, 209, 138, 140, -1, 63, |
| 1622 | 164, 178, 209, 136, 218, 137, 168, 31, 12, 209, |
| 1623 | 64, 12, 209, -1, 64, -1, 65, -1, 215, 152, |
| 1624 | 207, 133, 12, 209, -1, 152, 207, 133, 12, 209, |
| 1625 | -1, 156, 221, -1, 176, 138, 209, 133, 209, 140, |
| 1626 | -1, 217, 133, 138, 209, 133, 209, 140, -1, 176, |
| 1627 | 209, 166, -1, 218, 133, 176, 209, 166, -1, -1, |
| 1628 | -1, 219, 133, 210, -1, 49, 48, -1, 48, -1, |
| 1629 | 147, 176, 209, 133, 209, -1, 148, 176, 209, 133, |
| 1630 | 209, -1, 81, 150, 176, 209, 133, 209, -1, 82, |
| 1631 | 151, 176, 209, 133, 209, -1, 149, 210, 31, 176, |
| 1632 | -1, 122, 210, 133, 210, 133, 210, -1, 123, 210, |
| 1633 | 133, 176, -1, 124, 210, 133, 210, -1, 125, 210, |
| 1634 | 133, 210, 133, 210, -1, 126, 210, 133, 210, 133, |
| 1635 | 210, -1, 121, 217, -1, 220, 164, 178, 209, 136, |
| 1636 | 218, 137, 168, -1, 223, -1, 30, -1, -1, 103, |
| 1637 | 176, 170, -1, 103, 176, 133, 9, 209, 170, -1, |
| 1638 | 104, 176, 170, -1, 104, 176, 133, 9, 209, 170, |
| 1639 | -1, 105, 210, -1, 222, 106, 176, 209, -1, 222, |
| 1640 | 107, 210, 133, 176, 209, -1, 108, 176, 209, 219, |
| 1641 | -1 |
| 1642 | }; |
| 1643 | |
| 1644 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 1645 | static const unsigned short int yyrline[] = |
| 1646 | { |
| 1647 | 0, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, |
| 1648 | 1048, 1049, 1049, 1049, 1049, 1049, 1049, 1050, 1050, 1050, |
| 1649 | 1050, 1050, 1050, 1051, 1051, 1051, 1051, 1051, 1051, 1054, |
| 1650 | 1054, 1055, 1055, 1056, 1056, 1057, 1057, 1058, 1058, 1062, |
| 1651 | 1062, 1063, 1063, 1064, 1064, 1065, 1065, 1066, 1066, 1067, |
| 1652 | 1067, 1068, 1068, 1069, 1070, 1075, 1076, 1076, 1078, 1078, |
| 1653 | 1079, 1079, 1083, 1087, 1092, 1092, 1094, 1098, 1104, 1105, |
| 1654 | 1106, 1107, 1108, 1112, 1113, 1114, 1118, 1119, 1123, 1124, |
| 1655 | 1125, 1129, 1130, 1131, 1132, 1133, 1136, 1137, 1138, 1139, |
| 1656 | 1140, 1141, 1142, 1149, 1150, 1151, 1152, 1155, 1156, 1161, |
| 1657 | 1162, 1165, 1166, 1173, 1174, 1180, 1181, 1189, 1197, 1198, |
| 1658 | 1203, 1204, 1205, 1210, 1223, 1223, 1223, 1223, 1226, 1230, |
| 1659 | 1234, 1241, 1246, 1254, 1272, 1290, 1295, 1307, 1317, 1321, |
| 1660 | 1331, 1338, 1345, 1352, 1357, 1362, 1369, 1370, 1377, 1384, |
| 1661 | 1392, 1397, 1408, 1436, 1452, 1481, 1509, 1534, 1553, 1578, |
| 1662 | 1597, 1609, 1616, 1682, 1692, 1702, 1708, 1714, 1719, 1724, |
| 1663 | 1732, 1744, 1766, 1774, 1780, 1791, 1796, 1801, 1807, 1813, |
| 1664 | 1822, 1826, 1834, 1834, 1845, 1850, 1858, 1859, 1863, 1863, |
| 1665 | 1867, 1867, 1870, 1873, 1885, 1909, 1920, 1920, 1930, 1930, |
| 1666 | 1938, 1938, 1948, 1951, 1957, 1970, 1974, 1979, 1981, 1986, |
| 1667 | 1991, 2000, 2010, 2021, 2025, 2034, 2043, 2048, 2160, 2160, |
| 1668 | 2162, 2171, 2171, 2173, 2178, 2190, 2194, 2199, 2203, 2207, |
| 1669 | 2211, 2215, 2219, 2223, 2227, 2231, 2256, 2260, 2274, 2278, |
| 1670 | 2282, 2286, 2292, 2292, 2298, 2307, 2311, 2320, 2330, 2339, |
| 1671 | 2351, 2364, 2368, 2372, 2377, 2387, 2406, 2415, 2482, 2486, |
| 1672 | 2493, 2504, 2517, 2527, 2538, 2548, 2556, 2564, 2567, 2568, |
| 1673 | 2575, 2579, 2584, 2605, 2622, 2635, 2648, 2660, 2668, 2675, |
| 1674 | 2681, 2687, 2693, 2708, 2772, 2777, 2781, 2788, 2795, 2803, |
| 1675 | 2810, 2818, 2826, 2840, 2857 |
| 1676 | }; |
| 1677 | #endif |
| 1678 | |
| 1679 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
| 1680 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 1681 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 1682 | static const char *const yytname[] = |
| 1683 | { |
| 1684 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", |
| 1685 | "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE", "FLOAT", |
| 1686 | "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR", |
| 1687 | "STRINGCONSTANT", "ATSTRINGCONSTANT", "IMPLEMENTATION", |
| 1688 | "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", |
| 1689 | "DECLARE", "DEFINE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", |
| 1690 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK", |
| 1691 | "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 1692 | "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL", |
| 1693 | "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK", |
| 1694 | "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", |
| 1695 | "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", |
| 1696 | "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR", |
| 1697 | "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", |
| 1698 | "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", |
| 1699 | "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", |
| 1700 | "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", |
| 1701 | "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", |
| 1702 | "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT", |
| 1703 | "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET", "DEFAULT", |
| 1704 | "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'", |
| 1705 | "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps", |
| 1706 | "LogicalOps", "CastOps", "IPredicates", "FPredicates", "IntType", |
| 1707 | "FPType", "LocalName", "OptLocalName", "OptLocalAssign", "GlobalName", |
| 1708 | "OptGlobalAssign", "GVInternalLinkage", "GVExternalLinkage", |
| 1709 | "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage", |
| 1710 | "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr", |
| 1711 | "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString", "OptSection", |
| 1712 | "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types", |
| 1713 | "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI", |
| 1714 | "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "Module", |
| 1715 | "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock", |
| 1716 | "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH", |
| 1717 | "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", |
| 1718 | "Function", "FunctionProto", "OptSideEffect", "ConstValueRef", |
| 1719 | "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList", |
| 1720 | "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst", |
| 1721 | "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal", |
| 1722 | "OptVolatile", "MemoryInst", 0 |
| 1723 | }; |
| 1724 | #endif |
| 1725 | |
| 1726 | # ifdef YYPRINT |
| 1727 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 1728 | token YYLEX-NUM. */ |
| 1729 | static const unsigned short int yytoknum[] = |
| 1730 | { |
| 1731 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 1732 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 1733 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 1734 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 1735 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 1736 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 1737 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 1738 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 1739 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 1740 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
| 1741 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
| 1742 | 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, |
| 1743 | 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, |
| 1744 | 385, 386, 61, 44, 42, 92, 40, 41, 91, 120, |
| 1745 | 93, 60, 62, 123, 125, 99 |
| 1746 | }; |
| 1747 | # endif |
| 1748 | |
| 1749 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 1750 | static const unsigned char yyr1[] = |
| 1751 | { |
| 1752 | 0, 146, 147, 147, 147, 147, 147, 147, 147, 147, |
| 1753 | 147, 148, 148, 148, 148, 148, 148, 149, 149, 149, |
| 1754 | 149, 149, 149, 149, 149, 149, 149, 149, 149, 150, |
| 1755 | 150, 150, 150, 150, 150, 150, 150, 150, 150, 151, |
| 1756 | 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, |
| 1757 | 151, 151, 151, 151, 151, 152, 153, 153, 154, 154, |
| 1758 | 155, 155, 156, 156, 157, 157, 158, 158, 159, 159, |
| 1759 | 159, 159, 159, 160, 160, 160, 161, 161, 162, 162, |
| 1760 | 162, 163, 163, 163, 163, 163, 164, 164, 164, 164, |
| 1761 | 164, 164, 164, 165, 165, 165, 165, 166, 166, 167, |
| 1762 | 167, 168, 168, 169, 169, 170, 170, 171, 172, 172, |
| 1763 | 173, 173, 174, 174, 175, 175, 175, 175, 176, 176, |
| 1764 | 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, |
| 1765 | 176, 177, 178, 178, 179, 179, 180, 180, 180, 180, |
| 1766 | 181, 181, 182, 182, 182, 182, 182, 182, 182, 182, |
| 1767 | 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, |
| 1768 | 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, |
| 1769 | 184, 184, 185, 185, 186, 186, 187, 187, 189, 188, |
| 1770 | 190, 188, 188, 188, 188, 188, 191, 188, 192, 188, |
| 1771 | 193, 188, 188, 188, 194, 195, 195, 196, 197, 197, |
| 1772 | 197, 198, 198, 199, 199, 199, 199, 200, 201, 201, |
| 1773 | 202, 203, 203, 204, 205, 206, 206, 207, 207, 207, |
| 1774 | 207, 207, 207, 207, 207, 207, 207, 207, 208, 208, |
| 1775 | 208, 208, 209, 209, 210, 211, 211, 212, 213, 213, |
| 1776 | 213, 214, 214, 214, 214, 214, 214, 214, 214, 214, |
| 1777 | 215, 215, 216, 217, 217, 218, 218, 218, 219, 219, |
| 1778 | 220, 220, 221, 221, 221, 221, 221, 221, 221, 221, |
| 1779 | 221, 221, 221, 221, 221, 222, 222, 223, 223, 223, |
| 1780 | 223, 223, 223, 223, 223 |
| 1781 | }; |
| 1782 | |
| 1783 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 1784 | static const unsigned char yyr2[] = |
| 1785 | { |
| 1786 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1787 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1788 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1789 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1790 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1791 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1792 | 1, 0, 2, 0, 1, 1, 2, 0, 1, 1, |
| 1793 | 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, |
| 1794 | 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, |
| 1795 | 1, 1, 2, 1, 1, 1, 1, 0, 2, 1, |
| 1796 | 1, 0, 2, 0, 2, 0, 3, 2, 0, 1, |
| 1797 | 0, 3, 1, 2, 1, 1, 1, 1, 1, 1, |
| 1798 | 2, 1, 2, 5, 5, 5, 5, 3, 2, 5, |
| 1799 | 4, 2, 1, 1, 1, 3, 1, 3, 1, 0, |
| 1800 | 1, 3, 4, 3, 3, 4, 4, 3, 6, 5, |
| 1801 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1802 | 6, 5, 8, 6, 6, 7, 7, 6, 8, 8, |
| 1803 | 3, 1, 1, 1, 1, 0, 1, 2, 0, 3, |
| 1804 | 0, 3, 3, 1, 3, 3, 0, 6, 0, 7, |
| 1805 | 0, 7, 2, 3, 1, 3, 3, 3, 3, 1, |
| 1806 | 0, 5, 3, 1, 3, 1, 0, 9, 1, 1, |
| 1807 | 4, 1, 1, 2, 3, 0, 1, 1, 1, 1, |
| 1808 | 1, 1, 1, 1, 1, 3, 1, 5, 1, 1, |
| 1809 | 1, 1, 1, 1, 2, 2, 2, 3, 2, 0, |
| 1810 | 1, 2, 2, 3, 9, 9, 8, 14, 1, 1, |
| 1811 | 6, 5, 2, 6, 7, 3, 5, 0, 0, 3, |
| 1812 | 2, 1, 5, 5, 6, 6, 4, 6, 4, 4, |
| 1813 | 6, 6, 2, 8, 1, 1, 0, 3, 6, 3, |
| 1814 | 6, 2, 4, 6, 4 |
| 1815 | }; |
| 1816 | |
| 1817 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 1818 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 1819 | means the default is an error. */ |
| 1820 | static const unsigned short int yydefact[] = |
| 1821 | { |
| 1822 | 67, 58, 64, 59, 65, 183, 180, 178, 0, 0, |
| 1823 | 0, 0, 0, 0, 76, 0, 67, 176, 78, 81, |
| 1824 | 0, 0, 192, 0, 0, 62, 0, 66, 68, 70, |
| 1825 | 69, 71, 73, 72, 74, 75, 77, 76, 76, 0, |
| 1826 | 1, 177, 79, 80, 76, 181, 82, 83, 84, 85, |
| 1827 | 76, 239, 179, 239, 0, 0, 200, 193, 194, 182, |
| 1828 | 228, 229, 185, 114, 115, 116, 117, 118, 0, 0, |
| 1829 | 0, 0, 230, 231, 119, 184, 121, 0, 0, 172, |
| 1830 | 173, 0, 86, 86, 240, 236, 63, 211, 212, 213, |
| 1831 | 235, 195, 196, 199, 0, 139, 122, 0, 0, 0, |
| 1832 | 0, 128, 140, 0, 120, 139, 0, 0, 114, 115, |
| 1833 | 116, 0, 0, 0, 186, 0, 87, 88, 89, 90, |
| 1834 | 91, 0, 214, 0, 276, 238, 0, 197, 138, 97, |
| 1835 | 134, 136, 0, 0, 0, 0, 0, 0, 127, 0, |
| 1836 | 188, 190, 157, 158, 155, 156, 159, 154, 150, 151, |
| 1837 | 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, |
| 1838 | 15, 16, 11, 12, 13, 0, 0, 0, 17, 18, |
| 1839 | 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, |
| 1840 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1841 | 0, 153, 152, 110, 92, 133, 132, 0, 208, 209, |
| 1842 | 210, 275, 261, 0, 0, 0, 0, 86, 248, 249, |
| 1843 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1844 | 0, 0, 0, 0, 0, 237, 86, 252, 0, 274, |
| 1845 | 198, 131, 0, 101, 0, 0, 130, 0, 141, 101, |
| 1846 | 110, 110, 29, 30, 31, 32, 33, 34, 35, 36, |
| 1847 | 37, 38, 0, 53, 54, 49, 50, 51, 52, 39, |
| 1848 | 40, 41, 42, 43, 44, 45, 46, 47, 48, 0, |
| 1849 | 0, 0, 0, 0, 0, 143, 171, 0, 0, 0, |
| 1850 | 147, 0, 144, 0, 0, 0, 0, 187, 0, 260, |
| 1851 | 242, 0, 241, 0, 0, 55, 0, 0, 0, 0, |
| 1852 | 105, 105, 281, 0, 0, 272, 0, 0, 0, 0, |
| 1853 | 0, 0, 0, 0, 0, 0, 0, 93, 94, 95, |
| 1854 | 96, 98, 137, 135, 124, 125, 126, 129, 123, 189, |
| 1855 | 191, 0, 0, 258, 0, 0, 0, 0, 0, 142, |
| 1856 | 128, 140, 0, 145, 146, 0, 0, 0, 0, 0, |
| 1857 | 112, 110, 206, 217, 218, 219, 224, 220, 221, 222, |
| 1858 | 223, 215, 0, 226, 233, 232, 234, 0, 243, 0, |
| 1859 | 0, 0, 0, 0, 277, 0, 279, 258, 0, 0, |
| 1860 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1861 | 0, 99, 100, 102, 0, 0, 0, 0, 0, 0, |
| 1862 | 0, 170, 149, 0, 0, 0, 0, 107, 113, 111, |
| 1863 | 205, 97, 203, 0, 216, 0, 0, 0, 0, 0, |
| 1864 | 0, 0, 0, 0, 0, 284, 0, 0, 0, 268, |
| 1865 | 269, 0, 0, 0, 0, 266, 0, 282, 0, 0, |
| 1866 | 0, 0, 161, 0, 0, 0, 0, 148, 0, 0, |
| 1867 | 0, 61, 0, 101, 0, 225, 0, 0, 257, 0, |
| 1868 | 0, 105, 106, 105, 0, 0, 0, 0, 0, 262, |
| 1869 | 263, 257, 0, 0, 0, 259, 0, 167, 0, 0, |
| 1870 | 163, 164, 160, 60, 202, 204, 97, 108, 0, 0, |
| 1871 | 0, 0, 0, 264, 265, 0, 278, 280, 0, 0, |
| 1872 | 267, 270, 271, 0, 283, 165, 166, 0, 0, 0, |
| 1873 | 61, 109, 103, 227, 0, 0, 97, 0, 101, 253, |
| 1874 | 0, 101, 162, 168, 169, 201, 0, 207, 0, 246, |
| 1875 | 0, 0, 255, 0, 0, 254, 273, 104, 244, 0, |
| 1876 | 245, 0, 97, 0, 0, 0, 256, 0, 0, 0, |
| 1877 | 0, 251, 0, 0, 250, 0, 247 |
| 1878 | }; |
| 1879 | |
| 1880 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 1881 | static const short int yydefgoto[] = |
| 1882 | { |
| 1883 | -1, 188, 189, 190, 252, 269, 111, 112, 72, 484, |
| 1884 | 12, 73, 14, 37, 38, 39, 44, 50, 121, 321, |
| 1885 | 231, 393, 324, 527, 374, 350, 512, 287, 351, 74, |
| 1886 | 113, 130, 197, 131, 132, 103, 276, 363, 277, 81, |
| 1887 | 15, 16, 17, 19, 18, 193, 240, 241, 59, 22, |
| 1888 | 57, 94, 412, 413, 122, 200, 51, 89, 52, 45, |
| 1889 | 415, 364, 76, 366, 292, 53, 85, 86, 225, 531, |
| 1890 | 125, 305, 492, 396, 226, 227, 228, 229 |
| 1891 | }; |
| 1892 | |
| 1893 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 1894 | STATE-NUM. */ |
| 1895 | #define YYPACT_NINF -399 |
| 1896 | static const short int yypact[] = |
| 1897 | { |
| 1898 | 406, -399, -399, -399, -399, -399, -399, -399, -26, -114, |
| 1899 | -16, -53, 92, -11, 54, 136, 526, -399, 247, 173, |
| 1900 | 43, 49, -399, 62, 194, -399, 814, -399, -399, -399, |
| 1901 | -399, -399, -399, -399, -399, -399, -399, 134, 134, 99, |
| 1902 | -399, -399, -399, -399, 134, -399, -399, -399, -399, -399, |
| 1903 | 134, 212, -399, -1, 219, 225, 253, -399, -399, -399, |
| 1904 | -399, -399, 135, -399, -399, -399, -399, -399, 271, 275, |
| 1905 | 3, 33, -399, -399, -399, 160, -399, 99, 99, -399, |
| 1906 | -399, 1029, 287, 287, -399, -399, 220, -399, -399, -399, |
| 1907 | -399, -399, -399, -399, 20, 1071, -399, 141, 148, 105, |
| 1908 | 135, -399, 160, -75, -399, 1071, 1029, 1174, 32, 286, |
| 1909 | 293, 151, 294, 590, -399, 298, -399, -399, -399, -399, |
| 1910 | -399, 1190, -399, -13, 1313, -399, 289, -399, -399, 160, |
| 1911 | -399, 170, 167, 1174, 1174, 165, -68, 1174, -399, 174, |
| 1912 | -399, 160, -399, -399, -399, -399, -399, -399, -399, -399, |
| 1913 | -399, -399, -399, -399, -399, -399, -399, -399, -399, -399, |
| 1914 | -399, -399, -399, -399, -399, 495, 591, 176, -399, -399, |
| 1915 | -399, -399, -399, -399, -399, -399, -399, -399, -399, -399, |
| 1916 | 177, 178, 182, 183, 776, 1212, 123, 305, 187, 188, |
| 1917 | 189, -399, -399, 193, -399, 135, 160, 266, -399, -399, |
| 1918 | -399, -399, -399, 284, 1229, 283, 325, 287, -399, -399, |
| 1919 | 495, 591, 1174, 1174, 1174, 1174, 1174, 1174, 1174, 1174, |
| 1920 | 1174, 1174, 1174, 1174, 1174, -399, 287, -399, 144, -399, |
| 1921 | -399, -4, 1110, -399, -63, -110, -399, 204, 160, -399, |
| 1922 | 193, 193, -399, -399, -399, -399, -399, -399, -399, -399, |
| 1923 | -399, -399, 211, -399, -399, -399, -399, -399, -399, -399, |
| 1924 | -399, -399, -399, -399, -399, -399, -399, -399, -399, 214, |
| 1925 | 1029, 1029, 1029, 1029, 1029, -399, -399, 79, 494, -111, |
| 1926 | -399, -66, -399, 1029, 1029, 1029, 39, -399, 216, -399, |
| 1927 | 135, 733, -399, 858, 858, -399, 858, 1190, 1174, 1174, |
| 1928 | 50, 111, -399, 733, 97, 215, 230, 231, 232, 233, |
| 1929 | 234, 733, 733, 322, 1190, 1174, 1174, -399, -399, -399, |
| 1930 | -399, -399, -399, -399, -27, -399, -399, -399, -27, -399, |
| 1931 | -399, 1029, 1029, -399, 235, 236, 239, 240, 1029, -399, |
| 1932 | 237, 590, 26, -399, -399, 241, 242, 345, 360, 374, |
| 1933 | -399, 193, 1126, -399, -399, -399, -399, -399, -399, -399, |
| 1934 | -399, 328, 1029, -399, -399, -399, -399, 249, -399, 252, |
| 1935 | 858, 733, 733, 11, -399, 18, -399, -399, 858, 250, |
| 1936 | 1174, 1174, 1174, 1174, 1174, 256, 257, 1174, 858, 733, |
| 1937 | 259, -399, -399, -399, 262, 264, -34, 1029, 1029, 1029, |
| 1938 | 1029, -399, -399, 258, 1029, 1029, 1174, -399, -399, -399, |
| 1939 | -399, 160, 265, 267, -399, 384, -61, 390, 393, 272, |
| 1940 | 281, 282, 858, 413, 858, 295, 296, 858, 297, 160, |
| 1941 | -399, 301, 302, 858, 858, 160, 300, -399, 1174, 1029, |
| 1942 | 1029, 1174, -399, 304, 285, 306, 307, -399, 308, 310, |
| 1943 | 118, 38, 1145, -399, 311, -399, 858, 858, 1174, 858, |
| 1944 | 858, 315, -399, 315, 858, 316, 1174, 1174, 1174, -399, |
| 1945 | -399, 1174, 733, 317, 319, -399, 1029, -399, 1029, 1029, |
| 1946 | -399, -399, -399, -399, -399, -399, 160, 149, 421, 326, |
| 1947 | 314, 733, 19, -399, -399, 412, -399, -399, 321, 858, |
| 1948 | -399, -399, -399, 36, -399, -399, -399, 327, 329, 330, |
| 1949 | 38, -399, 416, -399, 451, 2, -399, 1174, -399, -399, |
| 1950 | 333, -399, -399, -399, -399, -399, 461, -399, 858, -399, |
| 1951 | 982, 5, -4, 733, 210, -399, -27, -399, -399, 335, |
| 1952 | -399, 982, -399, 457, 464, 344, -4, 858, 858, 468, |
| 1953 | 417, -399, 858, 471, -399, 858, -399 |
| 1954 | }; |
| 1955 | |
| 1956 | /* YYPGOTO[NTERM-NUM]. */ |
| 1957 | static const short int yypgoto[] = |
| 1958 | { |
| 1959 | -399, 361, 362, 363, 274, 279, -198, -399, 0, -19, |
| 1960 | 407, 9, -399, -399, -399, 113, -399, -399, -177, -307, |
| 1961 | -398, -399, -236, -399, -299, 7, -399, -212, -399, -399, |
| 1962 | -25, 263, -210, -399, 391, 398, -69, -109, -180, 179, |
| 1963 | -399, -399, 482, -399, -399, -399, -399, -399, -399, -399, |
| 1964 | -399, -399, -399, -399, 418, -399, -399, -399, -399, -399, |
| 1965 | -399, -369, -73, 100, -158, -399, 454, -399, -399, -399, |
| 1966 | -399, -399, 42, 137, -399, -399, -399, -399 |
| 1967 | }; |
| 1968 | |
| 1969 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 1970 | positive, shift that token. If negative, reduce the rule which |
| 1971 | number is the opposite. If zero, do what YYDEFACT says. |
| 1972 | If YYTABLE_NINF, syntax error. */ |
| 1973 | #define YYTABLE_NINF -176 |
| 1974 | static const short int yytable[] = |
| 1975 | { |
| 1976 | 11, 75, 376, 328, 191, 279, 281, 98, 296, 13, |
| 1977 | 198, 295, 114, 451, 295, 84, 11, 392, 23, 20, |
| 1978 | 422, 392, 338, 87, 104, 13, 105, 424, 329, 330, |
| 1979 | 297, 343, 326, 21, 24, -55, -55, 140, 60, 61, |
| 1980 | 192, 100, 63, 64, 65, 66, 102, 1, 2, 314, |
| 1981 | 3, 4, 1, 142, 143, 3, 302, 423, 137, 306, |
| 1982 | 307, 308, 309, 310, 423, 137, 313, 338, 348, 138, |
| 1983 | 129, 104, 338, 105, 102, 67, 237, 325, 344, 25, |
| 1984 | 129, 455, 141, 317, 318, 349, 11, 370, 510, 28, |
| 1985 | 29, 30, 31, 32, 33, 34, 196, 35, 342, 441, |
| 1986 | 391, 319, 320, 442, 388, 26, 317, 318, 234, 235, |
| 1987 | 60, 61, 238, 100, 63, 64, 65, 66, 532, 1, |
| 1988 | 2, 27, 3, 4, 319, 320, 79, 80, 60, 61, |
| 1989 | 199, 100, 108, 109, 110, 66, 40, 1, 2, 409, |
| 1990 | 3, 4, 529, 88, 546, 540, 99, 67, 317, 318, |
| 1991 | 77, 78, 517, 126, 144, 145, 518, 82, 390, 338, |
| 1992 | 127, 539, 496, 83, 497, 67, 319, 320, 68, 517, |
| 1993 | 403, 69, 545, 521, 70, 54, 71, 101, 348, 291, |
| 1994 | 392, 55, 416, 373, 104, 36, 105, 300, 301, 291, |
| 1995 | 303, 304, 291, 291, 291, 291, 291, 311, 312, 291, |
| 1996 | 56, 333, 334, 335, 336, 337, 288, 129, 46, 47, |
| 1997 | 48, 58, 338, 49, 345, 346, 347, 487, 365, 339, |
| 1998 | 365, 365, 428, 365, 430, 431, 432, 392, 84, 392, |
| 1999 | 365, 104, 191, 105, 1, 378, 91, 3, 365, 365, |
| 2000 | 68, 543, 92, 69, 375, 104, 70, 105, 71, 135, |
| 2001 | 315, 316, 104, 341, 105, 482, 106, 107, 68, 317, |
| 2002 | 318, 69, 394, 395, 70, 36, 71, 280, 192, 401, |
| 2003 | 93, 95, 196, 371, 372, 96, 391, 319, 320, 97, |
| 2004 | 133, 2, 534, 475, 4, 536, 42, 134, 43, 196, |
| 2005 | 389, 291, 293, -56, 104, 294, 105, 365, 365, 365, |
| 2006 | -57, 146, 194, 232, 233, 365, 230, 236, 500, 501, |
| 2007 | 502, 239, 270, 271, 272, 365, 365, 530, 273, 274, |
| 2008 | 317, 318, 282, 283, 284, 285, 286, 411, 443, 444, |
| 2009 | 445, 446, 289, 541, 295, 448, 449, 391, 319, 320, |
| 2010 | 115, 116, 117, 118, 119, 120, 327, 331, 379, 365, |
| 2011 | 332, 365, 352, 387, 365, 291, 429, 291, 291, 291, |
| 2012 | 365, 365, 435, 380, 381, 382, 383, 384, 397, 398, |
| 2013 | 473, 474, 399, 400, 404, 405, 406, 407, 408, 402, |
| 2014 | 414, 450, 417, 365, 365, 418, 365, 365, 427, 433, |
| 2015 | 434, 365, 438, 367, 368, 439, 369, 440, 452, 365, |
| 2016 | 447, 454, 456, 377, 453, 457, -175, 507, 458, 508, |
| 2017 | 509, 385, 386, 472, 459, 460, 291, 462, 365, -63, |
| 2018 | 1, 2, 477, 3, 4, 5, 365, 486, 441, 464, |
| 2019 | 466, 6, 7, 491, 467, 468, 471, 476, 513, 478, |
| 2020 | 479, 291, 291, 291, 488, 480, 491, 481, 495, 499, |
| 2021 | 8, 483, 515, 9, 505, 365, 506, 10, 423, 514, |
| 2022 | 365, 519, 526, 528, 522, 537, 523, 524, 544, 547, |
| 2023 | 419, 420, 421, 535, 365, 365, 548, 549, 426, 365, |
| 2024 | 552, 553, 365, 555, 298, 222, 223, 224, 436, 437, |
| 2025 | 299, 525, 533, 124, 511, 323, 139, 136, 41, 60, |
| 2026 | 61, 123, 100, 108, 109, 110, 66, 90, 1, 2, |
| 2027 | 483, 3, 4, 503, 425, 0, 0, 0, 0, 0, |
| 2028 | 0, 0, 461, 0, 463, 0, -174, 465, 0, 0, |
| 2029 | 0, 0, 0, 469, 470, 0, 67, 0, 0, -63, |
| 2030 | 1, 2, 0, 3, 4, 5, 0, 0, 0, 0, |
| 2031 | 0, 6, 7, 0, 0, 0, 489, 490, 0, 493, |
| 2032 | 494, 0, 0, 0, 498, 0, 0, 0, 0, 0, |
| 2033 | 8, 0, 504, 9, 0, 0, 0, 10, 242, 243, |
| 2034 | 244, 245, 246, 247, 248, 249, 250, 251, 0, 0, |
| 2035 | 0, 516, 0, 0, 0, 60, 61, 0, 0, 520, |
| 2036 | 0, 0, 0, 0, 1, 2, 0, 3, 4, 0, |
| 2037 | 147, 0, 253, 254, 0, 0, 0, 0, 0, 0, |
| 2038 | 0, 0, 0, 148, 149, 0, 0, 0, 538, 68, |
| 2039 | 0, 0, 69, 542, 0, 70, 0, 71, 340, 0, |
| 2040 | 0, 0, 0, 0, 0, 0, 0, 550, 551, 0, |
| 2041 | 0, 0, 554, 0, 0, 556, 150, 151, 152, 153, |
| 2042 | 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, |
| 2043 | 164, 165, 166, 0, 0, 0, 0, 0, 0, 0, |
| 2044 | 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 2045 | 265, 266, 267, 268, 0, 0, 0, 0, 167, 168, |
| 2046 | 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, |
| 2047 | 179, 0, 180, 0, 181, 182, 183, 0, 0, 0, |
| 2048 | 0, 0, 0, 0, 104, 0, 105, 0, 184, 0, |
| 2049 | 0, 185, 0, 186, 0, 187, 353, 354, 60, 61, |
| 2050 | 355, 0, 0, 0, 0, 0, 0, 1, 2, 0, |
| 2051 | 3, 4, 0, 356, 357, 358, 0, 0, 0, 0, |
| 2052 | 0, 0, 0, 0, 0, 0, 359, 360, 0, 0, |
| 2053 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2054 | 0, 60, 61, 361, 100, 108, 109, 110, 66, 0, |
| 2055 | 1, 2, 0, 3, 4, 0, 0, 0, 0, 150, |
| 2056 | 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, |
| 2057 | 161, 162, 163, 164, 165, 166, 0, 0, 67, 60, |
| 2058 | 61, 0, 62, 63, 64, 65, 66, 0, 1, 2, |
| 2059 | 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, |
| 2060 | 0, 167, 168, 169, 170, 171, 172, 173, 174, 175, |
| 2061 | 176, 177, 178, 179, 0, 180, 67, 181, 182, 183, |
| 2062 | 0, 353, 354, 60, 61, 355, 0, 104, 0, 105, |
| 2063 | 0, 0, 1, 2, 362, 3, 4, 0, 356, 357, |
| 2064 | 358, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2065 | 0, 359, 360, 0, 0, 0, 0, 0, 0, 0, |
| 2066 | 0, 0, 0, 0, 0, 0, 0, 0, 361, 0, |
| 2067 | 0, 68, 0, 0, 69, 0, 275, 70, 0, 71, |
| 2068 | 0, 0, 0, 0, 150, 151, 152, 153, 154, 155, |
| 2069 | 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, |
| 2070 | 166, 0, 0, 0, 0, 0, 0, 0, 0, 68, |
| 2071 | 0, 0, 69, 0, 0, 70, 0, 71, 0, 0, |
| 2072 | 0, 0, 0, 0, 0, 0, 167, 168, 169, 170, |
| 2073 | 171, 172, 173, 174, 175, 176, 177, 178, 179, 0, |
| 2074 | 180, 0, 181, 182, 183, 353, 354, 0, 0, 355, |
| 2075 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 362, |
| 2076 | 0, 0, 356, 357, 358, 0, 0, 0, 0, 0, |
| 2077 | 0, 0, 0, 0, 0, 359, 360, 0, 0, 0, |
| 2078 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2079 | 0, 0, 361, 0, 60, 61, 0, 100, 108, 109, |
| 2080 | 110, 66, 0, 1, 2, 0, 3, 4, 150, 151, |
| 2081 | 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, |
| 2082 | 162, 163, 164, 165, 166, 0, 0, 0, 0, 0, |
| 2083 | 0, 67, 0, 0, 0, 0, 60, 61, 0, 100, |
| 2084 | 63, 64, 65, 66, 0, 1, 2, 0, 3, 4, |
| 2085 | 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, |
| 2086 | 177, 178, 179, 128, 180, 0, 181, 182, 183, 0, |
| 2087 | 0, 0, 0, 67, 0, 60, 61, 0, 100, 63, |
| 2088 | 64, 65, 66, 362, 1, 2, 0, 3, 4, 0, |
| 2089 | 0, 60, 61, 0, 100, 63, 64, 65, 66, 0, |
| 2090 | 1, 2, 322, 3, 4, 0, 0, 0, 0, 0, |
| 2091 | 60, 61, 67, 100, 63, 64, 65, 66, 410, 1, |
| 2092 | 2, 0, 3, 4, 68, 0, 0, 69, 67, 0, |
| 2093 | 70, 0, 71, 0, 0, 0, 0, 485, 0, 60, |
| 2094 | 61, 0, 100, 63, 64, 65, 66, 67, 1, 2, |
| 2095 | 0, 3, 4, 0, 0, 60, 61, 0, 195, 63, |
| 2096 | 64, 65, 66, 0, 1, 2, 68, 3, 4, 69, |
| 2097 | 0, 0, 70, 0, 71, 0, 67, 60, 61, 0, |
| 2098 | 100, 108, 109, 110, 66, 0, 1, 2, 0, 3, |
| 2099 | 4, 0, 67, 0, 60, 61, 0, 290, 63, 64, |
| 2100 | 65, 66, 0, 1, 2, 68, 3, 4, 69, 0, |
| 2101 | 0, 70, 0, 71, 67, 0, 0, 0, 0, 0, |
| 2102 | 0, 68, 0, 0, 69, 0, 0, 70, 0, 71, |
| 2103 | 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2104 | 68, 0, 0, 69, 0, 0, 70, 0, 71, 0, |
| 2105 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2106 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, |
| 2107 | 0, 0, 69, 0, 0, 70, 0, 71, 0, 0, |
| 2108 | 0, 0, 0, 0, 0, 68, 0, 0, 69, 0, |
| 2109 | 0, 70, 0, 71, 0, 0, 0, 0, 0, 0, |
| 2110 | 0, 0, 0, 201, 0, 0, 0, 68, 0, 0, |
| 2111 | 69, 0, 0, 70, 0, 278, 0, 0, 0, 0, |
| 2112 | 0, 202, 203, 0, 68, 0, 0, 69, 0, 0, |
| 2113 | 70, 0, 71, 204, 205, 206, 207, 208, 209, 150, |
| 2114 | 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, |
| 2115 | 161, 162, 163, 164, 210, 211, 0, 0, 0, 0, |
| 2116 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2117 | 0, 0, 0, 0, 0, 0, 212, 213, 214, 0, |
| 2118 | 0, 215, 168, 169, 170, 171, 172, 173, 174, 175, |
| 2119 | 176, 177, 178, 179, 216, 217, 218, 219, 220, 221 |
| 2120 | }; |
| 2121 | |
| 2122 | static const short int yycheck[] = |
| 2123 | { |
| 2124 | 0, 26, 301, 239, 113, 185, 186, 4, 206, 0, |
| 2125 | 23, 9, 81, 411, 9, 16, 16, 324, 132, 45, |
| 2126 | 9, 328, 133, 24, 134, 16, 136, 9, 240, 241, |
| 2127 | 207, 142, 142, 59, 50, 3, 4, 106, 5, 6, |
| 2128 | 113, 8, 9, 10, 11, 12, 71, 14, 15, 226, |
| 2129 | 17, 18, 14, 21, 22, 17, 214, 46, 133, 217, |
| 2130 | 218, 219, 220, 221, 46, 133, 224, 133, 29, 144, |
| 2131 | 95, 134, 133, 136, 99, 42, 144, 140, 144, 132, |
| 2132 | 105, 142, 107, 110, 111, 46, 86, 297, 486, 35, |
| 2133 | 36, 37, 38, 39, 40, 41, 121, 43, 278, 133, |
| 2134 | 127, 128, 129, 137, 314, 13, 110, 111, 133, 134, |
| 2135 | 5, 6, 137, 8, 9, 10, 11, 12, 516, 14, |
| 2136 | 15, 132, 17, 18, 128, 129, 27, 28, 5, 6, |
| 2137 | 143, 8, 9, 10, 11, 12, 0, 14, 15, 351, |
| 2138 | 17, 18, 140, 144, 542, 140, 143, 42, 110, 111, |
| 2139 | 37, 38, 133, 133, 3, 4, 137, 44, 316, 133, |
| 2140 | 140, 530, 461, 50, 463, 42, 128, 129, 135, 133, |
| 2141 | 144, 138, 541, 137, 141, 132, 143, 144, 29, 204, |
| 2142 | 487, 132, 362, 133, 134, 131, 136, 212, 213, 214, |
| 2143 | 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, |
| 2144 | 138, 270, 271, 272, 273, 274, 197, 232, 35, 36, |
| 2145 | 37, 17, 133, 40, 283, 284, 285, 453, 291, 140, |
| 2146 | 293, 294, 380, 296, 382, 383, 384, 534, 16, 536, |
| 2147 | 303, 134, 341, 136, 14, 138, 17, 17, 311, 312, |
| 2148 | 135, 31, 17, 138, 133, 134, 141, 136, 143, 144, |
| 2149 | 106, 107, 134, 278, 136, 137, 77, 78, 135, 110, |
| 2150 | 111, 138, 331, 332, 141, 131, 143, 144, 341, 338, |
| 2151 | 17, 136, 297, 298, 299, 4, 127, 128, 129, 4, |
| 2152 | 139, 15, 518, 441, 18, 521, 39, 139, 41, 314, |
| 2153 | 315, 316, 9, 7, 134, 12, 136, 370, 371, 372, |
| 2154 | 7, 7, 4, 133, 137, 378, 17, 142, 466, 467, |
| 2155 | 468, 137, 136, 136, 136, 388, 389, 515, 136, 136, |
| 2156 | 110, 111, 17, 136, 136, 136, 133, 352, 397, 398, |
| 2157 | 399, 400, 48, 531, 9, 404, 405, 127, 128, 129, |
| 2158 | 53, 54, 55, 56, 57, 58, 142, 136, 133, 422, |
| 2159 | 136, 424, 136, 31, 427, 380, 381, 382, 383, 384, |
| 2160 | 433, 434, 387, 133, 133, 133, 133, 133, 133, 133, |
| 2161 | 439, 440, 133, 133, 133, 133, 31, 17, 4, 142, |
| 2162 | 52, 406, 133, 456, 457, 133, 459, 460, 138, 133, |
| 2163 | 133, 464, 133, 293, 294, 133, 296, 133, 133, 472, |
| 2164 | 142, 17, 12, 303, 137, 12, 0, 476, 136, 478, |
| 2165 | 479, 311, 312, 438, 133, 133, 441, 4, 491, 13, |
| 2166 | 14, 15, 137, 17, 18, 19, 499, 452, 133, 133, |
| 2167 | 133, 25, 26, 458, 133, 133, 136, 133, 17, 133, |
| 2168 | 133, 466, 467, 468, 133, 137, 471, 137, 133, 133, |
| 2169 | 44, 451, 138, 47, 137, 528, 137, 51, 46, 133, |
| 2170 | 533, 140, 46, 12, 137, 4, 137, 137, 133, 12, |
| 2171 | 370, 371, 372, 140, 547, 548, 12, 133, 378, 552, |
| 2172 | 12, 64, 555, 12, 210, 124, 124, 124, 388, 389, |
| 2173 | 211, 510, 517, 86, 487, 232, 105, 99, 16, 5, |
| 2174 | 6, 83, 8, 9, 10, 11, 12, 53, 14, 15, |
| 2175 | 510, 17, 18, 471, 377, -1, -1, -1, -1, -1, |
| 2176 | -1, -1, 422, -1, 424, -1, 0, 427, -1, -1, |
| 2177 | -1, -1, -1, 433, 434, -1, 42, -1, -1, 13, |
| 2178 | 14, 15, -1, 17, 18, 19, -1, -1, -1, -1, |
| 2179 | -1, 25, 26, -1, -1, -1, 456, 457, -1, 459, |
| 2180 | 460, -1, -1, -1, 464, -1, -1, -1, -1, -1, |
| 2181 | 44, -1, 472, 47, -1, -1, -1, 51, 83, 84, |
| 2182 | 85, 86, 87, 88, 89, 90, 91, 92, -1, -1, |
| 2183 | -1, 491, -1, -1, -1, 5, 6, -1, -1, 499, |
| 2184 | -1, -1, -1, -1, 14, 15, -1, 17, 18, -1, |
| 2185 | 20, -1, 21, 22, -1, -1, -1, -1, -1, -1, |
| 2186 | -1, -1, -1, 33, 34, -1, -1, -1, 528, 135, |
| 2187 | -1, -1, 138, 533, -1, 141, -1, 143, 144, -1, |
| 2188 | -1, -1, -1, -1, -1, -1, -1, 547, 548, -1, |
| 2189 | -1, -1, 552, -1, -1, 555, 66, 67, 68, 69, |
| 2190 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 2191 | 80, 81, 82, -1, -1, -1, -1, -1, -1, -1, |
| 2192 | 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, |
| 2193 | 99, 100, 101, 102, -1, -1, -1, -1, 108, 109, |
| 2194 | 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, |
| 2195 | 120, -1, 122, -1, 124, 125, 126, -1, -1, -1, |
| 2196 | -1, -1, -1, -1, 134, -1, 136, -1, 138, -1, |
| 2197 | -1, 141, -1, 143, -1, 145, 3, 4, 5, 6, |
| 2198 | 7, -1, -1, -1, -1, -1, -1, 14, 15, -1, |
| 2199 | 17, 18, -1, 20, 21, 22, -1, -1, -1, -1, |
| 2200 | -1, -1, -1, -1, -1, -1, 33, 34, -1, -1, |
| 2201 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2202 | -1, 5, 6, 50, 8, 9, 10, 11, 12, -1, |
| 2203 | 14, 15, -1, 17, 18, -1, -1, -1, -1, 66, |
| 2204 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 2205 | 77, 78, 79, 80, 81, 82, -1, -1, 42, 5, |
| 2206 | 6, -1, 8, 9, 10, 11, 12, -1, 14, 15, |
| 2207 | -1, 17, 18, -1, -1, -1, -1, -1, -1, -1, |
| 2208 | -1, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 2209 | 117, 118, 119, 120, -1, 122, 42, 124, 125, 126, |
| 2210 | -1, 3, 4, 5, 6, 7, -1, 134, -1, 136, |
| 2211 | -1, -1, 14, 15, 141, 17, 18, -1, 20, 21, |
| 2212 | 22, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2213 | -1, 33, 34, -1, -1, -1, -1, -1, -1, -1, |
| 2214 | -1, -1, -1, -1, -1, -1, -1, -1, 50, -1, |
| 2215 | -1, 135, -1, -1, 138, -1, 140, 141, -1, 143, |
| 2216 | -1, -1, -1, -1, 66, 67, 68, 69, 70, 71, |
| 2217 | 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, |
| 2218 | 82, -1, -1, -1, -1, -1, -1, -1, -1, 135, |
| 2219 | -1, -1, 138, -1, -1, 141, -1, 143, -1, -1, |
| 2220 | -1, -1, -1, -1, -1, -1, 108, 109, 110, 111, |
| 2221 | 112, 113, 114, 115, 116, 117, 118, 119, 120, -1, |
| 2222 | 122, -1, 124, 125, 126, 3, 4, -1, -1, 7, |
| 2223 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 141, |
| 2224 | -1, -1, 20, 21, 22, -1, -1, -1, -1, -1, |
| 2225 | -1, -1, -1, -1, -1, 33, 34, -1, -1, -1, |
| 2226 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2227 | -1, -1, 50, -1, 5, 6, -1, 8, 9, 10, |
| 2228 | 11, 12, -1, 14, 15, -1, 17, 18, 66, 67, |
| 2229 | 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 2230 | 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, |
| 2231 | -1, 42, -1, -1, -1, -1, 5, 6, -1, 8, |
| 2232 | 9, 10, 11, 12, -1, 14, 15, -1, 17, 18, |
| 2233 | 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, |
| 2234 | 118, 119, 120, 32, 122, -1, 124, 125, 126, -1, |
| 2235 | -1, -1, -1, 42, -1, 5, 6, -1, 8, 9, |
| 2236 | 10, 11, 12, 141, 14, 15, -1, 17, 18, -1, |
| 2237 | -1, 5, 6, -1, 8, 9, 10, 11, 12, -1, |
| 2238 | 14, 15, 32, 17, 18, -1, -1, -1, -1, -1, |
| 2239 | 5, 6, 42, 8, 9, 10, 11, 12, 32, 14, |
| 2240 | 15, -1, 17, 18, 135, -1, -1, 138, 42, -1, |
| 2241 | 141, -1, 143, -1, -1, -1, -1, 32, -1, 5, |
| 2242 | 6, -1, 8, 9, 10, 11, 12, 42, 14, 15, |
| 2243 | -1, 17, 18, -1, -1, 5, 6, -1, 8, 9, |
| 2244 | 10, 11, 12, -1, 14, 15, 135, 17, 18, 138, |
| 2245 | -1, -1, 141, -1, 143, -1, 42, 5, 6, -1, |
| 2246 | 8, 9, 10, 11, 12, -1, 14, 15, -1, 17, |
| 2247 | 18, -1, 42, -1, 5, 6, -1, 8, 9, 10, |
| 2248 | 11, 12, -1, 14, 15, 135, 17, 18, 138, -1, |
| 2249 | -1, 141, -1, 143, 42, -1, -1, -1, -1, -1, |
| 2250 | -1, 135, -1, -1, 138, -1, -1, 141, -1, 143, |
| 2251 | -1, 42, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2252 | 135, -1, -1, 138, -1, -1, 141, -1, 143, -1, |
| 2253 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2254 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 135, |
| 2255 | -1, -1, 138, -1, -1, 141, -1, 143, -1, -1, |
| 2256 | -1, -1, -1, -1, -1, 135, -1, -1, 138, -1, |
| 2257 | -1, 141, -1, 143, -1, -1, -1, -1, -1, -1, |
| 2258 | -1, -1, -1, 30, -1, -1, -1, 135, -1, -1, |
| 2259 | 138, -1, -1, 141, -1, 143, -1, -1, -1, -1, |
| 2260 | -1, 48, 49, -1, 135, -1, -1, 138, -1, -1, |
| 2261 | 141, -1, 143, 60, 61, 62, 63, 64, 65, 66, |
| 2262 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 2263 | 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, |
| 2264 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2265 | -1, -1, -1, -1, -1, -1, 103, 104, 105, -1, |
| 2266 | -1, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 2267 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 126 |
| 2268 | }; |
| 2269 | |
| 2270 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 2271 | symbol of state STATE-NUM. */ |
| 2272 | static const unsigned char yystos[] = |
| 2273 | { |
| 2274 | 0, 14, 15, 17, 18, 19, 25, 26, 44, 47, |
| 2275 | 51, 154, 156, 157, 158, 186, 187, 188, 190, 189, |
| 2276 | 45, 59, 195, 132, 50, 132, 13, 132, 35, 36, |
| 2277 | 37, 38, 39, 40, 41, 43, 131, 159, 160, 161, |
| 2278 | 0, 188, 39, 41, 162, 205, 35, 36, 37, 40, |
| 2279 | 163, 202, 204, 211, 132, 132, 138, 196, 17, 194, |
| 2280 | 5, 6, 8, 9, 10, 11, 12, 42, 135, 138, |
| 2281 | 141, 143, 154, 157, 175, 176, 208, 161, 161, 27, |
| 2282 | 28, 185, 161, 161, 16, 212, 213, 24, 144, 203, |
| 2283 | 212, 17, 17, 17, 197, 136, 4, 4, 4, 143, |
| 2284 | 8, 144, 176, 181, 134, 136, 185, 185, 9, 10, |
| 2285 | 11, 152, 153, 176, 182, 53, 54, 55, 56, 57, |
| 2286 | 58, 164, 200, 200, 156, 216, 133, 140, 32, 176, |
| 2287 | 177, 179, 180, 139, 139, 144, 181, 133, 144, 180, |
| 2288 | 182, 176, 21, 22, 3, 4, 7, 20, 33, 34, |
| 2289 | 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, |
| 2290 | 76, 77, 78, 79, 80, 81, 82, 108, 109, 110, |
| 2291 | 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, |
| 2292 | 122, 124, 125, 126, 138, 141, 143, 145, 147, 148, |
| 2293 | 149, 183, 208, 191, 4, 8, 176, 178, 23, 143, |
| 2294 | 201, 30, 48, 49, 60, 61, 62, 63, 64, 65, |
| 2295 | 81, 82, 103, 104, 105, 108, 121, 122, 123, 124, |
| 2296 | 125, 126, 147, 148, 149, 214, 220, 221, 222, 223, |
| 2297 | 17, 166, 133, 137, 176, 176, 142, 144, 176, 137, |
| 2298 | 192, 193, 83, 84, 85, 86, 87, 88, 89, 90, |
| 2299 | 91, 92, 150, 21, 22, 89, 90, 91, 92, 93, |
| 2300 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 151, |
| 2301 | 136, 136, 136, 136, 136, 140, 182, 184, 143, 184, |
| 2302 | 144, 184, 17, 136, 136, 136, 133, 173, 157, 48, |
| 2303 | 8, 176, 210, 9, 12, 9, 152, 164, 150, 151, |
| 2304 | 176, 176, 210, 176, 176, 217, 210, 210, 210, 210, |
| 2305 | 210, 176, 176, 210, 164, 106, 107, 110, 111, 128, |
| 2306 | 129, 165, 32, 177, 168, 140, 142, 142, 168, 173, |
| 2307 | 173, 136, 136, 182, 182, 182, 182, 182, 133, 140, |
| 2308 | 144, 176, 184, 142, 144, 182, 182, 182, 29, 46, |
| 2309 | 171, 174, 136, 3, 4, 7, 20, 21, 22, 33, |
| 2310 | 34, 50, 141, 183, 207, 208, 209, 209, 209, 209, |
| 2311 | 178, 176, 176, 133, 170, 133, 170, 209, 138, 133, |
| 2312 | 133, 133, 133, 133, 133, 209, 209, 31, 178, 176, |
| 2313 | 210, 127, 165, 167, 182, 182, 219, 133, 133, 133, |
| 2314 | 133, 182, 142, 144, 133, 133, 31, 17, 4, 173, |
| 2315 | 32, 176, 198, 199, 52, 206, 184, 133, 133, 209, |
| 2316 | 209, 209, 9, 46, 9, 219, 209, 138, 210, 176, |
| 2317 | 210, 210, 210, 133, 133, 176, 209, 209, 133, 133, |
| 2318 | 133, 133, 137, 182, 182, 182, 182, 142, 182, 182, |
| 2319 | 176, 166, 133, 137, 17, 142, 12, 12, 136, 133, |
| 2320 | 133, 209, 4, 209, 133, 209, 133, 133, 133, 209, |
| 2321 | 209, 136, 176, 182, 182, 210, 133, 137, 133, 133, |
| 2322 | 137, 137, 137, 154, 155, 32, 176, 168, 133, 209, |
| 2323 | 209, 176, 218, 209, 209, 133, 170, 170, 209, 133, |
| 2324 | 210, 210, 210, 218, 209, 137, 137, 182, 182, 182, |
| 2325 | 166, 171, 172, 17, 133, 138, 209, 133, 137, 140, |
| 2326 | 209, 137, 137, 137, 137, 155, 46, 169, 12, 140, |
| 2327 | 152, 215, 166, 176, 168, 140, 168, 4, 209, 207, |
| 2328 | 140, 152, 209, 31, 133, 207, 166, 12, 12, 133, |
| 2329 | 209, 209, 12, 64, 209, 12, 209 |
| 2330 | }; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2331 | |
| 2332 | #define yyerrok (yyerrstatus = 0) |
| 2333 | #define yyclearin (yychar = YYEMPTY) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2334 | #define YYEMPTY (-2) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2335 | #define YYEOF 0 |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2336 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2337 | #define YYACCEPT goto yyacceptlab |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2338 | #define YYABORT goto yyabortlab |
| 2339 | #define YYERROR goto yyerrorlab |
| 2340 | |
| 2341 | |
| 2342 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 2343 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2344 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2345 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2346 | #define YYFAIL goto yyerrlab |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2347 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2348 | #define YYRECOVERING() (!!yyerrstatus) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2349 | |
| 2350 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2351 | do \ |
| 2352 | if (yychar == YYEMPTY && yylen == 1) \ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2353 | { \ |
| 2354 | yychar = (Token); \ |
| 2355 | yylval = (Value); \ |
| 2356 | yytoken = YYTRANSLATE (yychar); \ |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2357 | YYPOPSTACK; \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2358 | goto yybackup; \ |
| 2359 | } \ |
| 2360 | else \ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2361 | { \ |
| 2362 | yyerror (YY_("syntax error: cannot back up")); \ |
| 2363 | YYERROR; \ |
| 2364 | } \ |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2365 | while (0) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2366 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2367 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2368 | #define YYTERROR 1 |
| 2369 | #define YYERRCODE 256 |
| 2370 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2371 | |
| 2372 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
| 2373 | If N is 0, then set CURRENT to the empty location which ends |
| 2374 | the previous symbol: RHS[0] (always defined). */ |
| 2375 | |
| 2376 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| 2377 | #ifndef YYLLOC_DEFAULT |
| 2378 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 2379 | do \ |
| 2380 | if (N) \ |
| 2381 | { \ |
| 2382 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
| 2383 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
| 2384 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
| 2385 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
| 2386 | } \ |
| 2387 | else \ |
| 2388 | { \ |
| 2389 | (Current).first_line = (Current).last_line = \ |
| 2390 | YYRHSLOC (Rhs, 0).last_line; \ |
| 2391 | (Current).first_column = (Current).last_column = \ |
| 2392 | YYRHSLOC (Rhs, 0).last_column; \ |
| 2393 | } \ |
| 2394 | while (0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2395 | #endif |
| 2396 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2397 | |
| 2398 | /* YY_LOCATION_PRINT -- Print the location on the stream. |
| 2399 | This macro was not mandated originally: define only if we know |
| 2400 | we won't break user code: when these are the locations we know. */ |
| 2401 | |
| 2402 | #ifndef YY_LOCATION_PRINT |
| 2403 | # if YYLTYPE_IS_TRIVIAL |
| 2404 | # define YY_LOCATION_PRINT(File, Loc) \ |
| 2405 | fprintf (File, "%d.%d-%d.%d", \ |
| 2406 | (Loc).first_line, (Loc).first_column, \ |
| 2407 | (Loc).last_line, (Loc).last_column) |
| 2408 | # else |
| 2409 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 2410 | # endif |
| 2411 | #endif |
| 2412 | |
| 2413 | |
| 2414 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 2415 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2416 | #ifdef YYLEX_PARAM |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2417 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2418 | #else |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2419 | # define YYLEX yylex () |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2420 | #endif |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2421 | |
| 2422 | /* Enable debugging if requested. */ |
| 2423 | #if YYDEBUG |
| 2424 | |
| 2425 | # ifndef YYFPRINTF |
| 2426 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 2427 | # define YYFPRINTF fprintf |
| 2428 | # endif |
| 2429 | |
| 2430 | # define YYDPRINTF(Args) \ |
| 2431 | do { \ |
| 2432 | if (yydebug) \ |
| 2433 | YYFPRINTF Args; \ |
| 2434 | } while (0) |
| 2435 | |
| 2436 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 2437 | do { \ |
| 2438 | if (yydebug) \ |
| 2439 | { \ |
| 2440 | YYFPRINTF (stderr, "%s ", Title); \ |
| 2441 | yysymprint (stderr, \ |
| 2442 | Type, Value); \ |
| 2443 | YYFPRINTF (stderr, "\n"); \ |
| 2444 | } \ |
| 2445 | } while (0) |
| 2446 | |
| 2447 | /*------------------------------------------------------------------. |
| 2448 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 2449 | | TOP (included). | |
| 2450 | `------------------------------------------------------------------*/ |
| 2451 | |
| 2452 | #if defined (__STDC__) || defined (__cplusplus) |
| 2453 | static void |
| 2454 | yy_stack_print (short int *bottom, short int *top) |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2455 | #else |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2456 | static void |
| 2457 | yy_stack_print (bottom, top) |
| 2458 | short int *bottom; |
| 2459 | short int *top; |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2460 | #endif |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2461 | { |
| 2462 | YYFPRINTF (stderr, "Stack now"); |
| 2463 | for (/* Nothing. */; bottom <= top; ++bottom) |
| 2464 | YYFPRINTF (stderr, " %d", *bottom); |
| 2465 | YYFPRINTF (stderr, "\n"); |
| 2466 | } |
| 2467 | |
| 2468 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 2469 | do { \ |
| 2470 | if (yydebug) \ |
| 2471 | yy_stack_print ((Bottom), (Top)); \ |
| 2472 | } while (0) |
| 2473 | |
| 2474 | |
| 2475 | /*------------------------------------------------. |
| 2476 | | Report that the YYRULE is going to be reduced. | |
| 2477 | `------------------------------------------------*/ |
| 2478 | |
| 2479 | #if defined (__STDC__) || defined (__cplusplus) |
| 2480 | static void |
| 2481 | yy_reduce_print (int yyrule) |
| 2482 | #else |
| 2483 | static void |
| 2484 | yy_reduce_print (yyrule) |
| 2485 | int yyrule; |
Chris Lattner | 8adde28 | 2007-02-11 21:40:10 +0000 | [diff] [blame] | 2486 | #endif |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2487 | { |
| 2488 | int yyi; |
| 2489 | unsigned long int yylno = yyrline[yyrule]; |
| 2490 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", |
| 2491 | yyrule - 1, yylno); |
| 2492 | /* Print the symbols being reduced, and their result. */ |
| 2493 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
| 2494 | YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); |
| 2495 | YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); |
| 2496 | } |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2497 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2498 | # define YY_REDUCE_PRINT(Rule) \ |
| 2499 | do { \ |
| 2500 | if (yydebug) \ |
| 2501 | yy_reduce_print (Rule); \ |
| 2502 | } while (0) |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2503 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2504 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 2505 | multiple parsers can coexist. */ |
| 2506 | int yydebug; |
| 2507 | #else /* !YYDEBUG */ |
| 2508 | # define YYDPRINTF(Args) |
| 2509 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
| 2510 | # define YY_STACK_PRINT(Bottom, Top) |
| 2511 | # define YY_REDUCE_PRINT(Rule) |
| 2512 | #endif /* !YYDEBUG */ |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2513 | |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2514 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2515 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2516 | #ifndef YYINITDEPTH |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2517 | # define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2518 | #endif |
| 2519 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2520 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 2521 | if the built-in stack extension method is used). |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2522 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2523 | Do not make this value too large; the results are undefined if |
| 2524 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
| 2525 | evaluated with infinite-precision integer arithmetic. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2526 | |
| 2527 | #ifndef YYMAXDEPTH |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2528 | # define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2529 | #endif |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2530 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2531 | |
| 2532 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2533 | #if YYERROR_VERBOSE |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2534 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2535 | # ifndef yystrlen |
| 2536 | # if defined (__GLIBC__) && defined (_STRING_H) |
| 2537 | # define yystrlen strlen |
| 2538 | # else |
| 2539 | /* Return the length of YYSTR. */ |
| 2540 | static YYSIZE_T |
| 2541 | # if defined (__STDC__) || defined (__cplusplus) |
| 2542 | yystrlen (const char *yystr) |
| 2543 | # else |
| 2544 | yystrlen (yystr) |
| 2545 | const char *yystr; |
| 2546 | # endif |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2547 | { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2548 | const char *yys = yystr; |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2549 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2550 | while (*yys++ != '\0') |
| 2551 | continue; |
| 2552 | |
| 2553 | return yys - yystr - 1; |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2554 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2555 | # endif |
| 2556 | # endif |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2557 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2558 | # ifndef yystpcpy |
| 2559 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
| 2560 | # define yystpcpy stpcpy |
| 2561 | # else |
| 2562 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 2563 | YYDEST. */ |
| 2564 | static char * |
| 2565 | # if defined (__STDC__) || defined (__cplusplus) |
| 2566 | yystpcpy (char *yydest, const char *yysrc) |
| 2567 | # else |
| 2568 | yystpcpy (yydest, yysrc) |
| 2569 | char *yydest; |
| 2570 | const char *yysrc; |
| 2571 | # endif |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2572 | { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2573 | char *yyd = yydest; |
| 2574 | const char *yys = yysrc; |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2575 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2576 | while ((*yyd++ = *yys++) != '\0') |
| 2577 | continue; |
| 2578 | |
| 2579 | return yyd - 1; |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2580 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2581 | # endif |
| 2582 | # endif |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2583 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2584 | # ifndef yytnamerr |
| 2585 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
| 2586 | quotes and backslashes, so that it's suitable for yyerror. The |
| 2587 | heuristic is that double-quoting is unnecessary unless the string |
| 2588 | contains an apostrophe, a comma, or backslash (other than |
| 2589 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
| 2590 | null, do not copy; instead, return the length of what the result |
| 2591 | would have been. */ |
| 2592 | static YYSIZE_T |
| 2593 | yytnamerr (char *yyres, const char *yystr) |
| 2594 | { |
| 2595 | if (*yystr == '"') |
| 2596 | { |
| 2597 | size_t yyn = 0; |
| 2598 | char const *yyp = yystr; |
| 2599 | |
| 2600 | for (;;) |
| 2601 | switch (*++yyp) |
| 2602 | { |
| 2603 | case '\'': |
| 2604 | case ',': |
| 2605 | goto do_not_strip_quotes; |
| 2606 | |
| 2607 | case '\\': |
| 2608 | if (*++yyp != '\\') |
| 2609 | goto do_not_strip_quotes; |
| 2610 | /* Fall through. */ |
| 2611 | default: |
| 2612 | if (yyres) |
| 2613 | yyres[yyn] = *yyp; |
| 2614 | yyn++; |
| 2615 | break; |
| 2616 | |
| 2617 | case '"': |
| 2618 | if (yyres) |
| 2619 | yyres[yyn] = '\0'; |
| 2620 | return yyn; |
| 2621 | } |
| 2622 | do_not_strip_quotes: ; |
| 2623 | } |
| 2624 | |
| 2625 | if (! yyres) |
| 2626 | return yystrlen (yystr); |
| 2627 | |
| 2628 | return yystpcpy (yyres, yystr) - yyres; |
| 2629 | } |
| 2630 | # endif |
| 2631 | |
| 2632 | #endif /* YYERROR_VERBOSE */ |
| 2633 | |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2634 | |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2635 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2636 | #if YYDEBUG |
| 2637 | /*--------------------------------. |
| 2638 | | Print this symbol on YYOUTPUT. | |
| 2639 | `--------------------------------*/ |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2640 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2641 | #if defined (__STDC__) || defined (__cplusplus) |
| 2642 | static void |
| 2643 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2644 | #else |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2645 | static void |
| 2646 | yysymprint (yyoutput, yytype, yyvaluep) |
| 2647 | FILE *yyoutput; |
| 2648 | int yytype; |
| 2649 | YYSTYPE *yyvaluep; |
| 2650 | #endif |
| 2651 | { |
| 2652 | /* Pacify ``unused variable'' warnings. */ |
| 2653 | (void) yyvaluep; |
| 2654 | |
| 2655 | if (yytype < YYNTOKENS) |
| 2656 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 2657 | else |
| 2658 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 2659 | |
| 2660 | |
| 2661 | # ifdef YYPRINT |
| 2662 | if (yytype < YYNTOKENS) |
| 2663 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 2664 | # endif |
| 2665 | switch (yytype) |
| 2666 | { |
| 2667 | default: |
| 2668 | break; |
| 2669 | } |
| 2670 | YYFPRINTF (yyoutput, ")"); |
| 2671 | } |
| 2672 | |
| 2673 | #endif /* ! YYDEBUG */ |
| 2674 | /*-----------------------------------------------. |
| 2675 | | Release the memory associated to this symbol. | |
| 2676 | `-----------------------------------------------*/ |
| 2677 | |
| 2678 | #if defined (__STDC__) || defined (__cplusplus) |
| 2679 | static void |
| 2680 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
| 2681 | #else |
| 2682 | static void |
| 2683 | yydestruct (yymsg, yytype, yyvaluep) |
| 2684 | const char *yymsg; |
| 2685 | int yytype; |
| 2686 | YYSTYPE *yyvaluep; |
| 2687 | #endif |
| 2688 | { |
| 2689 | /* Pacify ``unused variable'' warnings. */ |
| 2690 | (void) yyvaluep; |
| 2691 | |
| 2692 | if (!yymsg) |
| 2693 | yymsg = "Deleting"; |
| 2694 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 2695 | |
| 2696 | switch (yytype) |
| 2697 | { |
| 2698 | |
| 2699 | default: |
| 2700 | break; |
| 2701 | } |
| 2702 | } |
| 2703 | |
| 2704 | |
| 2705 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 2706 | |
| 2707 | #ifdef YYPARSE_PARAM |
| 2708 | # if defined (__STDC__) || defined (__cplusplus) |
| 2709 | int yyparse (void *YYPARSE_PARAM); |
| 2710 | # else |
| 2711 | int yyparse (); |
| 2712 | # endif |
| 2713 | #else /* ! YYPARSE_PARAM */ |
| 2714 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 2715 | int yyparse (void); |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2716 | #else |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2717 | int yyparse (); |
| 2718 | #endif |
| 2719 | #endif /* ! YYPARSE_PARAM */ |
| 2720 | |
| 2721 | |
| 2722 | |
| 2723 | /* The look-ahead symbol. */ |
| 2724 | int yychar; |
| 2725 | |
| 2726 | /* The semantic value of the look-ahead symbol. */ |
| 2727 | YYSTYPE yylval; |
| 2728 | |
| 2729 | /* Number of syntax errors so far. */ |
| 2730 | int yynerrs; |
| 2731 | |
| 2732 | |
| 2733 | |
| 2734 | /*----------. |
| 2735 | | yyparse. | |
| 2736 | `----------*/ |
| 2737 | |
| 2738 | #ifdef YYPARSE_PARAM |
| 2739 | # if defined (__STDC__) || defined (__cplusplus) |
| 2740 | int yyparse (void *YYPARSE_PARAM) |
| 2741 | # else |
| 2742 | int yyparse (YYPARSE_PARAM) |
| 2743 | void *YYPARSE_PARAM; |
| 2744 | # endif |
| 2745 | #else /* ! YYPARSE_PARAM */ |
| 2746 | #if defined (__STDC__) || defined (__cplusplus) |
| 2747 | int |
| 2748 | yyparse (void) |
| 2749 | #else |
| 2750 | int |
| 2751 | yyparse () |
| 2752 | |
| 2753 | #endif |
| 2754 | #endif |
| 2755 | { |
| 2756 | |
| 2757 | int yystate; |
| 2758 | int yyn; |
| 2759 | int yyresult; |
| 2760 | /* Number of tokens to shift before error messages enabled. */ |
| 2761 | int yyerrstatus; |
| 2762 | /* Look-ahead token as an internal (translated) token number. */ |
| 2763 | int yytoken = 0; |
| 2764 | |
| 2765 | /* Three stacks and their tools: |
| 2766 | `yyss': related to states, |
| 2767 | `yyvs': related to semantic values, |
| 2768 | `yyls': related to locations. |
| 2769 | |
| 2770 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 2771 | to reallocate them elsewhere. */ |
| 2772 | |
| 2773 | /* The state stack. */ |
| 2774 | short int yyssa[YYINITDEPTH]; |
| 2775 | short int *yyss = yyssa; |
| 2776 | short int *yyssp; |
| 2777 | |
| 2778 | /* The semantic value stack. */ |
| 2779 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 2780 | YYSTYPE *yyvs = yyvsa; |
| 2781 | YYSTYPE *yyvsp; |
| 2782 | |
| 2783 | |
| 2784 | |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2785 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2786 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2787 | YYSIZE_T yystacksize = YYINITDEPTH; |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2788 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2789 | /* The variables used to return semantic value and location from the |
| 2790 | action routines. */ |
| 2791 | YYSTYPE yyval; |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2792 | |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2793 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2794 | /* When reducing, the number of symbols on the RHS of the reduced |
| 2795 | rule. */ |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2796 | int yylen; |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2797 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2798 | YYDPRINTF ((stderr, "Starting parse\n")); |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2799 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2800 | yystate = 0; |
| 2801 | yyerrstatus = 0; |
| 2802 | yynerrs = 0; |
| 2803 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2804 | |
| 2805 | /* Initialize stack pointers. |
| 2806 | Waste one element of value and location stack |
| 2807 | so that they stay on the same level as the state stack. |
| 2808 | The wasted elements are never initialized. */ |
| 2809 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2810 | yyssp = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2811 | yyvsp = yyvs; |
| 2812 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2813 | goto yysetstate; |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2814 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2815 | /*------------------------------------------------------------. |
| 2816 | | yynewstate -- Push a new state, which is found in yystate. | |
| 2817 | `------------------------------------------------------------*/ |
| 2818 | yynewstate: |
| 2819 | /* In all cases, when you get here, the value and location stacks |
| 2820 | have just been pushed. so pushing a state here evens the stacks. |
| 2821 | */ |
| 2822 | yyssp++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2823 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2824 | yysetstate: |
| 2825 | *yyssp = yystate; |
| 2826 | |
| 2827 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2828 | { |
| 2829 | /* Get the current used size of the three stacks, in elements. */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2830 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2831 | |
| 2832 | #ifdef yyoverflow |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2833 | { |
| 2834 | /* Give user a chance to reallocate the stack. Use copies of |
| 2835 | these so that the &'s don't force the real ones into |
| 2836 | memory. */ |
| 2837 | YYSTYPE *yyvs1 = yyvs; |
| 2838 | short int *yyss1 = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2839 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2840 | |
| 2841 | /* Each stack pointer address is followed by the size of the |
| 2842 | data in use in that stack, in bytes. This used to be a |
| 2843 | conditional around just the two extra args, but that might |
| 2844 | be undefined if yyoverflow is a macro. */ |
| 2845 | yyoverflow (YY_("memory exhausted"), |
| 2846 | &yyss1, yysize * sizeof (*yyssp), |
| 2847 | &yyvs1, yysize * sizeof (*yyvsp), |
| 2848 | |
| 2849 | &yystacksize); |
| 2850 | |
| 2851 | yyss = yyss1; |
| 2852 | yyvs = yyvs1; |
| 2853 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2854 | #else /* no yyoverflow */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2855 | # ifndef YYSTACK_RELOCATE |
| 2856 | goto yyexhaustedlab; |
| 2857 | # else |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2858 | /* Extend the stack our own way. */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2859 | if (YYMAXDEPTH <= yystacksize) |
| 2860 | goto yyexhaustedlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2861 | yystacksize *= 2; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2862 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2863 | yystacksize = YYMAXDEPTH; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2864 | |
| 2865 | { |
| 2866 | short int *yyss1 = yyss; |
| 2867 | union yyalloc *yyptr = |
| 2868 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 2869 | if (! yyptr) |
| 2870 | goto yyexhaustedlab; |
| 2871 | YYSTACK_RELOCATE (yyss); |
| 2872 | YYSTACK_RELOCATE (yyvs); |
| 2873 | |
| 2874 | # undef YYSTACK_RELOCATE |
| 2875 | if (yyss1 != yyssa) |
| 2876 | YYSTACK_FREE (yyss1); |
| 2877 | } |
| 2878 | # endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2879 | #endif /* no yyoverflow */ |
| 2880 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2881 | yyssp = yyss + yysize - 1; |
| 2882 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2883 | |
| 2884 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2885 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 2886 | (unsigned long int) yystacksize)); |
| 2887 | |
| 2888 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2889 | YYABORT; |
| 2890 | } |
| 2891 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2892 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2893 | |
| 2894 | goto yybackup; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2895 | |
| 2896 | /*-----------. |
| 2897 | | yybackup. | |
| 2898 | `-----------*/ |
| 2899 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2900 | |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2901 | /* Do appropriate processing given the current state. */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2902 | /* Read a look-ahead token if we need one and don't already have one. */ |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2903 | /* yyresume: */ |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 2904 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2905 | /* First try to decide what to do without reference to look-ahead token. */ |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2906 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2907 | yyn = yypact[yystate]; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2908 | if (yyn == YYPACT_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2909 | goto yydefault; |
| 2910 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2911 | /* 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] | 2912 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2913 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2914 | if (yychar == YYEMPTY) |
| 2915 | { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2916 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2917 | yychar = YYLEX; |
| 2918 | } |
| 2919 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2920 | if (yychar <= YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2921 | { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2922 | yychar = yytoken = YYEOF; |
| 2923 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2924 | } |
| 2925 | else |
| 2926 | { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2927 | yytoken = YYTRANSLATE (yychar); |
| 2928 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2929 | } |
| 2930 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2931 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 2932 | detect an error, take that action. */ |
| 2933 | yyn += yytoken; |
| 2934 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2935 | goto yydefault; |
| 2936 | yyn = yytable[yyn]; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2937 | if (yyn <= 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2938 | { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2939 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2940 | goto yyerrlab; |
| 2941 | yyn = -yyn; |
| 2942 | goto yyreduce; |
| 2943 | } |
| 2944 | |
| 2945 | if (yyn == YYFINAL) |
| 2946 | YYACCEPT; |
| 2947 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2948 | /* Shift the look-ahead token. */ |
| 2949 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2950 | |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2951 | /* Discard the token being shifted unless it is eof. */ |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2952 | if (yychar != YYEOF) |
| 2953 | yychar = YYEMPTY; |
| 2954 | |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 2955 | *++yyvsp = yylval; |
| 2956 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2957 | |
| 2958 | /* Count tokens shifted since error; after three, turn off error |
| 2959 | status. */ |
| 2960 | if (yyerrstatus) |
| 2961 | yyerrstatus--; |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2962 | |
| 2963 | yystate = yyn; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2964 | goto yynewstate; |
| 2965 | |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 2966 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2967 | /*-----------------------------------------------------------. |
| 2968 | | yydefault -- do the default action for the current state. | |
| 2969 | `-----------------------------------------------------------*/ |
| 2970 | yydefault: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2971 | yyn = yydefact[yystate]; |
| 2972 | if (yyn == 0) |
| 2973 | goto yyerrlab; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2974 | goto yyreduce; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2975 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2976 | |
| 2977 | /*-----------------------------. |
| 2978 | | yyreduce -- Do a reduction. | |
| 2979 | `-----------------------------*/ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2980 | yyreduce: |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2981 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2982 | yylen = yyr2[yyn]; |
| 2983 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2984 | /* If YYLEN is nonzero, implement the default value of the action: |
| 2985 | `$$ = $1'. |
| 2986 | |
| 2987 | Otherwise, the following line sets YYVAL to garbage. |
| 2988 | This behavior is undocumented and Bison |
| 2989 | users should not rely upon it. Assigning to YYVAL |
| 2990 | unconditionally makes the parser a bit smaller, and it avoids a |
| 2991 | GCC warning that YYVAL may be used uninitialized. */ |
| 2992 | yyval = yyvsp[1-yylen]; |
| 2993 | |
| 2994 | |
| 2995 | YY_REDUCE_PRINT (yyn); |
| 2996 | switch (yyn) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2997 | { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 2998 | case 29: |
| 2999 | #line 1054 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3000 | { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;} |
| 3001 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3002 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3003 | case 30: |
| 3004 | #line 1054 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3005 | { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;} |
| 3006 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3007 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3008 | case 31: |
| 3009 | #line 1055 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3010 | { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;} |
| 3011 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3012 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3013 | case 32: |
| 3014 | #line 1055 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3015 | { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;} |
| 3016 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3017 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3018 | case 33: |
| 3019 | #line 1056 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3020 | { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;} |
| 3021 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3022 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3023 | case 34: |
| 3024 | #line 1056 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3025 | { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;} |
| 3026 | break; |
| 3027 | |
| 3028 | case 35: |
| 3029 | #line 1057 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3030 | { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;} |
| 3031 | break; |
| 3032 | |
| 3033 | case 36: |
| 3034 | #line 1057 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3035 | { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;} |
| 3036 | break; |
| 3037 | |
| 3038 | case 37: |
| 3039 | #line 1058 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3040 | { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;} |
| 3041 | break; |
| 3042 | |
| 3043 | case 38: |
| 3044 | #line 1058 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3045 | { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;} |
| 3046 | break; |
| 3047 | |
| 3048 | case 39: |
| 3049 | #line 1062 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3050 | { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;} |
| 3051 | break; |
| 3052 | |
| 3053 | case 40: |
| 3054 | #line 1062 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3055 | { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;} |
| 3056 | break; |
| 3057 | |
| 3058 | case 41: |
| 3059 | #line 1063 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3060 | { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;} |
| 3061 | break; |
| 3062 | |
| 3063 | case 42: |
| 3064 | #line 1063 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3065 | { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;} |
| 3066 | break; |
| 3067 | |
| 3068 | case 43: |
| 3069 | #line 1064 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3070 | { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;} |
| 3071 | break; |
| 3072 | |
| 3073 | case 44: |
| 3074 | #line 1064 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3075 | { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;} |
| 3076 | break; |
| 3077 | |
| 3078 | case 45: |
| 3079 | #line 1065 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3080 | { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;} |
| 3081 | break; |
| 3082 | |
| 3083 | case 46: |
| 3084 | #line 1065 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3085 | { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;} |
| 3086 | break; |
| 3087 | |
| 3088 | case 47: |
| 3089 | #line 1066 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3090 | { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;} |
| 3091 | break; |
| 3092 | |
| 3093 | case 48: |
| 3094 | #line 1066 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3095 | { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;} |
| 3096 | break; |
| 3097 | |
| 3098 | case 49: |
| 3099 | #line 1067 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3100 | { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;} |
| 3101 | break; |
| 3102 | |
| 3103 | case 50: |
| 3104 | #line 1067 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3105 | { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;} |
| 3106 | break; |
| 3107 | |
| 3108 | case 51: |
| 3109 | #line 1068 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3110 | { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;} |
| 3111 | break; |
| 3112 | |
| 3113 | case 52: |
| 3114 | #line 1068 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3115 | { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;} |
| 3116 | break; |
| 3117 | |
| 3118 | case 53: |
| 3119 | #line 1069 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3120 | { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;} |
| 3121 | break; |
| 3122 | |
| 3123 | case 54: |
| 3124 | #line 1070 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3125 | { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;} |
| 3126 | break; |
| 3127 | |
| 3128 | case 61: |
| 3129 | #line 1079 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3130 | { (yyval.StrVal) = 0; ;} |
| 3131 | break; |
| 3132 | |
| 3133 | case 62: |
| 3134 | #line 1083 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3135 | { |
| 3136 | (yyval.StrVal) = (yyvsp[-1].StrVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3137 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3138 | ;} |
| 3139 | break; |
| 3140 | |
| 3141 | case 63: |
| 3142 | #line 1087 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3143 | { |
| 3144 | (yyval.StrVal) = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3145 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3146 | ;} |
| 3147 | break; |
| 3148 | |
| 3149 | case 66: |
| 3150 | #line 1094 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3151 | { |
| 3152 | (yyval.StrVal) = (yyvsp[-1].StrVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3153 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3154 | ;} |
| 3155 | break; |
| 3156 | |
| 3157 | case 67: |
| 3158 | #line 1098 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3159 | { |
| 3160 | (yyval.StrVal) = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3161 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3162 | ;} |
| 3163 | break; |
| 3164 | |
| 3165 | case 68: |
| 3166 | #line 1104 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3167 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3168 | break; |
| 3169 | |
| 3170 | case 69: |
| 3171 | #line 1105 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3172 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3173 | break; |
| 3174 | |
| 3175 | case 70: |
| 3176 | #line 1106 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3177 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 3178 | break; |
| 3179 | |
| 3180 | case 71: |
| 3181 | #line 1107 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3182 | { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} |
| 3183 | break; |
| 3184 | |
| 3185 | case 72: |
| 3186 | #line 1108 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3187 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 3188 | break; |
| 3189 | |
| 3190 | case 73: |
| 3191 | #line 1112 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3192 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 3193 | break; |
| 3194 | |
| 3195 | case 74: |
| 3196 | #line 1113 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3197 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 3198 | break; |
| 3199 | |
| 3200 | case 75: |
| 3201 | #line 1114 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3202 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3203 | break; |
| 3204 | |
| 3205 | case 76: |
| 3206 | #line 1118 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3207 | { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;} |
| 3208 | break; |
| 3209 | |
| 3210 | case 77: |
| 3211 | #line 1119 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3212 | { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;} |
| 3213 | break; |
| 3214 | |
| 3215 | case 78: |
| 3216 | #line 1123 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3217 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3218 | break; |
| 3219 | |
| 3220 | case 79: |
| 3221 | #line 1124 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3222 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 3223 | break; |
| 3224 | |
| 3225 | case 80: |
| 3226 | #line 1125 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3227 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 3228 | break; |
| 3229 | |
| 3230 | case 81: |
| 3231 | #line 1129 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3232 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3233 | break; |
| 3234 | |
| 3235 | case 82: |
| 3236 | #line 1130 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3237 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3238 | break; |
| 3239 | |
| 3240 | case 83: |
| 3241 | #line 1131 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3242 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 3243 | break; |
| 3244 | |
| 3245 | case 84: |
| 3246 | #line 1132 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3247 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3248 | break; |
| 3249 | |
| 3250 | case 85: |
| 3251 | #line 1133 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3252 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 3253 | break; |
| 3254 | |
| 3255 | case 86: |
| 3256 | #line 1136 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3257 | { (yyval.UIntVal) = CallingConv::C; ;} |
| 3258 | break; |
| 3259 | |
| 3260 | case 87: |
| 3261 | #line 1137 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3262 | { (yyval.UIntVal) = CallingConv::C; ;} |
| 3263 | break; |
| 3264 | |
| 3265 | case 88: |
| 3266 | #line 1138 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3267 | { (yyval.UIntVal) = CallingConv::Fast; ;} |
| 3268 | break; |
| 3269 | |
| 3270 | case 89: |
| 3271 | #line 1139 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3272 | { (yyval.UIntVal) = CallingConv::Cold; ;} |
| 3273 | break; |
| 3274 | |
| 3275 | case 90: |
| 3276 | #line 1140 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3277 | { (yyval.UIntVal) = CallingConv::X86_StdCall; ;} |
| 3278 | break; |
| 3279 | |
| 3280 | case 91: |
| 3281 | #line 1141 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3282 | { (yyval.UIntVal) = CallingConv::X86_FastCall; ;} |
| 3283 | break; |
| 3284 | |
| 3285 | case 92: |
| 3286 | #line 1142 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3287 | { |
| 3288 | if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3289 | GEN_ERROR("Calling conv too large"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3290 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3291 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3292 | ;} |
| 3293 | break; |
| 3294 | |
| 3295 | case 93: |
| 3296 | #line 1149 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3297 | { (yyval.ParamAttrs) = FunctionType::ZExtAttribute; ;} |
| 3298 | break; |
| 3299 | |
| 3300 | case 94: |
| 3301 | #line 1150 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3302 | { (yyval.ParamAttrs) = FunctionType::SExtAttribute; ;} |
| 3303 | break; |
| 3304 | |
| 3305 | case 95: |
| 3306 | #line 1151 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3307 | { (yyval.ParamAttrs) = FunctionType::InRegAttribute; ;} |
| 3308 | break; |
| 3309 | |
| 3310 | case 96: |
| 3311 | #line 1152 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3312 | { (yyval.ParamAttrs) = FunctionType::StructRetAttribute; ;} |
| 3313 | break; |
| 3314 | |
| 3315 | case 97: |
| 3316 | #line 1155 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3317 | { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;} |
| 3318 | break; |
| 3319 | |
| 3320 | case 98: |
| 3321 | #line 1156 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3322 | { |
| 3323 | (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs)); |
| 3324 | ;} |
| 3325 | break; |
| 3326 | |
| 3327 | case 99: |
| 3328 | #line 1161 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3329 | { (yyval.ParamAttrs) = FunctionType::NoReturnAttribute; ;} |
| 3330 | break; |
| 3331 | |
| 3332 | case 101: |
| 3333 | #line 1165 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3334 | { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;} |
| 3335 | break; |
| 3336 | |
| 3337 | case 102: |
| 3338 | #line 1166 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3339 | { |
| 3340 | (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs)); |
| 3341 | ;} |
| 3342 | break; |
| 3343 | |
| 3344 | case 103: |
| 3345 | #line 1173 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3346 | { (yyval.UIntVal) = 0; ;} |
| 3347 | break; |
| 3348 | |
| 3349 | case 104: |
| 3350 | #line 1174 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3351 | { |
| 3352 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 3353 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3354 | GEN_ERROR("Alignment must be a power of two"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3355 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3356 | ;} |
| 3357 | break; |
| 3358 | |
| 3359 | case 105: |
| 3360 | #line 1180 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3361 | { (yyval.UIntVal) = 0; ;} |
| 3362 | break; |
| 3363 | |
| 3364 | case 106: |
| 3365 | #line 1181 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3366 | { |
| 3367 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 3368 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3369 | GEN_ERROR("Alignment must be a power of two"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3370 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3371 | ;} |
| 3372 | break; |
| 3373 | |
| 3374 | case 107: |
| 3375 | #line 1189 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3376 | { |
| 3377 | for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) |
| 3378 | if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3379 | GEN_ERROR("Invalid character in section name"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3380 | (yyval.StrVal) = (yyvsp[0].StrVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3381 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3382 | ;} |
| 3383 | break; |
| 3384 | |
| 3385 | case 108: |
| 3386 | #line 1197 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3387 | { (yyval.StrVal) = 0; ;} |
| 3388 | break; |
| 3389 | |
| 3390 | case 109: |
| 3391 | #line 1198 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3392 | { (yyval.StrVal) = (yyvsp[0].StrVal); ;} |
| 3393 | break; |
| 3394 | |
| 3395 | case 110: |
| 3396 | #line 1203 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3397 | {;} |
| 3398 | break; |
| 3399 | |
| 3400 | case 111: |
| 3401 | #line 1204 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3402 | {;} |
| 3403 | break; |
| 3404 | |
| 3405 | case 112: |
| 3406 | #line 1205 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3407 | { |
| 3408 | CurGV->setSection((yyvsp[0].StrVal)); |
| 3409 | free((yyvsp[0].StrVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3410 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3411 | ;} |
| 3412 | break; |
| 3413 | |
| 3414 | case 113: |
| 3415 | #line 1210 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3416 | { |
| 3417 | if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3418 | GEN_ERROR("Alignment must be a power of two"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3419 | CurGV->setAlignment((yyvsp[0].UInt64Val)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3420 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3421 | ;} |
| 3422 | break; |
| 3423 | |
| 3424 | case 118: |
| 3425 | #line 1226 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3426 | { |
| 3427 | (yyval.TypeVal) = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3428 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3429 | ;} |
| 3430 | break; |
| 3431 | |
| 3432 | case 119: |
| 3433 | #line 1230 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3434 | { |
| 3435 | (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3436 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3437 | ;} |
| 3438 | break; |
| 3439 | |
| 3440 | case 120: |
| 3441 | #line 1234 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3442 | { // Pointer type? |
| 3443 | if (*(yyvsp[-1].TypeVal) == Type::LabelTy) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3444 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3445 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal)))); |
| 3446 | delete (yyvsp[-1].TypeVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3447 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3448 | ;} |
| 3449 | break; |
| 3450 | |
| 3451 | case 121: |
| 3452 | #line 1241 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3453 | { // Named types are also simple types... |
| 3454 | const Type* tmp = getTypeVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3455 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3456 | (yyval.TypeVal) = new PATypeHolder(tmp); |
| 3457 | ;} |
| 3458 | break; |
| 3459 | |
| 3460 | case 122: |
| 3461 | #line 1246 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3462 | { // Type UpReference |
| 3463 | if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3464 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3465 | UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector... |
| 3466 | (yyval.TypeVal) = new PATypeHolder(OT); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3467 | UR_OUT("New Upreference!\n"); |
| 3468 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3469 | ;} |
| 3470 | break; |
| 3471 | |
| 3472 | case 123: |
| 3473 | #line 1254 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3474 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3475 | std::vector<const Type*> Params; |
| 3476 | std::vector<FunctionType::ParameterAttributes> Attrs; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3477 | Attrs.push_back((yyvsp[0].ParamAttrs)); |
| 3478 | for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3479 | Params.push_back(I->Ty->get()); |
| 3480 | if (I->Ty->get() != Type::VoidTy) |
| 3481 | Attrs.push_back(I->Attrs); |
| 3482 | } |
| 3483 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3484 | if (isVarArg) Params.pop_back(); |
| 3485 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3486 | FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, Attrs); |
| 3487 | delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list |
| 3488 | delete (yyvsp[-4].TypeVal); // Delete the return type handle |
| 3489 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3490 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3491 | ;} |
| 3492 | break; |
| 3493 | |
| 3494 | case 124: |
| 3495 | #line 1272 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3496 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3497 | std::vector<const Type*> Params; |
| 3498 | std::vector<FunctionType::ParameterAttributes> Attrs; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3499 | Attrs.push_back((yyvsp[0].ParamAttrs)); |
| 3500 | for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3501 | Params.push_back(I->Ty->get()); |
| 3502 | if (I->Ty->get() != Type::VoidTy) |
| 3503 | Attrs.push_back(I->Attrs); |
| 3504 | } |
| 3505 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3506 | if (isVarArg) Params.pop_back(); |
| 3507 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3508 | FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, Attrs); |
| 3509 | delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list |
| 3510 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3511 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3512 | ;} |
| 3513 | break; |
| 3514 | |
| 3515 | case 125: |
| 3516 | #line 1290 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3517 | { // Sized array type? |
| 3518 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); |
| 3519 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3520 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3521 | ;} |
| 3522 | break; |
| 3523 | |
| 3524 | case 126: |
| 3525 | #line 1295 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3526 | { // Packed array type? |
| 3527 | const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get(); |
| 3528 | if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3529 | GEN_ERROR("Unsigned result not equal to signed result"); |
| 3530 | if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3531 | GEN_ERROR("Element type of a VectorType must be primitive"); |
| 3532 | if (!isPowerOf2_32((yyvsp[-3].UInt64Val))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3533 | GEN_ERROR("Vector length should be a power of 2"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3534 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(VectorType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); |
| 3535 | delete (yyvsp[-1].TypeVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3536 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3537 | ;} |
| 3538 | break; |
| 3539 | |
| 3540 | case 127: |
| 3541 | #line 1307 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3542 | { // Structure type? |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3543 | std::vector<const Type*> Elements; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3544 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(), |
| 3545 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3546 | Elements.push_back(*I); |
| 3547 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3548 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 3549 | delete (yyvsp[-1].TypeList); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3550 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3551 | ;} |
| 3552 | break; |
| 3553 | |
| 3554 | case 128: |
| 3555 | #line 1317 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3556 | { // Empty structure type? |
| 3557 | (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3558 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3559 | ;} |
| 3560 | break; |
| 3561 | |
| 3562 | case 129: |
| 3563 | #line 1321 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3564 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3565 | std::vector<const Type*> Elements; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3566 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(), |
| 3567 | E = (yyvsp[-2].TypeList)->end(); I != E; ++I) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3568 | Elements.push_back(*I); |
| 3569 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3570 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); |
| 3571 | delete (yyvsp[-2].TypeList); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3572 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3573 | ;} |
| 3574 | break; |
| 3575 | |
| 3576 | case 130: |
| 3577 | #line 1331 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3578 | { // Empty structure type? |
| 3579 | (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3580 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3581 | ;} |
| 3582 | break; |
| 3583 | |
| 3584 | case 131: |
| 3585 | #line 1338 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3586 | { |
| 3587 | (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal); |
| 3588 | (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs); |
| 3589 | ;} |
| 3590 | break; |
| 3591 | |
| 3592 | case 132: |
| 3593 | #line 1345 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3594 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3595 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3596 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 3597 | if (!(*(yyvsp[0].TypeVal))->isFirstClassType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3598 | GEN_ERROR("LLVM functions cannot return aggregate types"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3599 | (yyval.TypeVal) = (yyvsp[0].TypeVal); |
| 3600 | ;} |
| 3601 | break; |
| 3602 | |
| 3603 | case 133: |
| 3604 | #line 1352 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3605 | { |
| 3606 | (yyval.TypeVal) = new PATypeHolder(Type::VoidTy); |
| 3607 | ;} |
| 3608 | break; |
| 3609 | |
| 3610 | case 134: |
| 3611 | #line 1357 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3612 | { |
| 3613 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); |
| 3614 | (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3615 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3616 | ;} |
| 3617 | break; |
| 3618 | |
| 3619 | case 135: |
| 3620 | #line 1362 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3621 | { |
| 3622 | ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3623 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3624 | ;} |
| 3625 | break; |
| 3626 | |
| 3627 | case 137: |
| 3628 | #line 1370 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3629 | { |
| 3630 | (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3631 | TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet; |
| 3632 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3633 | (yyval.TypeWithAttrsList)->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3634 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3635 | ;} |
| 3636 | break; |
| 3637 | |
| 3638 | case 138: |
| 3639 | #line 1377 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3640 | { |
| 3641 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3642 | TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet; |
| 3643 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3644 | (yyval.TypeWithAttrsList)->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3645 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3646 | ;} |
| 3647 | break; |
| 3648 | |
| 3649 | case 139: |
| 3650 | #line 1384 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3651 | { |
| 3652 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3653 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3654 | ;} |
| 3655 | break; |
| 3656 | |
| 3657 | case 140: |
| 3658 | #line 1392 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3659 | { |
| 3660 | (yyval.TypeList) = new std::list<PATypeHolder>(); |
| 3661 | (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3662 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3663 | ;} |
| 3664 | break; |
| 3665 | |
| 3666 | case 141: |
| 3667 | #line 1397 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3668 | { |
| 3669 | ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3670 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3671 | ;} |
| 3672 | break; |
| 3673 | |
| 3674 | case 142: |
| 3675 | #line 1408 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3676 | { // Nonempty unsized arr |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3677 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3678 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 3679 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3680 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3681 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3682 | (*(yyvsp[-3].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3683 | const Type *ETy = ATy->getElementType(); |
| 3684 | int NumElements = ATy->getNumElements(); |
| 3685 | |
| 3686 | // Verify that we have the correct size... |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3687 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3688 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3689 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3690 | itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3691 | |
| 3692 | // Verify all elements are correct type! |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3693 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 3694 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3695 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3696 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3697 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3698 | } |
| 3699 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3700 | (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector)); |
| 3701 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3702 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3703 | ;} |
| 3704 | break; |
| 3705 | |
| 3706 | case 143: |
| 3707 | #line 1436 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3708 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3709 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3710 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 3711 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3712 | if (ATy == 0) |
| 3713 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3714 | (*(yyvsp[-2].TypeVal))->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3715 | |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3716 | int NumElements = ATy->getNumElements(); |
| 3717 | if (NumElements != -1 && NumElements != 0) |
| 3718 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3719 | " arguments, but has size of " + itostr(NumElements) +""); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3720 | (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3721 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3722 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3723 | ;} |
| 3724 | break; |
| 3725 | |
| 3726 | case 144: |
| 3727 | #line 1452 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3728 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3729 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3730 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 3731 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3732 | if (ATy == 0) |
| 3733 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3734 | (*(yyvsp[-2].TypeVal))->getDescription() + "'"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3735 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3736 | int NumElements = ATy->getNumElements(); |
| 3737 | const Type *ETy = ATy->getElementType(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3738 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 3739 | if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal))) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3740 | GEN_ERROR("Can't build string constant of size " + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3741 | itostr((int)(EndStr-(yyvsp[0].StrVal))) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3742 | " when array has size " + itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3743 | std::vector<Constant*> Vals; |
| 3744 | if (ETy == Type::Int8Ty) { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3745 | for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3746 | C != (unsigned char*)EndStr; ++C) |
| 3747 | Vals.push_back(ConstantInt::get(ETy, *C)); |
| 3748 | } else { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3749 | free((yyvsp[0].StrVal)); |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3750 | GEN_ERROR("Cannot build string arrays of non byte sized elements"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3751 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3752 | free((yyvsp[0].StrVal)); |
| 3753 | (yyval.ConstVal) = ConstantArray::get(ATy, Vals); |
| 3754 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3755 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3756 | ;} |
| 3757 | break; |
| 3758 | |
| 3759 | case 145: |
| 3760 | #line 1481 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3761 | { // Nonempty unsized arr |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3762 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3763 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 3764 | const VectorType *PTy = dyn_cast<VectorType>((yyvsp[-3].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3765 | if (PTy == 0) |
| 3766 | GEN_ERROR("Cannot make packed constant with type: '" + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3767 | (*(yyvsp[-3].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3768 | const Type *ETy = PTy->getElementType(); |
| 3769 | int NumElements = PTy->getNumElements(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3770 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3771 | // Verify that we have the correct size... |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3772 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3773 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3774 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3775 | itostr(NumElements) + ""); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3776 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3777 | // Verify all elements are correct type! |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3778 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 3779 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3780 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3781 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3782 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3783 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3784 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3785 | (yyval.ConstVal) = ConstantVector::get(PTy, *(yyvsp[-1].ConstVector)); |
| 3786 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3787 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3788 | ;} |
| 3789 | break; |
| 3790 | |
| 3791 | case 146: |
| 3792 | #line 1509 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3793 | { |
| 3794 | const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3795 | if (STy == 0) |
| 3796 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3797 | (*(yyvsp[-3].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3798 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3799 | if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3800 | GEN_ERROR("Illegal number of initializers for structure type"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3801 | |
| 3802 | // Check to ensure that constants are compatible with the type initializer! |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3803 | for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) |
| 3804 | if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3805 | GEN_ERROR("Expected type '" + |
| 3806 | STy->getElementType(i)->getDescription() + |
| 3807 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3808 | " of structure initializer"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3809 | |
| 3810 | // Check to ensure that Type is not packed |
| 3811 | if (STy->isPacked()) |
| 3812 | GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); |
| 3813 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3814 | (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector)); |
| 3815 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3816 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3817 | ;} |
| 3818 | break; |
| 3819 | |
| 3820 | case 147: |
| 3821 | #line 1534 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3822 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3823 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3824 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 3825 | const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3826 | if (STy == 0) |
| 3827 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3828 | (*(yyvsp[-2].TypeVal))->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3829 | |
| 3830 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3831 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3832 | |
| 3833 | // Check to ensure that Type is not packed |
| 3834 | if (STy->isPacked()) |
| 3835 | GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); |
| 3836 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3837 | (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3838 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3839 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3840 | ;} |
| 3841 | break; |
| 3842 | |
| 3843 | case 148: |
| 3844 | #line 1553 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3845 | { |
| 3846 | const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3847 | if (STy == 0) |
| 3848 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3849 | (*(yyvsp[-5].TypeVal))->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3850 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3851 | if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3852 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3853 | |
| 3854 | // Check to ensure that constants are compatible with the type initializer! |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3855 | for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) |
| 3856 | if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3857 | GEN_ERROR("Expected type '" + |
| 3858 | STy->getElementType(i)->getDescription() + |
| 3859 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3860 | " of structure initializer"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3861 | |
| 3862 | // Check to ensure that Type is packed |
| 3863 | if (!STy->isPacked()) |
| 3864 | GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); |
| 3865 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3866 | (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector)); |
| 3867 | delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3868 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3869 | ;} |
| 3870 | break; |
| 3871 | |
| 3872 | case 149: |
| 3873 | #line 1578 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3874 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3875 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3876 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription()); |
| 3877 | const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3878 | if (STy == 0) |
| 3879 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3880 | (*(yyvsp[-4].TypeVal))->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3881 | |
| 3882 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3883 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3884 | |
| 3885 | // Check to ensure that Type is packed |
| 3886 | if (!STy->isPacked()) |
| 3887 | GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); |
| 3888 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3889 | (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3890 | delete (yyvsp[-4].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3891 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3892 | ;} |
| 3893 | break; |
| 3894 | |
| 3895 | case 150: |
| 3896 | #line 1597 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3897 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3898 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3899 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 3900 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3901 | if (PTy == 0) |
| 3902 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3903 | (*(yyvsp[-1].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3904 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3905 | (yyval.ConstVal) = ConstantPointerNull::get(PTy); |
| 3906 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3907 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3908 | ;} |
| 3909 | break; |
| 3910 | |
| 3911 | case 151: |
| 3912 | #line 1609 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3913 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3914 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3915 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 3916 | (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get()); |
| 3917 | delete (yyvsp[-1].TypeVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3918 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3919 | ;} |
| 3920 | break; |
| 3921 | |
| 3922 | case 152: |
| 3923 | #line 1616 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3924 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3925 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3926 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 3927 | const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3928 | if (Ty == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3929 | GEN_ERROR("Global const reference must be a pointer type"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3930 | |
| 3931 | // ConstExprs can exist in the body of a function, thus creating |
| 3932 | // GlobalValues whenever they refer to a variable. Because we are in |
| 3933 | // the context of a function, getValNonImprovising will search the functions |
| 3934 | // symbol table instead of the module symbol table for the global symbol, |
| 3935 | // which throws things all off. To get around this, we just tell |
| 3936 | // getValNonImprovising that we are at global scope here. |
| 3937 | // |
| 3938 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3939 | CurFun.CurrentFunction = 0; |
| 3940 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3941 | Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3942 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3943 | |
| 3944 | CurFun.CurrentFunction = SavedCurFn; |
| 3945 | |
| 3946 | // If this is an initializer for a constant pointer, which is referencing a |
| 3947 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3948 | // in the future with the right type of variable. |
| 3949 | // |
| 3950 | if (V == 0) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 3951 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3952 | const PointerType *PT = cast<PointerType>(Ty); |
| 3953 | |
| 3954 | // First check to see if the forward references value is already created! |
| 3955 | PerModuleInfo::GlobalRefsType::iterator I = |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3956 | CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal))); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3957 | |
| 3958 | if (I != CurModule.GlobalRefs.end()) { |
| 3959 | V = I->second; // Placeholder already exists, use it... |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3960 | (yyvsp[0].ValIDVal).destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3961 | } else { |
| 3962 | std::string Name; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3963 | if ((yyvsp[0].ValIDVal).Type == ValID::GlobalName) |
| 3964 | Name = (yyvsp[0].ValIDVal).Name; |
| 3965 | else if ((yyvsp[0].ValIDVal).Type != ValID::GlobalID) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3966 | GEN_ERROR("Invalid reference to global"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3967 | |
| 3968 | // Create the forward referenced global. |
| 3969 | GlobalValue *GV; |
| 3970 | if (const FunctionType *FTy = |
| 3971 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 3972 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 3973 | CurModule.CurrentModule); |
| 3974 | } else { |
| 3975 | GV = new GlobalVariable(PT->getElementType(), false, |
| 3976 | GlobalValue::ExternalLinkage, 0, |
| 3977 | Name, CurModule.CurrentModule); |
| 3978 | } |
| 3979 | |
| 3980 | // Keep track of the fact that we have a forward ref to recycle it |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3981 | CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3982 | V = GV; |
| 3983 | } |
| 3984 | } |
| 3985 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3986 | (yyval.ConstVal) = cast<GlobalValue>(V); |
| 3987 | delete (yyvsp[-1].TypeVal); // Free the type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3988 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3989 | ;} |
| 3990 | break; |
| 3991 | |
| 3992 | case 153: |
| 3993 | #line 1682 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 3994 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3995 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3996 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 3997 | if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3998 | GEN_ERROR("Mismatched types for constant expression: " + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 3999 | (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription()); |
| 4000 | (yyval.ConstVal) = (yyvsp[0].ConstVal); |
| 4001 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4002 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4003 | ;} |
| 4004 | break; |
| 4005 | |
| 4006 | case 154: |
| 4007 | #line 1692 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4008 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4009 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4010 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 4011 | const Type *Ty = (yyvsp[-1].TypeVal)->get(); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4012 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4013 | GEN_ERROR("Cannot create a null initialized value of this type"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4014 | (yyval.ConstVal) = Constant::getNullValue(Ty); |
| 4015 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4016 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4017 | ;} |
| 4018 | break; |
| 4019 | |
| 4020 | case 155: |
| 4021 | #line 1702 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4022 | { // integral constants |
| 4023 | if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4024 | GEN_ERROR("Constant value doesn't fit in type"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4025 | (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4026 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4027 | ;} |
| 4028 | break; |
| 4029 | |
| 4030 | case 156: |
| 4031 | #line 1708 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4032 | { // integral constants |
| 4033 | if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4034 | GEN_ERROR("Constant value doesn't fit in type"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4035 | (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4036 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4037 | ;} |
| 4038 | break; |
| 4039 | |
| 4040 | case 157: |
| 4041 | #line 1714 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4042 | { // Boolean constants |
| 4043 | assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 4044 | (yyval.ConstVal) = ConstantInt::getTrue(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4045 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4046 | ;} |
| 4047 | break; |
| 4048 | |
| 4049 | case 158: |
| 4050 | #line 1719 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4051 | { // Boolean constants |
| 4052 | assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 4053 | (yyval.ConstVal) = ConstantInt::getFalse(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4054 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4055 | ;} |
| 4056 | break; |
| 4057 | |
| 4058 | case 159: |
| 4059 | #line 1724 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4060 | { // Float & Double constants |
| 4061 | if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4062 | GEN_ERROR("Floating point constant invalid for type"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4063 | (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4064 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4065 | ;} |
| 4066 | break; |
| 4067 | |
| 4068 | case 160: |
| 4069 | #line 1732 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4070 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4071 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4072 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 4073 | Constant *Val = (yyvsp[-3].ConstVal); |
| 4074 | const Type *DestTy = (yyvsp[-1].TypeVal)->get(); |
| 4075 | if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4076 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 4077 | Val->getType()->getDescription() + "' to '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4078 | DestTy->getDescription() + "'"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4079 | (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy); |
| 4080 | delete (yyvsp[-1].TypeVal); |
| 4081 | ;} |
| 4082 | break; |
| 4083 | |
| 4084 | case 161: |
| 4085 | #line 1744 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4086 | { |
| 4087 | if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4088 | GEN_ERROR("GetElementPtr requires a pointer operand"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4089 | |
| 4090 | const Type *IdxTy = |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4091 | GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), &(*(yyvsp[-1].ValueList))[0], (yyvsp[-1].ValueList)->size(), |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 4092 | true); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4093 | if (!IdxTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4094 | GEN_ERROR("Index list invalid for constant getelementptr"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4095 | |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 4096 | SmallVector<Constant*, 8> IdxVec; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4097 | for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i) |
| 4098 | if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i])) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4099 | IdxVec.push_back(C); |
| 4100 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4101 | GEN_ERROR("Indices to constant getelementptr must be constants"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4102 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4103 | delete (yyvsp[-1].ValueList); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4104 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4105 | (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), &IdxVec[0], IdxVec.size()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4106 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4107 | ;} |
| 4108 | break; |
| 4109 | |
| 4110 | case 162: |
| 4111 | #line 1766 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4112 | { |
| 4113 | if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4114 | GEN_ERROR("Select condition must be of boolean type"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4115 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4116 | GEN_ERROR("Select operand types must match"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4117 | (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4118 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4119 | ;} |
| 4120 | break; |
| 4121 | |
| 4122 | case 163: |
| 4123 | #line 1774 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4124 | { |
| 4125 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4126 | GEN_ERROR("Binary operator types must match"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4127 | CHECK_FOR_ERROR; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4128 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
| 4129 | ;} |
| 4130 | break; |
| 4131 | |
| 4132 | case 164: |
| 4133 | #line 1780 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4134 | { |
| 4135 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4136 | GEN_ERROR("Logical operator types must match"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4137 | if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) { |
| 4138 | if (Instruction::isShift((yyvsp[-5].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].ConstVal)->getType()) || |
| 4139 | !cast<VectorType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4140 | GEN_ERROR("Logical operator requires integral operands"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4141 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4142 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4143 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4144 | ;} |
| 4145 | break; |
| 4146 | |
| 4147 | case 165: |
| 4148 | #line 1791 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4149 | { |
| 4150 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4151 | GEN_ERROR("icmp operand types must match"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4152 | (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
| 4153 | ;} |
| 4154 | break; |
| 4155 | |
| 4156 | case 166: |
| 4157 | #line 1796 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4158 | { |
| 4159 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4160 | GEN_ERROR("fcmp operand types must match"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4161 | (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
| 4162 | ;} |
| 4163 | break; |
| 4164 | |
| 4165 | case 167: |
| 4166 | #line 1801 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4167 | { |
| 4168 | if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4169 | GEN_ERROR("Invalid extractelement operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4170 | (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4171 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4172 | ;} |
| 4173 | break; |
| 4174 | |
| 4175 | case 168: |
| 4176 | #line 1807 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4177 | { |
| 4178 | if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4179 | GEN_ERROR("Invalid insertelement operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4180 | (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4181 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4182 | ;} |
| 4183 | break; |
| 4184 | |
| 4185 | case 169: |
| 4186 | #line 1813 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4187 | { |
| 4188 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4189 | GEN_ERROR("Invalid shufflevector operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4190 | (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4191 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4192 | ;} |
| 4193 | break; |
| 4194 | |
| 4195 | case 170: |
| 4196 | #line 1822 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4197 | { |
| 4198 | ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4199 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4200 | ;} |
| 4201 | break; |
| 4202 | |
| 4203 | case 171: |
| 4204 | #line 1826 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4205 | { |
| 4206 | (yyval.ConstVector) = new std::vector<Constant*>(); |
| 4207 | (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4208 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4209 | ;} |
| 4210 | break; |
| 4211 | |
| 4212 | case 172: |
| 4213 | #line 1834 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4214 | { (yyval.BoolVal) = false; ;} |
| 4215 | break; |
| 4216 | |
| 4217 | case 173: |
| 4218 | #line 1834 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4219 | { (yyval.BoolVal) = true; ;} |
| 4220 | break; |
| 4221 | |
| 4222 | case 174: |
| 4223 | #line 1845 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4224 | { |
| 4225 | (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4226 | CurModule.ModuleDone(); |
| 4227 | CHECK_FOR_ERROR; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4228 | ;} |
| 4229 | break; |
| 4230 | |
| 4231 | case 175: |
| 4232 | #line 1850 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4233 | { |
| 4234 | (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4235 | CurModule.ModuleDone(); |
| 4236 | CHECK_FOR_ERROR; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4237 | ;} |
| 4238 | break; |
| 4239 | |
| 4240 | case 178: |
| 4241 | #line 1863 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4242 | { CurFun.isDeclare = false; ;} |
| 4243 | break; |
| 4244 | |
| 4245 | case 179: |
| 4246 | #line 1863 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4247 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4248 | CurFun.FunctionDone(); |
| 4249 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4250 | ;} |
| 4251 | break; |
| 4252 | |
| 4253 | case 180: |
| 4254 | #line 1867 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4255 | { CurFun.isDeclare = true; ;} |
| 4256 | break; |
| 4257 | |
| 4258 | case 181: |
| 4259 | #line 1867 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4260 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4261 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4262 | ;} |
| 4263 | break; |
| 4264 | |
| 4265 | case 182: |
| 4266 | #line 1870 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4267 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4268 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4269 | ;} |
| 4270 | break; |
| 4271 | |
| 4272 | case 183: |
| 4273 | #line 1873 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4274 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4275 | // Emit an error if there are any unresolved types left. |
| 4276 | if (!CurModule.LateResolveTypes.empty()) { |
| 4277 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4278 | if (DID.Type == ValID::LocalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4279 | GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'"); |
| 4280 | } else { |
| 4281 | GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num)); |
| 4282 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4283 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4284 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4285 | ;} |
| 4286 | break; |
| 4287 | |
| 4288 | case 184: |
| 4289 | #line 1885 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4290 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4291 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4292 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4293 | // Eagerly resolve types. This is not an optimization, this is a |
| 4294 | // requirement that is due to the fact that we could have this: |
| 4295 | // |
| 4296 | // %list = type { %list * } |
| 4297 | // %list = type { %list * } ; repeated type decl |
| 4298 | // |
| 4299 | // If types are not resolved eagerly, then the two types will not be |
| 4300 | // determined to be the same type! |
| 4301 | // |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4302 | ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4303 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4304 | if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4305 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4306 | // If this is a named type that is not a redefinition, add it to the slot |
| 4307 | // table. |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4308 | CurModule.Types.push_back(*(yyvsp[0].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4309 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4310 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4311 | delete (yyvsp[0].TypeVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4312 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4313 | ;} |
| 4314 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4315 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4316 | case 185: |
| 4317 | #line 1909 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4318 | { |
| 4319 | ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType)); |
| 4320 | |
| 4321 | if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4322 | CHECK_FOR_ERROR |
| 4323 | // If this is a named type that is not a redefinition, add it to the slot |
| 4324 | // table. |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4325 | CurModule.Types.push_back((yyvsp[0].PrimType)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4326 | } |
Reid Spencer | 6e18b7d | 2006-12-03 06:59:29 +0000 | [diff] [blame] | 4327 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4328 | ;} |
| 4329 | break; |
| 4330 | |
| 4331 | case 186: |
| 4332 | #line 1920 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4333 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4334 | /* "Externally Visible" Linkage */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4335 | if ((yyvsp[0].ConstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4336 | GEN_ERROR("Global value initializer is not a constant"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4337 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, |
| 4338 | (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4339 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4340 | ;} |
| 4341 | break; |
| 4342 | |
| 4343 | case 187: |
| 4344 | #line 1927 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4345 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4346 | CurGV = 0; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4347 | ;} |
| 4348 | break; |
| 4349 | |
| 4350 | case 188: |
| 4351 | #line 1930 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4352 | { |
| 4353 | if ((yyvsp[0].ConstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4354 | GEN_ERROR("Global value initializer is not a constant"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4355 | CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4356 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4357 | ;} |
| 4358 | break; |
| 4359 | |
| 4360 | case 189: |
| 4361 | #line 1935 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4362 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4363 | CurGV = 0; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4364 | ;} |
| 4365 | break; |
| 4366 | |
| 4367 | case 190: |
| 4368 | #line 1938 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4369 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4370 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4371 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 4372 | CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4373 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4374 | delete (yyvsp[0].TypeVal); |
| 4375 | ;} |
| 4376 | break; |
| 4377 | |
| 4378 | case 191: |
| 4379 | #line 1944 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4380 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4381 | CurGV = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4382 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4383 | ;} |
| 4384 | break; |
| 4385 | |
| 4386 | case 192: |
| 4387 | #line 1948 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4388 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4389 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4390 | ;} |
| 4391 | break; |
| 4392 | |
| 4393 | case 193: |
| 4394 | #line 1951 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4395 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4396 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4397 | ;} |
| 4398 | break; |
| 4399 | |
| 4400 | case 194: |
| 4401 | #line 1957 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4402 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4403 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4404 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4405 | std::string NewAsm((yyvsp[0].StrVal), EndStr); |
| 4406 | free((yyvsp[0].StrVal)); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4407 | |
| 4408 | if (AsmSoFar.empty()) |
| 4409 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 4410 | else |
| 4411 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4412 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4413 | ;} |
| 4414 | break; |
| 4415 | |
| 4416 | case 195: |
| 4417 | #line 1970 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4418 | { |
| 4419 | CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); |
| 4420 | free((yyvsp[0].StrVal)); |
| 4421 | ;} |
| 4422 | break; |
| 4423 | |
| 4424 | case 196: |
| 4425 | #line 1974 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4426 | { |
| 4427 | CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); |
| 4428 | free((yyvsp[0].StrVal)); |
| 4429 | ;} |
| 4430 | break; |
| 4431 | |
| 4432 | case 198: |
| 4433 | #line 1981 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4434 | { |
| 4435 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 4436 | free((yyvsp[0].StrVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4437 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4438 | ;} |
| 4439 | break; |
| 4440 | |
| 4441 | case 199: |
| 4442 | #line 1986 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4443 | { |
| 4444 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 4445 | free((yyvsp[0].StrVal)); |
Reid Spencer | a54b7cb | 2007-01-12 07:05:14 +0000 | [diff] [blame] | 4446 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4447 | ;} |
| 4448 | break; |
| 4449 | |
| 4450 | case 200: |
| 4451 | #line 1991 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4452 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4453 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4454 | ;} |
| 4455 | break; |
| 4456 | |
| 4457 | case 201: |
| 4458 | #line 2000 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4459 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4460 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4461 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 4462 | if (*(yyvsp[-2].TypeVal) == Type::VoidTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4463 | GEN_ERROR("void typed arguments are invalid"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4464 | ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal); |
| 4465 | (yyval.ArgList) = (yyvsp[-4].ArgList); |
| 4466 | (yyvsp[-4].ArgList)->push_back(E); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4467 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4468 | ;} |
| 4469 | break; |
| 4470 | |
| 4471 | case 202: |
| 4472 | #line 2010 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4473 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4474 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4475 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 4476 | if (*(yyvsp[-2].TypeVal) == Type::VoidTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4477 | GEN_ERROR("void typed arguments are invalid"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4478 | ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal); |
| 4479 | (yyval.ArgList) = new ArgListType; |
| 4480 | (yyval.ArgList)->push_back(E); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4481 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4482 | ;} |
| 4483 | break; |
| 4484 | |
| 4485 | case 203: |
| 4486 | #line 2021 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4487 | { |
| 4488 | (yyval.ArgList) = (yyvsp[0].ArgList); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4489 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4490 | ;} |
| 4491 | break; |
| 4492 | |
| 4493 | case 204: |
| 4494 | #line 2025 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4495 | { |
| 4496 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4497 | struct ArgListEntry E; |
| 4498 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 4499 | E.Name = 0; |
| 4500 | E.Attrs = FunctionType::NoAttributeSet; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4501 | (yyval.ArgList)->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4502 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4503 | ;} |
| 4504 | break; |
| 4505 | |
| 4506 | case 205: |
| 4507 | #line 2034 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4508 | { |
| 4509 | (yyval.ArgList) = new ArgListType; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4510 | struct ArgListEntry E; |
| 4511 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 4512 | E.Name = 0; |
| 4513 | E.Attrs = FunctionType::NoAttributeSet; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4514 | (yyval.ArgList)->push_back(E); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4515 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4516 | ;} |
| 4517 | break; |
| 4518 | |
| 4519 | case 206: |
| 4520 | #line 2043 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4521 | { |
| 4522 | (yyval.ArgList) = 0; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4523 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4524 | ;} |
| 4525 | break; |
| 4526 | |
| 4527 | case 207: |
| 4528 | #line 2049 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4529 | { |
| 4530 | UnEscapeLexed((yyvsp[-6].StrVal)); |
| 4531 | std::string FunctionName((yyvsp[-6].StrVal)); |
| 4532 | free((yyvsp[-6].StrVal)); // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4533 | |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 4534 | // Check the function result for abstractness if this is a define. We should |
| 4535 | // have no abstract types at this point |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4536 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal))) |
| 4537 | GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription()); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 4538 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4539 | std::vector<const Type*> ParamTypeList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4540 | std::vector<FunctionType::ParameterAttributes> ParamAttrs; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4541 | ParamAttrs.push_back((yyvsp[-2].ParamAttrs)); |
| 4542 | if ((yyvsp[-4].ArgList)) { // If there are arguments... |
| 4543 | for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4544 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 4545 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty)) |
| 4546 | GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4547 | ParamTypeList.push_back(Ty); |
| 4548 | if (Ty != Type::VoidTy) |
| 4549 | ParamAttrs.push_back(I->Attrs); |
| 4550 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4551 | } |
| 4552 | |
| 4553 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 4554 | if (isVarArg) ParamTypeList.pop_back(); |
| 4555 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4556 | FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg, |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4557 | ParamAttrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4558 | const PointerType *PFT = PointerType::get(FT); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4559 | delete (yyvsp[-7].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4560 | |
| 4561 | ValID ID; |
| 4562 | if (!FunctionName.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4563 | ID = ValID::createGlobalName((char*)FunctionName.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4564 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4565 | ID = ValID::createGlobalID(CurModule.Values[PFT].size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4566 | } |
| 4567 | |
| 4568 | Function *Fn = 0; |
| 4569 | // See if this function was forward referenced. If so, recycle the object. |
| 4570 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 4571 | // Move the function to the end of the list, from whereever it was |
| 4572 | // previously inserted. |
| 4573 | Fn = cast<Function>(FWRef); |
| 4574 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 4575 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 4576 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4577 | (Fn = CurModule.CurrentModule->getFunction(FunctionName))) { |
| 4578 | if (Fn->getFunctionType() != FT ) { |
| 4579 | // The existing function doesn't have the same type. This is an overload |
| 4580 | // error. |
| 4581 | GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); |
| 4582 | } else if (!CurFun.isDeclare && !Fn->isDeclaration()) { |
| 4583 | // Neither the existing or the current function is a declaration and they |
| 4584 | // have the same name and same type. Clearly this is a redefinition. |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4585 | GEN_ERROR("Redefinition of function '" + FunctionName + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4586 | } if (Fn->isDeclaration()) { |
| 4587 | // 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] | 4588 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 4589 | AI != AE; ++AI) |
| 4590 | AI->setName(""); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4591 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4592 | } else { // Not already defined? |
| 4593 | Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, |
| 4594 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4595 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4596 | InsertValue(Fn, CurModule.Values); |
| 4597 | } |
| 4598 | |
| 4599 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4600 | |
| 4601 | if (CurFun.isDeclare) { |
| 4602 | // If we have declaration, always overwrite linkage. This will allow us to |
| 4603 | // correctly handle cases, when pointer to function is passed as argument to |
| 4604 | // another function. |
| 4605 | Fn->setLinkage(CurFun.Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4606 | Fn->setVisibility(CurFun.Visibility); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4607 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4608 | Fn->setCallingConv((yyvsp[-8].UIntVal)); |
| 4609 | Fn->setAlignment((yyvsp[0].UIntVal)); |
| 4610 | if ((yyvsp[-1].StrVal)) { |
| 4611 | Fn->setSection((yyvsp[-1].StrVal)); |
| 4612 | free((yyvsp[-1].StrVal)); |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 4613 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4614 | |
| 4615 | // Add all of the arguments we parsed to the function... |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4616 | if ((yyvsp[-4].ArgList)) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4617 | if (isVarArg) { // Nuke the last entry |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4618 | assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0 && |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 4619 | "Not a varargs marker!"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4620 | delete (yyvsp[-4].ArgList)->back().Ty; |
| 4621 | (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4622 | } |
| 4623 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4624 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4625 | unsigned Idx = 1; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4626 | for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); |
| 4627 | I != (yyvsp[-4].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4628 | delete I->Ty; // Delete the typeholder... |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 4629 | setValueName(ArgIt, I->Name); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4630 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4631 | InsertValue(ArgIt); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4632 | Idx++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4633 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4634 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4635 | delete (yyvsp[-4].ArgList); // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4636 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4637 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4638 | ;} |
| 4639 | break; |
| 4640 | |
| 4641 | case 210: |
| 4642 | #line 2162 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4643 | { |
| 4644 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4645 | |
| 4646 | // Make sure that we keep track of the linkage type even if there was a |
| 4647 | // previous "declare". |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4648 | (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage)); |
| 4649 | (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility)); |
| 4650 | ;} |
| 4651 | break; |
| 4652 | |
| 4653 | case 213: |
| 4654 | #line 2173 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4655 | { |
| 4656 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4657 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4658 | ;} |
| 4659 | break; |
| 4660 | |
| 4661 | case 214: |
| 4662 | #line 2178 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4663 | { |
| 4664 | CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage)); |
| 4665 | CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility)); |
| 4666 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4667 | CurFun.FunctionDone(); |
| 4668 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4669 | ;} |
| 4670 | break; |
| 4671 | |
| 4672 | case 215: |
| 4673 | #line 2190 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4674 | { |
| 4675 | (yyval.BoolVal) = false; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4676 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4677 | ;} |
| 4678 | break; |
| 4679 | |
| 4680 | case 216: |
| 4681 | #line 2194 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4682 | { |
| 4683 | (yyval.BoolVal) = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4684 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4685 | ;} |
| 4686 | break; |
| 4687 | |
| 4688 | case 217: |
| 4689 | #line 2199 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4690 | { // A reference to a direct constant |
| 4691 | (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4692 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4693 | ;} |
| 4694 | break; |
| 4695 | |
| 4696 | case 218: |
| 4697 | #line 2203 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4698 | { |
| 4699 | (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4700 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4701 | ;} |
| 4702 | break; |
| 4703 | |
| 4704 | case 219: |
| 4705 | #line 2207 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4706 | { // Perhaps it's an FP constant? |
| 4707 | (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4708 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4709 | ;} |
| 4710 | break; |
| 4711 | |
| 4712 | case 220: |
| 4713 | #line 2211 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4714 | { |
| 4715 | (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4716 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4717 | ;} |
| 4718 | break; |
| 4719 | |
| 4720 | case 221: |
| 4721 | #line 2215 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4722 | { |
| 4723 | (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4724 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4725 | ;} |
| 4726 | break; |
| 4727 | |
| 4728 | case 222: |
| 4729 | #line 2219 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4730 | { |
| 4731 | (yyval.ValIDVal) = ValID::createNull(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4732 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4733 | ;} |
| 4734 | break; |
| 4735 | |
| 4736 | case 223: |
| 4737 | #line 2223 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4738 | { |
| 4739 | (yyval.ValIDVal) = ValID::createUndef(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4740 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4741 | ;} |
| 4742 | break; |
| 4743 | |
| 4744 | case 224: |
| 4745 | #line 2227 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4746 | { // A vector zero constant. |
| 4747 | (yyval.ValIDVal) = ValID::createZeroInit(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4748 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4749 | ;} |
| 4750 | break; |
| 4751 | |
| 4752 | case 225: |
| 4753 | #line 2231 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4754 | { // Nonempty unsized packed vector |
| 4755 | const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType(); |
| 4756 | int NumElements = (yyvsp[-1].ConstVector)->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4757 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4758 | VectorType* pt = VectorType::get(ETy, NumElements); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4759 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4760 | HandleUpRefs( |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4761 | VectorType::get( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4762 | ETy, |
| 4763 | NumElements) |
| 4764 | ) |
| 4765 | ); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4766 | |
| 4767 | // Verify all elements are correct type! |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4768 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 4769 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4770 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4771 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4772 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4773 | } |
| 4774 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4775 | (yyval.ValIDVal) = ValID::create(ConstantVector::get(pt, *(yyvsp[-1].ConstVector))); |
| 4776 | delete PTy; delete (yyvsp[-1].ConstVector); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4777 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4778 | ;} |
| 4779 | break; |
| 4780 | |
| 4781 | case 226: |
| 4782 | #line 2256 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4783 | { |
| 4784 | (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal)); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4785 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4786 | ;} |
| 4787 | break; |
| 4788 | |
| 4789 | case 227: |
| 4790 | #line 2260 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4791 | { |
| 4792 | char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); |
| 4793 | std::string AsmStr = std::string((yyvsp[-2].StrVal), End); |
| 4794 | End = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4795 | std::string Constraints = std::string((yyvsp[0].StrVal), End); |
| 4796 | (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal)); |
| 4797 | free((yyvsp[-2].StrVal)); |
| 4798 | free((yyvsp[0].StrVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4799 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4800 | ;} |
| 4801 | break; |
| 4802 | |
| 4803 | case 228: |
| 4804 | #line 2274 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4805 | { // Is it an integer reference...? |
| 4806 | (yyval.ValIDVal) = ValID::createLocalID((yyvsp[0].UIntVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4807 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4808 | ;} |
| 4809 | break; |
| 4810 | |
| 4811 | case 229: |
| 4812 | #line 2278 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4813 | { |
| 4814 | (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[0].UIntVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4815 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4816 | ;} |
| 4817 | break; |
| 4818 | |
| 4819 | case 230: |
| 4820 | #line 2282 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4821 | { // Is it a named reference...? |
| 4822 | (yyval.ValIDVal) = ValID::createLocalName((yyvsp[0].StrVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4823 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4824 | ;} |
| 4825 | break; |
| 4826 | |
| 4827 | case 231: |
| 4828 | #line 2286 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4829 | { // Is it a named reference...? |
| 4830 | (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[0].StrVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4831 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4832 | ;} |
| 4833 | break; |
| 4834 | |
| 4835 | case 234: |
| 4836 | #line 2298 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4837 | { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4838 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4839 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 4840 | (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); |
| 4841 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4842 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4843 | ;} |
| 4844 | break; |
| 4845 | |
| 4846 | case 235: |
| 4847 | #line 2307 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4848 | { |
| 4849 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4850 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4851 | ;} |
| 4852 | break; |
| 4853 | |
| 4854 | case 236: |
| 4855 | #line 2311 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4856 | { // Do not allow functions with 0 basic blocks |
| 4857 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4858 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4859 | ;} |
| 4860 | break; |
| 4861 | |
| 4862 | case 237: |
| 4863 | #line 2320 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4864 | { |
| 4865 | setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4866 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4867 | InsertValue((yyvsp[0].TermInstVal)); |
| 4868 | (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal)); |
| 4869 | InsertValue((yyvsp[-2].BasicBlockVal)); |
| 4870 | (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4871 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4872 | ;} |
| 4873 | break; |
| 4874 | |
| 4875 | case 238: |
| 4876 | #line 2330 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4877 | { |
| 4878 | if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal))) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4879 | if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0))) |
| 4880 | if (CI2->getParent() == 0) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4881 | (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2); |
| 4882 | (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal)); |
| 4883 | (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4884 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4885 | ;} |
| 4886 | break; |
| 4887 | |
| 4888 | case 239: |
| 4889 | #line 2339 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4890 | { |
| 4891 | (yyval.BasicBlockVal) = getBBVal(ValID::createLocalID(CurFun.NextBBNum++), true); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4892 | CHECK_FOR_ERROR |
| 4893 | |
| 4894 | // Make sure to move the basic block to the correct location in the |
| 4895 | // function, instead of leaving it inserted wherever it was first |
| 4896 | // referenced. |
| 4897 | Function::BasicBlockListType &BBL = |
| 4898 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4899 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4900 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4901 | ;} |
| 4902 | break; |
| 4903 | |
| 4904 | case 240: |
| 4905 | #line 2351 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4906 | { |
| 4907 | (yyval.BasicBlockVal) = getBBVal(ValID::createLocalName((yyvsp[0].StrVal)), true); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4908 | CHECK_FOR_ERROR |
| 4909 | |
| 4910 | // Make sure to move the basic block to the correct location in the |
| 4911 | // function, instead of leaving it inserted wherever it was first |
| 4912 | // referenced. |
| 4913 | Function::BasicBlockListType &BBL = |
| 4914 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4915 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4916 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4917 | ;} |
| 4918 | break; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4919 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4920 | case 241: |
| 4921 | #line 2364 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4922 | { // Return with a result... |
| 4923 | (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal)); |
| 4924 | CHECK_FOR_ERROR |
| 4925 | ;} |
| 4926 | break; |
| 4927 | |
| 4928 | case 242: |
| 4929 | #line 2368 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4930 | { // Return with no result... |
| 4931 | (yyval.TermInstVal) = new ReturnInst(); |
| 4932 | CHECK_FOR_ERROR |
| 4933 | ;} |
| 4934 | break; |
| 4935 | |
| 4936 | case 243: |
| 4937 | #line 2372 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4938 | { // Unconditional Branch... |
| 4939 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
| 4940 | CHECK_FOR_ERROR |
| 4941 | (yyval.TermInstVal) = new BranchInst(tmpBB); |
| 4942 | ;} |
| 4943 | break; |
| 4944 | |
| 4945 | case 244: |
| 4946 | #line 2377 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4947 | { |
| 4948 | assert(cast<IntegerType>((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 4949 | BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); |
| 4950 | CHECK_FOR_ERROR |
| 4951 | BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal)); |
| 4952 | CHECK_FOR_ERROR |
| 4953 | Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal)); |
| 4954 | CHECK_FOR_ERROR |
| 4955 | (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4956 | ;} |
| 4957 | break; |
| 4958 | |
| 4959 | case 245: |
| 4960 | #line 2387 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4961 | { |
| 4962 | Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal)); |
| 4963 | CHECK_FOR_ERROR |
| 4964 | BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal)); |
| 4965 | CHECK_FOR_ERROR |
| 4966 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size()); |
| 4967 | (yyval.TermInstVal) = S; |
| 4968 | |
| 4969 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(), |
| 4970 | E = (yyvsp[-1].JumpTable)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4971 | for (; I != E; ++I) { |
| 4972 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4973 | S->addCase(CI, I->second); |
| 4974 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4975 | GEN_ERROR("Switch case is constant, but not a simple integer"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4976 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4977 | delete (yyvsp[-1].JumpTable); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4978 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4979 | ;} |
| 4980 | break; |
| 4981 | |
| 4982 | case 246: |
| 4983 | #line 2406 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4984 | { |
| 4985 | Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4986 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4987 | BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4988 | CHECK_FOR_ERROR |
| 4989 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4990 | (yyval.TermInstVal) = S; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4991 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 4992 | ;} |
| 4993 | break; |
| 4994 | |
| 4995 | case 247: |
| 4996 | #line 2416 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 4997 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4998 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4999 | // Handle the short syntax |
| 5000 | const PointerType *PFTy = 0; |
| 5001 | const FunctionType *Ty = 0; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5002 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5003 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5004 | // Pull out the types of all of the arguments... |
| 5005 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5006 | FunctionType::ParamAttrsList ParamAttrs; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5007 | ParamAttrs.push_back((yyvsp[-6].ParamAttrs)); |
| 5008 | for (ValueRefList::iterator I = (yyvsp[-8].ValueRefList)->begin(), E = (yyvsp[-8].ValueRefList)->end(); I != E; ++I) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5009 | const Type *Ty = I->Val->getType(); |
| 5010 | if (Ty == Type::VoidTy) |
| 5011 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 5012 | ParamTypes.push_back(Ty); |
| 5013 | ParamAttrs.push_back(I->Attrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5014 | } |
| 5015 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5016 | Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, ParamAttrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5017 | PFTy = PointerType::get(Ty); |
| 5018 | } |
| 5019 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5020 | Value *V = getVal(PFTy, (yyvsp[-10].ValIDVal)); // Get the function we're calling... |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5021 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5022 | BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5023 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5024 | BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5025 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5026 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5027 | // Check the arguments |
| 5028 | ValueList Args; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5029 | if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments? |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5030 | // Make sure no arguments is a good thing! |
| 5031 | if (Ty->getNumParams() != 0) |
| 5032 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5033 | "expects arguments"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5034 | } else { // Has arguments? |
| 5035 | // Loop through FunctionType's arguments and ensure they are specified |
| 5036 | // correctly! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5037 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5038 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5039 | ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5040 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5041 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5042 | if (ArgI->Val->getType() != *I) |
| 5043 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5044 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5045 | Args.push_back(ArgI->Val); |
| 5046 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5047 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5048 | if (Ty->isVarArg()) { |
| 5049 | if (I == E) |
| 5050 | for (; ArgI != ArgE; ++ArgI) |
| 5051 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 5052 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5053 | GEN_ERROR("Invalid number of parameters detected"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5054 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5055 | |
| 5056 | // Create the InvokeInst |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5057 | InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size()); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5058 | II->setCallingConv((yyvsp[-12].UIntVal)); |
| 5059 | (yyval.TermInstVal) = II; |
| 5060 | delete (yyvsp[-8].ValueRefList); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5061 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5062 | ;} |
| 5063 | break; |
| 5064 | |
| 5065 | case 248: |
| 5066 | #line 2482 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5067 | { |
| 5068 | (yyval.TermInstVal) = new UnwindInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5069 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5070 | ;} |
| 5071 | break; |
| 5072 | |
| 5073 | case 249: |
| 5074 | #line 2486 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5075 | { |
| 5076 | (yyval.TermInstVal) = new UnreachableInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5077 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5078 | ;} |
| 5079 | break; |
| 5080 | |
| 5081 | case 250: |
| 5082 | #line 2493 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5083 | { |
| 5084 | (yyval.JumpTable) = (yyvsp[-5].JumpTable); |
| 5085 | Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5086 | CHECK_FOR_ERROR |
| 5087 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5088 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5089 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5090 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5091 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5092 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5093 | ;} |
| 5094 | break; |
| 5095 | |
| 5096 | case 251: |
| 5097 | #line 2504 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5098 | { |
| 5099 | (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 5100 | Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5101 | CHECK_FOR_ERROR |
| 5102 | |
| 5103 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5104 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5105 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5106 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5107 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5108 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5109 | ;} |
| 5110 | break; |
| 5111 | |
| 5112 | case 252: |
| 5113 | #line 2517 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5114 | { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5115 | // Is this definition named?? if so, assign the name... |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5116 | setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal)); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5117 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5118 | InsertValue((yyvsp[0].InstVal)); |
| 5119 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5120 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5121 | ;} |
| 5122 | break; |
| 5123 | |
| 5124 | case 253: |
| 5125 | #line 2527 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5126 | { // Used for PHI nodes |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5127 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5128 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription()); |
| 5129 | (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 5130 | Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5131 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5132 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5133 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5134 | (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5135 | delete (yyvsp[-5].TypeVal); |
| 5136 | ;} |
| 5137 | break; |
| 5138 | |
| 5139 | case 254: |
| 5140 | #line 2538 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5141 | { |
| 5142 | (yyval.PHIList) = (yyvsp[-6].PHIList); |
| 5143 | Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5144 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5145 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5146 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5147 | (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5148 | ;} |
| 5149 | break; |
| 5150 | |
| 5151 | case 255: |
| 5152 | #line 2548 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5153 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5154 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5155 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5156 | // Used for call and invoke instructions |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5157 | (yyval.ValueRefList) = new ValueRefList(); |
| 5158 | ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal)); |
| 5159 | (yyval.ValueRefList)->push_back(E); |
| 5160 | ;} |
| 5161 | break; |
| 5162 | |
| 5163 | case 256: |
| 5164 | #line 2556 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5165 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5166 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5167 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 5168 | (yyval.ValueRefList) = (yyvsp[-4].ValueRefList); |
| 5169 | ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal)); |
| 5170 | (yyval.ValueRefList)->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5171 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5172 | ;} |
| 5173 | break; |
| 5174 | |
| 5175 | case 257: |
| 5176 | #line 2564 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5177 | { (yyval.ValueRefList) = new ValueRefList(); ;} |
| 5178 | break; |
| 5179 | |
| 5180 | case 258: |
| 5181 | #line 2567 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5182 | { (yyval.ValueList) = new std::vector<Value*>(); ;} |
| 5183 | break; |
| 5184 | |
| 5185 | case 259: |
| 5186 | #line 2568 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5187 | { |
| 5188 | (yyval.ValueList) = (yyvsp[-2].ValueList); |
| 5189 | (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5190 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5191 | ;} |
| 5192 | break; |
| 5193 | |
| 5194 | case 260: |
| 5195 | #line 2575 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5196 | { |
| 5197 | (yyval.BoolVal) = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5198 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5199 | ;} |
| 5200 | break; |
| 5201 | |
| 5202 | case 261: |
| 5203 | #line 2579 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5204 | { |
| 5205 | (yyval.BoolVal) = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5206 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5207 | ;} |
| 5208 | break; |
| 5209 | |
| 5210 | case 262: |
| 5211 | #line 2584 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5212 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5213 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5214 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 5215 | if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() && |
| 5216 | !isa<VectorType>((*(yyvsp[-3].TypeVal)).get())) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5217 | GEN_ERROR( |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5218 | "Arithmetic operator requires integer, FP, or packed operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5219 | if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get()) && |
| 5220 | ((yyvsp[-4].BinaryOpVal) == Instruction::URem || |
| 5221 | (yyvsp[-4].BinaryOpVal) == Instruction::SRem || |
| 5222 | (yyvsp[-4].BinaryOpVal) == Instruction::FRem)) |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5223 | GEN_ERROR("Remainder not supported on packed types"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5224 | Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5225 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5226 | Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5227 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5228 | (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2); |
| 5229 | if ((yyval.InstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5230 | GEN_ERROR("binary operator returned null"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5231 | delete (yyvsp[-3].TypeVal); |
| 5232 | ;} |
| 5233 | break; |
| 5234 | |
| 5235 | case 263: |
| 5236 | #line 2605 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5237 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5238 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5239 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 5240 | if (!(*(yyvsp[-3].TypeVal))->isInteger()) { |
| 5241 | if (Instruction::isShift((yyvsp[-4].BinaryOpVal)) || !isa<VectorType>((yyvsp[-3].TypeVal)->get()) || |
| 5242 | !cast<VectorType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5243 | GEN_ERROR("Logical operator requires integral operands"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5244 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5245 | Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5246 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5247 | Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5248 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5249 | (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2); |
| 5250 | if ((yyval.InstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5251 | GEN_ERROR("binary operator returned null"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5252 | delete (yyvsp[-3].TypeVal); |
| 5253 | ;} |
| 5254 | break; |
| 5255 | |
| 5256 | case 264: |
| 5257 | #line 2622 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5258 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5259 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5260 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 5261 | if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get())) |
Reid Spencer | ac4a1dd | 2007-01-04 02:57:52 +0000 | [diff] [blame] | 5262 | GEN_ERROR("Packed types not supported by icmp instruction"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5263 | Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5264 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5265 | Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5266 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5267 | (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2); |
| 5268 | if ((yyval.InstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5269 | GEN_ERROR("icmp operator returned null"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5270 | ;} |
| 5271 | break; |
| 5272 | |
| 5273 | case 265: |
| 5274 | #line 2635 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5275 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5276 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5277 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 5278 | if (isa<VectorType>((*(yyvsp[-3].TypeVal)).get())) |
Reid Spencer | ac4a1dd | 2007-01-04 02:57:52 +0000 | [diff] [blame] | 5279 | GEN_ERROR("Packed types not supported by fcmp instruction"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5280 | Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5281 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5282 | Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5283 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5284 | (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2); |
| 5285 | if ((yyval.InstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5286 | GEN_ERROR("fcmp operator returned null"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5287 | ;} |
| 5288 | break; |
| 5289 | |
| 5290 | case 266: |
| 5291 | #line 2648 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5292 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5293 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5294 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 5295 | Value* Val = (yyvsp[-2].ValueVal); |
| 5296 | const Type* DestTy = (yyvsp[0].TypeVal)->get(); |
| 5297 | if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5298 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 5299 | Val->getType()->getDescription() + "' to '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5300 | DestTy->getDescription() + "'"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5301 | (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy); |
| 5302 | delete (yyvsp[0].TypeVal); |
| 5303 | ;} |
| 5304 | break; |
| 5305 | |
| 5306 | case 267: |
| 5307 | #line 2660 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5308 | { |
| 5309 | if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5310 | GEN_ERROR("select condition must be boolean"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5311 | if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5312 | GEN_ERROR("select value types should match"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5313 | (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5314 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5315 | ;} |
| 5316 | break; |
| 5317 | |
| 5318 | case 268: |
| 5319 | #line 2668 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5320 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5321 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5322 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 5323 | (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal)); |
| 5324 | delete (yyvsp[0].TypeVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5325 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5326 | ;} |
| 5327 | break; |
| 5328 | |
| 5329 | case 269: |
| 5330 | #line 2675 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5331 | { |
| 5332 | if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5333 | GEN_ERROR("Invalid extractelement operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5334 | (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5335 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5336 | ;} |
| 5337 | break; |
| 5338 | |
| 5339 | case 270: |
| 5340 | #line 2681 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5341 | { |
| 5342 | if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5343 | GEN_ERROR("Invalid insertelement operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5344 | (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5345 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5346 | ;} |
| 5347 | break; |
| 5348 | |
| 5349 | case 271: |
| 5350 | #line 2687 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5351 | { |
| 5352 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5353 | GEN_ERROR("Invalid shufflevector operands"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5354 | (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5355 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5356 | ;} |
| 5357 | break; |
| 5358 | |
| 5359 | case 272: |
| 5360 | #line 2693 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5361 | { |
| 5362 | const Type *Ty = (yyvsp[0].PHIList)->front().first->getType(); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5363 | if (!Ty->isFirstClassType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5364 | GEN_ERROR("PHI node operands must be of first class type"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5365 | (yyval.InstVal) = new PHINode(Ty); |
| 5366 | ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size()); |
| 5367 | while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) { |
| 5368 | if ((yyvsp[0].PHIList)->front().first->getType() != Ty) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5369 | GEN_ERROR("All elements of a PHI node must be of the same type"); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5370 | cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second); |
| 5371 | (yyvsp[0].PHIList)->pop_front(); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5372 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5373 | delete (yyvsp[0].PHIList); // Free the list... |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5374 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5375 | ;} |
| 5376 | break; |
| 5377 | |
| 5378 | case 273: |
| 5379 | #line 2709 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5380 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5381 | |
| 5382 | // Handle the short syntax |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5383 | const PointerType *PFTy = 0; |
| 5384 | const FunctionType *Ty = 0; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5385 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) || |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5386 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5387 | // Pull out the types of all of the arguments... |
| 5388 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5389 | FunctionType::ParamAttrsList ParamAttrs; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5390 | ParamAttrs.push_back((yyvsp[0].ParamAttrs)); |
| 5391 | for (ValueRefList::iterator I = (yyvsp[-2].ValueRefList)->begin(), E = (yyvsp[-2].ValueRefList)->end(); I != E; ++I) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5392 | const Type *Ty = I->Val->getType(); |
| 5393 | if (Ty == Type::VoidTy) |
| 5394 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 5395 | ParamTypes.push_back(Ty); |
| 5396 | ParamAttrs.push_back(I->Attrs); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5397 | } |
| 5398 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5399 | Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, ParamAttrs); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5400 | PFTy = PointerType::get(Ty); |
| 5401 | } |
| 5402 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5403 | Value *V = getVal(PFTy, (yyvsp[-4].ValIDVal)); // Get the function we're calling... |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5404 | CHECK_FOR_ERROR |
| 5405 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5406 | // Check the arguments |
| 5407 | ValueList Args; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5408 | if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments? |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5409 | // Make sure no arguments is a good thing! |
| 5410 | if (Ty->getNumParams() != 0) |
| 5411 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5412 | "expects arguments"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5413 | } else { // Has arguments? |
| 5414 | // Loop through FunctionType's arguments and ensure they are specified |
| 5415 | // correctly! |
| 5416 | // |
| 5417 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5418 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5419 | ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5420 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5421 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5422 | if (ArgI->Val->getType() != *I) |
| 5423 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5424 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5425 | Args.push_back(ArgI->Val); |
| 5426 | } |
| 5427 | if (Ty->isVarArg()) { |
| 5428 | if (I == E) |
| 5429 | for (; ArgI != ArgE; ++ArgI) |
| 5430 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 5431 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5432 | GEN_ERROR("Invalid number of parameters detected"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5433 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5434 | // Create the call node |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5435 | CallInst *CI = new CallInst(V, &Args[0], Args.size()); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5436 | CI->setTailCall((yyvsp[-7].BoolVal)); |
| 5437 | CI->setCallingConv((yyvsp[-6].UIntVal)); |
| 5438 | (yyval.InstVal) = CI; |
| 5439 | delete (yyvsp[-2].ValueRefList); |
| 5440 | delete (yyvsp[-5].TypeVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5441 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5442 | ;} |
| 5443 | break; |
| 5444 | |
| 5445 | case 274: |
| 5446 | #line 2772 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5447 | { |
| 5448 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5449 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5450 | ;} |
| 5451 | break; |
| 5452 | |
| 5453 | case 275: |
| 5454 | #line 2777 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5455 | { |
| 5456 | (yyval.BoolVal) = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5457 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5458 | ;} |
| 5459 | break; |
| 5460 | |
| 5461 | case 276: |
| 5462 | #line 2781 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5463 | { |
| 5464 | (yyval.BoolVal) = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5465 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5466 | ;} |
| 5467 | break; |
| 5468 | |
| 5469 | case 277: |
| 5470 | #line 2788 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5471 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5472 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5473 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5474 | (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); |
| 5475 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5476 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5477 | ;} |
| 5478 | break; |
| 5479 | |
| 5480 | case 278: |
| 5481 | #line 2795 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5482 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5483 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5484 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription()); |
| 5485 | Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5486 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5487 | (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); |
| 5488 | delete (yyvsp[-4].TypeVal); |
| 5489 | ;} |
| 5490 | break; |
| 5491 | |
| 5492 | case 279: |
| 5493 | #line 2803 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5494 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5495 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5496 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5497 | (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); |
| 5498 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5499 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5500 | ;} |
| 5501 | break; |
| 5502 | |
| 5503 | case 280: |
| 5504 | #line 2810 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5505 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5506 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5507 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription()); |
| 5508 | Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5509 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5510 | (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); |
| 5511 | delete (yyvsp[-4].TypeVal); |
| 5512 | ;} |
| 5513 | break; |
| 5514 | |
| 5515 | case 281: |
| 5516 | #line 2818 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5517 | { |
| 5518 | if (!isa<PointerType>((yyvsp[0].ValueVal)->getType())) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5519 | GEN_ERROR("Trying to free nonpointer type " + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5520 | (yyvsp[0].ValueVal)->getType()->getDescription() + ""); |
| 5521 | (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5522 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5523 | ;} |
| 5524 | break; |
| 5525 | |
| 5526 | case 282: |
| 5527 | #line 2826 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5528 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5529 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5530 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5531 | if (!isa<PointerType>((yyvsp[-1].TypeVal)->get())) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5532 | GEN_ERROR("Can't load from nonpointer type: " + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5533 | (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5534 | if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5535 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5536 | (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5537 | Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5538 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5539 | (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal)); |
| 5540 | delete (yyvsp[-1].TypeVal); |
| 5541 | ;} |
| 5542 | break; |
| 5543 | |
| 5544 | case 283: |
| 5545 | #line 2840 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5546 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5547 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5548 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5549 | const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5550 | if (!PT) |
| 5551 | GEN_ERROR("Can't store to a nonpointer type: " + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5552 | (*(yyvsp[-1].TypeVal))->getDescription()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5553 | const Type *ElTy = PT->getElementType(); |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5554 | if (ElTy != (yyvsp[-3].ValueVal)->getType()) |
| 5555 | GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5556 | "' into space of type '" + ElTy->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5557 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5558 | Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5559 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5560 | (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal)); |
| 5561 | delete (yyvsp[-1].TypeVal); |
| 5562 | ;} |
| 5563 | break; |
| 5564 | |
| 5565 | case 284: |
| 5566 | #line 2857 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
| 5567 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5568 | if (!UpRefs.empty()) |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5569 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 5570 | if (!isa<PointerType>((yyvsp[-2].TypeVal)->get())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5571 | GEN_ERROR("getelementptr insn requires pointer operand"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5572 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5573 | if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size(), true)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5574 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5575 | (*(yyvsp[-2].TypeVal))->getDescription()+ "'"); |
| 5576 | Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5577 | CHECK_FOR_ERROR |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5578 | (yyval.InstVal) = new GetElementPtrInst(tmpVal, &(*(yyvsp[0].ValueList))[0], (yyvsp[0].ValueList)->size()); |
| 5579 | delete (yyvsp[-2].TypeVal); |
| 5580 | delete (yyvsp[0].ValueList); |
| 5581 | ;} |
| 5582 | break; |
| 5583 | |
| 5584 | |
| 5585 | default: break; |
| 5586 | } |
| 5587 | |
| 5588 | /* Line 1126 of yacc.c. */ |
| 5589 | #line 5590 "llvmAsmParser.tab.c" |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5590 | |
| 5591 | yyvsp -= yylen; |
| 5592 | yyssp -= yylen; |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 5593 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5594 | |
| 5595 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5596 | |
| 5597 | *++yyvsp = yyval; |
| 5598 | |
| 5599 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5600 | /* Now `shift' the result of the reduction. Determine what state |
| 5601 | that goes to, based on the state we popped back to and the rule |
| 5602 | number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5603 | |
| 5604 | yyn = yyr1[yyn]; |
| 5605 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5606 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 5607 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5608 | yystate = yytable[yystate]; |
| 5609 | else |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5610 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5611 | |
| 5612 | goto yynewstate; |
| 5613 | |
| 5614 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5615 | /*------------------------------------. |
| 5616 | | yyerrlab -- here on detecting error | |
| 5617 | `------------------------------------*/ |
| 5618 | yyerrlab: |
| 5619 | /* If not already recovering from an error, report this error. */ |
| 5620 | if (!yyerrstatus) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5621 | { |
| 5622 | ++yynerrs; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5623 | #if YYERROR_VERBOSE |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5624 | yyn = yypact[yystate]; |
| 5625 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5626 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5627 | { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5628 | int yytype = YYTRANSLATE (yychar); |
| 5629 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); |
| 5630 | YYSIZE_T yysize = yysize0; |
| 5631 | YYSIZE_T yysize1; |
| 5632 | int yysize_overflow = 0; |
| 5633 | char *yymsg = 0; |
| 5634 | # define YYERROR_VERBOSE_ARGS_MAXIMUM 5 |
| 5635 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 5636 | int yyx; |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5637 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5638 | #if 0 |
| 5639 | /* This is so xgettext sees the translatable formats that are |
| 5640 | constructed on the fly. */ |
| 5641 | YY_("syntax error, unexpected %s"); |
| 5642 | YY_("syntax error, unexpected %s, expecting %s"); |
| 5643 | YY_("syntax error, unexpected %s, expecting %s or %s"); |
| 5644 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); |
| 5645 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); |
| 5646 | #endif |
| 5647 | char *yyfmt; |
| 5648 | char const *yyf; |
| 5649 | static char const yyunexpected[] = "syntax error, unexpected %s"; |
| 5650 | static char const yyexpecting[] = ", expecting %s"; |
| 5651 | static char const yyor[] = " or %s"; |
| 5652 | char yyformat[sizeof yyunexpected |
| 5653 | + sizeof yyexpecting - 1 |
| 5654 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) |
| 5655 | * (sizeof yyor - 1))]; |
| 5656 | char const *yyprefix = yyexpecting; |
| 5657 | |
| 5658 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 5659 | YYCHECK. */ |
| 5660 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 5661 | |
| 5662 | /* Stay within bounds of both yycheck and yytname. */ |
| 5663 | int yychecklim = YYLAST - yyn; |
| 5664 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 5665 | int yycount = 1; |
| 5666 | |
| 5667 | yyarg[0] = yytname[yytype]; |
| 5668 | yyfmt = yystpcpy (yyformat, yyunexpected); |
| 5669 | |
| 5670 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 5671 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 5672 | { |
| 5673 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 5674 | { |
| 5675 | yycount = 1; |
| 5676 | yysize = yysize0; |
| 5677 | yyformat[sizeof yyunexpected - 1] = '\0'; |
| 5678 | break; |
| 5679 | } |
| 5680 | yyarg[yycount++] = yytname[yyx]; |
| 5681 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); |
| 5682 | yysize_overflow |= yysize1 < yysize; |
| 5683 | yysize = yysize1; |
| 5684 | yyfmt = yystpcpy (yyfmt, yyprefix); |
| 5685 | yyprefix = yyor; |
| 5686 | } |
| 5687 | |
| 5688 | yyf = YY_(yyformat); |
| 5689 | yysize1 = yysize + yystrlen (yyf); |
| 5690 | yysize_overflow |= yysize1 < yysize; |
| 5691 | yysize = yysize1; |
| 5692 | |
| 5693 | if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) |
| 5694 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
| 5695 | if (yymsg) |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5696 | { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5697 | /* Avoid sprintf, as that infringes on the user's name space. |
| 5698 | Don't have undefined behavior even if the translation |
| 5699 | produced a string with the wrong number of "%s"s. */ |
| 5700 | char *yyp = yymsg; |
| 5701 | int yyi = 0; |
| 5702 | while ((*yyp = *yyf)) |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5703 | { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5704 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) |
| 5705 | { |
| 5706 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
| 5707 | yyf += 2; |
| 5708 | } |
| 5709 | else |
| 5710 | { |
| 5711 | yyp++; |
| 5712 | yyf++; |
| 5713 | } |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5714 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5715 | yyerror (yymsg); |
| 5716 | YYSTACK_FREE (yymsg); |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5717 | } |
| 5718 | else |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5719 | { |
| 5720 | yyerror (YY_("syntax error")); |
| 5721 | goto yyexhaustedlab; |
| 5722 | } |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5723 | } |
| 5724 | else |
| 5725 | #endif /* YYERROR_VERBOSE */ |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5726 | yyerror (YY_("syntax error")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5727 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5728 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5729 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5730 | |
| 5731 | if (yyerrstatus == 3) |
| 5732 | { |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5733 | /* If just tried and failed to reuse look-ahead token after an |
| 5734 | error, discard it. */ |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5735 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5736 | if (yychar <= YYEOF) |
| 5737 | { |
| 5738 | /* Return failure if at end of input. */ |
| 5739 | if (yychar == YYEOF) |
| 5740 | YYABORT; |
| 5741 | } |
| 5742 | else |
| 5743 | { |
| 5744 | yydestruct ("Error: discarding", yytoken, &yylval); |
| 5745 | yychar = YYEMPTY; |
| 5746 | } |
| 5747 | } |
| 5748 | |
| 5749 | /* Else will try to reuse look-ahead token after shifting the error |
| 5750 | token. */ |
| 5751 | goto yyerrlab1; |
| 5752 | |
| 5753 | |
| 5754 | /*---------------------------------------------------. |
| 5755 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 5756 | `---------------------------------------------------*/ |
| 5757 | yyerrorlab: |
| 5758 | |
| 5759 | /* Pacify compilers like GCC when the user code never invokes |
| 5760 | YYERROR and the label yyerrorlab therefore never appears in user |
| 5761 | code. */ |
| 5762 | if (0) |
| 5763 | goto yyerrorlab; |
| 5764 | |
| 5765 | yyvsp -= yylen; |
| 5766 | yyssp -= yylen; |
| 5767 | yystate = *yyssp; |
| 5768 | goto yyerrlab1; |
| 5769 | |
| 5770 | |
| 5771 | /*-------------------------------------------------------------. |
| 5772 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 5773 | `-------------------------------------------------------------*/ |
| 5774 | yyerrlab1: |
| 5775 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 5776 | |
| 5777 | for (;;) |
| 5778 | { |
| 5779 | yyn = yypact[yystate]; |
| 5780 | if (yyn != YYPACT_NINF) |
| 5781 | { |
| 5782 | yyn += YYTERROR; |
| 5783 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 5784 | { |
| 5785 | yyn = yytable[yyn]; |
| 5786 | if (0 < yyn) |
| 5787 | break; |
| 5788 | } |
| 5789 | } |
| 5790 | |
| 5791 | /* Pop the current state because it cannot handle the error token. */ |
| 5792 | if (yyssp == yyss) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5793 | YYABORT; |
| 5794 | |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5795 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5796 | yydestruct ("Error: popping", yystos[yystate], yyvsp); |
| 5797 | YYPOPSTACK; |
| 5798 | yystate = *yyssp; |
| 5799 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5800 | } |
| 5801 | |
| 5802 | if (yyn == YYFINAL) |
| 5803 | YYACCEPT; |
| 5804 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5805 | *++yyvsp = yylval; |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5806 | |
| 5807 | |
| 5808 | /* Shift the error token. */ |
| 5809 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5810 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5811 | yystate = yyn; |
| 5812 | goto yynewstate; |
| 5813 | |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5814 | |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5815 | /*-------------------------------------. |
| 5816 | | yyacceptlab -- YYACCEPT comes here. | |
| 5817 | `-------------------------------------*/ |
| 5818 | yyacceptlab: |
| 5819 | yyresult = 0; |
| 5820 | goto yyreturn; |
| 5821 | |
| 5822 | /*-----------------------------------. |
| 5823 | | yyabortlab -- YYABORT comes here. | |
| 5824 | `-----------------------------------*/ |
| 5825 | yyabortlab: |
| 5826 | yyresult = 1; |
| 5827 | goto yyreturn; |
| 5828 | |
| 5829 | #ifndef yyoverflow |
| 5830 | /*-------------------------------------------------. |
| 5831 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 5832 | `-------------------------------------------------*/ |
| 5833 | yyexhaustedlab: |
| 5834 | yyerror (YY_("memory exhausted")); |
| 5835 | yyresult = 2; |
| 5836 | /* Fall through. */ |
Chris Lattner | 7d9801d | 2007-02-13 00:58:01 +0000 | [diff] [blame] | 5837 | #endif |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5838 | |
| 5839 | yyreturn: |
| 5840 | if (yychar != YYEOF && yychar != YYEMPTY) |
| 5841 | yydestruct ("Cleanup: discarding lookahead", |
| 5842 | yytoken, &yylval); |
| 5843 | while (yyssp != yyss) |
| 5844 | { |
| 5845 | yydestruct ("Cleanup: popping", |
| 5846 | yystos[*yyssp], yyvsp); |
| 5847 | YYPOPSTACK; |
Chris Lattner | 9d2fda6 | 2007-02-13 05:53:56 +0000 | [diff] [blame] | 5848 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5849 | #ifndef yyoverflow |
| 5850 | if (yyss != yyssa) |
| 5851 | YYSTACK_FREE (yyss); |
| 5852 | #endif |
| 5853 | return yyresult; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5854 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5855 | |
| 5856 | |
| 5857 | #line 2874 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5858 | |
| 5859 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5860 | // common code from the two 'RunVMAsmParser' functions |
| 5861 | static Module* RunParser(Module * M) { |
| 5862 | |
| 5863 | llvmAsmlineno = 1; // Reset the current line number... |
| 5864 | CurModule.CurrentModule = M; |
| 5865 | #if YYDEBUG |
| 5866 | yydebug = Debug; |
| 5867 | #endif |
| 5868 | |
| 5869 | // Check to make sure the parser succeeded |
| 5870 | if (yyparse()) { |
| 5871 | if (ParserResult) |
| 5872 | delete ParserResult; |
| 5873 | return 0; |
| 5874 | } |
| 5875 | |
| 5876 | // Check to make sure that parsing produced a result |
| 5877 | if (!ParserResult) |
| 5878 | return 0; |
| 5879 | |
| 5880 | // Reset ParserResult variable while saving its value for the result. |
| 5881 | Module *Result = ParserResult; |
| 5882 | ParserResult = 0; |
| 5883 | |
| 5884 | return Result; |
| 5885 | } |
| 5886 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5887 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 5888 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 5889 | // TODO: column number in exception |
| 5890 | if (TheParseError) |
| 5891 | TheParseError->setError(CurFilename, message, LineNo); |
| 5892 | TriggerError = 1; |
| 5893 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5894 | |
| 5895 | int yyerror(const char *ErrorMsg) { |
| 5896 | std::string where |
| 5897 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 5898 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame] | 5899 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 5900 | if (yychar != YYEMPTY && yychar != 0) |
| 5901 | errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+ |
| 5902 | "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5903 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5904 | return 0; |
| 5905 | } |
Reid Spencer | 9d6565a | 2007-02-15 02:26:10 +0000 | [diff] [blame^] | 5906 | |