Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +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 | b0fcf8f | 2007-01-17 02:48:45 +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 | b0fcf8f | 2007-01-17 02:48:45 +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 | b0fcf8f | 2007-01-17 02:48:45 +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 | b0fcf8f | 2007-01-17 02:48:45 +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 | b0fcf8f | 2007-01-17 02:48:45 +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 | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 60 | |
| 61 | /* Tokens. */ |
| 62 | #ifndef YYTOKENTYPE |
| 63 | # define YYTOKENTYPE |
| 64 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
| 65 | know about them. */ |
| 66 | enum yytokentype { |
| 67 | ESINT64VAL = 258, |
| 68 | EUINT64VAL = 259, |
| 69 | SINTVAL = 260, |
| 70 | UINTVAL = 261, |
| 71 | FPVAL = 262, |
| 72 | VOID = 263, |
| 73 | INTTYPE = 264, |
| 74 | FLOAT = 265, |
| 75 | DOUBLE = 266, |
| 76 | LABEL = 267, |
| 77 | TYPE = 268, |
| 78 | VAR_ID = 269, |
| 79 | LABELSTR = 270, |
| 80 | STRINGCONSTANT = 271, |
| 81 | IMPLEMENTATION = 272, |
| 82 | ZEROINITIALIZER = 273, |
| 83 | TRUETOK = 274, |
| 84 | FALSETOK = 275, |
| 85 | BEGINTOK = 276, |
| 86 | ENDTOK = 277, |
| 87 | DECLARE = 278, |
| 88 | DEFINE = 279, |
| 89 | GLOBAL = 280, |
| 90 | CONSTANT = 281, |
| 91 | SECTION = 282, |
| 92 | VOLATILE = 283, |
| 93 | TO = 284, |
| 94 | DOTDOTDOT = 285, |
| 95 | NULL_TOK = 286, |
| 96 | UNDEF = 287, |
| 97 | INTERNAL = 288, |
| 98 | LINKONCE = 289, |
| 99 | WEAK = 290, |
| 100 | APPENDING = 291, |
| 101 | DLLIMPORT = 292, |
| 102 | DLLEXPORT = 293, |
| 103 | EXTERN_WEAK = 294, |
| 104 | OPAQUE = 295, |
| 105 | EXTERNAL = 296, |
| 106 | TARGET = 297, |
| 107 | TRIPLE = 298, |
| 108 | ENDIAN = 299, |
| 109 | POINTERSIZE = 300, |
| 110 | LITTLE = 301, |
| 111 | BIG = 302, |
| 112 | ALIGN = 303, |
| 113 | DEPLIBS = 304, |
| 114 | CALL = 305, |
| 115 | TAIL = 306, |
| 116 | ASM_TOK = 307, |
| 117 | MODULE = 308, |
| 118 | SIDEEFFECT = 309, |
| 119 | CC_TOK = 310, |
| 120 | CCC_TOK = 311, |
| 121 | CSRETCC_TOK = 312, |
| 122 | FASTCC_TOK = 313, |
| 123 | COLDCC_TOK = 314, |
| 124 | X86_STDCALLCC_TOK = 315, |
| 125 | X86_FASTCALLCC_TOK = 316, |
| 126 | DATALAYOUT = 317, |
| 127 | RET = 318, |
| 128 | BR = 319, |
| 129 | SWITCH = 320, |
| 130 | INVOKE = 321, |
| 131 | UNWIND = 322, |
| 132 | UNREACHABLE = 323, |
| 133 | ADD = 324, |
| 134 | SUB = 325, |
| 135 | MUL = 326, |
| 136 | UDIV = 327, |
| 137 | SDIV = 328, |
| 138 | FDIV = 329, |
| 139 | UREM = 330, |
| 140 | SREM = 331, |
| 141 | FREM = 332, |
| 142 | AND = 333, |
| 143 | OR = 334, |
| 144 | XOR = 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 | SHL = 378, |
| 188 | LSHR = 379, |
| 189 | ASHR = 380, |
| 190 | VAARG = 381, |
| 191 | EXTRACTELEMENT = 382, |
| 192 | INSERTELEMENT = 383, |
| 193 | SHUFFLEVECTOR = 384, |
| 194 | NORETURN = 385, |
| 195 | DEFAULT = 386, |
| 196 | HIDDEN = 387 |
| 197 | }; |
| 198 | #endif |
| 199 | /* Tokens. */ |
| 200 | #define ESINT64VAL 258 |
| 201 | #define EUINT64VAL 259 |
| 202 | #define SINTVAL 260 |
| 203 | #define UINTVAL 261 |
| 204 | #define FPVAL 262 |
| 205 | #define VOID 263 |
| 206 | #define INTTYPE 264 |
| 207 | #define FLOAT 265 |
| 208 | #define DOUBLE 266 |
| 209 | #define LABEL 267 |
| 210 | #define TYPE 268 |
| 211 | #define VAR_ID 269 |
| 212 | #define LABELSTR 270 |
| 213 | #define STRINGCONSTANT 271 |
| 214 | #define IMPLEMENTATION 272 |
| 215 | #define ZEROINITIALIZER 273 |
| 216 | #define TRUETOK 274 |
| 217 | #define FALSETOK 275 |
| 218 | #define BEGINTOK 276 |
| 219 | #define ENDTOK 277 |
| 220 | #define DECLARE 278 |
| 221 | #define DEFINE 279 |
| 222 | #define GLOBAL 280 |
| 223 | #define CONSTANT 281 |
| 224 | #define SECTION 282 |
| 225 | #define VOLATILE 283 |
| 226 | #define TO 284 |
| 227 | #define DOTDOTDOT 285 |
| 228 | #define NULL_TOK 286 |
| 229 | #define UNDEF 287 |
| 230 | #define INTERNAL 288 |
| 231 | #define LINKONCE 289 |
| 232 | #define WEAK 290 |
| 233 | #define APPENDING 291 |
| 234 | #define DLLIMPORT 292 |
| 235 | #define DLLEXPORT 293 |
| 236 | #define EXTERN_WEAK 294 |
| 237 | #define OPAQUE 295 |
| 238 | #define EXTERNAL 296 |
| 239 | #define TARGET 297 |
| 240 | #define TRIPLE 298 |
| 241 | #define ENDIAN 299 |
| 242 | #define POINTERSIZE 300 |
| 243 | #define LITTLE 301 |
| 244 | #define BIG 302 |
| 245 | #define ALIGN 303 |
| 246 | #define DEPLIBS 304 |
| 247 | #define CALL 305 |
| 248 | #define TAIL 306 |
| 249 | #define ASM_TOK 307 |
| 250 | #define MODULE 308 |
| 251 | #define SIDEEFFECT 309 |
| 252 | #define CC_TOK 310 |
| 253 | #define CCC_TOK 311 |
| 254 | #define CSRETCC_TOK 312 |
| 255 | #define FASTCC_TOK 313 |
| 256 | #define COLDCC_TOK 314 |
| 257 | #define X86_STDCALLCC_TOK 315 |
| 258 | #define X86_FASTCALLCC_TOK 316 |
| 259 | #define DATALAYOUT 317 |
| 260 | #define RET 318 |
| 261 | #define BR 319 |
| 262 | #define SWITCH 320 |
| 263 | #define INVOKE 321 |
| 264 | #define UNWIND 322 |
| 265 | #define UNREACHABLE 323 |
| 266 | #define ADD 324 |
| 267 | #define SUB 325 |
| 268 | #define MUL 326 |
| 269 | #define UDIV 327 |
| 270 | #define SDIV 328 |
| 271 | #define FDIV 329 |
| 272 | #define UREM 330 |
| 273 | #define SREM 331 |
| 274 | #define FREM 332 |
| 275 | #define AND 333 |
| 276 | #define OR 334 |
| 277 | #define XOR 335 |
| 278 | #define ICMP 336 |
| 279 | #define FCMP 337 |
| 280 | #define EQ 338 |
| 281 | #define NE 339 |
| 282 | #define SLT 340 |
| 283 | #define SGT 341 |
| 284 | #define SLE 342 |
| 285 | #define SGE 343 |
| 286 | #define ULT 344 |
| 287 | #define UGT 345 |
| 288 | #define ULE 346 |
| 289 | #define UGE 347 |
| 290 | #define OEQ 348 |
| 291 | #define ONE 349 |
| 292 | #define OLT 350 |
| 293 | #define OGT 351 |
| 294 | #define OLE 352 |
| 295 | #define OGE 353 |
| 296 | #define ORD 354 |
| 297 | #define UNO 355 |
| 298 | #define UEQ 356 |
| 299 | #define UNE 357 |
| 300 | #define MALLOC 358 |
| 301 | #define ALLOCA 359 |
| 302 | #define FREE 360 |
| 303 | #define LOAD 361 |
| 304 | #define STORE 362 |
| 305 | #define GETELEMENTPTR 363 |
| 306 | #define TRUNC 364 |
| 307 | #define ZEXT 365 |
| 308 | #define SEXT 366 |
| 309 | #define FPTRUNC 367 |
| 310 | #define FPEXT 368 |
| 311 | #define BITCAST 369 |
| 312 | #define UITOFP 370 |
| 313 | #define SITOFP 371 |
| 314 | #define FPTOUI 372 |
| 315 | #define FPTOSI 373 |
| 316 | #define INTTOPTR 374 |
| 317 | #define PTRTOINT 375 |
| 318 | #define PHI_TOK 376 |
| 319 | #define SELECT 377 |
| 320 | #define SHL 378 |
| 321 | #define LSHR 379 |
| 322 | #define ASHR 380 |
| 323 | #define VAARG 381 |
| 324 | #define EXTRACTELEMENT 382 |
| 325 | #define INSERTELEMENT 383 |
| 326 | #define SHUFFLEVECTOR 384 |
| 327 | #define NORETURN 385 |
| 328 | #define DEFAULT 386 |
| 329 | #define HIDDEN 387 |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | /* Copy the first part of user declarations. */ |
| 335 | #line 14 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 336 | |
| 337 | #include "ParserInternals.h" |
| 338 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 339 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 340 | #include "llvm/Instructions.h" |
| 341 | #include "llvm/Module.h" |
| 342 | #include "llvm/SymbolTable.h" |
| 343 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 344 | #include "llvm/Support/CommandLine.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 345 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 346 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 481169e | 2006-12-01 00:33:46 +0000 | [diff] [blame] | 347 | #include "llvm/Support/Streams.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 348 | #include <algorithm> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 349 | #include <list> |
| 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; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 533 | bool isDeclare; // Is this function a forward declararation? |
| 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) { |
| 595 | case ValID::NumberVal: // Is it a numbered definition? |
| 596 | // Module constants occupy the lowest numbered slots... |
| 597 | if ((unsigned)D.Num < CurModule.Types.size()) |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 598 | return CurModule.Types[(unsigned)D.Num]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 599 | break; |
| 600 | case ValID::NameVal: // Is it a named definition? |
| 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 | 61c83e0 | 2006-08-18 08:43: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 | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 619 | if (D.Type == ValID::NameVal) { |
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 | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 623 | GenerateError("Reference to an undefined type: #" + itostr(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 | |
| 637 | static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) { |
| 638 | SymbolTable &SymTab = |
Reid Spencer | 78d033e | 2007-01-06 07:24:44 +0000 | [diff] [blame] | 639 | inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() : |
| 640 | CurModule.CurrentModule->getValueSymbolTable(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 641 | return SymTab.lookup(Ty, Name); |
| 642 | } |
| 643 | |
| 644 | // getValNonImprovising - Look up the value specified by the provided type and |
| 645 | // the provided ValID. If the value exists and has already been defined, return |
| 646 | // it. Otherwise return null. |
| 647 | // |
| 648 | static Value *getValNonImprovising(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 649 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 650 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 651 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 652 | return 0; |
| 653 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 654 | |
| 655 | switch (D.Type) { |
| 656 | case ValID::NumberVal: { // Is it a numbered definition? |
| 657 | unsigned Num = (unsigned)D.Num; |
| 658 | |
| 659 | // Module constants occupy the lowest numbered slots... |
| 660 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
| 661 | if (VI != CurModule.Values.end()) { |
| 662 | if (Num < VI->second.size()) |
| 663 | return VI->second[Num]; |
| 664 | Num -= VI->second.size(); |
| 665 | } |
| 666 | |
| 667 | // Make sure that our type is within bounds |
| 668 | VI = CurFun.Values.find(Ty); |
| 669 | if (VI == CurFun.Values.end()) return 0; |
| 670 | |
| 671 | // Check that the number is within bounds... |
| 672 | if (VI->second.size() <= Num) return 0; |
| 673 | |
| 674 | return VI->second[Num]; |
| 675 | } |
| 676 | |
| 677 | case ValID::NameVal: { // Is it a named definition? |
| 678 | Value *N = lookupInSymbolTable(Ty, std::string(D.Name)); |
| 679 | if (N == 0) return 0; |
| 680 | |
| 681 | D.destroy(); // Free old strdup'd memory... |
| 682 | return N; |
| 683 | } |
| 684 | |
| 685 | // Check to make sure that "Ty" is an integral type, and that our |
| 686 | // value will fit into the specified type... |
| 687 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 688 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 689 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 690 | itostr(D.ConstPool64) + "' is invalid for type '" + |
| 691 | Ty->getDescription() + "'!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 692 | return 0; |
| 693 | } |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 694 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 695 | |
| 696 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 697 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 698 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 699 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 700 | "' is invalid or out of range!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 701 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 702 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 703 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 704 | } |
| 705 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 706 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 710 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 711 | GenerateError("FP constant invalid for type!!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 712 | return 0; |
| 713 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 714 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 715 | |
| 716 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 717 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 718 | GenerateError("Cannot create a a non pointer null!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 719 | return 0; |
| 720 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 721 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 722 | |
| 723 | case ValID::ConstUndefVal: // Is it an undef value? |
| 724 | return UndefValue::get(Ty); |
| 725 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 726 | case ValID::ConstZeroVal: // Is it a zero value? |
| 727 | return Constant::getNullValue(Ty); |
| 728 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 729 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 730 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 731 | GenerateError("Constant expression type different from required type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 732 | return 0; |
| 733 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 734 | return D.ConstantValue; |
| 735 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 736 | case ValID::InlineAsmVal: { // Inline asm expression |
| 737 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 738 | const FunctionType *FTy = |
| 739 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 740 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 741 | GenerateError("Invalid type for asm constraint string!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 742 | return 0; |
| 743 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 744 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 745 | D.IAD->HasSideEffects); |
| 746 | D.destroy(); // Free InlineAsmDescriptor. |
| 747 | return IA; |
| 748 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 749 | default: |
| 750 | assert(0 && "Unhandled case!"); |
| 751 | return 0; |
| 752 | } // End of switch |
| 753 | |
| 754 | assert(0 && "Unhandled case!"); |
| 755 | return 0; |
| 756 | } |
| 757 | |
| 758 | // getVal - This function is identical to getValNonImprovising, except that if a |
| 759 | // value is not already defined, it "improvises" by creating a placeholder var |
| 760 | // that looks and acts just like the requested variable. When the value is |
| 761 | // defined later, all uses of the placeholder variable are replaced with the |
| 762 | // real thing. |
| 763 | // |
| 764 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 765 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 766 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 767 | return 0; |
| 768 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 769 | |
| 770 | // See if the value has already been defined. |
| 771 | Value *V = getValNonImprovising(Ty, ID); |
| 772 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 773 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 774 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 775 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 776 | GenerateError("Invalid use of a composite type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 777 | return 0; |
| 778 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 779 | |
| 780 | // If we reached here, we referenced either a symbol that we don't know about |
| 781 | // or an id number that hasn't been read yet. We may be referencing something |
| 782 | // forward, so just create an entry to be resolved later and get to it... |
| 783 | // |
| 784 | V = new Argument(Ty); |
| 785 | |
| 786 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 787 | // to recycle these things?? |
| 788 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 789 | llvmAsmlineno))); |
| 790 | |
| 791 | if (inFunctionScope()) |
| 792 | InsertValue(V, CurFun.LateResolveValues); |
| 793 | else |
| 794 | InsertValue(V, CurModule.LateResolveValues); |
| 795 | return V; |
| 796 | } |
| 797 | |
| 798 | /// getBBVal - This is used for two purposes: |
| 799 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 800 | /// defined. |
| 801 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 802 | /// or may not be a forward reference. |
| 803 | /// |
| 804 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
| 805 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
| 806 | |
| 807 | std::string Name; |
| 808 | BasicBlock *BB = 0; |
| 809 | switch (ID.Type) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 810 | default: |
| 811 | GenerateError("Illegal label reference " + ID.getName()); |
| 812 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 813 | case ValID::NumberVal: // Is it a numbered definition? |
| 814 | if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) |
| 815 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 816 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 817 | break; |
| 818 | case ValID::NameVal: // Is it a named definition? |
| 819 | Name = ID.Name; |
| 820 | if (Value *N = CurFun.CurrentFunction-> |
Reid Spencer | 78d033e | 2007-01-06 07:24:44 +0000 | [diff] [blame] | 821 | getValueSymbolTable().lookup(Type::LabelTy, Name)) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 822 | BB = cast<BasicBlock>(N); |
| 823 | break; |
| 824 | } |
| 825 | |
| 826 | // See if the block has already been defined. |
| 827 | if (BB) { |
| 828 | // If this is the definition of the block, make sure the existing value was |
| 829 | // just a forward reference. If it was a forward reference, there will be |
| 830 | // an entry for it in the PlaceHolderInfo map. |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 831 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 832 | // The existing value was a definition, not a forward reference. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 833 | GenerateError("Redefinition of label " + ID.getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 834 | return 0; |
| 835 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 836 | |
| 837 | ID.destroy(); // Free strdup'd memory. |
| 838 | return BB; |
| 839 | } |
| 840 | |
| 841 | // Otherwise this block has not been seen before. |
| 842 | BB = new BasicBlock("", CurFun.CurrentFunction); |
| 843 | if (ID.Type == ValID::NameVal) { |
| 844 | BB->setName(ID.Name); |
| 845 | } else { |
| 846 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 847 | } |
| 848 | |
| 849 | // If this is not a definition, keep track of it so we can use it as a forward |
| 850 | // reference. |
| 851 | if (!isDefinition) { |
| 852 | // Remember where this forward reference came from. |
| 853 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno); |
| 854 | } else { |
| 855 | // The forward declaration could have been inserted anywhere in the |
| 856 | // function: insert it into the correct place now. |
| 857 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 858 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 859 | } |
| 860 | ID.destroy(); |
| 861 | return BB; |
| 862 | } |
| 863 | |
| 864 | |
| 865 | //===----------------------------------------------------------------------===// |
| 866 | // Code to handle forward references in instructions |
| 867 | //===----------------------------------------------------------------------===// |
| 868 | // |
| 869 | // This code handles the late binding needed with statements that reference |
| 870 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 871 | // a loop body. |
| 872 | // |
| 873 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 874 | // and back patchs after we are done. |
| 875 | // |
| 876 | |
| 877 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 878 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 879 | // defs now... |
| 880 | // |
| 881 | static void |
| 882 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 883 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
| 884 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 885 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 886 | E = LateResolvers.end(); LRI != E; ++LRI) { |
| 887 | ValueList &List = LRI->second; |
| 888 | while (!List.empty()) { |
| 889 | Value *V = List.back(); |
| 890 | List.pop_back(); |
| 891 | |
| 892 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 893 | CurModule.PlaceHolderInfo.find(V); |
| 894 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
| 895 | |
| 896 | ValID &DID = PHI->second.first; |
| 897 | |
| 898 | Value *TheRealValue = getValNonImprovising(LRI->first, DID); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 899 | if (TriggerError) |
| 900 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 901 | if (TheRealValue) { |
| 902 | V->replaceAllUsesWith(TheRealValue); |
| 903 | delete V; |
| 904 | CurModule.PlaceHolderInfo.erase(PHI); |
| 905 | } else if (FutureLateResolvers) { |
| 906 | // Functions have their unresolved items forwarded to the module late |
| 907 | // resolver table |
| 908 | InsertValue(V, *FutureLateResolvers); |
| 909 | } else { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 910 | if (DID.Type == ValID::NameVal) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 911 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 912 | "' of type '" + V->getType()->getDescription() + "'", |
| 913 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 914 | return; |
| 915 | } else { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 916 | GenerateError("Reference to an invalid definition: #" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 917 | itostr(DID.Num) + " of type '" + |
| 918 | V->getType()->getDescription() + "'", |
| 919 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 920 | return; |
| 921 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 922 | } |
| 923 | } |
| 924 | } |
| 925 | |
| 926 | LateResolvers.clear(); |
| 927 | } |
| 928 | |
| 929 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 930 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 931 | // refering to the number can be resolved. Do this now. |
| 932 | // |
| 933 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 934 | ValID D; |
| 935 | if (Name) D = ValID::create(Name); |
| 936 | else D = ValID::create((int)CurModule.Types.size()); |
| 937 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 938 | std::map<ValID, PATypeHolder>::iterator I = |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 939 | CurModule.LateResolveTypes.find(D); |
| 940 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 941 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 942 | CurModule.LateResolveTypes.erase(I); |
| 943 | } |
| 944 | } |
| 945 | |
| 946 | // setValueName - Set the specified value to the name given. The name may be |
| 947 | // null potentially, in which case this is a noop. The string passed in is |
| 948 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 949 | // |
| 950 | static void setValueName(Value *V, char *NameStr) { |
| 951 | if (NameStr) { |
| 952 | std::string Name(NameStr); // Copy string |
| 953 | free(NameStr); // Free old string |
| 954 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 955 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 956 | GenerateError("Can't assign name '" + Name+"' to value with void type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 957 | return; |
| 958 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 959 | |
| 960 | assert(inFunctionScope() && "Must be in function scope!"); |
Reid Spencer | 78d033e | 2007-01-06 07:24:44 +0000 | [diff] [blame] | 961 | SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 962 | if (ST.lookup(V->getType(), Name)) { |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 963 | GenerateError("Redefinition of value '" + Name + "' of type '" + |
| 964 | V->getType()->getDescription() + "'!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 965 | return; |
| 966 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 967 | |
| 968 | // Set the name. |
| 969 | V->setName(Name); |
| 970 | } |
| 971 | } |
| 972 | |
| 973 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 974 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 975 | static GlobalVariable * |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 976 | ParseGlobalVariable(char *NameStr, |
| 977 | GlobalValue::LinkageTypes Linkage, |
| 978 | GlobalValue::VisibilityTypes Visibility, |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 979 | bool isConstantGlobal, const Type *Ty, |
| 980 | Constant *Initializer) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 981 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 982 | GenerateError("Cannot declare global vars of function type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 983 | return 0; |
| 984 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 985 | |
| 986 | const PointerType *PTy = PointerType::get(Ty); |
| 987 | |
| 988 | std::string Name; |
| 989 | if (NameStr) { |
| 990 | Name = NameStr; // Copy string |
| 991 | free(NameStr); // Free old string |
| 992 | } |
| 993 | |
| 994 | // See if this global value was forward referenced. If so, recycle the |
| 995 | // object. |
| 996 | ValID ID; |
| 997 | if (!Name.empty()) { |
| 998 | ID = ValID::create((char*)Name.c_str()); |
| 999 | } else { |
| 1000 | ID = ValID::create((int)CurModule.Values[PTy].size()); |
| 1001 | } |
| 1002 | |
| 1003 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 1004 | // Move the global to the end of the list, from whereever it was |
| 1005 | // previously inserted. |
| 1006 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 1007 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 1008 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 1009 | GV->setInitializer(Initializer); |
| 1010 | GV->setLinkage(Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1011 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1012 | GV->setConstant(isConstantGlobal); |
| 1013 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1014 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1015 | } |
| 1016 | |
| 1017 | // If this global has a name, check to see if there is already a definition |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 1018 | // of this global in the module. If so, it is an error. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1019 | if (!Name.empty()) { |
| 1020 | // We are a simple redefinition of a value, check to see if it is defined |
| 1021 | // the same as the old one. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 1022 | if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1023 | GenerateError("Redefinition of global variable named '" + Name + |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 1024 | "' of type '" + Ty->getDescription() + "'!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1025 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1026 | } |
| 1027 | } |
| 1028 | |
| 1029 | // Otherwise there is no existing GV to use, create one now. |
| 1030 | GlobalVariable *GV = |
| 1031 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 1032 | CurModule.CurrentModule); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1033 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1034 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1035 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | // setTypeName - Set the specified type to the name given. The name may be |
| 1039 | // null potentially, in which case this is a noop. The string passed in is |
| 1040 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 1041 | // |
| 1042 | // This function returns true if the type has already been defined, but is |
| 1043 | // allowed to be redefined in the specified context. If the name is a new name |
| 1044 | // for the type plane, it is inserted and false is returned. |
| 1045 | static bool setTypeName(const Type *T, char *NameStr) { |
| 1046 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
| 1047 | if (NameStr == 0) return false; |
| 1048 | |
| 1049 | std::string Name(NameStr); // Copy string |
| 1050 | free(NameStr); // Free old string |
| 1051 | |
| 1052 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1053 | if (T == Type::VoidTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 1054 | GenerateError("Can't assign name '" + Name + "' to the void type!"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1055 | return false; |
| 1056 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1057 | |
| 1058 | // Set the type name, checking for conflicts as we do so. |
| 1059 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 1060 | |
| 1061 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1062 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
| 1063 | assert(Existing && "Conflict but no matching type?"); |
| 1064 | |
| 1065 | // There is only one case where this is allowed: when we are refining an |
| 1066 | // opaque type. In this case, Existing will be an opaque type. |
| 1067 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1068 | // We ARE replacing an opaque type! |
| 1069 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 1070 | return true; |
| 1071 | } |
| 1072 | |
| 1073 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1074 | // the redefinition is identical to the original. This will be so if |
| 1075 | // Existing and T point to the same Type object. In this one case we |
| 1076 | // allow the equivalent redefinition. |
| 1077 | if (Existing == T) return true; // Yes, it's equal. |
| 1078 | |
| 1079 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 1080 | GenerateError("Redefinition of type named '" + Name + "' of type '" + |
| 1081 | T->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1082 | } |
| 1083 | |
| 1084 | return false; |
| 1085 | } |
| 1086 | |
| 1087 | //===----------------------------------------------------------------------===// |
| 1088 | // Code for handling upreferences in type names... |
| 1089 | // |
| 1090 | |
| 1091 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1092 | // |
| 1093 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1094 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1095 | E) != Ty->subtype_end(); |
| 1096 | } |
| 1097 | |
| 1098 | namespace { |
| 1099 | struct UpRefRecord { |
| 1100 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1101 | // this type is resolved. |
| 1102 | unsigned NestingLevel; |
| 1103 | |
| 1104 | // LastContainedTy - This is the type at the current binding level for the |
| 1105 | // type. Every time we reduce the nesting level, this gets updated. |
| 1106 | const Type *LastContainedTy; |
| 1107 | |
| 1108 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1109 | // represented with. |
| 1110 | OpaqueType *UpRefTy; |
| 1111 | |
| 1112 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 1113 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 1114 | }; |
| 1115 | } |
| 1116 | |
| 1117 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1118 | static std::vector<UpRefRecord> UpRefs; |
| 1119 | |
| 1120 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1121 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1122 | /// currently active types. For each type, if the up reference is contained in |
| 1123 | /// the newly completed type, we decrement the level count. When the level |
| 1124 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1125 | /// thus we can complete the cycle. |
| 1126 | /// |
| 1127 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 1128 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1129 | // nothing to resolve here. |
| 1130 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1131 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1132 | PATypeHolder Ty(ty); |
| 1133 | UR_OUT("Type '" << Ty->getDescription() << |
| 1134 | "' newly formed. Resolving upreferences.\n" << |
| 1135 | UpRefs.size() << " upreferences active!\n"); |
| 1136 | |
| 1137 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1138 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1139 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1140 | // this variable. |
| 1141 | OpaqueType *TypeToResolve = 0; |
| 1142 | |
| 1143 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1144 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1145 | << UpRefs[i].second->getDescription() << ") = " |
| 1146 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1147 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1148 | // Decrement level of upreference |
| 1149 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1150 | UpRefs[i].LastContainedTy = Ty; |
| 1151 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1152 | if (Level == 0) { // Upreference should be resolved! |
| 1153 | if (!TypeToResolve) { |
| 1154 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1155 | } else { |
| 1156 | UR_OUT(" * Resolving upreference for " |
| 1157 | << UpRefs[i].second->getDescription() << "\n"; |
| 1158 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1159 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1160 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1161 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1162 | } |
| 1163 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1164 | --i; // Do not skip the next element... |
| 1165 | } |
| 1166 | } |
| 1167 | } |
| 1168 | |
| 1169 | if (TypeToResolve) { |
| 1170 | UR_OUT(" * Resolving upreference for " |
| 1171 | << UpRefs[i].second->getDescription() << "\n"; |
| 1172 | std::string OldName = TypeToResolve->getDescription()); |
| 1173 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1174 | } |
| 1175 | |
| 1176 | return Ty; |
| 1177 | } |
| 1178 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1179 | //===----------------------------------------------------------------------===// |
| 1180 | // RunVMAsmParser - Define an interface to this parser |
| 1181 | //===----------------------------------------------------------------------===// |
| 1182 | // |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1183 | static Module* RunParser(Module * M); |
| 1184 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1185 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1186 | set_scan_file(F); |
| 1187 | |
| 1188 | CurFilename = Filename; |
| 1189 | return RunParser(new Module(CurFilename)); |
| 1190 | } |
| 1191 | |
| 1192 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1193 | set_scan_string(AsmString); |
| 1194 | |
| 1195 | CurFilename = "from_memory"; |
| 1196 | if (M == NULL) { |
| 1197 | return RunParser(new Module (CurFilename)); |
| 1198 | } else { |
| 1199 | return RunParser(M); |
| 1200 | } |
| 1201 | } |
| 1202 | |
| 1203 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 1204 | |
| 1205 | /* Enabling traces. */ |
| 1206 | #ifndef YYDEBUG |
| 1207 | # define YYDEBUG 0 |
| 1208 | #endif |
| 1209 | |
| 1210 | /* Enabling verbose error messages. */ |
| 1211 | #ifdef YYERROR_VERBOSE |
| 1212 | # undef YYERROR_VERBOSE |
| 1213 | # define YYERROR_VERBOSE 1 |
| 1214 | #else |
| 1215 | # define YYERROR_VERBOSE 0 |
| 1216 | #endif |
| 1217 | |
| 1218 | /* Enabling the token table. */ |
| 1219 | #ifndef YYTOKEN_TABLE |
| 1220 | # define YYTOKEN_TABLE 0 |
| 1221 | #endif |
| 1222 | |
| 1223 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
| 1224 | #line 883 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 1225 | typedef union YYSTYPE { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1226 | llvm::Module *ModuleVal; |
| 1227 | llvm::Function *FunctionVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1228 | llvm::BasicBlock *BasicBlockVal; |
| 1229 | llvm::TerminatorInst *TermInstVal; |
| 1230 | llvm::Instruction *InstVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1231 | llvm::Constant *ConstVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1232 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1233 | const llvm::Type *PrimType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1234 | std::list<llvm::PATypeHolder> *TypeList; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1235 | llvm::PATypeHolder *TypeVal; |
| 1236 | llvm::Value *ValueVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1237 | std::vector<llvm::Value*> *ValueList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1238 | llvm::ArgListType *ArgList; |
| 1239 | llvm::TypeWithAttrs TypeWithAttrs; |
| 1240 | llvm::TypeWithAttrsList *TypeWithAttrsList; |
| 1241 | llvm::ValueRefList *ValueRefList; |
| 1242 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1243 | // Represent the RHS of PHI node |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1244 | std::list<std::pair<llvm::Value*, |
| 1245 | llvm::BasicBlock*> > *PHIList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1246 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1247 | std::vector<llvm::Constant*> *ConstVector; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1248 | |
| 1249 | llvm::GlobalValue::LinkageTypes Linkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1250 | llvm::GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1251 | llvm::FunctionType::ParameterAttributes ParamAttrs; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1252 | int64_t SInt64Val; |
| 1253 | uint64_t UInt64Val; |
| 1254 | int SIntVal; |
| 1255 | unsigned UIntVal; |
| 1256 | double FPVal; |
| 1257 | bool BoolVal; |
| 1258 | |
| 1259 | char *StrVal; // This memory is strdup'd! |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1260 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1261 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1262 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1263 | llvm::Instruction::TermOps TermOpVal; |
| 1264 | llvm::Instruction::MemoryOps MemOpVal; |
| 1265 | llvm::Instruction::CastOps CastOpVal; |
| 1266 | llvm::Instruction::OtherOps OtherOpVal; |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1267 | llvm::Module::Endianness Endianness; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1268 | llvm::ICmpInst::Predicate IPredicate; |
| 1269 | llvm::FCmpInst::Predicate FPredicate; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 1270 | } YYSTYPE; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 1271 | /* Line 196 of yacc.c. */ |
| 1272 | #line 1273 "llvmAsmParser.tab.c" |
| 1273 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 1274 | # define YYSTYPE_IS_DECLARED 1 |
| 1275 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1276 | #endif |
| 1277 | |
| 1278 | |
| 1279 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 1280 | /* Copy the second part of user declarations. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1281 | |
| 1282 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 1283 | /* Line 219 of yacc.c. */ |
| 1284 | #line 1285 "llvmAsmParser.tab.c" |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 1285 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 1286 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
| 1287 | # define YYSIZE_T __SIZE_TYPE__ |
| 1288 | #endif |
| 1289 | #if ! defined (YYSIZE_T) && defined (size_t) |
| 1290 | # define YYSIZE_T size_t |
| 1291 | #endif |
| 1292 | #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) |
| 1293 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 1294 | # define YYSIZE_T size_t |
| 1295 | #endif |
| 1296 | #if ! defined (YYSIZE_T) |
| 1297 | # define YYSIZE_T unsigned int |
| 1298 | #endif |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1299 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 1300 | #ifndef YY_ |
| 1301 | # if YYENABLE_NLS |
| 1302 | # if ENABLE_NLS |
| 1303 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 1304 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
| 1305 | # endif |
| 1306 | # endif |
| 1307 | # ifndef YY_ |
| 1308 | # define YY_(msgid) msgid |
| 1309 | # endif |
| 1310 | #endif |
| 1311 | |
| 1312 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
| 1313 | |
| 1314 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 1315 | |
| 1316 | # ifdef YYSTACK_USE_ALLOCA |
| 1317 | # if YYSTACK_USE_ALLOCA |
| 1318 | # ifdef __GNUC__ |
| 1319 | # define YYSTACK_ALLOC __builtin_alloca |
| 1320 | # else |
| 1321 | # define YYSTACK_ALLOC alloca |
| 1322 | # if defined (__STDC__) || defined (__cplusplus) |
| 1323 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 1324 | # define YYINCLUDED_STDLIB_H |
| 1325 | # endif |
| 1326 | # endif |
| 1327 | # endif |
| 1328 | # endif |
| 1329 | |
| 1330 | # ifdef YYSTACK_ALLOC |
| 1331 | /* Pacify GCC's `empty if-body' warning. */ |
| 1332 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
| 1333 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1334 | /* The OS might guarantee only one guard page at the bottom of the stack, |
| 1335 | and a page size can be as small as 4096 bytes. So we cannot safely |
| 1336 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
| 1337 | to allow for a few compiler-allocated temporary stack slots. */ |
| 1338 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ |
| 1339 | # endif |
| 1340 | # else |
| 1341 | # define YYSTACK_ALLOC YYMALLOC |
| 1342 | # define YYSTACK_FREE YYFREE |
| 1343 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1344 | # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) |
| 1345 | # endif |
| 1346 | # ifdef __cplusplus |
| 1347 | extern "C" { |
| 1348 | # endif |
| 1349 | # ifndef YYMALLOC |
| 1350 | # define YYMALLOC malloc |
| 1351 | # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 1352 | && (defined (__STDC__) || defined (__cplusplus))) |
| 1353 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 1354 | # endif |
| 1355 | # endif |
| 1356 | # ifndef YYFREE |
| 1357 | # define YYFREE free |
| 1358 | # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 1359 | && (defined (__STDC__) || defined (__cplusplus))) |
| 1360 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 1361 | # endif |
| 1362 | # endif |
| 1363 | # ifdef __cplusplus |
| 1364 | } |
| 1365 | # endif |
| 1366 | # endif |
| 1367 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
| 1368 | |
| 1369 | |
| 1370 | #if (! defined (yyoverflow) \ |
| 1371 | && (! defined (__cplusplus) \ |
| 1372 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
| 1373 | |
| 1374 | /* A type that is properly aligned for any stack member. */ |
| 1375 | union yyalloc |
| 1376 | { |
| 1377 | short int yyss; |
| 1378 | YYSTYPE yyvs; |
| 1379 | }; |
| 1380 | |
| 1381 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 1382 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 1383 | |
| 1384 | /* The size of an array large to enough to hold all stacks, each with |
| 1385 | N elements. */ |
| 1386 | # define YYSTACK_BYTES(N) \ |
| 1387 | ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ |
| 1388 | + YYSTACK_GAP_MAXIMUM) |
| 1389 | |
| 1390 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 1391 | not overlap. */ |
| 1392 | # ifndef YYCOPY |
| 1393 | # if defined (__GNUC__) && 1 < __GNUC__ |
| 1394 | # define YYCOPY(To, From, Count) \ |
| 1395 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 1396 | # else |
| 1397 | # define YYCOPY(To, From, Count) \ |
| 1398 | do \ |
| 1399 | { \ |
| 1400 | YYSIZE_T yyi; \ |
| 1401 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 1402 | (To)[yyi] = (From)[yyi]; \ |
| 1403 | } \ |
| 1404 | while (0) |
| 1405 | # endif |
| 1406 | # endif |
| 1407 | |
| 1408 | /* Relocate STACK from its old location to the new one. The |
| 1409 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 1410 | elements in the stack, and YYPTR gives the new location of the |
| 1411 | stack. Advance YYPTR to a properly aligned location for the next |
| 1412 | stack. */ |
| 1413 | # define YYSTACK_RELOCATE(Stack) \ |
| 1414 | do \ |
| 1415 | { \ |
| 1416 | YYSIZE_T yynewbytes; \ |
| 1417 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 1418 | Stack = &yyptr->Stack; \ |
| 1419 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 1420 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 1421 | } \ |
| 1422 | while (0) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1423 | |
| 1424 | #endif |
| 1425 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 1426 | #if defined (__STDC__) || defined (__cplusplus) |
| 1427 | typedef signed char yysigned_char; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 1428 | #else |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 1429 | typedef short int yysigned_char; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 1430 | #endif |
| 1431 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 1432 | /* YYFINAL -- State number of the termination state. */ |
| 1433 | #define YYFINAL 36 |
| 1434 | /* YYLAST -- Last index in YYTABLE. */ |
| 1435 | #define YYLAST 1357 |
| 1436 | |
| 1437 | /* YYNTOKENS -- Number of terminals. */ |
| 1438 | #define YYNTOKENS 147 |
| 1439 | /* YYNNTS -- Number of nonterminals. */ |
| 1440 | #define YYNNTS 79 |
| 1441 | /* YYNRULES -- Number of rules. */ |
| 1442 | #define YYNRULES 285 |
| 1443 | /* YYNRULES -- Number of states. */ |
| 1444 | #define YYNSTATES 569 |
| 1445 | |
| 1446 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 1447 | #define YYUNDEFTOK 2 |
| 1448 | #define YYMAXUTOK 387 |
| 1449 | |
| 1450 | #define YYTRANSLATE(YYX) \ |
| 1451 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 1452 | |
| 1453 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 1454 | static const unsigned char yytranslate[] = |
| 1455 | { |
| 1456 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1457 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1458 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1459 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1460 | 137, 138, 135, 2, 134, 2, 2, 2, 2, 2, |
| 1461 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1462 | 142, 133, 143, 2, 2, 2, 2, 2, 2, 2, |
| 1463 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1464 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1465 | 2, 139, 136, 141, 2, 2, 2, 2, 2, 146, |
| 1466 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1467 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1468 | 140, 2, 2, 144, 2, 145, 2, 2, 2, 2, |
| 1469 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1470 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1471 | 2, 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 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1476 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1477 | 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1481 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 1482 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 1483 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 1484 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 1485 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 1486 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 1487 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 1488 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 1489 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 1490 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1491 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 1492 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 1493 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 1494 | 125, 126, 127, 128, 129, 130, 131, 132 |
| 1495 | }; |
| 1496 | |
| 1497 | #if YYDEBUG |
| 1498 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 1499 | YYRHS. */ |
| 1500 | static const unsigned short int yyprhs[] = |
| 1501 | { |
| 1502 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 1503 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 1504 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 1505 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, |
| 1506 | 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, |
| 1507 | 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, |
| 1508 | 119, 122, 123, 125, 127, 129, 131, 133, 135, 137, |
| 1509 | 139, 140, 142, 143, 145, 147, 148, 150, 152, 154, |
| 1510 | 156, 157, 159, 161, 163, 165, 167, 169, 172, 174, |
| 1511 | 176, 177, 180, 182, 184, 185, 188, 189, 192, 193, |
| 1512 | 197, 200, 201, 203, 204, 208, 210, 213, 215, 217, |
| 1513 | 219, 221, 223, 225, 228, 230, 233, 239, 245, 251, |
| 1514 | 257, 261, 264, 270, 275, 278, 280, 282, 284, 288, |
| 1515 | 290, 294, 296, 297, 299, 303, 308, 312, 316, 321, |
| 1516 | 326, 330, 337, 343, 346, 349, 352, 355, 358, 361, |
| 1517 | 364, 367, 370, 373, 380, 386, 395, 402, 409, 417, |
| 1518 | 425, 432, 439, 448, 457, 461, 463, 465, 467, 469, |
| 1519 | 470, 472, 475, 476, 480, 481, 485, 489, 491, 495, |
| 1520 | 499, 500, 507, 508, 516, 517, 525, 528, 532, 534, |
| 1521 | 536, 538, 542, 546, 550, 554, 558, 562, 564, 565, |
| 1522 | 567, 569, 571, 572, 578, 582, 584, 588, 590, 591, |
| 1523 | 601, 603, 605, 610, 612, 614, 617, 621, 622, 624, |
| 1524 | 626, 628, 630, 632, 634, 636, 638, 640, 644, 646, |
| 1525 | 652, 654, 656, 658, 660, 663, 666, 669, 673, 676, |
| 1526 | 677, 679, 682, 685, 689, 699, 709, 718, 733, 735, |
| 1527 | 737, 744, 750, 753, 760, 768, 772, 778, 779, 780, |
| 1528 | 784, 787, 789, 795, 801, 808, 815, 820, 825, 832, |
| 1529 | 837, 842, 849, 856, 859, 868, 870, 872, 873, 877, |
| 1530 | 884, 888, 895, 898, 903, 910 |
| 1531 | }; |
| 1532 | |
| 1533 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 1534 | static const short int yyrhs[] = |
| 1535 | { |
| 1536 | 185, 0, -1, 5, -1, 6, -1, 69, -1, 70, |
| 1537 | -1, 71, -1, 72, -1, 73, -1, 74, -1, 75, |
| 1538 | -1, 76, -1, 77, -1, 78, -1, 79, -1, 80, |
| 1539 | -1, 109, -1, 110, -1, 111, -1, 112, -1, 113, |
| 1540 | -1, 114, -1, 115, -1, 116, -1, 117, -1, 118, |
| 1541 | -1, 119, -1, 120, -1, 123, -1, 124, -1, 125, |
| 1542 | -1, 83, -1, 84, -1, 85, -1, 86, -1, 87, |
| 1543 | -1, 88, -1, 89, -1, 90, -1, 91, -1, 92, |
| 1544 | -1, 93, -1, 94, -1, 95, -1, 96, -1, 97, |
| 1545 | -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, |
| 1546 | -1, 89, -1, 90, -1, 91, -1, 92, -1, 19, |
| 1547 | -1, 20, -1, 9, -1, 10, -1, 11, -1, 198, |
| 1548 | 133, -1, -1, 33, -1, 35, -1, 34, -1, 36, |
| 1549 | -1, 38, -1, 37, -1, 39, -1, 41, -1, -1, |
| 1550 | 132, -1, -1, 37, -1, 39, -1, -1, 33, -1, |
| 1551 | 34, -1, 35, -1, 38, -1, -1, 56, -1, 57, |
| 1552 | -1, 58, -1, 59, -1, 60, -1, 61, -1, 55, |
| 1553 | 4, -1, 110, -1, 111, -1, -1, 165, 164, -1, |
| 1554 | 130, -1, 164, -1, -1, 167, 166, -1, -1, 48, |
| 1555 | 4, -1, -1, 134, 48, 4, -1, 27, 16, -1, |
| 1556 | -1, 170, -1, -1, 134, 173, 172, -1, 170, -1, |
| 1557 | 48, 4, -1, 9, -1, 10, -1, 11, -1, 12, |
| 1558 | -1, 40, -1, 174, -1, 175, 135, -1, 210, -1, |
| 1559 | 136, 4, -1, 175, 137, 179, 138, 167, -1, 8, |
| 1560 | 137, 179, 138, 167, -1, 139, 4, 140, 175, 141, |
| 1561 | -1, 142, 4, 140, 175, 143, -1, 144, 180, 145, |
| 1562 | -1, 144, 145, -1, 142, 144, 180, 145, 143, -1, |
| 1563 | 142, 144, 145, 143, -1, 175, 165, -1, 175, -1, |
| 1564 | 8, -1, 176, -1, 178, 134, 176, -1, 178, -1, |
| 1565 | 178, 134, 30, -1, 30, -1, -1, 175, -1, 180, |
| 1566 | 134, 175, -1, 175, 139, 183, 141, -1, 175, 139, |
| 1567 | 141, -1, 175, 146, 16, -1, 175, 142, 183, 143, |
| 1568 | -1, 175, 144, 183, 145, -1, 175, 144, 145, -1, |
| 1569 | 175, 142, 144, 183, 145, 143, -1, 175, 142, 144, |
| 1570 | 145, 143, -1, 175, 31, -1, 175, 32, -1, 175, |
| 1571 | 210, -1, 175, 182, -1, 175, 18, -1, 155, 3, |
| 1572 | -1, 155, 4, -1, 9, 19, -1, 9, 20, -1, |
| 1573 | 156, 7, -1, 151, 137, 181, 29, 175, 138, -1, |
| 1574 | 108, 137, 181, 221, 138, -1, 122, 137, 181, 134, |
| 1575 | 181, 134, 181, 138, -1, 149, 137, 181, 134, 181, |
| 1576 | 138, -1, 150, 137, 181, 134, 181, 138, -1, 81, |
| 1577 | 153, 137, 181, 134, 181, 138, -1, 82, 154, 137, |
| 1578 | 181, 134, 181, 138, -1, 152, 137, 181, 134, 181, |
| 1579 | 138, -1, 127, 137, 181, 134, 181, 138, -1, 128, |
| 1580 | 137, 181, 134, 181, 134, 181, 138, -1, 129, 137, |
| 1581 | 181, 134, 181, 134, 181, 138, -1, 183, 134, 181, |
| 1582 | -1, 181, -1, 25, -1, 26, -1, 186, -1, -1, |
| 1583 | 187, -1, 186, 187, -1, -1, 24, 188, 206, -1, |
| 1584 | -1, 23, 189, 207, -1, 53, 52, 193, -1, 17, |
| 1585 | -1, 157, 13, 175, -1, 157, 13, 8, -1, -1, |
| 1586 | 157, 160, 184, 181, 190, 172, -1, -1, 157, 158, |
| 1587 | 160, 184, 181, 191, 172, -1, -1, 157, 159, 160, |
| 1588 | 184, 175, 192, 172, -1, 42, 195, -1, 49, 133, |
| 1589 | 196, -1, 16, -1, 47, -1, 46, -1, 44, 133, |
| 1590 | 194, -1, 45, 133, 4, -1, 43, 133, 16, -1, |
| 1591 | 62, 133, 16, -1, 139, 197, 141, -1, 197, 134, |
| 1592 | 16, -1, 16, -1, -1, 14, -1, 16, -1, 198, |
| 1593 | -1, -1, 200, 134, 175, 165, 199, -1, 175, 165, |
| 1594 | 199, -1, 200, -1, 200, 134, 30, -1, 30, -1, |
| 1595 | -1, 163, 177, 198, 137, 201, 138, 167, 171, 168, |
| 1596 | -1, 21, -1, 144, -1, 162, 160, 202, 203, -1, |
| 1597 | 22, -1, 145, -1, 213, 205, -1, 161, 160, 202, |
| 1598 | -1, -1, 54, -1, 3, -1, 4, -1, 7, -1, |
| 1599 | 19, -1, 20, -1, 31, -1, 32, -1, 18, -1, |
| 1600 | 142, 183, 143, -1, 182, -1, 52, 208, 16, 134, |
| 1601 | 16, -1, 148, -1, 198, -1, 210, -1, 209, -1, |
| 1602 | 175, 211, -1, 213, 214, -1, 204, 214, -1, 215, |
| 1603 | 157, 216, -1, 215, 218, -1, -1, 15, -1, 63, |
| 1604 | 212, -1, 63, 8, -1, 64, 12, 211, -1, 64, |
| 1605 | 9, 211, 134, 12, 211, 134, 12, 211, -1, 65, |
| 1606 | 155, 211, 134, 12, 211, 139, 217, 141, -1, 65, |
| 1607 | 155, 211, 134, 12, 211, 139, 141, -1, 66, 163, |
| 1608 | 177, 211, 137, 220, 138, 167, 29, 12, 211, 67, |
| 1609 | 12, 211, -1, 67, -1, 68, -1, 217, 155, 209, |
| 1610 | 134, 12, 211, -1, 155, 209, 134, 12, 211, -1, |
| 1611 | 157, 223, -1, 175, 139, 211, 134, 211, 141, -1, |
| 1612 | 219, 134, 139, 211, 134, 211, 141, -1, 175, 211, |
| 1613 | 165, -1, 220, 134, 175, 211, 165, -1, -1, -1, |
| 1614 | 221, 134, 212, -1, 51, 50, -1, 50, -1, 149, |
| 1615 | 175, 211, 134, 211, -1, 150, 175, 211, 134, 211, |
| 1616 | -1, 81, 153, 175, 211, 134, 211, -1, 82, 154, |
| 1617 | 175, 211, 134, 211, -1, 152, 212, 134, 212, -1, |
| 1618 | 151, 212, 29, 175, -1, 122, 212, 134, 212, 134, |
| 1619 | 212, -1, 126, 212, 134, 175, -1, 127, 212, 134, |
| 1620 | 212, -1, 128, 212, 134, 212, 134, 212, -1, 129, |
| 1621 | 212, 134, 212, 134, 212, -1, 121, 219, -1, 222, |
| 1622 | 163, 177, 211, 137, 220, 138, 167, -1, 225, -1, |
| 1623 | 28, -1, -1, 103, 175, 169, -1, 103, 175, 134, |
| 1624 | 9, 211, 169, -1, 104, 175, 169, -1, 104, 175, |
| 1625 | 134, 9, 211, 169, -1, 105, 212, -1, 224, 106, |
| 1626 | 175, 211, -1, 224, 107, 212, 134, 175, 211, -1, |
| 1627 | 108, 175, 211, 221, -1 |
| 1628 | }; |
| 1629 | |
| 1630 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 1631 | static const unsigned short int yyrline[] = |
| 1632 | { |
| 1633 | 0, 1031, 1031, 1032, 1042, 1042, 1042, 1042, 1042, 1042, |
| 1634 | 1042, 1042, 1042, 1043, 1043, 1043, 1044, 1044, 1044, 1044, |
| 1635 | 1044, 1044, 1045, 1045, 1045, 1045, 1045, 1045, 1046, 1046, |
| 1636 | 1046, 1048, 1048, 1049, 1049, 1050, 1050, 1051, 1051, 1052, |
| 1637 | 1052, 1056, 1056, 1057, 1057, 1058, 1058, 1059, 1059, 1060, |
| 1638 | 1060, 1061, 1061, 1062, 1062, 1063, 1064, 1069, 1070, 1070, |
| 1639 | 1073, 1077, 1083, 1084, 1085, 1086, 1087, 1091, 1092, 1093, |
| 1640 | 1097, 1098, 1102, 1103, 1104, 1108, 1109, 1110, 1111, 1112, |
| 1641 | 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1129, 1130, |
| 1642 | 1133, 1134, 1139, 1140, 1143, 1144, 1151, 1152, 1158, 1159, |
| 1643 | 1167, 1175, 1176, 1181, 1182, 1183, 1188, 1201, 1201, 1201, |
| 1644 | 1201, 1204, 1208, 1212, 1219, 1224, 1232, 1250, 1268, 1273, |
| 1645 | 1285, 1295, 1299, 1309, 1316, 1323, 1330, 1335, 1340, 1347, |
| 1646 | 1348, 1355, 1362, 1370, 1375, 1386, 1414, 1430, 1459, 1487, |
| 1647 | 1512, 1531, 1556, 1575, 1587, 1594, 1657, 1667, 1677, 1683, |
| 1648 | 1689, 1694, 1699, 1707, 1719, 1740, 1748, 1754, 1765, 1770, |
| 1649 | 1775, 1784, 1790, 1796, 1805, 1809, 1817, 1817, 1828, 1833, |
| 1650 | 1841, 1842, 1846, 1846, 1850, 1850, 1853, 1856, 1868, 1892, |
| 1651 | 1903, 1903, 1912, 1912, 1920, 1920, 1930, 1933, 1939, 1952, |
| 1652 | 1953, 1955, 1959, 1968, 1972, 1977, 1979, 1984, 1989, 1998, |
| 1653 | 1998, 1999, 1999, 2001, 2011, 2022, 2026, 2035, 2044, 2049, |
| 1654 | 2155, 2155, 2157, 2166, 2166, 2168, 2173, 2185, 2189, 2194, |
| 1655 | 2198, 2202, 2206, 2210, 2214, 2218, 2222, 2226, 2251, 2255, |
| 1656 | 2269, 2273, 2279, 2279, 2285, 2294, 2298, 2307, 2318, 2327, |
| 1657 | 2339, 2352, 2356, 2360, 2365, 2375, 2394, 2403, 2470, 2474, |
| 1658 | 2481, 2492, 2505, 2514, 2525, 2535, 2543, 2551, 2554, 2555, |
| 1659 | 2562, 2566, 2571, 2592, 2609, 2622, 2635, 2644, 2656, 2664, |
| 1660 | 2671, 2677, 2683, 2689, 2704, 2767, 2772, 2776, 2783, 2790, |
| 1661 | 2798, 2805, 2813, 2821, 2835, 2852 |
| 1662 | }; |
| 1663 | #endif |
| 1664 | |
| 1665 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
| 1666 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 1667 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 1668 | static const char *const yytname[] = |
| 1669 | { |
| 1670 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", |
| 1671 | "UINTVAL", "FPVAL", "VOID", "INTTYPE", "FLOAT", "DOUBLE", "LABEL", |
| 1672 | "TYPE", "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION", |
| 1673 | "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", |
| 1674 | "DECLARE", "DEFINE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", |
| 1675 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK", |
| 1676 | "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 1677 | "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE", "BIG", |
| 1678 | "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", |
| 1679 | "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK", "COLDCC_TOK", |
| 1680 | "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", "RET", "BR", |
| 1681 | "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "UDIV", |
| 1682 | "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR", "XOR", "ICMP", |
| 1683 | "FCMP", "EQ", "NE", "SLT", "SGT", "SLE", "SGE", "ULT", "UGT", "ULE", |
| 1684 | "UGE", "OEQ", "ONE", "OLT", "OGT", "OLE", "OGE", "ORD", "UNO", "UEQ", |
| 1685 | "UNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", |
| 1686 | "TRUNC", "ZEXT", "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP", |
| 1687 | "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK", |
| 1688 | "SELECT", "SHL", "LSHR", "ASHR", "VAARG", "EXTRACTELEMENT", |
| 1689 | "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "DEFAULT", "HIDDEN", "'='", |
| 1690 | "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'", |
| 1691 | "'{'", "'}'", "'c'", "$accept", "INTVAL", "ArithmeticOps", "LogicalOps", |
| 1692 | "CastOps", "ShiftOps", "IPredicates", "FPredicates", "IntType", "FPType", |
| 1693 | "OptAssign", "GVInternalLinkage", "GVExternalLinkage", |
| 1694 | "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage", |
| 1695 | "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr", |
| 1696 | "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString", "OptSection", |
| 1697 | "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types", |
| 1698 | "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI", |
| 1699 | "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "Module", |
| 1700 | "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock", |
| 1701 | "BigOrLittle", "TargetDefinition", "LibrariesDefinition", "LibList", |
| 1702 | "Name", "OptName", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", |
| 1703 | "FunctionHeader", "END", "Function", "FunctionProto", "OptSideEffect", |
| 1704 | "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal", |
| 1705 | "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst", |
| 1706 | "JumpTable", "Inst", "PHIList", "ValueRefList", "IndexList", |
| 1707 | "OptTailCall", "InstVal", "OptVolatile", "MemoryInst", 0 |
| 1708 | }; |
| 1709 | #endif |
| 1710 | |
| 1711 | # ifdef YYPRINT |
| 1712 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 1713 | token YYLEX-NUM. */ |
| 1714 | static const unsigned short int yytoknum[] = |
| 1715 | { |
| 1716 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 1717 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 1718 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 1719 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 1720 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 1721 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 1722 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 1723 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 1724 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 1725 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
| 1726 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
| 1727 | 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, |
| 1728 | 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, |
| 1729 | 385, 386, 387, 61, 44, 42, 92, 40, 41, 91, |
| 1730 | 120, 93, 60, 62, 123, 125, 99 |
| 1731 | }; |
| 1732 | # endif |
| 1733 | |
| 1734 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 1735 | static const unsigned char yyr1[] = |
| 1736 | { |
| 1737 | 0, 147, 148, 148, 149, 149, 149, 149, 149, 149, |
| 1738 | 149, 149, 149, 150, 150, 150, 151, 151, 151, 151, |
| 1739 | 151, 151, 151, 151, 151, 151, 151, 151, 152, 152, |
| 1740 | 152, 153, 153, 153, 153, 153, 153, 153, 153, 153, |
| 1741 | 153, 154, 154, 154, 154, 154, 154, 154, 154, 154, |
| 1742 | 154, 154, 154, 154, 154, 154, 154, 155, 156, 156, |
| 1743 | 157, 157, 158, 158, 158, 158, 158, 159, 159, 159, |
| 1744 | 160, 160, 161, 161, 161, 162, 162, 162, 162, 162, |
| 1745 | 163, 163, 163, 163, 163, 163, 163, 163, 164, 164, |
| 1746 | 165, 165, 166, 166, 167, 167, 168, 168, 169, 169, |
| 1747 | 170, 171, 171, 172, 172, 173, 173, 174, 174, 174, |
| 1748 | 174, 175, 175, 175, 175, 175, 175, 175, 175, 175, |
| 1749 | 175, 175, 175, 175, 176, 177, 177, 178, 178, 179, |
| 1750 | 179, 179, 179, 180, 180, 181, 181, 181, 181, 181, |
| 1751 | 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, |
| 1752 | 181, 181, 181, 182, 182, 182, 182, 182, 182, 182, |
| 1753 | 182, 182, 182, 182, 183, 183, 184, 184, 185, 185, |
| 1754 | 186, 186, 188, 187, 189, 187, 187, 187, 187, 187, |
| 1755 | 190, 187, 191, 187, 192, 187, 187, 187, 193, 194, |
| 1756 | 194, 195, 195, 195, 195, 196, 197, 197, 197, 198, |
| 1757 | 198, 199, 199, 200, 200, 201, 201, 201, 201, 202, |
| 1758 | 203, 203, 204, 205, 205, 206, 207, 208, 208, 209, |
| 1759 | 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, |
| 1760 | 210, 210, 211, 211, 212, 213, 213, 214, 215, 215, |
| 1761 | 215, 216, 216, 216, 216, 216, 216, 216, 216, 216, |
| 1762 | 217, 217, 218, 219, 219, 220, 220, 220, 221, 221, |
| 1763 | 222, 222, 223, 223, 223, 223, 223, 223, 223, 223, |
| 1764 | 223, 223, 223, 223, 223, 223, 224, 224, 225, 225, |
| 1765 | 225, 225, 225, 225, 225, 225 |
| 1766 | }; |
| 1767 | |
| 1768 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 1769 | static const unsigned char yyr2[] = |
| 1770 | { |
| 1771 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1772 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1773 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1774 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1775 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1776 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1777 | 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1778 | 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, |
| 1779 | 0, 1, 1, 1, 1, 1, 1, 2, 1, 1, |
| 1780 | 0, 2, 1, 1, 0, 2, 0, 2, 0, 3, |
| 1781 | 2, 0, 1, 0, 3, 1, 2, 1, 1, 1, |
| 1782 | 1, 1, 1, 2, 1, 2, 5, 5, 5, 5, |
| 1783 | 3, 2, 5, 4, 2, 1, 1, 1, 3, 1, |
| 1784 | 3, 1, 0, 1, 3, 4, 3, 3, 4, 4, |
| 1785 | 3, 6, 5, 2, 2, 2, 2, 2, 2, 2, |
| 1786 | 2, 2, 2, 6, 5, 8, 6, 6, 7, 7, |
| 1787 | 6, 6, 8, 8, 3, 1, 1, 1, 1, 0, |
| 1788 | 1, 2, 0, 3, 0, 3, 3, 1, 3, 3, |
| 1789 | 0, 6, 0, 7, 0, 7, 2, 3, 1, 1, |
| 1790 | 1, 3, 3, 3, 3, 3, 3, 1, 0, 1, |
| 1791 | 1, 1, 0, 5, 3, 1, 3, 1, 0, 9, |
| 1792 | 1, 1, 4, 1, 1, 2, 3, 0, 1, 1, |
| 1793 | 1, 1, 1, 1, 1, 1, 1, 3, 1, 5, |
| 1794 | 1, 1, 1, 1, 2, 2, 2, 3, 2, 0, |
| 1795 | 1, 2, 2, 3, 9, 9, 8, 14, 1, 1, |
| 1796 | 6, 5, 2, 6, 7, 3, 5, 0, 0, 3, |
| 1797 | 2, 1, 5, 5, 6, 6, 4, 4, 6, 4, |
| 1798 | 4, 6, 6, 2, 8, 1, 1, 0, 3, 6, |
| 1799 | 3, 6, 2, 4, 6, 4 |
| 1800 | }; |
| 1801 | |
| 1802 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 1803 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 1804 | means the default is an error. */ |
| 1805 | static const unsigned short int yydefact[] = |
| 1806 | { |
| 1807 | 61, 199, 200, 177, 174, 172, 0, 0, 0, 70, |
| 1808 | 0, 61, 170, 0, 72, 75, 0, 0, 0, 0, |
| 1809 | 186, 0, 0, 0, 62, 64, 63, 65, 67, 66, |
| 1810 | 68, 69, 71, 70, 70, 0, 1, 171, 60, 73, |
| 1811 | 74, 70, 175, 76, 77, 78, 79, 70, 239, 173, |
| 1812 | 239, 0, 0, 0, 0, 198, 187, 188, 176, 2, |
| 1813 | 3, 179, 107, 108, 109, 110, 111, 0, 0, 0, |
| 1814 | 0, 230, 112, 178, 231, 114, 0, 0, 166, 167, |
| 1815 | 0, 80, 80, 240, 236, 61, 213, 214, 215, 235, |
| 1816 | 193, 190, 189, 191, 192, 194, 197, 0, 132, 115, |
| 1817 | 0, 0, 0, 0, 121, 133, 0, 113, 132, 0, |
| 1818 | 0, 107, 108, 109, 0, 0, 0, 180, 0, 81, |
| 1819 | 82, 83, 84, 85, 86, 0, 216, 0, 277, 238, |
| 1820 | 0, 195, 131, 90, 127, 129, 0, 0, 0, 0, |
| 1821 | 0, 0, 120, 0, 182, 184, 150, 151, 148, 149, |
| 1822 | 152, 147, 143, 144, 4, 5, 6, 7, 8, 9, |
| 1823 | 10, 11, 12, 13, 14, 15, 0, 0, 0, 16, |
| 1824 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
| 1825 | 27, 0, 28, 29, 30, 0, 0, 0, 0, 0, |
| 1826 | 0, 0, 0, 0, 0, 0, 146, 145, 103, 87, |
| 1827 | 126, 125, 0, 210, 211, 212, 276, 261, 0, 0, |
| 1828 | 0, 0, 80, 248, 249, 0, 0, 0, 0, 0, |
| 1829 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1830 | 0, 237, 80, 252, 0, 275, 196, 124, 0, 94, |
| 1831 | 0, 0, 123, 0, 134, 94, 103, 103, 31, 32, |
| 1832 | 33, 34, 35, 36, 37, 38, 39, 40, 0, 55, |
| 1833 | 56, 51, 52, 53, 54, 41, 42, 43, 44, 45, |
| 1834 | 46, 47, 48, 49, 50, 0, 0, 0, 0, 0, |
| 1835 | 0, 136, 165, 0, 0, 0, 140, 0, 137, 0, |
| 1836 | 0, 0, 0, 0, 181, 0, 260, 242, 0, 241, |
| 1837 | 0, 0, 57, 0, 0, 0, 0, 98, 98, 282, |
| 1838 | 0, 0, 273, 0, 0, 0, 0, 0, 0, 0, |
| 1839 | 0, 0, 0, 0, 0, 88, 89, 91, 130, 128, |
| 1840 | 117, 118, 119, 122, 116, 183, 185, 0, 0, 258, |
| 1841 | 0, 0, 0, 0, 0, 135, 121, 133, 0, 138, |
| 1842 | 139, 0, 0, 0, 0, 0, 0, 105, 103, 208, |
| 1843 | 219, 220, 221, 226, 222, 223, 224, 225, 217, 0, |
| 1844 | 228, 233, 232, 234, 0, 243, 0, 0, 0, 0, |
| 1845 | 0, 278, 0, 280, 258, 0, 0, 0, 0, 0, |
| 1846 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, |
| 1847 | 93, 95, 0, 0, 0, 0, 0, 0, 0, 164, |
| 1848 | 142, 0, 0, 0, 0, 0, 100, 106, 104, 207, |
| 1849 | 90, 205, 0, 218, 0, 0, 0, 0, 0, 0, |
| 1850 | 0, 0, 0, 0, 285, 0, 0, 0, 269, 270, |
| 1851 | 0, 0, 0, 0, 267, 266, 0, 283, 0, 0, |
| 1852 | 0, 0, 154, 0, 0, 0, 0, 141, 0, 0, |
| 1853 | 0, 0, 202, 0, 94, 0, 227, 0, 0, 257, |
| 1854 | 0, 0, 98, 99, 98, 0, 0, 0, 0, 0, |
| 1855 | 262, 263, 257, 0, 0, 0, 259, 0, 161, 0, |
| 1856 | 0, 156, 157, 153, 160, 201, 204, 206, 90, 101, |
| 1857 | 0, 0, 0, 0, 0, 264, 265, 0, 279, 281, |
| 1858 | 0, 0, 268, 271, 272, 0, 284, 158, 159, 0, |
| 1859 | 0, 0, 202, 102, 96, 229, 0, 0, 90, 0, |
| 1860 | 94, 253, 0, 94, 155, 162, 163, 203, 0, 209, |
| 1861 | 0, 246, 0, 0, 255, 0, 0, 254, 274, 97, |
| 1862 | 244, 0, 245, 0, 90, 0, 0, 0, 256, 0, |
| 1863 | 0, 0, 0, 251, 0, 0, 250, 0, 247 |
| 1864 | }; |
| 1865 | |
| 1866 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 1867 | static const short int yydefgoto[] = |
| 1868 | { |
| 1869 | -1, 71, 192, 193, 194, 195, 258, 275, 114, 115, |
| 1870 | 9, 33, 34, 35, 41, 47, 125, 327, 237, 401, |
| 1871 | 330, 539, 381, 357, 524, 294, 358, 72, 116, 134, |
| 1872 | 202, 135, 136, 106, 282, 370, 283, 80, 10, 11, |
| 1873 | 12, 15, 14, 198, 246, 247, 58, 93, 20, 56, |
| 1874 | 97, 74, 496, 421, 422, 126, 205, 48, 88, 49, |
| 1875 | 42, 424, 371, 75, 373, 299, 50, 84, 85, 231, |
| 1876 | 543, 129, 312, 504, 404, 232, 233, 234, 235 |
| 1877 | }; |
| 1878 | |
| 1879 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 1880 | STATE-NUM. */ |
| 1881 | #define YYPACT_NINF -413 |
| 1882 | static const short int yypact[] = |
| 1883 | { |
| 1884 | 401, -413, -413, -413, -413, -413, 110, -107, 30, 67, |
| 1885 | 77, 527, -413, -43, 2, 238, -16, 8, 47, 84, |
| 1886 | -413, -4, 132, 791, -413, -413, -413, -413, -413, -413, |
| 1887 | -413, -413, -413, 91, 91, 149, -413, -413, -413, -413, |
| 1888 | -413, 91, -413, -413, -413, -413, -413, 91, 147, -413, |
| 1889 | 20, 210, 208, 280, 226, 273, -413, -413, -413, -413, |
| 1890 | -413, 160, -413, -413, -413, -413, -413, 295, 299, 3, |
| 1891 | 7, -413, -413, 140, -413, -413, 149, 149, -413, -413, |
| 1892 | 954, 192, 192, -413, -413, 184, -413, -413, -413, -413, |
| 1893 | -413, -413, -413, -413, -413, -413, -413, -65, 549, -413, |
| 1894 | 167, 171, 22, 160, -413, 140, -81, -413, 549, 954, |
| 1895 | 1045, 95, 311, 312, 284, 313, 602, -413, 317, -413, |
| 1896 | -413, -413, -413, -413, -413, 1125, -413, -7, 1228, -413, |
| 1897 | 306, -413, -413, 140, -413, 191, 193, 1045, 1045, 186, |
| 1898 | -64, 1045, -413, 194, -413, 140, -413, -413, -413, -413, |
| 1899 | -413, -413, -413, -413, -413, -413, -413, -413, -413, -413, |
| 1900 | -413, -413, -413, -413, -413, -413, 251, 501, 207, -413, |
| 1901 | -413, -413, -413, -413, -413, -413, -413, -413, -413, -413, |
| 1902 | -413, 209, -413, -413, -413, 214, 215, 216, 49, 1138, |
| 1903 | 120, 314, 219, 222, 224, 225, -413, -413, 230, -413, |
| 1904 | 160, 140, 184, -413, -413, -413, -413, -413, 315, 1185, |
| 1905 | 175, 357, 192, -413, -413, 251, 501, 1045, 1045, 1045, |
| 1906 | 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, |
| 1907 | 1045, -413, 192, -413, 195, -413, -413, 203, 693, -413, |
| 1908 | 126, 46, -413, 228, 140, -413, 230, 230, -413, -413, |
| 1909 | -413, -413, -413, -413, -413, -413, -413, -413, 231, -413, |
| 1910 | -413, -413, -413, -413, -413, -413, -413, -413, -413, -413, |
| 1911 | -413, -413, -413, -413, -413, 235, 954, 954, 954, 954, |
| 1912 | 954, -413, -413, 29, 500, -24, -413, -27, -413, 954, |
| 1913 | 954, 954, 954, 39, -413, 241, -413, 160, 746, -413, |
| 1914 | 873, 873, -413, 873, 1125, 1045, 1045, 123, 159, -413, |
| 1915 | 746, 146, 233, 245, 248, 249, 250, 252, 746, 746, |
| 1916 | 356, 253, 1125, 1045, 1045, -413, -413, -413, -413, -413, |
| 1917 | -18, -413, -413, -413, -18, -413, -413, 954, 954, -413, |
| 1918 | 254, 255, 256, 259, 954, -413, 262, 602, -12, -413, |
| 1919 | -413, 265, 274, 367, 275, 391, 407, -413, 230, 774, |
| 1920 | -413, -413, -413, -413, -413, -413, -413, -413, 358, 954, |
| 1921 | -413, -413, -413, -413, 282, -413, 285, 873, 746, 746, |
| 1922 | 35, -413, 43, -413, -413, 873, 281, 1045, 1045, 1045, |
| 1923 | 1045, 1045, 289, 292, 1045, 1045, 873, 746, 293, -413, |
| 1924 | -413, -413, 294, 301, -25, 954, 954, 954, 954, -413, |
| 1925 | -413, 271, 954, 954, 1045, 954, -413, -413, -413, -413, |
| 1926 | 140, 302, 303, -413, 417, 25, 427, 428, 305, 310, |
| 1927 | 318, 873, 441, 873, 319, 322, 873, 323, 140, -413, |
| 1928 | 324, 325, 873, 873, 140, -413, 309, -413, 1045, 954, |
| 1929 | 954, 1045, -413, 326, 328, 327, 335, -413, 332, 333, |
| 1930 | 131, 336, 34, 1028, -413, 339, -413, 873, 873, 1045, |
| 1931 | 873, 873, 341, -413, 341, 873, 342, 1045, 1045, 1045, |
| 1932 | -413, -413, 1045, 746, 340, 345, -413, 954, -413, 954, |
| 1933 | 954, -413, -413, -413, -413, -413, -413, -413, 140, 10, |
| 1934 | 431, 343, 346, 746, 63, -413, -413, 400, -413, -413, |
| 1935 | 338, 873, -413, -413, -413, 144, -413, -413, -413, 351, |
| 1936 | 352, 354, 34, -413, 403, -413, 472, -3, -413, 1045, |
| 1937 | -413, -413, 355, -413, -413, -413, -413, -413, 489, -413, |
| 1938 | 873, -413, 1000, 15, 203, 746, 66, -413, -18, -413, |
| 1939 | -413, 361, -413, 1000, -413, 485, 486, 368, 203, 873, |
| 1940 | 873, 491, 434, -413, 873, 492, -413, 873, -413 |
| 1941 | }; |
| 1942 | |
| 1943 | /* YYPGOTO[NTERM-NUM]. */ |
| 1944 | static const short int yypgoto[] = |
| 1945 | { |
| 1946 | -413, -413, 379, 385, 389, 390, 304, 307, -210, -413, |
| 1947 | 439, -413, -413, 145, -413, -413, -192, -305, -412, -413, |
| 1948 | -235, -413, -303, 26, -413, -201, -413, -413, -14, 288, |
| 1949 | -255, -413, 420, 429, -58, -112, -187, 239, -413, -413, |
| 1950 | 518, -413, -413, -413, -413, -413, -413, -413, -413, -413, |
| 1951 | -413, 0, 11, -413, -413, 448, -413, -413, -413, -413, |
| 1952 | -413, -413, -403, -73, 103, -151, -413, 482, -413, -413, |
| 1953 | -413, -413, -413, 53, 153, -413, -413, -413, -413 |
| 1954 | }; |
| 1955 | |
| 1956 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 1957 | positive, shift that token. If negative, reduce the rule which |
| 1958 | number is the opposite. If zero, do what YYDEFACT says. |
| 1959 | If YYTABLE_NINF, syntax error. */ |
| 1960 | #define YYTABLE_NINF -170 |
| 1961 | static const short int yytable[] = |
| 1962 | { |
| 1963 | 13, 303, 285, 287, 196, 383, 302, 101, 462, 73, |
| 1964 | 334, 13, 59, 60, 203, 103, 62, 63, 64, 65, |
| 1965 | 304, 1, 117, 2, 302, 400, 21, 59, 60, 400, |
| 1966 | 103, 62, 63, 64, 65, 83, 1, 355, 2, 39, |
| 1967 | 322, 40, 86, 197, 431, 335, 336, 66, 1, 377, |
| 1968 | 2, 144, 433, 141, 59, 60, 105, 103, 111, 112, |
| 1969 | 113, 65, 66, 1, 142, 2, 355, 396, 309, 130, |
| 1970 | 141, 313, 314, 315, 316, 317, 131, 36, 320, 321, |
| 1971 | 23, 243, 22, 432, 133, 13, 522, 356, 105, 66, |
| 1972 | 38, 432, 325, 326, 133, 555, 145, 348, -57, -57, |
| 1973 | 24, 25, 26, 27, 28, 29, 30, 344, 31, 451, |
| 1974 | 344, 201, 399, 452, 146, 147, 544, 51, 350, 349, |
| 1975 | 325, 326, 344, 240, 241, 59, 60, 244, 103, 111, |
| 1976 | 112, 113, 65, 411, 1, 55, 2, 204, 541, 551, |
| 1977 | 399, 52, 558, 67, 325, 326, 68, 102, 57, 69, |
| 1978 | 557, 70, 104, 16, 17, 18, 552, 418, 67, 344, |
| 1979 | 66, 68, 83, 344, 69, 87, 70, 139, 466, 508, |
| 1980 | 345, 509, 19, 398, 78, 79, 325, 326, 76, 77, |
| 1981 | 53, 107, 425, 108, 300, 67, 81, 301, 68, 332, |
| 1982 | 281, 69, 82, 70, 400, 298, 399, 529, 1, 32, |
| 1983 | 2, 530, 295, 307, 308, 298, 310, 311, 298, 298, |
| 1984 | 298, 298, 298, 318, 319, 298, 298, 54, 339, 340, |
| 1985 | 341, 342, 343, 32, 133, 372, 90, 372, 372, 499, |
| 1986 | 372, 351, 352, 353, 354, 196, 437, 372, 439, 440, |
| 1987 | 441, 400, 95, 400, 445, 372, 372, 118, 119, 120, |
| 1988 | 121, 122, 123, 124, 91, 92, 67, 380, 107, 68, |
| 1989 | 108, 107, 69, 108, 70, 286, 107, 331, 108, 493, |
| 1990 | 347, 43, 44, 45, 197, 107, 46, 108, 529, 402, |
| 1991 | 403, 107, 533, 108, 94, 385, 409, 148, 149, 96, |
| 1992 | 201, 378, 379, 382, 107, 546, 108, 98, 548, 99, |
| 1993 | 486, 323, 324, 100, 372, 372, 372, 137, 201, 397, |
| 1994 | 298, 138, 372, 325, 326, 109, 110, 542, -58, -59, |
| 1995 | 150, 199, 236, 372, 372, 238, 512, 513, 514, 242, |
| 1996 | 288, 239, 245, 553, 248, 249, 250, 251, 252, 253, |
| 1997 | 254, 255, 256, 257, 276, 420, 277, 453, 454, 455, |
| 1998 | 456, 278, 279, 280, 458, 459, 289, 461, 372, 290, |
| 1999 | 372, 291, 292, 372, 293, 296, 302, 386, 337, 372, |
| 2000 | 372, 333, 338, 298, 438, 298, 298, 298, 359, 387, |
| 2001 | 444, 298, 388, 389, 390, 394, 391, 395, 405, 406, |
| 2002 | 407, 484, 485, 408, 372, 372, 414, 372, 372, 412, |
| 2003 | 460, -169, 372, 374, 375, 410, 376, 416, 413, 415, |
| 2004 | 372, 417, 423, 384, 457, 1, 426, 2, 3, 427, |
| 2005 | 436, 392, 393, 442, 4, 5, 443, 448, 449, 519, |
| 2006 | 372, 520, 521, 465, 483, 450, 463, 298, 372, 467, |
| 2007 | 468, 464, 469, 6, 470, 473, 482, 525, 432, 498, |
| 2008 | 7, 538, 471, 451, 8, 503, 475, 477, 478, 479, |
| 2009 | 487, 489, 495, 298, 298, 298, 488, 372, 503, 490, |
| 2010 | 491, 492, 372, 500, 494, 507, 511, 526, 517, 531, |
| 2011 | 428, 429, 430, 518, 540, 527, 372, 372, 435, 534, |
| 2012 | 535, 372, 536, 549, 372, 556, 547, 559, 560, 446, |
| 2013 | 447, 565, 561, 564, 567, 59, 60, 227, 103, 111, |
| 2014 | 112, 113, 65, 228, 1, 545, 2, 229, 230, 305, |
| 2015 | 259, 260, 495, 306, 128, 523, 329, -168, 143, 37, |
| 2016 | 127, 140, 89, 537, 472, 515, 474, 434, 0, 476, |
| 2017 | 66, 1, 0, 2, 3, 480, 481, 0, 0, 0, |
| 2018 | 4, 5, 0, 0, 59, 60, 0, 103, 62, 63, |
| 2019 | 64, 65, 0, 1, 0, 2, 0, 0, 0, 6, |
| 2020 | 501, 502, 0, 505, 506, 0, 7, 0, 510, 132, |
| 2021 | 8, 0, 0, 0, 0, 0, 516, 0, 0, 66, |
| 2022 | 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, |
| 2023 | 271, 272, 273, 274, 0, 0, 528, 59, 60, 0, |
| 2024 | 0, 0, 0, 0, 532, 0, 1, 0, 2, 0, |
| 2025 | 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2026 | 0, 0, 0, 152, 153, 0, 67, 0, 0, 68, |
| 2027 | 0, 0, 69, 550, 70, 346, 0, 0, 554, 0, |
| 2028 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2029 | 0, 0, 562, 563, 0, 0, 0, 566, 0, 0, |
| 2030 | 568, 154, 155, 156, 157, 158, 159, 160, 161, 162, |
| 2031 | 163, 164, 165, 166, 167, 67, 0, 0, 68, 0, |
| 2032 | 0, 69, 0, 70, 0, 0, 0, 0, 59, 60, |
| 2033 | 0, 103, 62, 63, 64, 65, 0, 1, 0, 2, |
| 2034 | 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, |
| 2035 | 178, 179, 180, 328, 181, 182, 183, 184, 0, 185, |
| 2036 | 186, 187, 0, 66, 0, 0, 0, 107, 0, 108, |
| 2037 | 0, 188, 0, 0, 189, 0, 190, 0, 191, 360, |
| 2038 | 361, 59, 60, 362, 0, 0, 0, 0, 0, 0, |
| 2039 | 1, 0, 2, 0, 363, 364, 365, 0, 0, 0, |
| 2040 | 0, 0, 0, 0, 0, 0, 0, 366, 367, 59, |
| 2041 | 60, 0, 103, 62, 63, 64, 65, 0, 1, 0, |
| 2042 | 2, 0, 0, 0, 0, 0, 59, 60, 368, 61, |
| 2043 | 62, 63, 64, 65, 419, 1, 0, 2, 0, 0, |
| 2044 | 0, 0, 0, 0, 66, 154, 155, 156, 157, 158, |
| 2045 | 159, 160, 161, 162, 163, 164, 165, 166, 167, 67, |
| 2046 | 0, 66, 68, 0, 0, 69, 0, 70, 0, 0, |
| 2047 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2048 | 0, 0, 0, 0, 168, 169, 170, 171, 172, 173, |
| 2049 | 174, 175, 176, 177, 178, 179, 180, 0, 181, 182, |
| 2050 | 183, 184, 0, 185, 186, 187, 360, 361, 59, 60, |
| 2051 | 362, 107, 0, 108, 0, 0, 0, 1, 369, 2, |
| 2052 | 0, 363, 364, 365, 0, 0, 0, 0, 0, 0, |
| 2053 | 0, 0, 0, 0, 366, 367, 0, 0, 0, 0, |
| 2054 | 67, 0, 0, 68, 0, 0, 69, 0, 70, 0, |
| 2055 | 0, 0, 0, 0, 0, 368, 0, 67, 0, 0, |
| 2056 | 68, 0, 0, 69, 0, 70, 0, 0, 0, 0, |
| 2057 | 0, 0, 154, 155, 156, 157, 158, 159, 160, 161, |
| 2058 | 162, 163, 164, 165, 166, 167, 0, 0, 0, 59, |
| 2059 | 60, 0, 103, 111, 112, 113, 65, 0, 1, 0, |
| 2060 | 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2061 | 0, 168, 169, 170, 171, 172, 173, 174, 175, 176, |
| 2062 | 177, 178, 179, 180, 66, 181, 182, 183, 184, 0, |
| 2063 | 185, 186, 187, 360, 361, 0, 0, 362, 0, 0, |
| 2064 | 0, 0, 0, 0, 0, 369, 0, 0, 363, 364, |
| 2065 | 365, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2066 | 0, 366, 367, 59, 60, 0, 103, 62, 63, 64, |
| 2067 | 65, 0, 1, 0, 2, 0, 0, 0, 0, 0, |
| 2068 | 59, 60, 368, 103, 62, 63, 64, 65, 497, 1, |
| 2069 | 0, 2, 0, 0, 0, 0, 0, 0, 66, 154, |
| 2070 | 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, |
| 2071 | 165, 166, 167, 0, 0, 66, 0, 0, 0, 0, |
| 2072 | 67, 0, 0, 68, 0, 0, 69, 0, 70, 0, |
| 2073 | 0, 0, 0, 0, 0, 0, 0, 0, 168, 169, |
| 2074 | 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, |
| 2075 | 180, 0, 181, 182, 183, 184, 0, 185, 186, 187, |
| 2076 | 59, 60, 0, 200, 62, 63, 64, 65, 0, 1, |
| 2077 | 0, 2, 369, 59, 60, 0, 103, 111, 112, 113, |
| 2078 | 65, 0, 1, 0, 2, 0, 0, 0, 0, 0, |
| 2079 | 0, 0, 0, 0, 67, 66, 0, 68, 0, 0, |
| 2080 | 69, 0, 70, 0, 0, 0, 0, 0, 66, 0, |
| 2081 | 0, 67, 0, 0, 68, 0, 0, 69, 0, 70, |
| 2082 | 59, 60, 0, 297, 62, 63, 64, 65, 0, 1, |
| 2083 | 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2084 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2085 | 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, |
| 2086 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2087 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2088 | 0, 0, 0, 0, 0, 0, 206, 0, 0, 0, |
| 2089 | 0, 67, 0, 0, 68, 0, 0, 69, 0, 70, |
| 2090 | 0, 0, 0, 0, 67, 0, 0, 68, 207, 208, |
| 2091 | 69, 0, 284, 0, 0, 0, 0, 0, 0, 0, |
| 2092 | 0, 209, 210, 211, 212, 213, 214, 154, 155, 156, |
| 2093 | 157, 158, 159, 160, 161, 162, 163, 164, 165, 215, |
| 2094 | 216, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2095 | 0, 67, 0, 0, 68, 0, 0, 69, 0, 70, |
| 2096 | 0, 217, 218, 219, 0, 0, 220, 169, 170, 171, |
| 2097 | 172, 173, 174, 175, 176, 177, 178, 179, 180, 221, |
| 2098 | 222, 182, 183, 184, 223, 224, 225, 226 |
| 2099 | }; |
| 2100 | |
| 2101 | static const short int yycheck[] = |
| 2102 | { |
| 2103 | 0, 211, 189, 190, 116, 308, 9, 4, 420, 23, |
| 2104 | 245, 11, 5, 6, 21, 8, 9, 10, 11, 12, |
| 2105 | 212, 14, 80, 16, 9, 330, 133, 5, 6, 334, |
| 2106 | 8, 9, 10, 11, 12, 15, 14, 27, 16, 37, |
| 2107 | 232, 39, 22, 116, 9, 246, 247, 40, 14, 304, |
| 2108 | 16, 109, 9, 134, 5, 6, 70, 8, 9, 10, |
| 2109 | 11, 12, 40, 14, 145, 16, 27, 322, 219, 134, |
| 2110 | 134, 222, 223, 224, 225, 226, 141, 0, 229, 230, |
| 2111 | 13, 145, 52, 48, 98, 85, 498, 48, 102, 40, |
| 2112 | 133, 48, 110, 111, 108, 29, 110, 284, 3, 4, |
| 2113 | 33, 34, 35, 36, 37, 38, 39, 134, 41, 134, |
| 2114 | 134, 125, 130, 138, 19, 20, 528, 133, 145, 143, |
| 2115 | 110, 111, 134, 137, 138, 5, 6, 141, 8, 9, |
| 2116 | 10, 11, 12, 145, 14, 139, 16, 144, 141, 542, |
| 2117 | 130, 133, 554, 136, 110, 111, 139, 144, 16, 142, |
| 2118 | 553, 144, 145, 43, 44, 45, 141, 358, 136, 134, |
| 2119 | 40, 139, 15, 134, 142, 145, 144, 145, 143, 472, |
| 2120 | 141, 474, 62, 324, 25, 26, 110, 111, 33, 34, |
| 2121 | 133, 135, 369, 137, 9, 136, 41, 12, 139, 143, |
| 2122 | 141, 142, 47, 144, 499, 209, 130, 134, 14, 132, |
| 2123 | 16, 138, 202, 217, 218, 219, 220, 221, 222, 223, |
| 2124 | 224, 225, 226, 227, 228, 229, 230, 133, 276, 277, |
| 2125 | 278, 279, 280, 132, 238, 298, 16, 300, 301, 464, |
| 2126 | 303, 289, 290, 291, 292, 347, 387, 310, 389, 390, |
| 2127 | 391, 546, 16, 548, 395, 318, 319, 55, 56, 57, |
| 2128 | 58, 59, 60, 61, 46, 47, 136, 134, 135, 139, |
| 2129 | 137, 135, 142, 137, 144, 145, 135, 141, 137, 138, |
| 2130 | 284, 33, 34, 35, 347, 135, 38, 137, 134, 337, |
| 2131 | 338, 135, 138, 137, 4, 139, 344, 3, 4, 16, |
| 2132 | 304, 305, 306, 134, 135, 530, 137, 137, 533, 4, |
| 2133 | 451, 106, 107, 4, 377, 378, 379, 140, 322, 323, |
| 2134 | 324, 140, 385, 110, 111, 76, 77, 527, 7, 7, |
| 2135 | 7, 4, 16, 396, 397, 134, 477, 478, 479, 143, |
| 2136 | 16, 138, 138, 543, 83, 84, 85, 86, 87, 88, |
| 2137 | 89, 90, 91, 92, 137, 359, 137, 405, 406, 407, |
| 2138 | 408, 137, 137, 137, 412, 413, 137, 415, 431, 137, |
| 2139 | 433, 137, 137, 436, 134, 50, 9, 134, 137, 442, |
| 2140 | 443, 143, 137, 387, 388, 389, 390, 391, 137, 134, |
| 2141 | 394, 395, 134, 134, 134, 29, 134, 134, 134, 134, |
| 2142 | 134, 449, 450, 134, 467, 468, 29, 470, 471, 134, |
| 2143 | 414, 0, 475, 300, 301, 143, 303, 16, 134, 134, |
| 2144 | 483, 4, 54, 310, 143, 14, 134, 16, 17, 134, |
| 2145 | 139, 318, 319, 134, 23, 24, 134, 134, 134, 487, |
| 2146 | 503, 489, 490, 16, 448, 134, 134, 451, 511, 12, |
| 2147 | 12, 138, 137, 42, 134, 4, 137, 16, 48, 463, |
| 2148 | 49, 48, 134, 134, 53, 469, 134, 134, 134, 134, |
| 2149 | 134, 134, 462, 477, 478, 479, 138, 540, 482, 134, |
| 2150 | 138, 138, 545, 134, 138, 134, 134, 134, 138, 141, |
| 2151 | 377, 378, 379, 138, 12, 139, 559, 560, 385, 138, |
| 2152 | 138, 564, 138, 4, 567, 134, 141, 12, 12, 396, |
| 2153 | 397, 67, 134, 12, 12, 5, 6, 128, 8, 9, |
| 2154 | 10, 11, 12, 128, 14, 529, 16, 128, 128, 215, |
| 2155 | 19, 20, 522, 216, 85, 499, 238, 0, 108, 11, |
| 2156 | 82, 102, 50, 522, 431, 482, 433, 384, -1, 436, |
| 2157 | 40, 14, -1, 16, 17, 442, 443, -1, -1, -1, |
| 2158 | 23, 24, -1, -1, 5, 6, -1, 8, 9, 10, |
| 2159 | 11, 12, -1, 14, -1, 16, -1, -1, -1, 42, |
| 2160 | 467, 468, -1, 470, 471, -1, 49, -1, 475, 30, |
| 2161 | 53, -1, -1, -1, -1, -1, 483, -1, -1, 40, |
| 2162 | 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, |
| 2163 | 99, 100, 101, 102, -1, -1, 503, 5, 6, -1, |
| 2164 | -1, -1, -1, -1, 511, -1, 14, -1, 16, -1, |
| 2165 | 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2166 | -1, -1, -1, 31, 32, -1, 136, -1, -1, 139, |
| 2167 | -1, -1, 142, 540, 144, 145, -1, -1, 545, -1, |
| 2168 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2169 | -1, -1, 559, 560, -1, -1, -1, 564, -1, -1, |
| 2170 | 567, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 2171 | 78, 79, 80, 81, 82, 136, -1, -1, 139, -1, |
| 2172 | -1, 142, -1, 144, -1, -1, -1, -1, 5, 6, |
| 2173 | -1, 8, 9, 10, 11, 12, -1, 14, -1, 16, |
| 2174 | 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, |
| 2175 | 118, 119, 120, 30, 122, 123, 124, 125, -1, 127, |
| 2176 | 128, 129, -1, 40, -1, -1, -1, 135, -1, 137, |
| 2177 | -1, 139, -1, -1, 142, -1, 144, -1, 146, 3, |
| 2178 | 4, 5, 6, 7, -1, -1, -1, -1, -1, -1, |
| 2179 | 14, -1, 16, -1, 18, 19, 20, -1, -1, -1, |
| 2180 | -1, -1, -1, -1, -1, -1, -1, 31, 32, 5, |
| 2181 | 6, -1, 8, 9, 10, 11, 12, -1, 14, -1, |
| 2182 | 16, -1, -1, -1, -1, -1, 5, 6, 52, 8, |
| 2183 | 9, 10, 11, 12, 30, 14, -1, 16, -1, -1, |
| 2184 | -1, -1, -1, -1, 40, 69, 70, 71, 72, 73, |
| 2185 | 74, 75, 76, 77, 78, 79, 80, 81, 82, 136, |
| 2186 | -1, 40, 139, -1, -1, 142, -1, 144, -1, -1, |
| 2187 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2188 | -1, -1, -1, -1, 108, 109, 110, 111, 112, 113, |
| 2189 | 114, 115, 116, 117, 118, 119, 120, -1, 122, 123, |
| 2190 | 124, 125, -1, 127, 128, 129, 3, 4, 5, 6, |
| 2191 | 7, 135, -1, 137, -1, -1, -1, 14, 142, 16, |
| 2192 | -1, 18, 19, 20, -1, -1, -1, -1, -1, -1, |
| 2193 | -1, -1, -1, -1, 31, 32, -1, -1, -1, -1, |
| 2194 | 136, -1, -1, 139, -1, -1, 142, -1, 144, -1, |
| 2195 | -1, -1, -1, -1, -1, 52, -1, 136, -1, -1, |
| 2196 | 139, -1, -1, 142, -1, 144, -1, -1, -1, -1, |
| 2197 | -1, -1, 69, 70, 71, 72, 73, 74, 75, 76, |
| 2198 | 77, 78, 79, 80, 81, 82, -1, -1, -1, 5, |
| 2199 | 6, -1, 8, 9, 10, 11, 12, -1, 14, -1, |
| 2200 | 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2201 | -1, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 2202 | 117, 118, 119, 120, 40, 122, 123, 124, 125, -1, |
| 2203 | 127, 128, 129, 3, 4, -1, -1, 7, -1, -1, |
| 2204 | -1, -1, -1, -1, -1, 142, -1, -1, 18, 19, |
| 2205 | 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2206 | -1, 31, 32, 5, 6, -1, 8, 9, 10, 11, |
| 2207 | 12, -1, 14, -1, 16, -1, -1, -1, -1, -1, |
| 2208 | 5, 6, 52, 8, 9, 10, 11, 12, 30, 14, |
| 2209 | -1, 16, -1, -1, -1, -1, -1, -1, 40, 69, |
| 2210 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 2211 | 80, 81, 82, -1, -1, 40, -1, -1, -1, -1, |
| 2212 | 136, -1, -1, 139, -1, -1, 142, -1, 144, -1, |
| 2213 | -1, -1, -1, -1, -1, -1, -1, -1, 108, 109, |
| 2214 | 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, |
| 2215 | 120, -1, 122, 123, 124, 125, -1, 127, 128, 129, |
| 2216 | 5, 6, -1, 8, 9, 10, 11, 12, -1, 14, |
| 2217 | -1, 16, 142, 5, 6, -1, 8, 9, 10, 11, |
| 2218 | 12, -1, 14, -1, 16, -1, -1, -1, -1, -1, |
| 2219 | -1, -1, -1, -1, 136, 40, -1, 139, -1, -1, |
| 2220 | 142, -1, 144, -1, -1, -1, -1, -1, 40, -1, |
| 2221 | -1, 136, -1, -1, 139, -1, -1, 142, -1, 144, |
| 2222 | 5, 6, -1, 8, 9, 10, 11, 12, -1, 14, |
| 2223 | -1, 16, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2224 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2225 | -1, -1, -1, -1, -1, 40, -1, -1, -1, -1, |
| 2226 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2227 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2228 | -1, -1, -1, -1, -1, -1, 28, -1, -1, -1, |
| 2229 | -1, 136, -1, -1, 139, -1, -1, 142, -1, 144, |
| 2230 | -1, -1, -1, -1, 136, -1, -1, 139, 50, 51, |
| 2231 | 142, -1, 144, -1, -1, -1, -1, -1, -1, -1, |
| 2232 | -1, 63, 64, 65, 66, 67, 68, 69, 70, 71, |
| 2233 | 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, |
| 2234 | 82, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2235 | -1, 136, -1, -1, 139, -1, -1, 142, -1, 144, |
| 2236 | -1, 103, 104, 105, -1, -1, 108, 109, 110, 111, |
| 2237 | 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, |
| 2238 | 122, 123, 124, 125, 126, 127, 128, 129 |
| 2239 | }; |
| 2240 | |
| 2241 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 2242 | symbol of state STATE-NUM. */ |
| 2243 | static const unsigned char yystos[] = |
| 2244 | { |
| 2245 | 0, 14, 16, 17, 23, 24, 42, 49, 53, 157, |
| 2246 | 185, 186, 187, 198, 189, 188, 43, 44, 45, 62, |
| 2247 | 195, 133, 52, 13, 33, 34, 35, 36, 37, 38, |
| 2248 | 39, 41, 132, 158, 159, 160, 0, 187, 133, 37, |
| 2249 | 39, 161, 207, 33, 34, 35, 38, 162, 204, 206, |
| 2250 | 213, 133, 133, 133, 133, 139, 196, 16, 193, 5, |
| 2251 | 6, 8, 9, 10, 11, 12, 40, 136, 139, 142, |
| 2252 | 144, 148, 174, 175, 198, 210, 160, 160, 25, 26, |
| 2253 | 184, 160, 160, 15, 214, 215, 22, 145, 205, 214, |
| 2254 | 16, 46, 47, 194, 4, 16, 16, 197, 137, 4, |
| 2255 | 4, 4, 144, 8, 145, 175, 180, 135, 137, 184, |
| 2256 | 184, 9, 10, 11, 155, 156, 175, 181, 55, 56, |
| 2257 | 57, 58, 59, 60, 61, 163, 202, 202, 157, 218, |
| 2258 | 134, 141, 30, 175, 176, 178, 179, 140, 140, 145, |
| 2259 | 180, 134, 145, 179, 181, 175, 19, 20, 3, 4, |
| 2260 | 7, 18, 31, 32, 69, 70, 71, 72, 73, 74, |
| 2261 | 75, 76, 77, 78, 79, 80, 81, 82, 108, 109, |
| 2262 | 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, |
| 2263 | 120, 122, 123, 124, 125, 127, 128, 129, 139, 142, |
| 2264 | 144, 146, 149, 150, 151, 152, 182, 210, 190, 4, |
| 2265 | 8, 175, 177, 21, 144, 203, 28, 50, 51, 63, |
| 2266 | 64, 65, 66, 67, 68, 81, 82, 103, 104, 105, |
| 2267 | 108, 121, 122, 126, 127, 128, 129, 149, 150, 151, |
| 2268 | 152, 216, 222, 223, 224, 225, 16, 165, 134, 138, |
| 2269 | 175, 175, 143, 145, 175, 138, 191, 192, 83, 84, |
| 2270 | 85, 86, 87, 88, 89, 90, 91, 92, 153, 19, |
| 2271 | 20, 89, 90, 91, 92, 93, 94, 95, 96, 97, |
| 2272 | 98, 99, 100, 101, 102, 154, 137, 137, 137, 137, |
| 2273 | 137, 141, 181, 183, 144, 183, 145, 183, 16, 137, |
| 2274 | 137, 137, 137, 134, 172, 198, 50, 8, 175, 212, |
| 2275 | 9, 12, 9, 155, 163, 153, 154, 175, 175, 212, |
| 2276 | 175, 175, 219, 212, 212, 212, 212, 212, 175, 175, |
| 2277 | 212, 212, 163, 106, 107, 110, 111, 164, 30, 176, |
| 2278 | 167, 141, 143, 143, 167, 172, 172, 137, 137, 181, |
| 2279 | 181, 181, 181, 181, 134, 141, 145, 175, 183, 143, |
| 2280 | 145, 181, 181, 181, 181, 27, 48, 170, 173, 137, |
| 2281 | 3, 4, 7, 18, 19, 20, 31, 32, 52, 142, |
| 2282 | 182, 209, 210, 211, 211, 211, 211, 177, 175, 175, |
| 2283 | 134, 169, 134, 169, 211, 139, 134, 134, 134, 134, |
| 2284 | 134, 134, 211, 211, 29, 134, 177, 175, 212, 130, |
| 2285 | 164, 166, 181, 181, 221, 134, 134, 134, 134, 181, |
| 2286 | 143, 145, 134, 134, 29, 134, 16, 4, 172, 30, |
| 2287 | 175, 200, 201, 54, 208, 183, 134, 134, 211, 211, |
| 2288 | 211, 9, 48, 9, 221, 211, 139, 212, 175, 212, |
| 2289 | 212, 212, 134, 134, 175, 212, 211, 211, 134, 134, |
| 2290 | 134, 134, 138, 181, 181, 181, 181, 143, 181, 181, |
| 2291 | 175, 181, 165, 134, 138, 16, 143, 12, 12, 137, |
| 2292 | 134, 134, 211, 4, 211, 134, 211, 134, 134, 134, |
| 2293 | 211, 211, 137, 175, 181, 181, 212, 134, 138, 134, |
| 2294 | 134, 138, 138, 138, 138, 198, 199, 30, 175, 167, |
| 2295 | 134, 211, 211, 175, 220, 211, 211, 134, 169, 169, |
| 2296 | 211, 134, 212, 212, 212, 220, 211, 138, 138, 181, |
| 2297 | 181, 181, 165, 170, 171, 16, 134, 139, 211, 134, |
| 2298 | 138, 141, 211, 138, 138, 138, 138, 199, 48, 168, |
| 2299 | 12, 141, 155, 217, 165, 175, 167, 141, 167, 4, |
| 2300 | 211, 209, 141, 155, 211, 29, 134, 209, 165, 12, |
| 2301 | 12, 134, 211, 211, 12, 67, 211, 12, 211 |
| 2302 | }; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2303 | |
| 2304 | #define yyerrok (yyerrstatus = 0) |
| 2305 | #define yyclearin (yychar = YYEMPTY) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2306 | #define YYEMPTY (-2) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2307 | #define YYEOF 0 |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2308 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2309 | #define YYACCEPT goto yyacceptlab |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2310 | #define YYABORT goto yyabortlab |
| 2311 | #define YYERROR goto yyerrorlab |
| 2312 | |
| 2313 | |
| 2314 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 2315 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2316 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2317 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2318 | #define YYFAIL goto yyerrlab |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2319 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2320 | #define YYRECOVERING() (!!yyerrstatus) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2321 | |
| 2322 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2323 | do \ |
| 2324 | if (yychar == YYEMPTY && yylen == 1) \ |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2325 | { \ |
| 2326 | yychar = (Token); \ |
| 2327 | yylval = (Value); \ |
| 2328 | yytoken = YYTRANSLATE (yychar); \ |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2329 | YYPOPSTACK; \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2330 | goto yybackup; \ |
| 2331 | } \ |
| 2332 | else \ |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2333 | { \ |
| 2334 | yyerror (YY_("syntax error: cannot back up")); \ |
| 2335 | YYERROR; \ |
| 2336 | } \ |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2337 | while (0) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2338 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2339 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2340 | #define YYTERROR 1 |
| 2341 | #define YYERRCODE 256 |
| 2342 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2343 | |
| 2344 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
| 2345 | If N is 0, then set CURRENT to the empty location which ends |
| 2346 | the previous symbol: RHS[0] (always defined). */ |
| 2347 | |
| 2348 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| 2349 | #ifndef YYLLOC_DEFAULT |
| 2350 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 2351 | do \ |
| 2352 | if (N) \ |
| 2353 | { \ |
| 2354 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
| 2355 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
| 2356 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
| 2357 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
| 2358 | } \ |
| 2359 | else \ |
| 2360 | { \ |
| 2361 | (Current).first_line = (Current).last_line = \ |
| 2362 | YYRHSLOC (Rhs, 0).last_line; \ |
| 2363 | (Current).first_column = (Current).last_column = \ |
| 2364 | YYRHSLOC (Rhs, 0).last_column; \ |
| 2365 | } \ |
| 2366 | while (0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2367 | #endif |
| 2368 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2369 | |
| 2370 | /* YY_LOCATION_PRINT -- Print the location on the stream. |
| 2371 | This macro was not mandated originally: define only if we know |
| 2372 | we won't break user code: when these are the locations we know. */ |
| 2373 | |
| 2374 | #ifndef YY_LOCATION_PRINT |
| 2375 | # if YYLTYPE_IS_TRIVIAL |
| 2376 | # define YY_LOCATION_PRINT(File, Loc) \ |
| 2377 | fprintf (File, "%d.%d-%d.%d", \ |
| 2378 | (Loc).first_line, (Loc).first_column, \ |
| 2379 | (Loc).last_line, (Loc).last_column) |
| 2380 | # else |
| 2381 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 2382 | # endif |
| 2383 | #endif |
| 2384 | |
| 2385 | |
| 2386 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 2387 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2388 | #ifdef YYLEX_PARAM |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2389 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2390 | #else |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2391 | # define YYLEX yylex () |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2392 | #endif |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2393 | |
| 2394 | /* Enable debugging if requested. */ |
| 2395 | #if YYDEBUG |
| 2396 | |
| 2397 | # ifndef YYFPRINTF |
| 2398 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 2399 | # define YYFPRINTF fprintf |
| 2400 | # endif |
| 2401 | |
| 2402 | # define YYDPRINTF(Args) \ |
| 2403 | do { \ |
| 2404 | if (yydebug) \ |
| 2405 | YYFPRINTF Args; \ |
| 2406 | } while (0) |
| 2407 | |
| 2408 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 2409 | do { \ |
| 2410 | if (yydebug) \ |
| 2411 | { \ |
| 2412 | YYFPRINTF (stderr, "%s ", Title); \ |
| 2413 | yysymprint (stderr, \ |
| 2414 | Type, Value); \ |
| 2415 | YYFPRINTF (stderr, "\n"); \ |
| 2416 | } \ |
| 2417 | } while (0) |
| 2418 | |
| 2419 | /*------------------------------------------------------------------. |
| 2420 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 2421 | | TOP (included). | |
| 2422 | `------------------------------------------------------------------*/ |
| 2423 | |
| 2424 | #if defined (__STDC__) || defined (__cplusplus) |
| 2425 | static void |
| 2426 | yy_stack_print (short int *bottom, short int *top) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2427 | #else |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2428 | static void |
| 2429 | yy_stack_print (bottom, top) |
| 2430 | short int *bottom; |
| 2431 | short int *top; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2432 | #endif |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2433 | { |
| 2434 | YYFPRINTF (stderr, "Stack now"); |
| 2435 | for (/* Nothing. */; bottom <= top; ++bottom) |
| 2436 | YYFPRINTF (stderr, " %d", *bottom); |
| 2437 | YYFPRINTF (stderr, "\n"); |
| 2438 | } |
| 2439 | |
| 2440 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 2441 | do { \ |
| 2442 | if (yydebug) \ |
| 2443 | yy_stack_print ((Bottom), (Top)); \ |
| 2444 | } while (0) |
| 2445 | |
| 2446 | |
| 2447 | /*------------------------------------------------. |
| 2448 | | Report that the YYRULE is going to be reduced. | |
| 2449 | `------------------------------------------------*/ |
| 2450 | |
| 2451 | #if defined (__STDC__) || defined (__cplusplus) |
| 2452 | static void |
| 2453 | yy_reduce_print (int yyrule) |
| 2454 | #else |
| 2455 | static void |
| 2456 | yy_reduce_print (yyrule) |
| 2457 | int yyrule; |
Chris Lattner | 0fab59c | 2007-01-12 18:33:30 +0000 | [diff] [blame] | 2458 | #endif |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2459 | { |
| 2460 | int yyi; |
| 2461 | unsigned long int yylno = yyrline[yyrule]; |
| 2462 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", |
| 2463 | yyrule - 1, yylno); |
| 2464 | /* Print the symbols being reduced, and their result. */ |
| 2465 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
| 2466 | YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); |
| 2467 | YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); |
| 2468 | } |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2469 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2470 | # define YY_REDUCE_PRINT(Rule) \ |
| 2471 | do { \ |
| 2472 | if (yydebug) \ |
| 2473 | yy_reduce_print (Rule); \ |
| 2474 | } while (0) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2475 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2476 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 2477 | multiple parsers can coexist. */ |
| 2478 | int yydebug; |
| 2479 | #else /* !YYDEBUG */ |
| 2480 | # define YYDPRINTF(Args) |
| 2481 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
| 2482 | # define YY_STACK_PRINT(Bottom, Top) |
| 2483 | # define YY_REDUCE_PRINT(Rule) |
| 2484 | #endif /* !YYDEBUG */ |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2485 | |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2486 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2487 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2488 | #ifndef YYINITDEPTH |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2489 | # define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2490 | #endif |
| 2491 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2492 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 2493 | if the built-in stack extension method is used). |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2494 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2495 | Do not make this value too large; the results are undefined if |
| 2496 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
| 2497 | evaluated with infinite-precision integer arithmetic. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2498 | |
| 2499 | #ifndef YYMAXDEPTH |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2500 | # define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2501 | #endif |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2502 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2503 | |
| 2504 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2505 | #if YYERROR_VERBOSE |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2506 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2507 | # ifndef yystrlen |
| 2508 | # if defined (__GLIBC__) && defined (_STRING_H) |
| 2509 | # define yystrlen strlen |
| 2510 | # else |
| 2511 | /* Return the length of YYSTR. */ |
| 2512 | static YYSIZE_T |
| 2513 | # if defined (__STDC__) || defined (__cplusplus) |
| 2514 | yystrlen (const char *yystr) |
| 2515 | # else |
| 2516 | yystrlen (yystr) |
| 2517 | const char *yystr; |
| 2518 | # endif |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2519 | { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2520 | const char *yys = yystr; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2521 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2522 | while (*yys++ != '\0') |
| 2523 | continue; |
| 2524 | |
| 2525 | return yys - yystr - 1; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2526 | } |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2527 | # endif |
| 2528 | # endif |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2529 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2530 | # ifndef yystpcpy |
| 2531 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
| 2532 | # define yystpcpy stpcpy |
| 2533 | # else |
| 2534 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 2535 | YYDEST. */ |
| 2536 | static char * |
| 2537 | # if defined (__STDC__) || defined (__cplusplus) |
| 2538 | yystpcpy (char *yydest, const char *yysrc) |
| 2539 | # else |
| 2540 | yystpcpy (yydest, yysrc) |
| 2541 | char *yydest; |
| 2542 | const char *yysrc; |
| 2543 | # endif |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2544 | { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2545 | char *yyd = yydest; |
| 2546 | const char *yys = yysrc; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2547 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2548 | while ((*yyd++ = *yys++) != '\0') |
| 2549 | continue; |
| 2550 | |
| 2551 | return yyd - 1; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2552 | } |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2553 | # endif |
| 2554 | # endif |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2555 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2556 | # ifndef yytnamerr |
| 2557 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
| 2558 | quotes and backslashes, so that it's suitable for yyerror. The |
| 2559 | heuristic is that double-quoting is unnecessary unless the string |
| 2560 | contains an apostrophe, a comma, or backslash (other than |
| 2561 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
| 2562 | null, do not copy; instead, return the length of what the result |
| 2563 | would have been. */ |
| 2564 | static YYSIZE_T |
| 2565 | yytnamerr (char *yyres, const char *yystr) |
| 2566 | { |
| 2567 | if (*yystr == '"') |
| 2568 | { |
| 2569 | size_t yyn = 0; |
| 2570 | char const *yyp = yystr; |
| 2571 | |
| 2572 | for (;;) |
| 2573 | switch (*++yyp) |
| 2574 | { |
| 2575 | case '\'': |
| 2576 | case ',': |
| 2577 | goto do_not_strip_quotes; |
| 2578 | |
| 2579 | case '\\': |
| 2580 | if (*++yyp != '\\') |
| 2581 | goto do_not_strip_quotes; |
| 2582 | /* Fall through. */ |
| 2583 | default: |
| 2584 | if (yyres) |
| 2585 | yyres[yyn] = *yyp; |
| 2586 | yyn++; |
| 2587 | break; |
| 2588 | |
| 2589 | case '"': |
| 2590 | if (yyres) |
| 2591 | yyres[yyn] = '\0'; |
| 2592 | return yyn; |
| 2593 | } |
| 2594 | do_not_strip_quotes: ; |
| 2595 | } |
| 2596 | |
| 2597 | if (! yyres) |
| 2598 | return yystrlen (yystr); |
| 2599 | |
| 2600 | return yystpcpy (yyres, yystr) - yyres; |
| 2601 | } |
| 2602 | # endif |
| 2603 | |
| 2604 | #endif /* YYERROR_VERBOSE */ |
| 2605 | |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2606 | |
| 2607 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2608 | #if YYDEBUG |
| 2609 | /*--------------------------------. |
| 2610 | | Print this symbol on YYOUTPUT. | |
| 2611 | `--------------------------------*/ |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2612 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2613 | #if defined (__STDC__) || defined (__cplusplus) |
| 2614 | static void |
| 2615 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2616 | #else |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2617 | static void |
| 2618 | yysymprint (yyoutput, yytype, yyvaluep) |
| 2619 | FILE *yyoutput; |
| 2620 | int yytype; |
| 2621 | YYSTYPE *yyvaluep; |
| 2622 | #endif |
| 2623 | { |
| 2624 | /* Pacify ``unused variable'' warnings. */ |
| 2625 | (void) yyvaluep; |
| 2626 | |
| 2627 | if (yytype < YYNTOKENS) |
| 2628 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 2629 | else |
| 2630 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 2631 | |
| 2632 | |
| 2633 | # ifdef YYPRINT |
| 2634 | if (yytype < YYNTOKENS) |
| 2635 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 2636 | # endif |
| 2637 | switch (yytype) |
| 2638 | { |
| 2639 | default: |
| 2640 | break; |
| 2641 | } |
| 2642 | YYFPRINTF (yyoutput, ")"); |
| 2643 | } |
| 2644 | |
| 2645 | #endif /* ! YYDEBUG */ |
| 2646 | /*-----------------------------------------------. |
| 2647 | | Release the memory associated to this symbol. | |
| 2648 | `-----------------------------------------------*/ |
| 2649 | |
| 2650 | #if defined (__STDC__) || defined (__cplusplus) |
| 2651 | static void |
| 2652 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
| 2653 | #else |
| 2654 | static void |
| 2655 | yydestruct (yymsg, yytype, yyvaluep) |
| 2656 | const char *yymsg; |
| 2657 | int yytype; |
| 2658 | YYSTYPE *yyvaluep; |
| 2659 | #endif |
| 2660 | { |
| 2661 | /* Pacify ``unused variable'' warnings. */ |
| 2662 | (void) yyvaluep; |
| 2663 | |
| 2664 | if (!yymsg) |
| 2665 | yymsg = "Deleting"; |
| 2666 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 2667 | |
| 2668 | switch (yytype) |
| 2669 | { |
| 2670 | |
| 2671 | default: |
| 2672 | break; |
| 2673 | } |
| 2674 | } |
| 2675 | |
| 2676 | |
| 2677 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 2678 | |
| 2679 | #ifdef YYPARSE_PARAM |
| 2680 | # if defined (__STDC__) || defined (__cplusplus) |
| 2681 | int yyparse (void *YYPARSE_PARAM); |
| 2682 | # else |
| 2683 | int yyparse (); |
| 2684 | # endif |
| 2685 | #else /* ! YYPARSE_PARAM */ |
| 2686 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 2687 | int yyparse (void); |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2688 | #else |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2689 | int yyparse (); |
| 2690 | #endif |
| 2691 | #endif /* ! YYPARSE_PARAM */ |
| 2692 | |
| 2693 | |
| 2694 | |
| 2695 | /* The look-ahead symbol. */ |
| 2696 | int yychar; |
| 2697 | |
| 2698 | /* The semantic value of the look-ahead symbol. */ |
| 2699 | YYSTYPE yylval; |
| 2700 | |
| 2701 | /* Number of syntax errors so far. */ |
| 2702 | int yynerrs; |
| 2703 | |
| 2704 | |
| 2705 | |
| 2706 | /*----------. |
| 2707 | | yyparse. | |
| 2708 | `----------*/ |
| 2709 | |
| 2710 | #ifdef YYPARSE_PARAM |
| 2711 | # if defined (__STDC__) || defined (__cplusplus) |
| 2712 | int yyparse (void *YYPARSE_PARAM) |
| 2713 | # else |
| 2714 | int yyparse (YYPARSE_PARAM) |
| 2715 | void *YYPARSE_PARAM; |
| 2716 | # endif |
| 2717 | #else /* ! YYPARSE_PARAM */ |
| 2718 | #if defined (__STDC__) || defined (__cplusplus) |
| 2719 | int |
| 2720 | yyparse (void) |
| 2721 | #else |
| 2722 | int |
| 2723 | yyparse () |
| 2724 | |
| 2725 | #endif |
| 2726 | #endif |
| 2727 | { |
| 2728 | |
| 2729 | int yystate; |
| 2730 | int yyn; |
| 2731 | int yyresult; |
| 2732 | /* Number of tokens to shift before error messages enabled. */ |
| 2733 | int yyerrstatus; |
| 2734 | /* Look-ahead token as an internal (translated) token number. */ |
| 2735 | int yytoken = 0; |
| 2736 | |
| 2737 | /* Three stacks and their tools: |
| 2738 | `yyss': related to states, |
| 2739 | `yyvs': related to semantic values, |
| 2740 | `yyls': related to locations. |
| 2741 | |
| 2742 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 2743 | to reallocate them elsewhere. */ |
| 2744 | |
| 2745 | /* The state stack. */ |
| 2746 | short int yyssa[YYINITDEPTH]; |
| 2747 | short int *yyss = yyssa; |
| 2748 | short int *yyssp; |
| 2749 | |
| 2750 | /* The semantic value stack. */ |
| 2751 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 2752 | YYSTYPE *yyvs = yyvsa; |
| 2753 | YYSTYPE *yyvsp; |
| 2754 | |
| 2755 | |
| 2756 | |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2757 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2758 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2759 | YYSIZE_T yystacksize = YYINITDEPTH; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2760 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2761 | /* The variables used to return semantic value and location from the |
| 2762 | action routines. */ |
| 2763 | YYSTYPE yyval; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2764 | |
| 2765 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2766 | /* When reducing, the number of symbols on the RHS of the reduced |
| 2767 | rule. */ |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2768 | int yylen; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2769 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2770 | YYDPRINTF ((stderr, "Starting parse\n")); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2771 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2772 | yystate = 0; |
| 2773 | yyerrstatus = 0; |
| 2774 | yynerrs = 0; |
| 2775 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2776 | |
| 2777 | /* Initialize stack pointers. |
| 2778 | Waste one element of value and location stack |
| 2779 | so that they stay on the same level as the state stack. |
| 2780 | The wasted elements are never initialized. */ |
| 2781 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2782 | yyssp = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2783 | yyvsp = yyvs; |
| 2784 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2785 | goto yysetstate; |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2786 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2787 | /*------------------------------------------------------------. |
| 2788 | | yynewstate -- Push a new state, which is found in yystate. | |
| 2789 | `------------------------------------------------------------*/ |
| 2790 | yynewstate: |
| 2791 | /* In all cases, when you get here, the value and location stacks |
| 2792 | have just been pushed. so pushing a state here evens the stacks. |
| 2793 | */ |
| 2794 | yyssp++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2795 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2796 | yysetstate: |
| 2797 | *yyssp = yystate; |
| 2798 | |
| 2799 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2800 | { |
| 2801 | /* Get the current used size of the three stacks, in elements. */ |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2802 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2803 | |
| 2804 | #ifdef yyoverflow |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2805 | { |
| 2806 | /* Give user a chance to reallocate the stack. Use copies of |
| 2807 | these so that the &'s don't force the real ones into |
| 2808 | memory. */ |
| 2809 | YYSTYPE *yyvs1 = yyvs; |
| 2810 | short int *yyss1 = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2811 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2812 | |
| 2813 | /* Each stack pointer address is followed by the size of the |
| 2814 | data in use in that stack, in bytes. This used to be a |
| 2815 | conditional around just the two extra args, but that might |
| 2816 | be undefined if yyoverflow is a macro. */ |
| 2817 | yyoverflow (YY_("memory exhausted"), |
| 2818 | &yyss1, yysize * sizeof (*yyssp), |
| 2819 | &yyvs1, yysize * sizeof (*yyvsp), |
| 2820 | |
| 2821 | &yystacksize); |
| 2822 | |
| 2823 | yyss = yyss1; |
| 2824 | yyvs = yyvs1; |
| 2825 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2826 | #else /* no yyoverflow */ |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2827 | # ifndef YYSTACK_RELOCATE |
| 2828 | goto yyexhaustedlab; |
| 2829 | # else |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2830 | /* Extend the stack our own way. */ |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2831 | if (YYMAXDEPTH <= yystacksize) |
| 2832 | goto yyexhaustedlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2833 | yystacksize *= 2; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2834 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2835 | yystacksize = YYMAXDEPTH; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2836 | |
| 2837 | { |
| 2838 | short int *yyss1 = yyss; |
| 2839 | union yyalloc *yyptr = |
| 2840 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 2841 | if (! yyptr) |
| 2842 | goto yyexhaustedlab; |
| 2843 | YYSTACK_RELOCATE (yyss); |
| 2844 | YYSTACK_RELOCATE (yyvs); |
| 2845 | |
| 2846 | # undef YYSTACK_RELOCATE |
| 2847 | if (yyss1 != yyssa) |
| 2848 | YYSTACK_FREE (yyss1); |
| 2849 | } |
| 2850 | # endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2851 | #endif /* no yyoverflow */ |
| 2852 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2853 | yyssp = yyss + yysize - 1; |
| 2854 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2855 | |
| 2856 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2857 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 2858 | (unsigned long int) yystacksize)); |
| 2859 | |
| 2860 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2861 | YYABORT; |
| 2862 | } |
| 2863 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2864 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2865 | |
| 2866 | goto yybackup; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2867 | |
| 2868 | /*-----------. |
| 2869 | | yybackup. | |
| 2870 | `-----------*/ |
| 2871 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2872 | |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2873 | /* Do appropriate processing given the current state. */ |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2874 | /* Read a look-ahead token if we need one and don't already have one. */ |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2875 | /* yyresume: */ |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 2876 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2877 | /* First try to decide what to do without reference to look-ahead token. */ |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2878 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2879 | yyn = yypact[yystate]; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2880 | if (yyn == YYPACT_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2881 | goto yydefault; |
| 2882 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2883 | /* 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] | 2884 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2885 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2886 | if (yychar == YYEMPTY) |
| 2887 | { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2888 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2889 | yychar = YYLEX; |
| 2890 | } |
| 2891 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2892 | if (yychar <= YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2893 | { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2894 | yychar = yytoken = YYEOF; |
| 2895 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2896 | } |
| 2897 | else |
| 2898 | { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2899 | yytoken = YYTRANSLATE (yychar); |
| 2900 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2901 | } |
| 2902 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2903 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 2904 | detect an error, take that action. */ |
| 2905 | yyn += yytoken; |
| 2906 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2907 | goto yydefault; |
| 2908 | yyn = yytable[yyn]; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2909 | if (yyn <= 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2910 | { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2911 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2912 | goto yyerrlab; |
| 2913 | yyn = -yyn; |
| 2914 | goto yyreduce; |
| 2915 | } |
| 2916 | |
| 2917 | if (yyn == YYFINAL) |
| 2918 | YYACCEPT; |
| 2919 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2920 | /* Shift the look-ahead token. */ |
| 2921 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 2922 | |
| 2923 | /* Discard the token being shifted unless it is eof. */ |
| 2924 | if (yychar != YYEOF) |
| 2925 | yychar = YYEMPTY; |
| 2926 | |
| 2927 | *++yyvsp = yylval; |
| 2928 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2929 | |
| 2930 | /* Count tokens shifted since error; after three, turn off error |
| 2931 | status. */ |
| 2932 | if (yyerrstatus) |
| 2933 | yyerrstatus--; |
Chris Lattner | 0fab59c | 2007-01-12 18:33:30 +0000 | [diff] [blame] | 2934 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2935 | yystate = yyn; |
| 2936 | goto yynewstate; |
| 2937 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 2938 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2939 | /*-----------------------------------------------------------. |
| 2940 | | yydefault -- do the default action for the current state. | |
| 2941 | `-----------------------------------------------------------*/ |
| 2942 | yydefault: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2943 | yyn = yydefact[yystate]; |
| 2944 | if (yyn == 0) |
| 2945 | goto yyerrlab; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2946 | goto yyreduce; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2947 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2948 | |
| 2949 | /*-----------------------------. |
| 2950 | | yyreduce -- Do a reduction. | |
| 2951 | `-----------------------------*/ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2952 | yyreduce: |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2953 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2954 | yylen = yyr2[yyn]; |
| 2955 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2956 | /* If YYLEN is nonzero, implement the default value of the action: |
| 2957 | `$$ = $1'. |
| 2958 | |
| 2959 | Otherwise, the following line sets YYVAL to garbage. |
| 2960 | This behavior is undocumented and Bison |
| 2961 | users should not rely upon it. Assigning to YYVAL |
| 2962 | unconditionally makes the parser a bit smaller, and it avoids a |
| 2963 | GCC warning that YYVAL may be used uninitialized. */ |
| 2964 | yyval = yyvsp[1-yylen]; |
| 2965 | |
| 2966 | |
| 2967 | YY_REDUCE_PRINT (yyn); |
| 2968 | switch (yyn) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2969 | { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2970 | case 3: |
| 2971 | #line 1032 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 2972 | { |
| 2973 | if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range! |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 2974 | GEN_ERROR("Value too large for type!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2975 | (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 2976 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2977 | ;} |
| 2978 | break; |
| 2979 | |
| 2980 | case 31: |
| 2981 | #line 1048 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 2982 | { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;} |
| 2983 | break; |
| 2984 | |
| 2985 | case 32: |
| 2986 | #line 1048 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 2987 | { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;} |
| 2988 | break; |
| 2989 | |
| 2990 | case 33: |
| 2991 | #line 1049 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 2992 | { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;} |
| 2993 | break; |
| 2994 | |
| 2995 | case 34: |
| 2996 | #line 1049 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 2997 | { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;} |
| 2998 | break; |
| 2999 | |
| 3000 | case 35: |
| 3001 | #line 1050 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3002 | { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;} |
| 3003 | break; |
| 3004 | |
| 3005 | case 36: |
| 3006 | #line 1050 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3007 | { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;} |
| 3008 | break; |
| 3009 | |
| 3010 | case 37: |
| 3011 | #line 1051 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3012 | { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;} |
| 3013 | break; |
| 3014 | |
| 3015 | case 38: |
| 3016 | #line 1051 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3017 | { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;} |
| 3018 | break; |
| 3019 | |
| 3020 | case 39: |
| 3021 | #line 1052 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3022 | { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;} |
| 3023 | break; |
| 3024 | |
| 3025 | case 40: |
| 3026 | #line 1052 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3027 | { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;} |
| 3028 | break; |
| 3029 | |
| 3030 | case 41: |
| 3031 | #line 1056 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3032 | { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;} |
| 3033 | break; |
| 3034 | |
| 3035 | case 42: |
| 3036 | #line 1056 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3037 | { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;} |
| 3038 | break; |
| 3039 | |
| 3040 | case 43: |
| 3041 | #line 1057 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3042 | { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;} |
| 3043 | break; |
| 3044 | |
| 3045 | case 44: |
| 3046 | #line 1057 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3047 | { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;} |
| 3048 | break; |
| 3049 | |
| 3050 | case 45: |
| 3051 | #line 1058 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3052 | { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;} |
| 3053 | break; |
| 3054 | |
| 3055 | case 46: |
| 3056 | #line 1058 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3057 | { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;} |
| 3058 | break; |
| 3059 | |
| 3060 | case 47: |
| 3061 | #line 1059 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3062 | { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;} |
| 3063 | break; |
| 3064 | |
| 3065 | case 48: |
| 3066 | #line 1059 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3067 | { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;} |
| 3068 | break; |
| 3069 | |
| 3070 | case 49: |
| 3071 | #line 1060 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3072 | { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;} |
| 3073 | break; |
| 3074 | |
| 3075 | case 50: |
| 3076 | #line 1060 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3077 | { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;} |
| 3078 | break; |
| 3079 | |
| 3080 | case 51: |
| 3081 | #line 1061 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3082 | { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;} |
| 3083 | break; |
| 3084 | |
| 3085 | case 52: |
| 3086 | #line 1061 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3087 | { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;} |
| 3088 | break; |
| 3089 | |
| 3090 | case 53: |
| 3091 | #line 1062 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3092 | { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;} |
| 3093 | break; |
| 3094 | |
| 3095 | case 54: |
| 3096 | #line 1062 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3097 | { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;} |
| 3098 | break; |
| 3099 | |
| 3100 | case 55: |
| 3101 | #line 1063 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3102 | { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;} |
| 3103 | break; |
| 3104 | |
| 3105 | case 56: |
| 3106 | #line 1064 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3107 | { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;} |
| 3108 | break; |
| 3109 | |
| 3110 | case 60: |
| 3111 | #line 1073 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3112 | { |
| 3113 | (yyval.StrVal) = (yyvsp[-1].StrVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3114 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3115 | ;} |
| 3116 | break; |
| 3117 | |
| 3118 | case 61: |
| 3119 | #line 1077 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3120 | { |
| 3121 | (yyval.StrVal) = 0; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3122 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3123 | ;} |
| 3124 | break; |
| 3125 | |
| 3126 | case 62: |
| 3127 | #line 1083 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3128 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3129 | break; |
| 3130 | |
| 3131 | case 63: |
| 3132 | #line 1084 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3133 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3134 | break; |
| 3135 | |
| 3136 | case 64: |
| 3137 | #line 1085 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3138 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 3139 | break; |
| 3140 | |
| 3141 | case 65: |
| 3142 | #line 1086 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3143 | { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} |
| 3144 | break; |
| 3145 | |
| 3146 | case 66: |
| 3147 | #line 1087 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3148 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 3149 | break; |
| 3150 | |
| 3151 | case 67: |
| 3152 | #line 1091 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3153 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 3154 | break; |
| 3155 | |
| 3156 | case 68: |
| 3157 | #line 1092 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3158 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 3159 | break; |
| 3160 | |
| 3161 | case 69: |
| 3162 | #line 1093 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3163 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3164 | break; |
| 3165 | |
| 3166 | case 70: |
| 3167 | #line 1097 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3168 | { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;} |
| 3169 | break; |
| 3170 | |
| 3171 | case 71: |
| 3172 | #line 1098 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3173 | { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;} |
| 3174 | break; |
| 3175 | |
| 3176 | case 72: |
| 3177 | #line 1102 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3178 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3179 | break; |
| 3180 | |
| 3181 | case 73: |
| 3182 | #line 1103 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3183 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 3184 | break; |
| 3185 | |
| 3186 | case 74: |
| 3187 | #line 1104 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3188 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 3189 | break; |
| 3190 | |
| 3191 | case 75: |
| 3192 | #line 1108 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3193 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3194 | break; |
| 3195 | |
| 3196 | case 76: |
| 3197 | #line 1109 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3198 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3199 | break; |
| 3200 | |
| 3201 | case 77: |
| 3202 | #line 1110 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3203 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 3204 | break; |
| 3205 | |
| 3206 | case 78: |
| 3207 | #line 1111 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3208 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3209 | break; |
| 3210 | |
| 3211 | case 79: |
| 3212 | #line 1112 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3213 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 3214 | break; |
| 3215 | |
| 3216 | case 80: |
| 3217 | #line 1115 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3218 | { (yyval.UIntVal) = CallingConv::C; ;} |
| 3219 | break; |
| 3220 | |
| 3221 | case 81: |
| 3222 | #line 1116 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3223 | { (yyval.UIntVal) = CallingConv::C; ;} |
| 3224 | break; |
| 3225 | |
| 3226 | case 82: |
| 3227 | #line 1117 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3228 | { (yyval.UIntVal) = CallingConv::CSRet; ;} |
| 3229 | break; |
| 3230 | |
| 3231 | case 83: |
| 3232 | #line 1118 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3233 | { (yyval.UIntVal) = CallingConv::Fast; ;} |
| 3234 | break; |
| 3235 | |
| 3236 | case 84: |
| 3237 | #line 1119 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3238 | { (yyval.UIntVal) = CallingConv::Cold; ;} |
| 3239 | break; |
| 3240 | |
| 3241 | case 85: |
| 3242 | #line 1120 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3243 | { (yyval.UIntVal) = CallingConv::X86_StdCall; ;} |
| 3244 | break; |
| 3245 | |
| 3246 | case 86: |
| 3247 | #line 1121 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3248 | { (yyval.UIntVal) = CallingConv::X86_FastCall; ;} |
| 3249 | break; |
| 3250 | |
| 3251 | case 87: |
| 3252 | #line 1122 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3253 | { |
| 3254 | if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3255 | GEN_ERROR("Calling conv too large!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3256 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3257 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3258 | ;} |
| 3259 | break; |
| 3260 | |
| 3261 | case 88: |
| 3262 | #line 1129 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3263 | { (yyval.ParamAttrs) = FunctionType::ZExtAttribute; ;} |
| 3264 | break; |
| 3265 | |
| 3266 | case 89: |
| 3267 | #line 1130 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3268 | { (yyval.ParamAttrs) = FunctionType::SExtAttribute; ;} |
| 3269 | break; |
| 3270 | |
| 3271 | case 90: |
| 3272 | #line 1133 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3273 | { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;} |
| 3274 | break; |
| 3275 | |
| 3276 | case 91: |
| 3277 | #line 1134 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3278 | { |
| 3279 | (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs)); |
| 3280 | ;} |
| 3281 | break; |
| 3282 | |
| 3283 | case 92: |
| 3284 | #line 1139 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3285 | { (yyval.ParamAttrs) = FunctionType::NoReturnAttribute; ;} |
| 3286 | break; |
| 3287 | |
| 3288 | case 94: |
| 3289 | #line 1143 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3290 | { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;} |
| 3291 | break; |
| 3292 | |
| 3293 | case 95: |
| 3294 | #line 1144 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3295 | { |
| 3296 | (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs)); |
| 3297 | ;} |
| 3298 | break; |
| 3299 | |
| 3300 | case 96: |
| 3301 | #line 1151 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3302 | { (yyval.UIntVal) = 0; ;} |
| 3303 | break; |
| 3304 | |
| 3305 | case 97: |
| 3306 | #line 1152 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3307 | { |
| 3308 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 3309 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | a54b7cb | 2007-01-12 07:05:14 +0000 | [diff] [blame] | 3310 | GEN_ERROR("Alignment must be a power of two!"); |
| 3311 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3312 | ;} |
| 3313 | break; |
| 3314 | |
| 3315 | case 98: |
| 3316 | #line 1158 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3317 | { (yyval.UIntVal) = 0; ;} |
| 3318 | break; |
| 3319 | |
| 3320 | case 99: |
| 3321 | #line 1159 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3322 | { |
| 3323 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 3324 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | a54b7cb | 2007-01-12 07:05:14 +0000 | [diff] [blame] | 3325 | GEN_ERROR("Alignment must be a power of two!"); |
| 3326 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3327 | ;} |
| 3328 | break; |
| 3329 | |
| 3330 | case 100: |
| 3331 | #line 1167 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3332 | { |
| 3333 | for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) |
| 3334 | if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3335 | GEN_ERROR("Invalid character in section name!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3336 | (yyval.StrVal) = (yyvsp[0].StrVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3337 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3338 | ;} |
| 3339 | break; |
| 3340 | |
| 3341 | case 101: |
| 3342 | #line 1175 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3343 | { (yyval.StrVal) = 0; ;} |
| 3344 | break; |
| 3345 | |
| 3346 | case 102: |
| 3347 | #line 1176 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3348 | { (yyval.StrVal) = (yyvsp[0].StrVal); ;} |
| 3349 | break; |
| 3350 | |
| 3351 | case 103: |
| 3352 | #line 1181 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3353 | {;} |
| 3354 | break; |
| 3355 | |
| 3356 | case 104: |
| 3357 | #line 1182 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3358 | {;} |
| 3359 | break; |
| 3360 | |
| 3361 | case 105: |
| 3362 | #line 1183 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3363 | { |
| 3364 | CurGV->setSection((yyvsp[0].StrVal)); |
| 3365 | free((yyvsp[0].StrVal)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3366 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3367 | ;} |
| 3368 | break; |
| 3369 | |
| 3370 | case 106: |
| 3371 | #line 1188 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3372 | { |
| 3373 | if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3374 | GEN_ERROR("Alignment must be a power of two!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3375 | CurGV->setAlignment((yyvsp[0].UInt64Val)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3376 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3377 | ;} |
| 3378 | break; |
| 3379 | |
| 3380 | case 111: |
| 3381 | #line 1204 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3382 | { |
| 3383 | (yyval.TypeVal) = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3384 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3385 | ;} |
| 3386 | break; |
| 3387 | |
| 3388 | case 112: |
| 3389 | #line 1208 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3390 | { |
| 3391 | (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3392 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3393 | ;} |
| 3394 | break; |
| 3395 | |
| 3396 | case 113: |
| 3397 | #line 1212 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3398 | { // Pointer type? |
| 3399 | if (*(yyvsp[-1].TypeVal) == Type::LabelTy) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3400 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3401 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal)))); |
| 3402 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 3403 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3404 | ;} |
| 3405 | break; |
| 3406 | |
| 3407 | case 114: |
| 3408 | #line 1219 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3409 | { // Named types are also simple types... |
| 3410 | const Type* tmp = getTypeVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3411 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3412 | (yyval.TypeVal) = new PATypeHolder(tmp); |
| 3413 | ;} |
| 3414 | break; |
| 3415 | |
| 3416 | case 115: |
| 3417 | #line 1224 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3418 | { // Type UpReference |
| 3419 | if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!"); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3420 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3421 | UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector... |
| 3422 | (yyval.TypeVal) = new PATypeHolder(OT); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3423 | UR_OUT("New Upreference!\n"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3424 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3425 | ;} |
| 3426 | break; |
| 3427 | |
| 3428 | case 116: |
| 3429 | #line 1232 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3430 | { |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3431 | std::vector<const Type*> Params; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3432 | std::vector<FunctionType::ParameterAttributes> Attrs; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3433 | Attrs.push_back((yyvsp[0].ParamAttrs)); |
| 3434 | for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3435 | Params.push_back(I->Ty->get()); |
| 3436 | if (I->Ty->get() != Type::VoidTy) |
| 3437 | Attrs.push_back(I->Attrs); |
| 3438 | } |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3439 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3440 | if (isVarArg) Params.pop_back(); |
| 3441 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3442 | FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, Attrs); |
| 3443 | delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list |
| 3444 | delete (yyvsp[-4].TypeVal); // Delete the return type handle |
| 3445 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3446 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3447 | ;} |
| 3448 | break; |
| 3449 | |
| 3450 | case 117: |
| 3451 | #line 1250 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3452 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3453 | std::vector<const Type*> Params; |
| 3454 | std::vector<FunctionType::ParameterAttributes> Attrs; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3455 | Attrs.push_back((yyvsp[0].ParamAttrs)); |
| 3456 | for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3457 | Params.push_back(I->Ty->get()); |
| 3458 | if (I->Ty->get() != Type::VoidTy) |
| 3459 | Attrs.push_back(I->Attrs); |
| 3460 | } |
| 3461 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3462 | if (isVarArg) Params.pop_back(); |
| 3463 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3464 | FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, Attrs); |
| 3465 | delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list |
| 3466 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3467 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3468 | ;} |
| 3469 | break; |
| 3470 | |
| 3471 | case 118: |
| 3472 | #line 1268 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3473 | { // Sized array type? |
| 3474 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); |
| 3475 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3476 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3477 | ;} |
| 3478 | break; |
| 3479 | |
| 3480 | case 119: |
| 3481 | #line 1273 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3482 | { // Packed array type? |
| 3483 | const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get(); |
| 3484 | if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3485 | GEN_ERROR("Unsigned result not equal to signed result"); |
Chris Lattner | 42a7551 | 2007-01-15 02:27:26 +0000 | [diff] [blame] | 3486 | if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) |
Reid Spencer | a54b7cb | 2007-01-12 07:05:14 +0000 | [diff] [blame] | 3487 | GEN_ERROR("Element type of a PackedType must be primitive"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3488 | if (!isPowerOf2_32((yyvsp[-3].UInt64Val))) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3489 | GEN_ERROR("Vector length should be a power of 2!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3490 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); |
| 3491 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3492 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3493 | ;} |
| 3494 | break; |
| 3495 | |
| 3496 | case 120: |
| 3497 | #line 1285 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3498 | { // Structure type? |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3499 | std::vector<const Type*> Elements; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3500 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(), |
| 3501 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3502 | Elements.push_back(*I); |
| 3503 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3504 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 3505 | delete (yyvsp[-1].TypeList); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3506 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3507 | ;} |
| 3508 | break; |
| 3509 | |
| 3510 | case 121: |
| 3511 | #line 1295 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3512 | { // Empty structure type? |
| 3513 | (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3514 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3515 | ;} |
| 3516 | break; |
| 3517 | |
| 3518 | case 122: |
| 3519 | #line 1299 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3520 | { |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3521 | std::vector<const Type*> Elements; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3522 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(), |
| 3523 | E = (yyvsp[-2].TypeList)->end(); I != E; ++I) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3524 | Elements.push_back(*I); |
| 3525 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3526 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); |
| 3527 | delete (yyvsp[-2].TypeList); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3528 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3529 | ;} |
| 3530 | break; |
| 3531 | |
| 3532 | case 123: |
| 3533 | #line 1309 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3534 | { // Empty structure type? |
| 3535 | (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3536 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3537 | ;} |
| 3538 | break; |
| 3539 | |
| 3540 | case 124: |
| 3541 | #line 1316 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3542 | { |
| 3543 | (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal); |
| 3544 | (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs); |
| 3545 | ;} |
| 3546 | break; |
| 3547 | |
| 3548 | case 125: |
| 3549 | #line 1323 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3550 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3551 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3552 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 3553 | if (!(*(yyvsp[0].TypeVal))->isFirstClassType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3554 | GEN_ERROR("LLVM functions cannot return aggregate types!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3555 | (yyval.TypeVal) = (yyvsp[0].TypeVal); |
| 3556 | ;} |
| 3557 | break; |
| 3558 | |
| 3559 | case 126: |
| 3560 | #line 1330 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3561 | { |
| 3562 | (yyval.TypeVal) = new PATypeHolder(Type::VoidTy); |
| 3563 | ;} |
| 3564 | break; |
| 3565 | |
| 3566 | case 127: |
| 3567 | #line 1335 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3568 | { |
| 3569 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); |
| 3570 | (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs)); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3571 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3572 | ;} |
| 3573 | break; |
| 3574 | |
| 3575 | case 128: |
| 3576 | #line 1340 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3577 | { |
| 3578 | ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs)); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3579 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3580 | ;} |
| 3581 | break; |
| 3582 | |
| 3583 | case 130: |
| 3584 | #line 1348 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3585 | { |
| 3586 | (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3587 | TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet; |
| 3588 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3589 | (yyval.TypeWithAttrsList)->push_back(TWA); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3590 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3591 | ;} |
| 3592 | break; |
| 3593 | |
| 3594 | case 131: |
| 3595 | #line 1355 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3596 | { |
| 3597 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3598 | TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet; |
| 3599 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3600 | (yyval.TypeWithAttrsList)->push_back(TWA); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3601 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3602 | ;} |
| 3603 | break; |
| 3604 | |
| 3605 | case 132: |
| 3606 | #line 1362 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3607 | { |
| 3608 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3609 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3610 | ;} |
| 3611 | break; |
| 3612 | |
| 3613 | case 133: |
| 3614 | #line 1370 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3615 | { |
| 3616 | (yyval.TypeList) = new std::list<PATypeHolder>(); |
| 3617 | (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3618 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3619 | ;} |
| 3620 | break; |
| 3621 | |
| 3622 | case 134: |
| 3623 | #line 1375 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3624 | { |
| 3625 | ((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] | 3626 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3627 | ;} |
| 3628 | break; |
| 3629 | |
| 3630 | case 135: |
| 3631 | #line 1386 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3632 | { // Nonempty unsized arr |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3633 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3634 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 3635 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3636 | if (ATy == 0) |
| 3637 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3638 | (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3639 | const Type *ETy = ATy->getElementType(); |
| 3640 | int NumElements = ATy->getNumElements(); |
| 3641 | |
| 3642 | // Verify that we have the correct size... |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3643 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3644 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3645 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3646 | itostr(NumElements) + "!"); |
| 3647 | |
| 3648 | // Verify all elements are correct type! |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3649 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 3650 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3651 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3652 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3653 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3654 | } |
| 3655 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3656 | (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector)); |
| 3657 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3658 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3659 | ;} |
| 3660 | break; |
| 3661 | |
| 3662 | case 136: |
| 3663 | #line 1414 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3664 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3665 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3666 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 3667 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3668 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3669 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3670 | (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3671 | |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3672 | int NumElements = ATy->getNumElements(); |
| 3673 | if (NumElements != -1 && NumElements != 0) |
| 3674 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
| 3675 | " arguments, but has size of " + itostr(NumElements) +"!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3676 | (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3677 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3678 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3679 | ;} |
| 3680 | break; |
| 3681 | |
| 3682 | case 137: |
| 3683 | #line 1430 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3684 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3685 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3686 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 3687 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3688 | if (ATy == 0) |
| 3689 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3690 | (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3691 | |
| 3692 | int NumElements = ATy->getNumElements(); |
| 3693 | const Type *ETy = ATy->getElementType(); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3694 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 3695 | if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal))) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3696 | GEN_ERROR("Can't build string constant of size " + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3697 | itostr((int)(EndStr-(yyvsp[0].StrVal))) + |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3698 | " when array has size " + itostr(NumElements) + "!"); |
| 3699 | std::vector<Constant*> Vals; |
| 3700 | if (ETy == Type::Int8Ty) { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3701 | for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3702 | C != (unsigned char*)EndStr; ++C) |
| 3703 | Vals.push_back(ConstantInt::get(ETy, *C)); |
| 3704 | } else { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3705 | free((yyvsp[0].StrVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3706 | GEN_ERROR("Cannot build string arrays of non byte sized elements!"); |
| 3707 | } |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3708 | free((yyvsp[0].StrVal)); |
| 3709 | (yyval.ConstVal) = ConstantArray::get(ATy, Vals); |
| 3710 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3711 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3712 | ;} |
| 3713 | break; |
| 3714 | |
| 3715 | case 138: |
| 3716 | #line 1459 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3717 | { // Nonempty unsized arr |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3718 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3719 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 3720 | const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3721 | if (PTy == 0) |
| 3722 | GEN_ERROR("Cannot make packed constant with type: '" + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3723 | (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3724 | const Type *ETy = PTy->getElementType(); |
| 3725 | int NumElements = PTy->getNumElements(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3726 | |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3727 | // Verify that we have the correct size... |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3728 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3729 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3730 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3731 | itostr(NumElements) + "!"); |
| 3732 | |
| 3733 | // Verify all elements are correct type! |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3734 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 3735 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3736 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3737 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3738 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3739 | } |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3740 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3741 | (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector)); |
| 3742 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3743 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3744 | ;} |
| 3745 | break; |
| 3746 | |
| 3747 | case 139: |
| 3748 | #line 1487 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3749 | { |
| 3750 | const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3751 | if (STy == 0) |
| 3752 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3753 | (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3754 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3755 | if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3756 | GEN_ERROR("Illegal number of initializers for structure type!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3757 | |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3758 | // Check to ensure that constants are compatible with the type initializer! |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3759 | for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) |
| 3760 | if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3761 | GEN_ERROR("Expected type '" + |
| 3762 | STy->getElementType(i)->getDescription() + |
| 3763 | "' for element #" + utostr(i) + |
| 3764 | " of structure initializer!"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3765 | |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3766 | // Check to ensure that Type is not packed |
| 3767 | if (STy->isPacked()) |
| 3768 | GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); |
| 3769 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3770 | (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector)); |
| 3771 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3772 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3773 | ;} |
| 3774 | break; |
| 3775 | |
| 3776 | case 140: |
| 3777 | #line 1512 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3778 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3779 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3780 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 3781 | const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3782 | if (STy == 0) |
| 3783 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3784 | (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3785 | |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3786 | if (STy->getNumContainedTypes() != 0) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3787 | GEN_ERROR("Illegal number of initializers for structure type!"); |
| 3788 | |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3789 | // Check to ensure that Type is not packed |
| 3790 | if (STy->isPacked()) |
| 3791 | GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); |
| 3792 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3793 | (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3794 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3795 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3796 | ;} |
| 3797 | break; |
| 3798 | |
| 3799 | case 141: |
| 3800 | #line 1531 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3801 | { |
| 3802 | const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3803 | if (STy == 0) |
| 3804 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3805 | (*(yyvsp[-5].TypeVal))->getDescription() + "'!"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3806 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3807 | if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes()) |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3808 | GEN_ERROR("Illegal number of initializers for structure type!"); |
| 3809 | |
| 3810 | // Check to ensure that constants are compatible with the type initializer! |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3811 | for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) |
| 3812 | if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i)) |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3813 | GEN_ERROR("Expected type '" + |
| 3814 | STy->getElementType(i)->getDescription() + |
| 3815 | "' for element #" + utostr(i) + |
| 3816 | " of structure initializer!"); |
| 3817 | |
| 3818 | // Check to ensure that Type is packed |
| 3819 | if (!STy->isPacked()) |
| 3820 | GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); |
| 3821 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3822 | (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector)); |
| 3823 | delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3824 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3825 | ;} |
| 3826 | break; |
| 3827 | |
| 3828 | case 142: |
| 3829 | #line 1556 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3830 | { |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3831 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3832 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription()); |
| 3833 | const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get()); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3834 | if (STy == 0) |
| 3835 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3836 | (*(yyvsp[-4].TypeVal))->getDescription() + "'!"); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3837 | |
| 3838 | if (STy->getNumContainedTypes() != 0) |
| 3839 | GEN_ERROR("Illegal number of initializers for structure type!"); |
| 3840 | |
| 3841 | // Check to ensure that Type is packed |
| 3842 | if (!STy->isPacked()) |
| 3843 | GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); |
| 3844 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3845 | (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3846 | delete (yyvsp[-4].TypeVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3847 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3848 | ;} |
| 3849 | break; |
| 3850 | |
| 3851 | case 143: |
| 3852 | #line 1575 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3853 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3854 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3855 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 3856 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3857 | if (PTy == 0) |
| 3858 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3859 | (*(yyvsp[-1].TypeVal))->getDescription() + "'!"); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3860 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3861 | (yyval.ConstVal) = ConstantPointerNull::get(PTy); |
| 3862 | delete (yyvsp[-1].TypeVal); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3863 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3864 | ;} |
| 3865 | break; |
| 3866 | |
| 3867 | case 144: |
| 3868 | #line 1587 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3869 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3870 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3871 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 3872 | (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get()); |
| 3873 | delete (yyvsp[-1].TypeVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3874 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3875 | ;} |
| 3876 | break; |
| 3877 | |
| 3878 | case 145: |
| 3879 | #line 1594 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3880 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3881 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3882 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 3883 | const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3884 | if (Ty == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3885 | GEN_ERROR("Global const reference must be a pointer type!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3886 | |
| 3887 | // ConstExprs can exist in the body of a function, thus creating |
| 3888 | // GlobalValues whenever they refer to a variable. Because we are in |
| 3889 | // the context of a function, getValNonImprovising will search the functions |
| 3890 | // symbol table instead of the module symbol table for the global symbol, |
| 3891 | // which throws things all off. To get around this, we just tell |
| 3892 | // getValNonImprovising that we are at global scope here. |
| 3893 | // |
| 3894 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3895 | CurFun.CurrentFunction = 0; |
| 3896 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3897 | Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3898 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3899 | |
| 3900 | CurFun.CurrentFunction = SavedCurFn; |
| 3901 | |
| 3902 | // If this is an initializer for a constant pointer, which is referencing a |
| 3903 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3904 | // in the future with the right type of variable. |
| 3905 | // |
| 3906 | if (V == 0) { |
| 3907 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
| 3908 | const PointerType *PT = cast<PointerType>(Ty); |
| 3909 | |
| 3910 | // First check to see if the forward references value is already created! |
| 3911 | PerModuleInfo::GlobalRefsType::iterator I = |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3912 | CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal))); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3913 | |
| 3914 | if (I != CurModule.GlobalRefs.end()) { |
| 3915 | V = I->second; // Placeholder already exists, use it... |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3916 | (yyvsp[0].ValIDVal).destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3917 | } else { |
| 3918 | std::string Name; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3919 | if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3920 | |
| 3921 | // Create the forward referenced global. |
| 3922 | GlobalValue *GV; |
| 3923 | if (const FunctionType *FTy = |
| 3924 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 3925 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 3926 | CurModule.CurrentModule); |
| 3927 | } else { |
| 3928 | GV = new GlobalVariable(PT->getElementType(), false, |
| 3929 | GlobalValue::ExternalLinkage, 0, |
| 3930 | Name, CurModule.CurrentModule); |
| 3931 | } |
| 3932 | |
| 3933 | // Keep track of the fact that we have a forward ref to recycle it |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3934 | 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] | 3935 | V = GV; |
| 3936 | } |
| 3937 | } |
| 3938 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3939 | (yyval.ConstVal) = cast<GlobalValue>(V); |
| 3940 | delete (yyvsp[-1].TypeVal); // Free the type handle |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3941 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3942 | ;} |
| 3943 | break; |
| 3944 | |
| 3945 | case 146: |
| 3946 | #line 1657 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3947 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3948 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3949 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 3950 | if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3951 | GEN_ERROR("Mismatched types for constant expression: " + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3952 | (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription()); |
| 3953 | (yyval.ConstVal) = (yyvsp[0].ConstVal); |
| 3954 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3955 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3956 | ;} |
| 3957 | break; |
| 3958 | |
| 3959 | case 147: |
| 3960 | #line 1667 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3961 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3962 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3963 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 3964 | const Type *Ty = (yyvsp[-1].TypeVal)->get(); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3965 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
| 3966 | GEN_ERROR("Cannot create a null initialized value of this type!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3967 | (yyval.ConstVal) = Constant::getNullValue(Ty); |
| 3968 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3969 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3970 | ;} |
| 3971 | break; |
| 3972 | |
| 3973 | case 148: |
| 3974 | #line 1677 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3975 | { // integral constants |
| 3976 | if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val))) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3977 | GEN_ERROR("Constant value doesn't fit in type!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3978 | (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3979 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3980 | ;} |
| 3981 | break; |
| 3982 | |
| 3983 | case 149: |
| 3984 | #line 1683 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3985 | { // integral constants |
| 3986 | if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val))) |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3987 | GEN_ERROR("Constant value doesn't fit in type!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3988 | (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3989 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3990 | ;} |
| 3991 | break; |
| 3992 | |
| 3993 | case 150: |
| 3994 | #line 1689 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 3995 | { // Boolean constants |
| 3996 | assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 3997 | (yyval.ConstVal) = ConstantInt::getTrue(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 3998 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3999 | ;} |
| 4000 | break; |
| 4001 | |
| 4002 | case 151: |
| 4003 | #line 1694 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4004 | { // Boolean constants |
| 4005 | assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 4006 | (yyval.ConstVal) = ConstantInt::getFalse(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4007 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4008 | ;} |
| 4009 | break; |
| 4010 | |
| 4011 | case 152: |
| 4012 | #line 1699 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4013 | { // Float & Double constants |
| 4014 | if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal))) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4015 | GEN_ERROR("Floating point constant invalid for type!!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4016 | (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4017 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4018 | ;} |
| 4019 | break; |
| 4020 | |
| 4021 | case 153: |
| 4022 | #line 1707 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4023 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4024 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4025 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 4026 | Constant *Val = (yyvsp[-3].ConstVal); |
| 4027 | const Type *DestTy = (yyvsp[-1].TypeVal)->get(); |
| 4028 | if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy)) |
| 4029 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 4030 | Val->getType()->getDescription() + "' to '" + |
| 4031 | DestTy->getDescription() + "'!"); |
| 4032 | (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy); |
| 4033 | delete (yyvsp[-1].TypeVal); |
| 4034 | ;} |
| 4035 | break; |
| 4036 | |
| 4037 | case 154: |
| 4038 | #line 1719 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4039 | { |
| 4040 | if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType())) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4041 | GEN_ERROR("GetElementPtr requires a pointer operand!"); |
| 4042 | |
| 4043 | const Type *IdxTy = |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4044 | GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4045 | if (!IdxTy) |
| 4046 | GEN_ERROR("Index list invalid for constant getelementptr!"); |
| 4047 | |
| 4048 | std::vector<Constant*> IdxVec; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4049 | for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i) |
| 4050 | if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i])) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4051 | IdxVec.push_back(C); |
| 4052 | else |
| 4053 | GEN_ERROR("Indices to constant getelementptr must be constants!"); |
| 4054 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4055 | delete (yyvsp[-1].ValueList); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4056 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4057 | (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4058 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4059 | ;} |
| 4060 | break; |
| 4061 | |
| 4062 | case 155: |
| 4063 | #line 1740 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4064 | { |
| 4065 | if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4066 | GEN_ERROR("Select condition must be of boolean type!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4067 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4068 | GEN_ERROR("Select operand types must match!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4069 | (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4070 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4071 | ;} |
| 4072 | break; |
| 4073 | |
| 4074 | case 156: |
| 4075 | #line 1748 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4076 | { |
| 4077 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4078 | GEN_ERROR("Binary operator types must match!"); |
| 4079 | CHECK_FOR_ERROR; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4080 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
| 4081 | ;} |
| 4082 | break; |
| 4083 | |
| 4084 | case 157: |
| 4085 | #line 1754 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4086 | { |
| 4087 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4088 | GEN_ERROR("Logical operator types must match!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4089 | if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) { |
| 4090 | if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) || |
| 4091 | !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger()) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4092 | GEN_ERROR("Logical operator requires integral operands!"); |
| 4093 | } |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4094 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4095 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4096 | ;} |
| 4097 | break; |
| 4098 | |
| 4099 | case 158: |
| 4100 | #line 1765 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4101 | { |
| 4102 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4103 | GEN_ERROR("icmp operand types must match!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4104 | (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
| 4105 | ;} |
| 4106 | break; |
| 4107 | |
| 4108 | case 159: |
| 4109 | #line 1770 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4110 | { |
| 4111 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4112 | GEN_ERROR("fcmp operand types must match!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4113 | (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
| 4114 | ;} |
| 4115 | break; |
| 4116 | |
| 4117 | case 160: |
| 4118 | #line 1775 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4119 | { |
| 4120 | if ((yyvsp[-1].ConstVal)->getType() != Type::Int8Ty) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4121 | GEN_ERROR("Shift count for shift constant must be i8 type!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4122 | if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4123 | GEN_ERROR("Shift constant expression requires integer operand!"); |
| 4124 | CHECK_FOR_ERROR; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4125 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4126 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4127 | ;} |
| 4128 | break; |
| 4129 | |
| 4130 | case 161: |
| 4131 | #line 1784 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4132 | { |
| 4133 | if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4134 | GEN_ERROR("Invalid extractelement operands!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4135 | (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4136 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4137 | ;} |
| 4138 | break; |
| 4139 | |
| 4140 | case 162: |
| 4141 | #line 1790 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4142 | { |
| 4143 | if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4144 | GEN_ERROR("Invalid insertelement operands!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4145 | (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4146 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4147 | ;} |
| 4148 | break; |
| 4149 | |
| 4150 | case 163: |
| 4151 | #line 1796 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4152 | { |
| 4153 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4154 | GEN_ERROR("Invalid shufflevector operands!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4155 | (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4156 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4157 | ;} |
| 4158 | break; |
| 4159 | |
| 4160 | case 164: |
| 4161 | #line 1805 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4162 | { |
| 4163 | ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4164 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4165 | ;} |
| 4166 | break; |
| 4167 | |
| 4168 | case 165: |
| 4169 | #line 1809 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4170 | { |
| 4171 | (yyval.ConstVector) = new std::vector<Constant*>(); |
| 4172 | (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4173 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4174 | ;} |
| 4175 | break; |
| 4176 | |
| 4177 | case 166: |
| 4178 | #line 1817 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4179 | { (yyval.BoolVal) = false; ;} |
| 4180 | break; |
| 4181 | |
| 4182 | case 167: |
| 4183 | #line 1817 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4184 | { (yyval.BoolVal) = true; ;} |
| 4185 | break; |
| 4186 | |
| 4187 | case 168: |
| 4188 | #line 1828 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4189 | { |
| 4190 | (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4191 | CurModule.ModuleDone(); |
| 4192 | CHECK_FOR_ERROR; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4193 | ;} |
| 4194 | break; |
| 4195 | |
| 4196 | case 169: |
| 4197 | #line 1833 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4198 | { |
| 4199 | (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4200 | CurModule.ModuleDone(); |
| 4201 | CHECK_FOR_ERROR; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4202 | ;} |
| 4203 | break; |
| 4204 | |
| 4205 | case 172: |
| 4206 | #line 1846 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4207 | { CurFun.isDeclare = false ;} |
| 4208 | break; |
| 4209 | |
| 4210 | case 173: |
| 4211 | #line 1846 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4212 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4213 | CurFun.FunctionDone(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4214 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4215 | ;} |
| 4216 | break; |
| 4217 | |
| 4218 | case 174: |
| 4219 | #line 1850 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4220 | { CurFun.isDeclare = true; ;} |
| 4221 | break; |
| 4222 | |
| 4223 | case 175: |
| 4224 | #line 1850 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4225 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4226 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4227 | ;} |
| 4228 | break; |
| 4229 | |
| 4230 | case 176: |
| 4231 | #line 1853 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4232 | { |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4233 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4234 | ;} |
| 4235 | break; |
| 4236 | |
| 4237 | case 177: |
| 4238 | #line 1856 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4239 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4240 | // Emit an error if there are any unresolved types left. |
| 4241 | if (!CurModule.LateResolveTypes.empty()) { |
| 4242 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4243 | if (DID.Type == ValID::NameVal) { |
| 4244 | GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'"); |
| 4245 | } else { |
| 4246 | GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num)); |
| 4247 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4248 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4249 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4250 | ;} |
| 4251 | break; |
| 4252 | |
| 4253 | case 178: |
| 4254 | #line 1868 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4255 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4256 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4257 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4258 | // Eagerly resolve types. This is not an optimization, this is a |
| 4259 | // requirement that is due to the fact that we could have this: |
| 4260 | // |
| 4261 | // %list = type { %list * } |
| 4262 | // %list = type { %list * } ; repeated type decl |
| 4263 | // |
| 4264 | // If types are not resolved eagerly, then the two types will not be |
| 4265 | // determined to be the same type! |
| 4266 | // |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4267 | ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4268 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4269 | if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4270 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4271 | // If this is a named type that is not a redefinition, add it to the slot |
| 4272 | // table. |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4273 | CurModule.Types.push_back(*(yyvsp[0].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4274 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4275 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4276 | delete (yyvsp[0].TypeVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4277 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4278 | ;} |
| 4279 | break; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4280 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4281 | case 179: |
| 4282 | #line 1892 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4283 | { |
| 4284 | ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType)); |
| 4285 | |
| 4286 | if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4287 | CHECK_FOR_ERROR |
| 4288 | // If this is a named type that is not a redefinition, add it to the slot |
| 4289 | // table. |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4290 | CurModule.Types.push_back((yyvsp[0].PrimType)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4291 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4292 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4293 | ;} |
| 4294 | break; |
| 4295 | |
| 4296 | case 180: |
| 4297 | #line 1903 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4298 | { /* "Externally Visible" Linkage */ |
| 4299 | if ((yyvsp[0].ConstVal) == 0) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4300 | GEN_ERROR("Global value initializer is not a constant!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4301 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, |
| 4302 | (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal)); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4303 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4304 | ;} |
| 4305 | break; |
| 4306 | |
| 4307 | case 181: |
| 4308 | #line 1909 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4309 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4310 | CurGV = 0; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4311 | ;} |
| 4312 | break; |
| 4313 | |
| 4314 | case 182: |
| 4315 | #line 1912 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4316 | { |
| 4317 | if ((yyvsp[0].ConstVal) == 0) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4318 | GEN_ERROR("Global value initializer is not a constant!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4319 | CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4320 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4321 | ;} |
| 4322 | break; |
| 4323 | |
| 4324 | case 183: |
| 4325 | #line 1917 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4326 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4327 | CurGV = 0; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4328 | ;} |
| 4329 | break; |
| 4330 | |
| 4331 | case 184: |
| 4332 | #line 1920 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4333 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4334 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4335 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 4336 | CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4337 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4338 | delete (yyvsp[0].TypeVal); |
| 4339 | ;} |
| 4340 | break; |
| 4341 | |
| 4342 | case 185: |
| 4343 | #line 1926 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4344 | { |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4345 | CurGV = 0; |
| 4346 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4347 | ;} |
| 4348 | break; |
| 4349 | |
| 4350 | case 186: |
| 4351 | #line 1930 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4352 | { |
Reid Spencer | 6e18b7d | 2006-12-03 06:59:29 +0000 | [diff] [blame] | 4353 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4354 | ;} |
| 4355 | break; |
| 4356 | |
| 4357 | case 187: |
| 4358 | #line 1933 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4359 | { |
Reid Spencer | 218ded2 | 2007-01-05 17:07:23 +0000 | [diff] [blame] | 4360 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4361 | ;} |
| 4362 | break; |
| 4363 | |
| 4364 | case 188: |
| 4365 | #line 1939 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4366 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4367 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4368 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4369 | std::string NewAsm((yyvsp[0].StrVal), EndStr); |
| 4370 | free((yyvsp[0].StrVal)); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4371 | |
| 4372 | if (AsmSoFar.empty()) |
| 4373 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 4374 | else |
| 4375 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4376 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4377 | ;} |
| 4378 | break; |
| 4379 | |
| 4380 | case 189: |
| 4381 | #line 1952 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4382 | { (yyval.Endianness) = Module::BigEndian; ;} |
| 4383 | break; |
| 4384 | |
| 4385 | case 190: |
| 4386 | #line 1953 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4387 | { (yyval.Endianness) = Module::LittleEndian; ;} |
| 4388 | break; |
| 4389 | |
| 4390 | case 191: |
| 4391 | #line 1955 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4392 | { |
| 4393 | CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4394 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4395 | ;} |
| 4396 | break; |
| 4397 | |
| 4398 | case 192: |
| 4399 | #line 1959 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4400 | { |
| 4401 | if ((yyvsp[0].UInt64Val) == 32) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4402 | CurModule.CurrentModule->setPointerSize(Module::Pointer32); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4403 | else if ((yyvsp[0].UInt64Val) == 64) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4404 | CurModule.CurrentModule->setPointerSize(Module::Pointer64); |
| 4405 | else |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4406 | GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!"); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4407 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4408 | ;} |
| 4409 | break; |
| 4410 | |
| 4411 | case 193: |
| 4412 | #line 1968 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4413 | { |
| 4414 | CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); |
| 4415 | free((yyvsp[0].StrVal)); |
| 4416 | ;} |
| 4417 | break; |
| 4418 | |
| 4419 | case 194: |
| 4420 | #line 1972 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4421 | { |
| 4422 | CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); |
| 4423 | free((yyvsp[0].StrVal)); |
| 4424 | ;} |
| 4425 | break; |
| 4426 | |
| 4427 | case 196: |
| 4428 | #line 1979 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4429 | { |
| 4430 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 4431 | free((yyvsp[0].StrVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4432 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4433 | ;} |
| 4434 | break; |
| 4435 | |
| 4436 | case 197: |
| 4437 | #line 1984 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4438 | { |
| 4439 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 4440 | free((yyvsp[0].StrVal)); |
Reid Spencer | a54b7cb | 2007-01-12 07:05:14 +0000 | [diff] [blame] | 4441 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4442 | ;} |
| 4443 | break; |
| 4444 | |
| 4445 | case 198: |
| 4446 | #line 1989 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4447 | { |
Reid Spencer | a54b7cb | 2007-01-12 07:05:14 +0000 | [diff] [blame] | 4448 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4449 | ;} |
| 4450 | break; |
| 4451 | |
| 4452 | case 202: |
| 4453 | #line 1999 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4454 | { (yyval.StrVal) = 0; ;} |
| 4455 | break; |
| 4456 | |
| 4457 | case 203: |
| 4458 | #line 2001 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4459 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4460 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4461 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 4462 | if (*(yyvsp[-2].TypeVal) == Type::VoidTy) |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4463 | GEN_ERROR("void typed arguments are invalid!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +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 | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4467 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4468 | ;} |
| 4469 | break; |
| 4470 | |
| 4471 | case 204: |
| 4472 | #line 2011 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4473 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4474 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4475 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 4476 | if (*(yyvsp[-2].TypeVal) == Type::VoidTy) |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4477 | GEN_ERROR("void typed arguments are invalid!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +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 | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4482 | ;} |
| 4483 | break; |
| 4484 | |
| 4485 | case 205: |
| 4486 | #line 2022 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4487 | { |
| 4488 | (yyval.ArgList) = (yyvsp[0].ArgList); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4489 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4490 | ;} |
| 4491 | break; |
| 4492 | |
| 4493 | case 206: |
| 4494 | #line 2026 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4495 | { |
| 4496 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +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 | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4501 | (yyval.ArgList)->push_back(E); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4502 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4503 | ;} |
| 4504 | break; |
| 4505 | |
| 4506 | case 207: |
| 4507 | #line 2035 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4508 | { |
| 4509 | (yyval.ArgList) = new ArgListType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +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 | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4514 | (yyval.ArgList)->push_back(E); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4515 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4516 | ;} |
| 4517 | break; |
| 4518 | |
| 4519 | case 208: |
| 4520 | #line 2044 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4521 | { |
| 4522 | (yyval.ArgList) = 0; |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4523 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4524 | ;} |
| 4525 | break; |
| 4526 | |
| 4527 | case 209: |
| 4528 | #line 2050 "/proj/llvm/llvm-4/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 | b0fcf8f | 2007-01-17 02:48:45 +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 | b0fcf8f | 2007-01-17 02:48:45 +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 | b0fcf8f | 2007-01-17 02:48:45 +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 | b0fcf8f | 2007-01-17 02:48:45 +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()) { |
| 4563 | ID = ValID::create((char*)FunctionName.c_str()); |
| 4564 | } else { |
| 4565 | ID = ValID::create((int)CurModule.Values[PFT].size()); |
| 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? |
| 4577 | (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) { |
| 4578 | // If this is the case, either we need to be a forward decl, or it needs |
| 4579 | // to be. |
| 4580 | if (!CurFun.isDeclare && !Fn->isExternal()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4581 | GEN_ERROR("Redefinition of function '" + FunctionName + "'!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4582 | |
| 4583 | // Make sure to strip off any argument names so we can't get conflicts. |
| 4584 | if (Fn->isExternal()) |
| 4585 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 4586 | AI != AE; ++AI) |
| 4587 | AI->setName(""); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4588 | } else { // Not already defined? |
| 4589 | Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, |
| 4590 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4591 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4592 | InsertValue(Fn, CurModule.Values); |
| 4593 | } |
| 4594 | |
| 4595 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4596 | |
| 4597 | if (CurFun.isDeclare) { |
| 4598 | // If we have declaration, always overwrite linkage. This will allow us to |
| 4599 | // correctly handle cases, when pointer to function is passed as argument to |
| 4600 | // another function. |
| 4601 | Fn->setLinkage(CurFun.Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4602 | Fn->setVisibility(CurFun.Visibility); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4603 | } |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4604 | Fn->setCallingConv((yyvsp[-8].UIntVal)); |
| 4605 | Fn->setAlignment((yyvsp[0].UIntVal)); |
| 4606 | if ((yyvsp[-1].StrVal)) { |
| 4607 | Fn->setSection((yyvsp[-1].StrVal)); |
| 4608 | free((yyvsp[-1].StrVal)); |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 4609 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4610 | |
| 4611 | // Add all of the arguments we parsed to the function... |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4612 | if ((yyvsp[-4].ArgList)) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4613 | if (isVarArg) { // Nuke the last entry |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4614 | assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0&& |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4615 | "Not a varargs marker!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4616 | delete (yyvsp[-4].ArgList)->back().Ty; |
| 4617 | (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4618 | } |
| 4619 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4620 | unsigned Idx = 1; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4621 | for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); I != (yyvsp[-4].ArgList)->end(); ++I, ++ArgIt) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4622 | delete I->Ty; // Delete the typeholder... |
| 4623 | setValueName(ArgIt, I->Name); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4624 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4625 | InsertValue(ArgIt); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4626 | Idx++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4627 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4628 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4629 | delete (yyvsp[-4].ArgList); // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4630 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4631 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4632 | ;} |
| 4633 | break; |
| 4634 | |
| 4635 | case 212: |
| 4636 | #line 2157 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4637 | { |
| 4638 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4639 | |
| 4640 | // Make sure that we keep track of the linkage type even if there was a |
| 4641 | // previous "declare". |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4642 | (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage)); |
| 4643 | (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility)); |
| 4644 | ;} |
| 4645 | break; |
| 4646 | |
| 4647 | case 215: |
| 4648 | #line 2168 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4649 | { |
| 4650 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4651 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4652 | ;} |
| 4653 | break; |
| 4654 | |
| 4655 | case 216: |
| 4656 | #line 2173 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4657 | { |
| 4658 | CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage)); |
| 4659 | CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility)); |
| 4660 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4661 | CurFun.FunctionDone(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4662 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4663 | ;} |
| 4664 | break; |
| 4665 | |
| 4666 | case 217: |
| 4667 | #line 2185 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4668 | { |
| 4669 | (yyval.BoolVal) = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4670 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4671 | ;} |
| 4672 | break; |
| 4673 | |
| 4674 | case 218: |
| 4675 | #line 2189 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4676 | { |
| 4677 | (yyval.BoolVal) = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4678 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4679 | ;} |
| 4680 | break; |
| 4681 | |
| 4682 | case 219: |
| 4683 | #line 2194 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4684 | { // A reference to a direct constant |
| 4685 | (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4686 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4687 | ;} |
| 4688 | break; |
| 4689 | |
| 4690 | case 220: |
| 4691 | #line 2198 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4692 | { |
| 4693 | (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4694 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4695 | ;} |
| 4696 | break; |
| 4697 | |
| 4698 | case 221: |
| 4699 | #line 2202 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4700 | { // Perhaps it's an FP constant? |
| 4701 | (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4702 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4703 | ;} |
| 4704 | break; |
| 4705 | |
| 4706 | case 222: |
| 4707 | #line 2206 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4708 | { |
| 4709 | (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue()); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4710 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4711 | ;} |
| 4712 | break; |
| 4713 | |
| 4714 | case 223: |
| 4715 | #line 2210 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4716 | { |
| 4717 | (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse()); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4718 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4719 | ;} |
| 4720 | break; |
| 4721 | |
| 4722 | case 224: |
| 4723 | #line 2214 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4724 | { |
| 4725 | (yyval.ValIDVal) = ValID::createNull(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4726 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4727 | ;} |
| 4728 | break; |
| 4729 | |
| 4730 | case 225: |
| 4731 | #line 2218 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4732 | { |
| 4733 | (yyval.ValIDVal) = ValID::createUndef(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4734 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4735 | ;} |
| 4736 | break; |
| 4737 | |
| 4738 | case 226: |
| 4739 | #line 2222 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4740 | { // A vector zero constant. |
| 4741 | (yyval.ValIDVal) = ValID::createZeroInit(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4742 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4743 | ;} |
| 4744 | break; |
| 4745 | |
| 4746 | case 227: |
| 4747 | #line 2226 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4748 | { // Nonempty unsized packed vector |
| 4749 | const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType(); |
| 4750 | int NumElements = (yyvsp[-1].ConstVector)->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4751 | |
| 4752 | PackedType* pt = PackedType::get(ETy, NumElements); |
| 4753 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4754 | HandleUpRefs( |
| 4755 | PackedType::get( |
| 4756 | ETy, |
| 4757 | NumElements) |
| 4758 | ) |
| 4759 | ); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4760 | |
| 4761 | // Verify all elements are correct type! |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4762 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 4763 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4764 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4765 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4766 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4767 | } |
| 4768 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4769 | (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector))); |
| 4770 | delete PTy; delete (yyvsp[-1].ConstVector); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4771 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4772 | ;} |
| 4773 | break; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4774 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4775 | case 228: |
| 4776 | #line 2251 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4777 | { |
| 4778 | (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal)); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4779 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4780 | ;} |
| 4781 | break; |
| 4782 | |
| 4783 | case 229: |
| 4784 | #line 2255 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4785 | { |
| 4786 | char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); |
| 4787 | std::string AsmStr = std::string((yyvsp[-2].StrVal), End); |
| 4788 | End = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4789 | std::string Constraints = std::string((yyvsp[0].StrVal), End); |
| 4790 | (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal)); |
| 4791 | free((yyvsp[-2].StrVal)); |
| 4792 | free((yyvsp[0].StrVal)); |
| 4793 | CHECK_FOR_ERROR |
| 4794 | ;} |
| 4795 | break; |
| 4796 | |
| 4797 | case 230: |
| 4798 | #line 2269 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4799 | { // Is it an integer reference...? |
| 4800 | (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); |
| 4801 | CHECK_FOR_ERROR |
| 4802 | ;} |
| 4803 | break; |
| 4804 | |
| 4805 | case 231: |
| 4806 | #line 2273 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4807 | { // Is it a named reference...? |
| 4808 | (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); |
| 4809 | CHECK_FOR_ERROR |
| 4810 | ;} |
| 4811 | break; |
| 4812 | |
| 4813 | case 234: |
| 4814 | #line 2285 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4815 | { |
| 4816 | if (!UpRefs.empty()) |
| 4817 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 4818 | (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); |
| 4819 | delete (yyvsp[-1].TypeVal); |
| 4820 | CHECK_FOR_ERROR |
| 4821 | ;} |
| 4822 | break; |
| 4823 | |
| 4824 | case 235: |
| 4825 | #line 2294 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4826 | { |
| 4827 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 4828 | CHECK_FOR_ERROR |
| 4829 | ;} |
| 4830 | break; |
| 4831 | |
| 4832 | case 236: |
| 4833 | #line 2298 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4834 | { // Do not allow functions with 0 basic blocks |
| 4835 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 4836 | CHECK_FOR_ERROR |
| 4837 | ;} |
| 4838 | break; |
| 4839 | |
| 4840 | case 237: |
| 4841 | #line 2307 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4842 | { |
| 4843 | setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal)); |
| 4844 | CHECK_FOR_ERROR |
| 4845 | InsertValue((yyvsp[0].TermInstVal)); |
| 4846 | |
| 4847 | (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal)); |
| 4848 | InsertValue((yyvsp[-2].BasicBlockVal)); |
| 4849 | (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal); |
| 4850 | CHECK_FOR_ERROR |
| 4851 | ;} |
| 4852 | break; |
| 4853 | |
| 4854 | case 238: |
| 4855 | #line 2318 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4856 | { |
| 4857 | if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal))) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4858 | if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0))) |
| 4859 | if (CI2->getParent() == 0) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4860 | (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2); |
| 4861 | (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal)); |
| 4862 | (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4863 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4864 | ;} |
| 4865 | break; |
| 4866 | |
| 4867 | case 239: |
| 4868 | #line 2327 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4869 | { |
| 4870 | (yyval.BasicBlockVal) = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4871 | CHECK_FOR_ERROR |
| 4872 | |
| 4873 | // Make sure to move the basic block to the correct location in the |
| 4874 | // function, instead of leaving it inserted wherever it was first |
| 4875 | // referenced. |
| 4876 | Function::BasicBlockListType &BBL = |
| 4877 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4878 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4879 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4880 | ;} |
| 4881 | break; |
| 4882 | |
| 4883 | case 240: |
| 4884 | #line 2339 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4885 | { |
| 4886 | (yyval.BasicBlockVal) = getBBVal(ValID::create((yyvsp[0].StrVal)), true); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4887 | CHECK_FOR_ERROR |
| 4888 | |
| 4889 | // Make sure to move the basic block to the correct location in the |
| 4890 | // function, instead of leaving it inserted wherever it was first |
| 4891 | // referenced. |
| 4892 | Function::BasicBlockListType &BBL = |
| 4893 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4894 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4895 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4896 | ;} |
| 4897 | break; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4898 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4899 | case 241: |
| 4900 | #line 2352 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4901 | { // Return with a result... |
| 4902 | (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal)); |
| 4903 | CHECK_FOR_ERROR |
| 4904 | ;} |
| 4905 | break; |
| 4906 | |
| 4907 | case 242: |
| 4908 | #line 2356 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4909 | { // Return with no result... |
| 4910 | (yyval.TermInstVal) = new ReturnInst(); |
| 4911 | CHECK_FOR_ERROR |
| 4912 | ;} |
| 4913 | break; |
| 4914 | |
| 4915 | case 243: |
| 4916 | #line 2360 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4917 | { // Unconditional Branch... |
| 4918 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
| 4919 | CHECK_FOR_ERROR |
| 4920 | (yyval.TermInstVal) = new BranchInst(tmpBB); |
| 4921 | ;} |
| 4922 | break; |
| 4923 | |
| 4924 | case 244: |
| 4925 | #line 2365 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4926 | { |
| 4927 | assert(cast<IntegerType>((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 4928 | BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); |
| 4929 | CHECK_FOR_ERROR |
| 4930 | BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal)); |
| 4931 | CHECK_FOR_ERROR |
| 4932 | Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal)); |
| 4933 | CHECK_FOR_ERROR |
| 4934 | (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4935 | ;} |
| 4936 | break; |
| 4937 | |
| 4938 | case 245: |
| 4939 | #line 2375 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4940 | { |
| 4941 | Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal)); |
| 4942 | CHECK_FOR_ERROR |
| 4943 | BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal)); |
| 4944 | CHECK_FOR_ERROR |
| 4945 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size()); |
| 4946 | (yyval.TermInstVal) = S; |
| 4947 | |
| 4948 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(), |
| 4949 | E = (yyvsp[-1].JumpTable)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4950 | for (; I != E; ++I) { |
| 4951 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4952 | S->addCase(CI, I->second); |
| 4953 | else |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4954 | GEN_ERROR("Switch case is constant, but not a simple integer!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4955 | } |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4956 | delete (yyvsp[-1].JumpTable); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4957 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4958 | ;} |
| 4959 | break; |
| 4960 | |
| 4961 | case 246: |
| 4962 | #line 2394 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4963 | { |
| 4964 | Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4965 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4966 | BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4967 | CHECK_FOR_ERROR |
| 4968 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4969 | (yyval.TermInstVal) = S; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4970 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4971 | ;} |
| 4972 | break; |
| 4973 | |
| 4974 | case 247: |
| 4975 | #line 2404 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 4976 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4977 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4978 | // Handle the short syntax |
| 4979 | const PointerType *PFTy = 0; |
| 4980 | const FunctionType *Ty = 0; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4981 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4982 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 4983 | // Pull out the types of all of the arguments... |
| 4984 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4985 | FunctionType::ParamAttrsList ParamAttrs; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4986 | ParamAttrs.push_back((yyvsp[-6].ParamAttrs)); |
| 4987 | 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] | 4988 | const Type *Ty = I->Val->getType(); |
| 4989 | if (Ty == Type::VoidTy) |
| 4990 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 4991 | ParamTypes.push_back(Ty); |
| 4992 | ParamAttrs.push_back(I->Attrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4993 | } |
| 4994 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4995 | Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, ParamAttrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4996 | PFTy = PointerType::get(Ty); |
| 4997 | } |
| 4998 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4999 | 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] | 5000 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5001 | BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5002 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5003 | BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5004 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5005 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5006 | // Check the arguments |
| 5007 | ValueList Args; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5008 | if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments? |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5009 | // Make sure no arguments is a good thing! |
| 5010 | if (Ty->getNumParams() != 0) |
| 5011 | GEN_ERROR("No arguments passed to a function that " |
| 5012 | "expects arguments!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5013 | } else { // Has arguments? |
| 5014 | // Loop through FunctionType's arguments and ensure they are specified |
| 5015 | // correctly! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5016 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5017 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5018 | ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5019 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5020 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5021 | if (ArgI->Val->getType() != *I) |
| 5022 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 5023 | (*I)->getDescription() + "'!"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5024 | Args.push_back(ArgI->Val); |
| 5025 | } |
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 | if (Ty->isVarArg()) { |
| 5028 | if (I == E) |
| 5029 | for (; ArgI != ArgE; ++ArgI) |
| 5030 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 5031 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5032 | GEN_ERROR("Invalid number of parameters detected!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5033 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5034 | |
| 5035 | // Create the InvokeInst |
| 5036 | InvokeInst *II = new InvokeInst(V, Normal, Except, Args); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5037 | II->setCallingConv((yyvsp[-12].UIntVal)); |
| 5038 | (yyval.TermInstVal) = II; |
| 5039 | delete (yyvsp[-8].ValueRefList); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5040 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5041 | ;} |
| 5042 | break; |
| 5043 | |
| 5044 | case 248: |
| 5045 | #line 2470 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5046 | { |
| 5047 | (yyval.TermInstVal) = new UnwindInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5048 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5049 | ;} |
| 5050 | break; |
| 5051 | |
| 5052 | case 249: |
| 5053 | #line 2474 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5054 | { |
| 5055 | (yyval.TermInstVal) = new UnreachableInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5056 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5057 | ;} |
| 5058 | break; |
| 5059 | |
| 5060 | case 250: |
| 5061 | #line 2481 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5062 | { |
| 5063 | (yyval.JumpTable) = (yyvsp[-5].JumpTable); |
| 5064 | Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5065 | CHECK_FOR_ERROR |
| 5066 | if (V == 0) |
| 5067 | GEN_ERROR("May only switch on a constant pool value!"); |
| 5068 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5069 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5070 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5071 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5072 | ;} |
| 5073 | break; |
| 5074 | |
| 5075 | case 251: |
| 5076 | #line 2492 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5077 | { |
| 5078 | (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 5079 | Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5080 | CHECK_FOR_ERROR |
| 5081 | |
| 5082 | if (V == 0) |
| 5083 | GEN_ERROR("May only switch on a constant pool value!"); |
| 5084 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5085 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5086 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5087 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5088 | ;} |
| 5089 | break; |
| 5090 | |
| 5091 | case 252: |
| 5092 | #line 2505 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5093 | { |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5094 | // Is this definition named?? if so, assign the name... |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5095 | setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5096 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5097 | InsertValue((yyvsp[0].InstVal)); |
| 5098 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5099 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5100 | ;} |
| 5101 | break; |
| 5102 | |
| 5103 | case 253: |
| 5104 | #line 2514 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5105 | { // Used for PHI nodes |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5106 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5107 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription()); |
| 5108 | (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 5109 | Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5110 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5111 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5112 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5113 | (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5114 | delete (yyvsp[-5].TypeVal); |
| 5115 | ;} |
| 5116 | break; |
| 5117 | |
| 5118 | case 254: |
| 5119 | #line 2525 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5120 | { |
| 5121 | (yyval.PHIList) = (yyvsp[-6].PHIList); |
| 5122 | Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5123 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5124 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5125 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5126 | (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5127 | ;} |
| 5128 | break; |
| 5129 | |
| 5130 | case 255: |
| 5131 | #line 2535 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5132 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5133 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5134 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5135 | // Used for call and invoke instructions |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5136 | (yyval.ValueRefList) = new ValueRefList(); |
| 5137 | ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal)); |
| 5138 | (yyval.ValueRefList)->push_back(E); |
| 5139 | ;} |
| 5140 | break; |
| 5141 | |
| 5142 | case 256: |
| 5143 | #line 2543 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5144 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5145 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5146 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 5147 | (yyval.ValueRefList) = (yyvsp[-4].ValueRefList); |
| 5148 | ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal)); |
| 5149 | (yyval.ValueRefList)->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5150 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5151 | ;} |
| 5152 | break; |
| 5153 | |
| 5154 | case 257: |
| 5155 | #line 2551 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5156 | { (yyval.ValueRefList) = new ValueRefList(); ;} |
| 5157 | break; |
| 5158 | |
| 5159 | case 258: |
| 5160 | #line 2554 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5161 | { (yyval.ValueList) = new std::vector<Value*>(); ;} |
| 5162 | break; |
| 5163 | |
| 5164 | case 259: |
| 5165 | #line 2555 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5166 | { |
| 5167 | (yyval.ValueList) = (yyvsp[-2].ValueList); |
| 5168 | (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5169 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5170 | ;} |
| 5171 | break; |
| 5172 | |
| 5173 | case 260: |
| 5174 | #line 2562 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5175 | { |
| 5176 | (yyval.BoolVal) = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5177 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5178 | ;} |
| 5179 | break; |
| 5180 | |
| 5181 | case 261: |
| 5182 | #line 2566 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5183 | { |
| 5184 | (yyval.BoolVal) = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5185 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5186 | ;} |
| 5187 | break; |
| 5188 | |
| 5189 | case 262: |
| 5190 | #line 2571 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5191 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5192 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5193 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 5194 | if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() && |
| 5195 | !isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5196 | GEN_ERROR( |
| 5197 | "Arithmetic operator requires integer, FP, or packed operands!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5198 | if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) && |
| 5199 | ((yyvsp[-4].BinaryOpVal) == Instruction::URem || |
| 5200 | (yyvsp[-4].BinaryOpVal) == Instruction::SRem || |
| 5201 | (yyvsp[-4].BinaryOpVal) == Instruction::FRem)) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5202 | GEN_ERROR("U/S/FRem not supported on packed types!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5203 | Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5204 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5205 | Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5206 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5207 | (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2); |
| 5208 | if ((yyval.InstVal) == 0) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5209 | GEN_ERROR("binary operator returned null!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5210 | delete (yyvsp[-3].TypeVal); |
| 5211 | ;} |
| 5212 | break; |
| 5213 | |
| 5214 | case 263: |
| 5215 | #line 2592 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5216 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5217 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5218 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 5219 | if (!(*(yyvsp[-3].TypeVal))->isInteger()) { |
| 5220 | if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) || |
| 5221 | !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5222 | GEN_ERROR("Logical operator requires integral operands!"); |
| 5223 | } |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5224 | Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5225 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5226 | Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5227 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5228 | (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2); |
| 5229 | if ((yyval.InstVal) == 0) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5230 | GEN_ERROR("binary operator returned null!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5231 | delete (yyvsp[-3].TypeVal); |
| 5232 | ;} |
| 5233 | break; |
| 5234 | |
| 5235 | case 264: |
| 5236 | #line 2609 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5237 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5238 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5239 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 5240 | if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) |
Reid Spencer | ac4a1dd | 2007-01-04 02:57:52 +0000 | [diff] [blame] | 5241 | GEN_ERROR("Packed types not supported by icmp instruction"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5242 | Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5243 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5244 | Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5245 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5246 | (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2); |
| 5247 | if ((yyval.InstVal) == 0) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5248 | GEN_ERROR("icmp operator returned null!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5249 | ;} |
| 5250 | break; |
| 5251 | |
| 5252 | case 265: |
| 5253 | #line 2622 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5254 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5255 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5256 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 5257 | if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) |
Reid Spencer | ac4a1dd | 2007-01-04 02:57:52 +0000 | [diff] [blame] | 5258 | GEN_ERROR("Packed types not supported by fcmp instruction"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5259 | Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5260 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5261 | Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5262 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5263 | (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2); |
| 5264 | if ((yyval.InstVal) == 0) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5265 | GEN_ERROR("fcmp operator returned null!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5266 | ;} |
| 5267 | break; |
| 5268 | |
| 5269 | case 266: |
| 5270 | #line 2635 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5271 | { |
| 5272 | if ((yyvsp[0].ValueVal)->getType() != Type::Int8Ty) |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5273 | GEN_ERROR("Shift amount must be i8 type!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5274 | if (!(yyvsp[-2].ValueVal)->getType()->isInteger()) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5275 | GEN_ERROR("Shift constant expression requires integer operand!"); |
| 5276 | CHECK_FOR_ERROR; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5277 | (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5278 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5279 | ;} |
| 5280 | break; |
| 5281 | |
| 5282 | case 267: |
| 5283 | #line 2644 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5284 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5285 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5286 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 5287 | Value* Val = (yyvsp[-2].ValueVal); |
| 5288 | const Type* DestTy = (yyvsp[0].TypeVal)->get(); |
| 5289 | if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy)) |
| 5290 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 5291 | Val->getType()->getDescription() + "' to '" + |
| 5292 | DestTy->getDescription() + "'!"); |
| 5293 | (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy); |
| 5294 | delete (yyvsp[0].TypeVal); |
| 5295 | ;} |
| 5296 | break; |
| 5297 | |
| 5298 | case 268: |
| 5299 | #line 2656 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5300 | { |
| 5301 | if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5302 | GEN_ERROR("select condition must be boolean!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5303 | if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5304 | GEN_ERROR("select value types should match!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5305 | (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5306 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5307 | ;} |
| 5308 | break; |
| 5309 | |
| 5310 | case 269: |
| 5311 | #line 2664 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5312 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5313 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5314 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 5315 | (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal)); |
| 5316 | delete (yyvsp[0].TypeVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5317 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5318 | ;} |
| 5319 | break; |
| 5320 | |
| 5321 | case 270: |
| 5322 | #line 2671 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5323 | { |
| 5324 | if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5325 | GEN_ERROR("Invalid extractelement operands!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5326 | (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5327 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5328 | ;} |
| 5329 | break; |
| 5330 | |
| 5331 | case 271: |
| 5332 | #line 2677 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5333 | { |
| 5334 | if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5335 | GEN_ERROR("Invalid insertelement operands!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5336 | (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] | 5337 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5338 | ;} |
| 5339 | break; |
| 5340 | |
| 5341 | case 272: |
| 5342 | #line 2683 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5343 | { |
| 5344 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5345 | GEN_ERROR("Invalid shufflevector operands!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5346 | (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5347 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5348 | ;} |
| 5349 | break; |
| 5350 | |
| 5351 | case 273: |
| 5352 | #line 2689 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5353 | { |
| 5354 | const Type *Ty = (yyvsp[0].PHIList)->front().first->getType(); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5355 | if (!Ty->isFirstClassType()) |
| 5356 | GEN_ERROR("PHI node operands must be of first class type!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5357 | (yyval.InstVal) = new PHINode(Ty); |
| 5358 | ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size()); |
| 5359 | while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) { |
| 5360 | if ((yyvsp[0].PHIList)->front().first->getType() != Ty) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5361 | GEN_ERROR("All elements of a PHI node must be of the same type!"); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5362 | cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second); |
| 5363 | (yyvsp[0].PHIList)->pop_front(); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5364 | } |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5365 | delete (yyvsp[0].PHIList); // Free the list... |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5366 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5367 | ;} |
| 5368 | break; |
| 5369 | |
| 5370 | case 274: |
| 5371 | #line 2705 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5372 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5373 | |
| 5374 | // Handle the short syntax |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5375 | const PointerType *PFTy = 0; |
| 5376 | const FunctionType *Ty = 0; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5377 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) || |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5378 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5379 | // Pull out the types of all of the arguments... |
| 5380 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5381 | FunctionType::ParamAttrsList ParamAttrs; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5382 | ParamAttrs.push_back((yyvsp[0].ParamAttrs)); |
| 5383 | 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] | 5384 | const Type *Ty = I->Val->getType(); |
| 5385 | if (Ty == Type::VoidTy) |
| 5386 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 5387 | ParamTypes.push_back(Ty); |
| 5388 | ParamAttrs.push_back(I->Attrs); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5389 | } |
| 5390 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5391 | Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, ParamAttrs); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5392 | PFTy = PointerType::get(Ty); |
| 5393 | } |
| 5394 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5395 | 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] | 5396 | CHECK_FOR_ERROR |
| 5397 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5398 | // Check the arguments |
| 5399 | ValueList Args; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5400 | if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments? |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5401 | // Make sure no arguments is a good thing! |
| 5402 | if (Ty->getNumParams() != 0) |
| 5403 | GEN_ERROR("No arguments passed to a function that " |
| 5404 | "expects arguments!"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5405 | } else { // Has arguments? |
| 5406 | // Loop through FunctionType's arguments and ensure they are specified |
| 5407 | // correctly! |
| 5408 | // |
| 5409 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5410 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5411 | ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5412 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5413 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5414 | if (ArgI->Val->getType() != *I) |
| 5415 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5416 | (*I)->getDescription() + "'!"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5417 | Args.push_back(ArgI->Val); |
| 5418 | } |
| 5419 | if (Ty->isVarArg()) { |
| 5420 | if (I == E) |
| 5421 | for (; ArgI != ArgE; ++ArgI) |
| 5422 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 5423 | } else if (I != E || ArgI != ArgE) |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5424 | GEN_ERROR("Invalid number of parameters detected!"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5425 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5426 | // Create the call node |
| 5427 | CallInst *CI = new CallInst(V, Args); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5428 | CI->setTailCall((yyvsp[-7].BoolVal)); |
| 5429 | CI->setCallingConv((yyvsp[-6].UIntVal)); |
| 5430 | (yyval.InstVal) = CI; |
| 5431 | delete (yyvsp[-2].ValueRefList); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5432 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5433 | ;} |
| 5434 | break; |
| 5435 | |
| 5436 | case 275: |
| 5437 | #line 2767 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5438 | { |
| 5439 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5440 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5441 | ;} |
| 5442 | break; |
| 5443 | |
| 5444 | case 276: |
| 5445 | #line 2772 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5446 | { |
| 5447 | (yyval.BoolVal) = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5448 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5449 | ;} |
| 5450 | break; |
| 5451 | |
| 5452 | case 277: |
| 5453 | #line 2776 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5454 | { |
| 5455 | (yyval.BoolVal) = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5456 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5457 | ;} |
| 5458 | break; |
| 5459 | |
| 5460 | case 278: |
| 5461 | #line 2783 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5462 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5463 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5464 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5465 | (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); |
| 5466 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5467 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5468 | ;} |
| 5469 | break; |
| 5470 | |
| 5471 | case 279: |
| 5472 | #line 2790 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5473 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5474 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5475 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription()); |
| 5476 | Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5477 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5478 | (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); |
| 5479 | delete (yyvsp[-4].TypeVal); |
| 5480 | ;} |
| 5481 | break; |
| 5482 | |
| 5483 | case 280: |
| 5484 | #line 2798 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5485 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5486 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5487 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5488 | (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); |
| 5489 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5490 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5491 | ;} |
| 5492 | break; |
| 5493 | |
| 5494 | case 281: |
| 5495 | #line 2805 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5496 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5497 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5498 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription()); |
| 5499 | Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5500 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5501 | (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); |
| 5502 | delete (yyvsp[-4].TypeVal); |
| 5503 | ;} |
| 5504 | break; |
| 5505 | |
| 5506 | case 282: |
| 5507 | #line 2813 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5508 | { |
| 5509 | if (!isa<PointerType>((yyvsp[0].ValueVal)->getType())) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5510 | GEN_ERROR("Trying to free nonpointer type " + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5511 | (yyvsp[0].ValueVal)->getType()->getDescription() + "!"); |
| 5512 | (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5513 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5514 | ;} |
| 5515 | break; |
| 5516 | |
| 5517 | case 283: |
| 5518 | #line 2821 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5519 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5520 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5521 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5522 | if (!isa<PointerType>((yyvsp[-1].TypeVal)->get())) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5523 | GEN_ERROR("Can't load from nonpointer type: " + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5524 | (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5525 | if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType()) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5526 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5527 | (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5528 | Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5529 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5530 | (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal)); |
| 5531 | delete (yyvsp[-1].TypeVal); |
| 5532 | ;} |
| 5533 | break; |
| 5534 | |
| 5535 | case 284: |
| 5536 | #line 2835 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5537 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5538 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5539 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5540 | const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5541 | if (!PT) |
| 5542 | GEN_ERROR("Can't store to a nonpointer type: " + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5543 | (*(yyvsp[-1].TypeVal))->getDescription()); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5544 | const Type *ElTy = PT->getElementType(); |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5545 | if (ElTy != (yyvsp[-3].ValueVal)->getType()) |
| 5546 | GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() + |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5547 | "' into space of type '" + ElTy->getDescription() + "'!"); |
| 5548 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5549 | Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5550 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5551 | (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal)); |
| 5552 | delete (yyvsp[-1].TypeVal); |
| 5553 | ;} |
| 5554 | break; |
| 5555 | |
| 5556 | case 285: |
| 5557 | #line 2852 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
| 5558 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5559 | if (!UpRefs.empty()) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5560 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 5561 | if (!isa<PointerType>((yyvsp[-2].TypeVal)->get())) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5562 | GEN_ERROR("getelementptr insn requires pointer operand!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5563 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5564 | if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5565 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5566 | (*(yyvsp[-2].TypeVal))->getDescription()+ "'!"); |
| 5567 | Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5568 | CHECK_FOR_ERROR |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5569 | (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList)); |
| 5570 | delete (yyvsp[-2].TypeVal); |
| 5571 | delete (yyvsp[0].ValueList); |
| 5572 | ;} |
| 5573 | break; |
| 5574 | |
| 5575 | |
| 5576 | default: break; |
| 5577 | } |
| 5578 | |
| 5579 | /* Line 1126 of yacc.c. */ |
| 5580 | #line 5581 "llvmAsmParser.tab.c" |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5581 | |
| 5582 | yyvsp -= yylen; |
| 5583 | yyssp -= yylen; |
| 5584 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5585 | |
| 5586 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5587 | |
| 5588 | *++yyvsp = yyval; |
| 5589 | |
| 5590 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5591 | /* Now `shift' the result of the reduction. Determine what state |
| 5592 | that goes to, based on the state we popped back to and the rule |
| 5593 | number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5594 | |
| 5595 | yyn = yyr1[yyn]; |
| 5596 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5597 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 5598 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5599 | yystate = yytable[yystate]; |
| 5600 | else |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5601 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5602 | |
| 5603 | goto yynewstate; |
| 5604 | |
| 5605 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5606 | /*------------------------------------. |
| 5607 | | yyerrlab -- here on detecting error | |
| 5608 | `------------------------------------*/ |
| 5609 | yyerrlab: |
| 5610 | /* If not already recovering from an error, report this error. */ |
| 5611 | if (!yyerrstatus) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5612 | { |
| 5613 | ++yynerrs; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5614 | #if YYERROR_VERBOSE |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5615 | yyn = yypact[yystate]; |
Chris Lattner | 0fab59c | 2007-01-12 18:33:30 +0000 | [diff] [blame] | 5616 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5617 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5618 | { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5619 | int yytype = YYTRANSLATE (yychar); |
| 5620 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); |
| 5621 | YYSIZE_T yysize = yysize0; |
| 5622 | YYSIZE_T yysize1; |
| 5623 | int yysize_overflow = 0; |
| 5624 | char *yymsg = 0; |
| 5625 | # define YYERROR_VERBOSE_ARGS_MAXIMUM 5 |
| 5626 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 5627 | int yyx; |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5628 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5629 | #if 0 |
| 5630 | /* This is so xgettext sees the translatable formats that are |
| 5631 | constructed on the fly. */ |
| 5632 | YY_("syntax error, unexpected %s"); |
| 5633 | YY_("syntax error, unexpected %s, expecting %s"); |
| 5634 | YY_("syntax error, unexpected %s, expecting %s or %s"); |
| 5635 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); |
| 5636 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); |
| 5637 | #endif |
| 5638 | char *yyfmt; |
| 5639 | char const *yyf; |
| 5640 | static char const yyunexpected[] = "syntax error, unexpected %s"; |
| 5641 | static char const yyexpecting[] = ", expecting %s"; |
| 5642 | static char const yyor[] = " or %s"; |
| 5643 | char yyformat[sizeof yyunexpected |
| 5644 | + sizeof yyexpecting - 1 |
| 5645 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) |
| 5646 | * (sizeof yyor - 1))]; |
| 5647 | char const *yyprefix = yyexpecting; |
| 5648 | |
| 5649 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 5650 | YYCHECK. */ |
| 5651 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 5652 | |
| 5653 | /* Stay within bounds of both yycheck and yytname. */ |
| 5654 | int yychecklim = YYLAST - yyn; |
| 5655 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 5656 | int yycount = 1; |
| 5657 | |
| 5658 | yyarg[0] = yytname[yytype]; |
| 5659 | yyfmt = yystpcpy (yyformat, yyunexpected); |
| 5660 | |
| 5661 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 5662 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 5663 | { |
| 5664 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 5665 | { |
| 5666 | yycount = 1; |
| 5667 | yysize = yysize0; |
| 5668 | yyformat[sizeof yyunexpected - 1] = '\0'; |
| 5669 | break; |
| 5670 | } |
| 5671 | yyarg[yycount++] = yytname[yyx]; |
| 5672 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); |
| 5673 | yysize_overflow |= yysize1 < yysize; |
| 5674 | yysize = yysize1; |
| 5675 | yyfmt = yystpcpy (yyfmt, yyprefix); |
| 5676 | yyprefix = yyor; |
| 5677 | } |
| 5678 | |
| 5679 | yyf = YY_(yyformat); |
| 5680 | yysize1 = yysize + yystrlen (yyf); |
| 5681 | yysize_overflow |= yysize1 < yysize; |
| 5682 | yysize = yysize1; |
| 5683 | |
| 5684 | if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) |
| 5685 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
| 5686 | if (yymsg) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5687 | { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5688 | /* Avoid sprintf, as that infringes on the user's name space. |
| 5689 | Don't have undefined behavior even if the translation |
| 5690 | produced a string with the wrong number of "%s"s. */ |
| 5691 | char *yyp = yymsg; |
| 5692 | int yyi = 0; |
| 5693 | while ((*yyp = *yyf)) |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5694 | { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5695 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) |
| 5696 | { |
| 5697 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
| 5698 | yyf += 2; |
| 5699 | } |
| 5700 | else |
| 5701 | { |
| 5702 | yyp++; |
| 5703 | yyf++; |
| 5704 | } |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5705 | } |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5706 | yyerror (yymsg); |
| 5707 | YYSTACK_FREE (yymsg); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5708 | } |
| 5709 | else |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5710 | { |
| 5711 | yyerror (YY_("syntax error")); |
| 5712 | goto yyexhaustedlab; |
| 5713 | } |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5714 | } |
| 5715 | else |
| 5716 | #endif /* YYERROR_VERBOSE */ |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5717 | yyerror (YY_("syntax error")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5718 | } |
| 5719 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5720 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5721 | |
| 5722 | if (yyerrstatus == 3) |
| 5723 | { |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5724 | /* If just tried and failed to reuse look-ahead token after an |
| 5725 | error, discard it. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5726 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5727 | if (yychar <= YYEOF) |
| 5728 | { |
| 5729 | /* Return failure if at end of input. */ |
| 5730 | if (yychar == YYEOF) |
| 5731 | YYABORT; |
| 5732 | } |
| 5733 | else |
| 5734 | { |
| 5735 | yydestruct ("Error: discarding", yytoken, &yylval); |
| 5736 | yychar = YYEMPTY; |
| 5737 | } |
| 5738 | } |
| 5739 | |
| 5740 | /* Else will try to reuse look-ahead token after shifting the error |
| 5741 | token. */ |
| 5742 | goto yyerrlab1; |
| 5743 | |
| 5744 | |
| 5745 | /*---------------------------------------------------. |
| 5746 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 5747 | `---------------------------------------------------*/ |
| 5748 | yyerrorlab: |
| 5749 | |
| 5750 | /* Pacify compilers like GCC when the user code never invokes |
| 5751 | YYERROR and the label yyerrorlab therefore never appears in user |
| 5752 | code. */ |
| 5753 | if (0) |
| 5754 | goto yyerrorlab; |
| 5755 | |
| 5756 | yyvsp -= yylen; |
| 5757 | yyssp -= yylen; |
| 5758 | yystate = *yyssp; |
| 5759 | goto yyerrlab1; |
| 5760 | |
| 5761 | |
| 5762 | /*-------------------------------------------------------------. |
| 5763 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 5764 | `-------------------------------------------------------------*/ |
| 5765 | yyerrlab1: |
| 5766 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 5767 | |
| 5768 | for (;;) |
| 5769 | { |
| 5770 | yyn = yypact[yystate]; |
| 5771 | if (yyn != YYPACT_NINF) |
| 5772 | { |
| 5773 | yyn += YYTERROR; |
| 5774 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 5775 | { |
| 5776 | yyn = yytable[yyn]; |
| 5777 | if (0 < yyn) |
| 5778 | break; |
| 5779 | } |
| 5780 | } |
| 5781 | |
| 5782 | /* Pop the current state because it cannot handle the error token. */ |
| 5783 | if (yyssp == yyss) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5784 | YYABORT; |
| 5785 | |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5786 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5787 | yydestruct ("Error: popping", yystos[yystate], yyvsp); |
| 5788 | YYPOPSTACK; |
| 5789 | yystate = *yyssp; |
| 5790 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5791 | } |
| 5792 | |
| 5793 | if (yyn == YYFINAL) |
| 5794 | YYACCEPT; |
| 5795 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5796 | *++yyvsp = yylval; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5797 | |
| 5798 | |
| 5799 | /* Shift the error token. */ |
| 5800 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5801 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5802 | yystate = yyn; |
| 5803 | goto yynewstate; |
| 5804 | |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 5805 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5806 | /*-------------------------------------. |
| 5807 | | yyacceptlab -- YYACCEPT comes here. | |
| 5808 | `-------------------------------------*/ |
| 5809 | yyacceptlab: |
| 5810 | yyresult = 0; |
| 5811 | goto yyreturn; |
| 5812 | |
| 5813 | /*-----------------------------------. |
| 5814 | | yyabortlab -- YYABORT comes here. | |
| 5815 | `-----------------------------------*/ |
| 5816 | yyabortlab: |
| 5817 | yyresult = 1; |
| 5818 | goto yyreturn; |
| 5819 | |
| 5820 | #ifndef yyoverflow |
| 5821 | /*-------------------------------------------------. |
| 5822 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 5823 | `-------------------------------------------------*/ |
| 5824 | yyexhaustedlab: |
| 5825 | yyerror (YY_("memory exhausted")); |
| 5826 | yyresult = 2; |
| 5827 | /* Fall through. */ |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 5828 | #endif |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5829 | |
| 5830 | yyreturn: |
| 5831 | if (yychar != YYEOF && yychar != YYEMPTY) |
| 5832 | yydestruct ("Cleanup: discarding lookahead", |
| 5833 | yytoken, &yylval); |
| 5834 | while (yyssp != yyss) |
| 5835 | { |
| 5836 | yydestruct ("Cleanup: popping", |
| 5837 | yystos[*yyssp], yyvsp); |
| 5838 | YYPOPSTACK; |
Chris Lattner | b25c4ca | 2007-01-15 02:12:07 +0000 | [diff] [blame] | 5839 | } |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5840 | #ifndef yyoverflow |
| 5841 | if (yyss != yyssa) |
| 5842 | YYSTACK_FREE (yyss); |
| 5843 | #endif |
| 5844 | return yyresult; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5845 | } |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5846 | |
| 5847 | |
| 5848 | #line 2869 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5849 | |
| 5850 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5851 | // common code from the two 'RunVMAsmParser' functions |
| 5852 | static Module* RunParser(Module * M) { |
| 5853 | |
| 5854 | llvmAsmlineno = 1; // Reset the current line number... |
| 5855 | CurModule.CurrentModule = M; |
| 5856 | #if YYDEBUG |
| 5857 | yydebug = Debug; |
| 5858 | #endif |
| 5859 | |
| 5860 | // Check to make sure the parser succeeded |
| 5861 | if (yyparse()) { |
| 5862 | if (ParserResult) |
| 5863 | delete ParserResult; |
| 5864 | return 0; |
| 5865 | } |
| 5866 | |
| 5867 | // Check to make sure that parsing produced a result |
| 5868 | if (!ParserResult) |
| 5869 | return 0; |
| 5870 | |
| 5871 | // Reset ParserResult variable while saving its value for the result. |
| 5872 | Module *Result = ParserResult; |
| 5873 | ParserResult = 0; |
| 5874 | |
| 5875 | return Result; |
| 5876 | } |
| 5877 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5878 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 5879 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 5880 | // TODO: column number in exception |
| 5881 | if (TheParseError) |
| 5882 | TheParseError->setError(CurFilename, message, LineNo); |
| 5883 | TriggerError = 1; |
| 5884 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5885 | |
| 5886 | int yyerror(const char *ErrorMsg) { |
| 5887 | std::string where |
| 5888 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 5889 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
| 5890 | std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading "; |
| 5891 | if (yychar == YYEMPTY || yychar == 0) |
| 5892 | errMsg += "end-of-file."; |
| 5893 | else |
| 5894 | errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5895 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5896 | return 0; |
| 5897 | } |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 5898 | |