Reid Spencer | 832254e | 2007-02-02 02:16:23 +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 | 832254e | 2007-02-02 02:16:23 +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 | 832254e | 2007-02-02 02:16:23 +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 | 832254e | 2007-02-02 02:16:23 +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 | 832254e | 2007-02-02 02:16:23 +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 | 832254e | 2007-02-02 02:16:23 +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 | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 60 | |
| 61 | /* Tokens. */ |
| 62 | #ifndef YYTOKENTYPE |
| 63 | # define YYTOKENTYPE |
| 64 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
| 65 | know about them. */ |
| 66 | enum yytokentype { |
| 67 | ESINT64VAL = 258, |
| 68 | EUINT64VAL = 259, |
| 69 | LOCALVAL_ID = 260, |
| 70 | GLOBALVAL_ID = 261, |
| 71 | FPVAL = 262, |
| 72 | VOID = 263, |
| 73 | INTTYPE = 264, |
| 74 | FLOAT = 265, |
| 75 | DOUBLE = 266, |
| 76 | LABEL = 267, |
| 77 | TYPE = 268, |
| 78 | LOCALVAR = 269, |
| 79 | GLOBALVAR = 270, |
| 80 | LABELSTR = 271, |
| 81 | STRINGCONSTANT = 272, |
| 82 | ATSTRINGCONSTANT = 273, |
| 83 | IMPLEMENTATION = 274, |
| 84 | ZEROINITIALIZER = 275, |
| 85 | TRUETOK = 276, |
| 86 | FALSETOK = 277, |
| 87 | BEGINTOK = 278, |
| 88 | ENDTOK = 279, |
| 89 | DECLARE = 280, |
| 90 | DEFINE = 281, |
| 91 | GLOBAL = 282, |
| 92 | CONSTANT = 283, |
| 93 | SECTION = 284, |
| 94 | VOLATILE = 285, |
| 95 | TO = 286, |
| 96 | DOTDOTDOT = 287, |
| 97 | NULL_TOK = 288, |
| 98 | UNDEF = 289, |
| 99 | INTERNAL = 290, |
| 100 | LINKONCE = 291, |
| 101 | WEAK = 292, |
| 102 | APPENDING = 293, |
| 103 | DLLIMPORT = 294, |
| 104 | DLLEXPORT = 295, |
| 105 | EXTERN_WEAK = 296, |
| 106 | OPAQUE = 297, |
| 107 | EXTERNAL = 298, |
| 108 | TARGET = 299, |
| 109 | TRIPLE = 300, |
| 110 | ALIGN = 301, |
| 111 | DEPLIBS = 302, |
| 112 | CALL = 303, |
| 113 | TAIL = 304, |
| 114 | ASM_TOK = 305, |
| 115 | MODULE = 306, |
| 116 | SIDEEFFECT = 307, |
| 117 | CC_TOK = 308, |
| 118 | CCC_TOK = 309, |
| 119 | FASTCC_TOK = 310, |
| 120 | COLDCC_TOK = 311, |
| 121 | X86_STDCALLCC_TOK = 312, |
| 122 | X86_FASTCALLCC_TOK = 313, |
| 123 | DATALAYOUT = 314, |
| 124 | RET = 315, |
| 125 | BR = 316, |
| 126 | SWITCH = 317, |
| 127 | INVOKE = 318, |
| 128 | UNWIND = 319, |
| 129 | UNREACHABLE = 320, |
| 130 | ADD = 321, |
| 131 | SUB = 322, |
| 132 | MUL = 323, |
| 133 | UDIV = 324, |
| 134 | SDIV = 325, |
| 135 | FDIV = 326, |
| 136 | UREM = 327, |
| 137 | SREM = 328, |
| 138 | FREM = 329, |
| 139 | AND = 330, |
| 140 | OR = 331, |
| 141 | XOR = 332, |
| 142 | SHL = 333, |
| 143 | LSHR = 334, |
| 144 | ASHR = 335, |
| 145 | ICMP = 336, |
| 146 | FCMP = 337, |
| 147 | EQ = 338, |
| 148 | NE = 339, |
| 149 | SLT = 340, |
| 150 | SGT = 341, |
| 151 | SLE = 342, |
| 152 | SGE = 343, |
| 153 | ULT = 344, |
| 154 | UGT = 345, |
| 155 | ULE = 346, |
| 156 | UGE = 347, |
| 157 | OEQ = 348, |
| 158 | ONE = 349, |
| 159 | OLT = 350, |
| 160 | OGT = 351, |
| 161 | OLE = 352, |
| 162 | OGE = 353, |
| 163 | ORD = 354, |
| 164 | UNO = 355, |
| 165 | UEQ = 356, |
| 166 | UNE = 357, |
| 167 | MALLOC = 358, |
| 168 | ALLOCA = 359, |
| 169 | FREE = 360, |
| 170 | LOAD = 361, |
| 171 | STORE = 362, |
| 172 | GETELEMENTPTR = 363, |
| 173 | TRUNC = 364, |
| 174 | ZEXT = 365, |
| 175 | SEXT = 366, |
| 176 | FPTRUNC = 367, |
| 177 | FPEXT = 368, |
| 178 | BITCAST = 369, |
| 179 | UITOFP = 370, |
| 180 | SITOFP = 371, |
| 181 | FPTOUI = 372, |
| 182 | FPTOSI = 373, |
| 183 | INTTOPTR = 374, |
| 184 | PTRTOINT = 375, |
| 185 | PHI_TOK = 376, |
| 186 | SELECT = 377, |
| 187 | VAARG = 378, |
| 188 | EXTRACTELEMENT = 379, |
| 189 | INSERTELEMENT = 380, |
| 190 | SHUFFLEVECTOR = 381, |
| 191 | NORETURN = 382, |
| 192 | INREG = 383, |
| 193 | SRET = 384, |
| 194 | DEFAULT = 385, |
| 195 | HIDDEN = 386 |
| 196 | }; |
| 197 | #endif |
| 198 | /* Tokens. */ |
| 199 | #define ESINT64VAL 258 |
| 200 | #define EUINT64VAL 259 |
| 201 | #define LOCALVAL_ID 260 |
| 202 | #define GLOBALVAL_ID 261 |
| 203 | #define FPVAL 262 |
| 204 | #define VOID 263 |
| 205 | #define INTTYPE 264 |
| 206 | #define FLOAT 265 |
| 207 | #define DOUBLE 266 |
| 208 | #define LABEL 267 |
| 209 | #define TYPE 268 |
| 210 | #define LOCALVAR 269 |
| 211 | #define GLOBALVAR 270 |
| 212 | #define LABELSTR 271 |
| 213 | #define STRINGCONSTANT 272 |
| 214 | #define ATSTRINGCONSTANT 273 |
| 215 | #define IMPLEMENTATION 274 |
| 216 | #define ZEROINITIALIZER 275 |
| 217 | #define TRUETOK 276 |
| 218 | #define FALSETOK 277 |
| 219 | #define BEGINTOK 278 |
| 220 | #define ENDTOK 279 |
| 221 | #define DECLARE 280 |
| 222 | #define DEFINE 281 |
| 223 | #define GLOBAL 282 |
| 224 | #define CONSTANT 283 |
| 225 | #define SECTION 284 |
| 226 | #define VOLATILE 285 |
| 227 | #define TO 286 |
| 228 | #define DOTDOTDOT 287 |
| 229 | #define NULL_TOK 288 |
| 230 | #define UNDEF 289 |
| 231 | #define INTERNAL 290 |
| 232 | #define LINKONCE 291 |
| 233 | #define WEAK 292 |
| 234 | #define APPENDING 293 |
| 235 | #define DLLIMPORT 294 |
| 236 | #define DLLEXPORT 295 |
| 237 | #define EXTERN_WEAK 296 |
| 238 | #define OPAQUE 297 |
| 239 | #define EXTERNAL 298 |
| 240 | #define TARGET 299 |
| 241 | #define TRIPLE 300 |
| 242 | #define ALIGN 301 |
| 243 | #define DEPLIBS 302 |
| 244 | #define CALL 303 |
| 245 | #define TAIL 304 |
| 246 | #define ASM_TOK 305 |
| 247 | #define MODULE 306 |
| 248 | #define SIDEEFFECT 307 |
| 249 | #define CC_TOK 308 |
| 250 | #define CCC_TOK 309 |
| 251 | #define FASTCC_TOK 310 |
| 252 | #define COLDCC_TOK 311 |
| 253 | #define X86_STDCALLCC_TOK 312 |
| 254 | #define X86_FASTCALLCC_TOK 313 |
| 255 | #define DATALAYOUT 314 |
| 256 | #define RET 315 |
| 257 | #define BR 316 |
| 258 | #define SWITCH 317 |
| 259 | #define INVOKE 318 |
| 260 | #define UNWIND 319 |
| 261 | #define UNREACHABLE 320 |
| 262 | #define ADD 321 |
| 263 | #define SUB 322 |
| 264 | #define MUL 323 |
| 265 | #define UDIV 324 |
| 266 | #define SDIV 325 |
| 267 | #define FDIV 326 |
| 268 | #define UREM 327 |
| 269 | #define SREM 328 |
| 270 | #define FREM 329 |
| 271 | #define AND 330 |
| 272 | #define OR 331 |
| 273 | #define XOR 332 |
| 274 | #define SHL 333 |
| 275 | #define LSHR 334 |
| 276 | #define ASHR 335 |
| 277 | #define ICMP 336 |
| 278 | #define FCMP 337 |
| 279 | #define EQ 338 |
| 280 | #define NE 339 |
| 281 | #define SLT 340 |
| 282 | #define SGT 341 |
| 283 | #define SLE 342 |
| 284 | #define SGE 343 |
| 285 | #define ULT 344 |
| 286 | #define UGT 345 |
| 287 | #define ULE 346 |
| 288 | #define UGE 347 |
| 289 | #define OEQ 348 |
| 290 | #define ONE 349 |
| 291 | #define OLT 350 |
| 292 | #define OGT 351 |
| 293 | #define OLE 352 |
| 294 | #define OGE 353 |
| 295 | #define ORD 354 |
| 296 | #define UNO 355 |
| 297 | #define UEQ 356 |
| 298 | #define UNE 357 |
| 299 | #define MALLOC 358 |
| 300 | #define ALLOCA 359 |
| 301 | #define FREE 360 |
| 302 | #define LOAD 361 |
| 303 | #define STORE 362 |
| 304 | #define GETELEMENTPTR 363 |
| 305 | #define TRUNC 364 |
| 306 | #define ZEXT 365 |
| 307 | #define SEXT 366 |
| 308 | #define FPTRUNC 367 |
| 309 | #define FPEXT 368 |
| 310 | #define BITCAST 369 |
| 311 | #define UITOFP 370 |
| 312 | #define SITOFP 371 |
| 313 | #define FPTOUI 372 |
| 314 | #define FPTOSI 373 |
| 315 | #define INTTOPTR 374 |
| 316 | #define PTRTOINT 375 |
| 317 | #define PHI_TOK 376 |
| 318 | #define SELECT 377 |
| 319 | #define VAARG 378 |
| 320 | #define EXTRACTELEMENT 379 |
| 321 | #define INSERTELEMENT 380 |
| 322 | #define SHUFFLEVECTOR 381 |
| 323 | #define NORETURN 382 |
| 324 | #define INREG 383 |
| 325 | #define SRET 384 |
| 326 | #define DEFAULT 385 |
| 327 | #define HIDDEN 386 |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | /* Copy the first part of user declarations. */ |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 333 | #line 14 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 334 | |
| 335 | #include "ParserInternals.h" |
| 336 | #include "llvm/CallingConv.h" |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 337 | #include "llvm/InlineAsm.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 338 | #include "llvm/Instructions.h" |
| 339 | #include "llvm/Module.h" |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 340 | #include "llvm/ValueSymbolTable.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 341 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 342 | #include "llvm/Support/CommandLine.h" |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 343 | #include "llvm/ADT/SmallVector.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 344 | #include "llvm/ADT/STLExtras.h" |
Chris Lattner | 0019bbe | 2005-11-06 06:46:53 +0000 | [diff] [blame] | 345 | #include "llvm/Support/MathExtras.h" |
Reid Spencer | 481169e | 2006-12-01 00:33:46 +0000 | [diff] [blame] | 346 | #include "llvm/Support/Streams.h" |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 347 | #include <algorithm> |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 348 | #include <list> |
| 349 | #include <utility> |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 350 | #ifndef NDEBUG |
| 351 | #define YYDEBUG 1 |
| 352 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 353 | |
Reid Spencer | e4f4759 | 2006-08-18 17:32:55 +0000 | [diff] [blame] | 354 | // The following is a gross hack. In order to rid the libAsmParser library of |
| 355 | // exceptions, we have to have a way of getting the yyparse function to go into |
| 356 | // an error situation. So, whenever we want an error to occur, the GenerateError |
| 357 | // function (see bottom of file) sets TriggerError. Then, at the end of each |
| 358 | // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR |
| 359 | // (a goto) to put YACC in error state. Furthermore, several calls to |
| 360 | // GenerateError are made from inside productions and they must simulate the |
| 361 | // previous exception behavior by exiting the production immediately. We have |
| 362 | // replaced these with the GEN_ERROR macro which calls GeneratError and then |
| 363 | // immediately invokes YYERROR. This would be so much cleaner if it was a |
| 364 | // recursive descent parser. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 365 | static bool TriggerError = false; |
Reid Spencer | f63697d | 2006-10-09 17:36:59 +0000 | [diff] [blame] | 366 | #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 367 | #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; } |
| 368 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 369 | int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit |
| 370 | int yylex(); // declaration" of xxx warnings. |
| 371 | int yyparse(); |
| 372 | |
| 373 | namespace llvm { |
| 374 | std::string CurFilename; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 375 | #if YYDEBUG |
| 376 | static cl::opt<bool> |
| 377 | Debug("debug-yacc", cl::desc("Print yacc debug state changes"), |
| 378 | cl::Hidden, cl::init(false)); |
| 379 | #endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 380 | } |
| 381 | using namespace llvm; |
| 382 | |
| 383 | static Module *ParserResult; |
| 384 | |
| 385 | // DEBUG_UPREFS - Define this symbol if you want to enable debugging output |
| 386 | // relating to upreferences in the input stream. |
| 387 | // |
| 388 | //#define DEBUG_UPREFS 1 |
| 389 | #ifdef DEBUG_UPREFS |
Bill Wendling | e815619 | 2006-12-07 01:30:32 +0000 | [diff] [blame] | 390 | #define UR_OUT(X) cerr << X |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 391 | #else |
| 392 | #define UR_OUT(X) |
| 393 | #endif |
| 394 | |
| 395 | #define YYERROR_VERBOSE 1 |
| 396 | |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 397 | static GlobalVariable *CurGV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 398 | |
| 399 | |
| 400 | // This contains info used when building the body of a function. It is |
| 401 | // destroyed when the function is completed. |
| 402 | // |
| 403 | typedef std::vector<Value *> ValueList; // Numbered defs |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 404 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 405 | static void |
| 406 | ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers, |
| 407 | std::map<const Type *,ValueList> *FutureLateResolvers = 0); |
| 408 | |
| 409 | static struct PerModuleInfo { |
| 410 | Module *CurrentModule; |
| 411 | std::map<const Type *, ValueList> Values; // Module level numbered definitions |
| 412 | std::map<const Type *,ValueList> LateResolveValues; |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 413 | std::vector<PATypeHolder> Types; |
| 414 | std::map<ValID, PATypeHolder> LateResolveTypes; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 415 | |
| 416 | /// PlaceHolderInfo - When temporary placeholder objects are created, remember |
Chris Lattner | 0ad1970 | 2006-06-21 16:53:00 +0000 | [diff] [blame] | 417 | /// 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] | 418 | /// that we can resolve them later and print error messages as appropriate. |
| 419 | std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo; |
| 420 | |
| 421 | // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward |
| 422 | // references to global values. Global values may be referenced before they |
| 423 | // are defined, and if so, the temporary object that they represent is held |
| 424 | // here. This is used for forward references of GlobalValues. |
| 425 | // |
| 426 | typedef std::map<std::pair<const PointerType *, |
| 427 | ValID>, GlobalValue*> GlobalRefsType; |
| 428 | GlobalRefsType GlobalRefs; |
| 429 | |
| 430 | void ModuleDone() { |
| 431 | // If we could not resolve some functions at function compilation time |
| 432 | // (calls to functions before they are defined), resolve them now... Types |
| 433 | // are resolved when the constant pool has been completely parsed. |
| 434 | // |
| 435 | ResolveDefinitions(LateResolveValues); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 436 | if (TriggerError) |
| 437 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 438 | |
| 439 | // Check to make sure that all global value forward references have been |
| 440 | // resolved! |
| 441 | // |
| 442 | if (!GlobalRefs.empty()) { |
| 443 | std::string UndefinedReferences = "Unresolved global references exist:\n"; |
| 444 | |
| 445 | for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end(); |
| 446 | I != E; ++I) { |
| 447 | UndefinedReferences += " " + I->first.first->getDescription() + " " + |
| 448 | I->first.second.getName() + "\n"; |
| 449 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 450 | GenerateError(UndefinedReferences); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 451 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | Values.clear(); // Clear out function local definitions |
| 455 | Types.clear(); |
| 456 | CurrentModule = 0; |
| 457 | } |
| 458 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 459 | // GetForwardRefForGlobal - Check to see if there is a forward reference |
| 460 | // for this global. If so, remove it from the GlobalRefs map and return it. |
| 461 | // If not, just return null. |
| 462 | GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { |
| 463 | // Check to see if there is a forward reference to this global variable... |
| 464 | // if there is, eliminate it and patch the reference to use the new def'n. |
| 465 | GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); |
| 466 | GlobalValue *Ret = 0; |
| 467 | if (I != GlobalRefs.end()) { |
| 468 | Ret = I->second; |
| 469 | GlobalRefs.erase(I); |
| 470 | } |
| 471 | return Ret; |
| 472 | } |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 473 | |
| 474 | bool TypeIsUnresolved(PATypeHolder* PATy) { |
| 475 | // If it isn't abstract, its resolved |
| 476 | const Type* Ty = PATy->get(); |
| 477 | if (!Ty->isAbstract()) |
| 478 | return false; |
| 479 | // Traverse the type looking for abstract types. If it isn't abstract then |
| 480 | // we don't need to traverse that leg of the type. |
| 481 | std::vector<const Type*> WorkList, SeenList; |
| 482 | WorkList.push_back(Ty); |
| 483 | while (!WorkList.empty()) { |
| 484 | const Type* Ty = WorkList.back(); |
| 485 | SeenList.push_back(Ty); |
| 486 | WorkList.pop_back(); |
| 487 | if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) { |
| 488 | // Check to see if this is an unresolved type |
| 489 | std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin(); |
| 490 | std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end(); |
| 491 | for ( ; I != E; ++I) { |
| 492 | if (I->second.get() == OpTy) |
| 493 | return true; |
| 494 | } |
| 495 | } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) { |
| 496 | const Type* TheTy = SeqTy->getElementType(); |
| 497 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 498 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 499 | E = SeenList.end(); |
| 500 | for ( ; I != E; ++I) |
| 501 | if (*I == TheTy) |
| 502 | break; |
| 503 | if (I == E) |
| 504 | WorkList.push_back(TheTy); |
| 505 | } |
| 506 | } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) { |
| 507 | for (unsigned i = 0; i < StrTy->getNumElements(); ++i) { |
| 508 | const Type* TheTy = StrTy->getElementType(i); |
| 509 | if (TheTy->isAbstract() && TheTy != Ty) { |
| 510 | std::vector<const Type*>::iterator I = SeenList.begin(), |
| 511 | E = SeenList.end(); |
| 512 | for ( ; I != E; ++I) |
| 513 | if (*I == TheTy) |
| 514 | break; |
| 515 | if (I == E) |
| 516 | WorkList.push_back(TheTy); |
| 517 | } |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | return false; |
| 522 | } |
| 523 | |
| 524 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 525 | } CurModule; |
| 526 | |
| 527 | static struct PerFunctionInfo { |
| 528 | Function *CurrentFunction; // Pointer to current function being created |
| 529 | |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 530 | std::map<const Type*, ValueList> Values; // Keep track of #'d definitions |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 531 | std::map<const Type*, ValueList> LateResolveValues; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 532 | bool isDeclare; // Is this function a forward declararation? |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 533 | GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 534 | GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 535 | |
| 536 | /// BBForwardRefs - When we see forward references to basic blocks, keep |
| 537 | /// track of them here. |
| 538 | std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs; |
| 539 | std::vector<BasicBlock*> NumberedBlocks; |
| 540 | unsigned NextBBNum; |
| 541 | |
| 542 | inline PerFunctionInfo() { |
| 543 | CurrentFunction = 0; |
| 544 | isDeclare = false; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 545 | Linkage = GlobalValue::ExternalLinkage; |
| 546 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 547 | } |
| 548 | |
| 549 | inline void FunctionStart(Function *M) { |
| 550 | CurrentFunction = M; |
| 551 | NextBBNum = 0; |
| 552 | } |
| 553 | |
| 554 | void FunctionDone() { |
| 555 | NumberedBlocks.clear(); |
| 556 | |
| 557 | // Any forward referenced blocks left? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 558 | if (!BBForwardRefs.empty()) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 559 | GenerateError("Undefined reference to label " + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 560 | BBForwardRefs.begin()->first->getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 561 | return; |
| 562 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 563 | |
| 564 | // Resolve all forward references now. |
| 565 | ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); |
| 566 | |
| 567 | Values.clear(); // Clear out function local definitions |
| 568 | CurrentFunction = 0; |
| 569 | isDeclare = false; |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 570 | Linkage = GlobalValue::ExternalLinkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 571 | Visibility = GlobalValue::DefaultVisibility; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 572 | } |
| 573 | } CurFun; // Info for the current function... |
| 574 | |
| 575 | static bool inFunctionScope() { return CurFun.CurrentFunction != 0; } |
| 576 | |
| 577 | |
| 578 | //===----------------------------------------------------------------------===// |
| 579 | // Code to handle definitions of all the types |
| 580 | //===----------------------------------------------------------------------===// |
| 581 | |
| 582 | static int InsertValue(Value *V, |
| 583 | std::map<const Type*,ValueList> &ValueTab = CurFun.Values) { |
| 584 | if (V->hasName()) return -1; // Is this a numbered definition? |
| 585 | |
| 586 | // Yes, insert the value into the value table... |
| 587 | ValueList &List = ValueTab[V->getType()]; |
| 588 | List.push_back(V); |
| 589 | return List.size()-1; |
| 590 | } |
| 591 | |
| 592 | static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { |
| 593 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 594 | case ValID::LocalID: // Is it a numbered definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 595 | // Module constants occupy the lowest numbered slots... |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 596 | if (D.Num < CurModule.Types.size()) |
| 597 | return CurModule.Types[D.Num]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 598 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 599 | case ValID::LocalName: // Is it a named definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 600 | if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { |
| 601 | D.destroy(); // Free old strdup'd memory... |
| 602 | return N; |
| 603 | } |
| 604 | break; |
| 605 | default: |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 606 | GenerateError("Internal parser error: Invalid symbol type reference"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 607 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | // If we reached here, we referenced either a symbol that we don't know about |
| 611 | // or an id number that hasn't been read yet. We may be referencing something |
| 612 | // forward, so just create an entry to be resolved later and get to it... |
| 613 | // |
| 614 | if (DoNotImprovise) return 0; // Do we just want a null to be returned? |
| 615 | |
| 616 | |
| 617 | if (inFunctionScope()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 618 | if (D.Type == ValID::LocalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 619 | GenerateError("Reference to an undefined type: '" + D.getName() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 620 | return 0; |
| 621 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 622 | GenerateError("Reference to an undefined type: #" + utostr(D.Num)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 623 | return 0; |
| 624 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 625 | } |
| 626 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 627 | std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 628 | if (I != CurModule.LateResolveTypes.end()) |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 629 | return I->second; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 630 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 631 | Type *Typ = OpaqueType::get(); |
| 632 | CurModule.LateResolveTypes.insert(std::make_pair(D, Typ)); |
| 633 | return Typ; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 634 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 635 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 636 | // getValNonImprovising - Look up the value specified by the provided type and |
| 637 | // the provided ValID. If the value exists and has already been defined, return |
| 638 | // it. Otherwise return null. |
| 639 | // |
| 640 | static Value *getValNonImprovising(const Type *Ty, const ValID &D) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 641 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 642 | GenerateError("Functions are not values and " |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 643 | "must be referenced as pointers"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 644 | return 0; |
| 645 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 646 | |
| 647 | switch (D.Type) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 648 | case ValID::LocalID: { // Is it a numbered definition? |
| 649 | // Module constants occupy the lowest numbered slots. |
| 650 | std::map<const Type*,ValueList>::iterator VI = CurFun.Values.find(Ty); |
| 651 | // Make sure that our type is within bounds. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 652 | if (VI == CurFun.Values.end()) return 0; |
| 653 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 654 | // Check that the number is within bounds. |
| 655 | if (D.Num >= VI->second.size()) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 656 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 657 | return VI->second[D.Num]; |
| 658 | } |
| 659 | case ValID::GlobalID: { // Is it a numbered definition? |
| 660 | unsigned Num = D.Num; |
| 661 | |
| 662 | // Module constants occupy the lowest numbered slots... |
| 663 | std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 664 | if (VI == CurModule.Values.end()) |
| 665 | return 0; |
| 666 | if (D.Num >= VI->second.size()) |
| 667 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 668 | return VI->second[Num]; |
| 669 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 670 | |
| 671 | case ValID::LocalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 672 | if (!inFunctionScope()) |
| 673 | return 0; |
| 674 | ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); |
| 675 | Value *N = SymTab.lookup(D.Name); |
| 676 | if (N == 0) |
| 677 | return 0; |
| 678 | if (N->getType() != Ty) |
| 679 | return 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 680 | |
| 681 | D.destroy(); // Free old strdup'd memory... |
| 682 | return N; |
| 683 | } |
| 684 | case ValID::GlobalName: { // Is it a named definition? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 685 | ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable(); |
| 686 | Value *N = SymTab.lookup(D.Name); |
| 687 | if (N == 0) |
| 688 | return 0; |
| 689 | if (N->getType() != Ty) |
| 690 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 691 | |
| 692 | D.destroy(); // Free old strdup'd memory... |
| 693 | return N; |
| 694 | } |
| 695 | |
| 696 | // Check to make sure that "Ty" is an integral type, and that our |
| 697 | // value will fit into the specified type... |
| 698 | case ValID::ConstSIntVal: // Is it a constant pool reference?? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 699 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 700 | GenerateError("Signed integral constant '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 701 | itostr(D.ConstPool64) + "' is invalid for type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 702 | Ty->getDescription() + "'"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 703 | return 0; |
| 704 | } |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 705 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 706 | |
| 707 | case ValID::ConstUIntVal: // Is it an unsigned const pool reference? |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 708 | if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { |
| 709 | if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 710 | GenerateError("Integral constant '" + utostr(D.UConstPool64) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 711 | "' is invalid or out of range"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 712 | return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 713 | } else { // This is really a signed reference. Transmogrify. |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 714 | return ConstantInt::get(Ty, D.ConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 715 | } |
| 716 | } else { |
Reid Spencer | b83eb64 | 2006-10-20 07:07:24 +0000 | [diff] [blame] | 717 | return ConstantInt::get(Ty, D.UConstPool64); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 718 | } |
| 719 | |
| 720 | case ValID::ConstFPVal: // Is it a floating point const pool reference? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 721 | if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 722 | GenerateError("FP constant invalid for type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 723 | return 0; |
| 724 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 725 | return ConstantFP::get(Ty, D.ConstPoolFP); |
| 726 | |
| 727 | case ValID::ConstNullVal: // Is it a null value? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 728 | if (!isa<PointerType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 729 | GenerateError("Cannot create a a non pointer null"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 730 | return 0; |
| 731 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 732 | return ConstantPointerNull::get(cast<PointerType>(Ty)); |
| 733 | |
| 734 | case ValID::ConstUndefVal: // Is it an undef value? |
| 735 | return UndefValue::get(Ty); |
| 736 | |
Chris Lattner | 7aa6189 | 2005-12-21 17:53:23 +0000 | [diff] [blame] | 737 | case ValID::ConstZeroVal: // Is it a zero value? |
| 738 | return Constant::getNullValue(Ty); |
| 739 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 740 | case ValID::ConstantVal: // Fully resolved constant? |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 741 | if (D.ConstantValue->getType() != Ty) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 742 | GenerateError("Constant expression type different from required type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 743 | return 0; |
| 744 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 745 | return D.ConstantValue; |
| 746 | |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 747 | case ValID::InlineAsmVal: { // Inline asm expression |
| 748 | const PointerType *PTy = dyn_cast<PointerType>(Ty); |
| 749 | const FunctionType *FTy = |
| 750 | PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 751 | if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 752 | GenerateError("Invalid type for asm constraint string"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 753 | return 0; |
| 754 | } |
Chris Lattner | 0e9c376 | 2006-01-25 22:27:16 +0000 | [diff] [blame] | 755 | InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, |
| 756 | D.IAD->HasSideEffects); |
| 757 | D.destroy(); // Free InlineAsmDescriptor. |
| 758 | return IA; |
| 759 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 760 | default: |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 761 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 762 | return 0; |
| 763 | } // End of switch |
| 764 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 765 | assert(0 && "Unhandled case!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 766 | return 0; |
| 767 | } |
| 768 | |
| 769 | // getVal - This function is identical to getValNonImprovising, except that if a |
| 770 | // value is not already defined, it "improvises" by creating a placeholder var |
| 771 | // that looks and acts just like the requested variable. When the value is |
| 772 | // defined later, all uses of the placeholder variable are replaced with the |
| 773 | // real thing. |
| 774 | // |
| 775 | static Value *getVal(const Type *Ty, const ValID &ID) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 776 | if (Ty == Type::LabelTy) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 777 | GenerateError("Cannot use a basic block here"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 778 | return 0; |
| 779 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 780 | |
| 781 | // See if the value has already been defined. |
| 782 | Value *V = getValNonImprovising(Ty, ID); |
| 783 | if (V) return V; |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 784 | if (TriggerError) return 0; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 785 | |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 786 | if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 787 | GenerateError("Invalid use of a composite type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 788 | return 0; |
| 789 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 790 | |
| 791 | // If we reached here, we referenced either a symbol that we don't know about |
| 792 | // or an id number that hasn't been read yet. We may be referencing something |
| 793 | // forward, so just create an entry to be resolved later and get to it... |
| 794 | // |
| 795 | V = new Argument(Ty); |
| 796 | |
| 797 | // Remember where this forward reference came from. FIXME, shouldn't we try |
| 798 | // to recycle these things?? |
| 799 | CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, |
| 800 | llvmAsmlineno))); |
| 801 | |
| 802 | if (inFunctionScope()) |
| 803 | InsertValue(V, CurFun.LateResolveValues); |
| 804 | else |
| 805 | InsertValue(V, CurModule.LateResolveValues); |
| 806 | return V; |
| 807 | } |
| 808 | |
| 809 | /// getBBVal - This is used for two purposes: |
| 810 | /// * If isDefinition is true, a new basic block with the specified ID is being |
| 811 | /// defined. |
| 812 | /// * If isDefinition is true, this is a reference to a basic block, which may |
| 813 | /// or may not be a forward reference. |
| 814 | /// |
| 815 | static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 816 | assert(inFunctionScope() && "Can't get basic block at global scope!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 817 | |
| 818 | std::string Name; |
| 819 | BasicBlock *BB = 0; |
| 820 | switch (ID.Type) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 821 | default: |
| 822 | GenerateError("Illegal label reference " + ID.getName()); |
| 823 | return 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 824 | case ValID::LocalID: // Is it a numbered definition? |
| 825 | if (ID.Num >= CurFun.NumberedBlocks.size()) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 826 | CurFun.NumberedBlocks.resize(ID.Num+1); |
| 827 | BB = CurFun.NumberedBlocks[ID.Num]; |
| 828 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 829 | case ValID::LocalName: // Is it a named definition? |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 830 | Name = ID.Name; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 831 | Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name); |
| 832 | if (N && N->getType()->getTypeID() == Type::LabelTyID) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 833 | BB = cast<BasicBlock>(N); |
| 834 | break; |
| 835 | } |
| 836 | |
| 837 | // See if the block has already been defined. |
| 838 | if (BB) { |
| 839 | // If this is the definition of the block, make sure the existing value was |
| 840 | // just a forward reference. If it was a forward reference, there will be |
| 841 | // an entry for it in the PlaceHolderInfo map. |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 842 | if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 843 | // The existing value was a definition, not a forward reference. |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 844 | GenerateError("Redefinition of label " + ID.getName()); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 845 | return 0; |
| 846 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 847 | |
| 848 | ID.destroy(); // Free strdup'd memory. |
| 849 | return BB; |
| 850 | } |
| 851 | |
| 852 | // Otherwise this block has not been seen before. |
| 853 | BB = new BasicBlock("", CurFun.CurrentFunction); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 854 | if (ID.Type == ValID::LocalName) { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 855 | BB->setName(ID.Name); |
| 856 | } else { |
| 857 | CurFun.NumberedBlocks[ID.Num] = BB; |
| 858 | } |
| 859 | |
| 860 | // If this is not a definition, keep track of it so we can use it as a forward |
| 861 | // reference. |
| 862 | if (!isDefinition) { |
| 863 | // Remember where this forward reference came from. |
| 864 | CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno); |
| 865 | } else { |
| 866 | // The forward declaration could have been inserted anywhere in the |
| 867 | // function: insert it into the correct place now. |
| 868 | CurFun.CurrentFunction->getBasicBlockList().remove(BB); |
| 869 | CurFun.CurrentFunction->getBasicBlockList().push_back(BB); |
| 870 | } |
| 871 | ID.destroy(); |
| 872 | return BB; |
| 873 | } |
| 874 | |
| 875 | |
| 876 | //===----------------------------------------------------------------------===// |
| 877 | // Code to handle forward references in instructions |
| 878 | //===----------------------------------------------------------------------===// |
| 879 | // |
| 880 | // This code handles the late binding needed with statements that reference |
| 881 | // values not defined yet... for example, a forward branch, or the PHI node for |
| 882 | // a loop body. |
| 883 | // |
| 884 | // This keeps a table (CurFun.LateResolveValues) of all such forward references |
| 885 | // and back patchs after we are done. |
| 886 | // |
| 887 | |
| 888 | // ResolveDefinitions - If we could not resolve some defs at parsing |
| 889 | // time (forward branches, phi functions for loops, etc...) resolve the |
| 890 | // defs now... |
| 891 | // |
| 892 | static void |
| 893 | ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers, |
| 894 | std::map<const Type*,ValueList> *FutureLateResolvers) { |
| 895 | // Loop over LateResolveDefs fixing up stuff that couldn't be resolved |
| 896 | for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(), |
| 897 | E = LateResolvers.end(); LRI != E; ++LRI) { |
| 898 | ValueList &List = LRI->second; |
| 899 | while (!List.empty()) { |
| 900 | Value *V = List.back(); |
| 901 | List.pop_back(); |
| 902 | |
| 903 | std::map<Value*, std::pair<ValID, int> >::iterator PHI = |
| 904 | CurModule.PlaceHolderInfo.find(V); |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 905 | assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 906 | |
| 907 | ValID &DID = PHI->second.first; |
| 908 | |
| 909 | Value *TheRealValue = getValNonImprovising(LRI->first, DID); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 910 | if (TriggerError) |
| 911 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 912 | if (TheRealValue) { |
| 913 | V->replaceAllUsesWith(TheRealValue); |
| 914 | delete V; |
| 915 | CurModule.PlaceHolderInfo.erase(PHI); |
| 916 | } else if (FutureLateResolvers) { |
| 917 | // Functions have their unresolved items forwarded to the module late |
| 918 | // resolver table |
| 919 | InsertValue(V, *FutureLateResolvers); |
| 920 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 921 | if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 922 | GenerateError("Reference to an invalid definition: '" +DID.getName()+ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 923 | "' of type '" + V->getType()->getDescription() + "'", |
| 924 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 925 | return; |
| 926 | } else { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 927 | GenerateError("Reference to an invalid definition: #" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 928 | itostr(DID.Num) + " of type '" + |
| 929 | V->getType()->getDescription() + "'", |
| 930 | PHI->second.second); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 931 | return; |
| 932 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 933 | } |
| 934 | } |
| 935 | } |
| 936 | |
| 937 | LateResolvers.clear(); |
| 938 | } |
| 939 | |
| 940 | // ResolveTypeTo - A brand new type was just declared. This means that (if |
| 941 | // name is not null) things referencing Name can be resolved. Otherwise, things |
| 942 | // refering to the number can be resolved. Do this now. |
| 943 | // |
| 944 | static void ResolveTypeTo(char *Name, const Type *ToTy) { |
| 945 | ValID D; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 946 | if (Name) D = ValID::createLocalName(Name); |
| 947 | else D = ValID::createLocalID(CurModule.Types.size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 948 | |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 949 | std::map<ValID, PATypeHolder>::iterator I = |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 950 | CurModule.LateResolveTypes.find(D); |
| 951 | if (I != CurModule.LateResolveTypes.end()) { |
Reid Spencer | 861d9d6 | 2006-11-28 07:29:44 +0000 | [diff] [blame] | 952 | ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 953 | CurModule.LateResolveTypes.erase(I); |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | // setValueName - Set the specified value to the name given. The name may be |
| 958 | // null potentially, in which case this is a noop. The string passed in is |
| 959 | // assumed to be a malloc'd string buffer, and is free'd by this function. |
| 960 | // |
| 961 | static void setValueName(Value *V, char *NameStr) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 962 | if (!NameStr) return; |
| 963 | std::string Name(NameStr); // Copy string |
| 964 | free(NameStr); // Free old string |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 965 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 966 | if (V->getType() == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 967 | GenerateError("Can't assign name '" + Name+"' to value with void type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 968 | return; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 969 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 970 | |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 971 | assert(inFunctionScope() && "Must be in function scope!"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 972 | ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); |
| 973 | if (ST.lookup(Name)) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 974 | GenerateError("Redefinition of value '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 975 | V->getType()->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 976 | return; |
| 977 | } |
| 978 | |
| 979 | // Set the name. |
| 980 | V->setName(Name); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, |
| 984 | /// this is a declaration, otherwise it is a definition. |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 985 | static GlobalVariable * |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 986 | ParseGlobalVariable(char *NameStr, |
| 987 | GlobalValue::LinkageTypes Linkage, |
| 988 | GlobalValue::VisibilityTypes Visibility, |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 989 | bool isConstantGlobal, const Type *Ty, |
| 990 | Constant *Initializer) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 991 | if (isa<FunctionType>(Ty)) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 992 | GenerateError("Cannot declare global vars of function type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 993 | return 0; |
| 994 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 995 | |
| 996 | const PointerType *PTy = PointerType::get(Ty); |
| 997 | |
| 998 | std::string Name; |
| 999 | if (NameStr) { |
| 1000 | Name = NameStr; // Copy string |
| 1001 | free(NameStr); // Free old string |
| 1002 | } |
| 1003 | |
| 1004 | // See if this global value was forward referenced. If so, recycle the |
| 1005 | // object. |
| 1006 | ValID ID; |
| 1007 | if (!Name.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1008 | ID = ValID::createGlobalName((char*)Name.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1009 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1010 | ID = ValID::createGlobalID(CurModule.Values[PTy].size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1011 | } |
| 1012 | |
| 1013 | if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { |
| 1014 | // Move the global to the end of the list, from whereever it was |
| 1015 | // previously inserted. |
| 1016 | GlobalVariable *GV = cast<GlobalVariable>(FWGV); |
| 1017 | CurModule.CurrentModule->getGlobalList().remove(GV); |
| 1018 | CurModule.CurrentModule->getGlobalList().push_back(GV); |
| 1019 | GV->setInitializer(Initializer); |
| 1020 | GV->setLinkage(Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1021 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1022 | GV->setConstant(isConstantGlobal); |
| 1023 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1024 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1025 | } |
| 1026 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 1027 | // If this global has a name |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1028 | if (!Name.empty()) { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 1029 | // if the global we're parsing has an initializer (is a definition) and |
| 1030 | // has external linkage. |
| 1031 | if (Initializer && Linkage != GlobalValue::InternalLinkage) |
| 1032 | // If there is already a global with external linkage with this name |
| 1033 | if (CurModule.CurrentModule->getGlobalVariable(Name, false)) { |
| 1034 | // If we allow this GVar to get created, it will be renamed in the |
| 1035 | // symbol table because it conflicts with an existing GVar. We can't |
| 1036 | // allow redefinition of GVars whose linking indicates that their name |
| 1037 | // must stay the same. Issue the error. |
| 1038 | GenerateError("Redefinition of global variable named '" + Name + |
| 1039 | "' of type '" + Ty->getDescription() + "'"); |
| 1040 | return 0; |
| 1041 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1042 | } |
| 1043 | |
| 1044 | // Otherwise there is no existing GV to use, create one now. |
| 1045 | GlobalVariable *GV = |
| 1046 | new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, |
| 1047 | CurModule.CurrentModule); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1048 | GV->setVisibility(Visibility); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1049 | InsertValue(GV, CurModule.Values); |
Chris Lattner | b475c42 | 2005-11-12 18:22:38 +0000 | [diff] [blame] | 1050 | return GV; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1051 | } |
| 1052 | |
| 1053 | // setTypeName - Set the specified type to the name given. The name may be |
| 1054 | // null potentially, in which case this is a noop. The string passed in is |
| 1055 | // assumed to be a malloc'd string buffer, and is freed by this function. |
| 1056 | // |
| 1057 | // This function returns true if the type has already been defined, but is |
| 1058 | // allowed to be redefined in the specified context. If the name is a new name |
| 1059 | // for the type plane, it is inserted and false is returned. |
| 1060 | static bool setTypeName(const Type *T, char *NameStr) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 1061 | assert(!inFunctionScope() && "Can't give types function-local names!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1062 | if (NameStr == 0) return false; |
| 1063 | |
| 1064 | std::string Name(NameStr); // Copy string |
| 1065 | free(NameStr); // Free old string |
| 1066 | |
| 1067 | // We don't allow assigning names to void type |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1068 | if (T == Type::VoidTy) { |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1069 | GenerateError("Can't assign name '" + Name + "' to the void type"); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 1070 | return false; |
| 1071 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1072 | |
| 1073 | // Set the type name, checking for conflicts as we do so. |
| 1074 | bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); |
| 1075 | |
| 1076 | if (AlreadyExists) { // Inserting a name that is already defined??? |
| 1077 | const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 1078 | assert(Existing && "Conflict but no matching type?!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1079 | |
| 1080 | // There is only one case where this is allowed: when we are refining an |
| 1081 | // opaque type. In this case, Existing will be an opaque type. |
| 1082 | if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) { |
| 1083 | // We ARE replacing an opaque type! |
| 1084 | const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T); |
| 1085 | return true; |
| 1086 | } |
| 1087 | |
| 1088 | // Otherwise, this is an attempt to redefine a type. That's okay if |
| 1089 | // the redefinition is identical to the original. This will be so if |
| 1090 | // Existing and T point to the same Type object. In this one case we |
| 1091 | // allow the equivalent redefinition. |
| 1092 | if (Existing == T) return true; // Yes, it's equal. |
| 1093 | |
| 1094 | // Any other kind of (non-equivalent) redefinition is an error. |
Reid Spencer | 63c3445 | 2007-01-05 21:51:07 +0000 | [diff] [blame] | 1095 | GenerateError("Redefinition of type named '" + Name + "' of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 1096 | T->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1097 | } |
| 1098 | |
| 1099 | return false; |
| 1100 | } |
| 1101 | |
| 1102 | //===----------------------------------------------------------------------===// |
| 1103 | // Code for handling upreferences in type names... |
| 1104 | // |
| 1105 | |
| 1106 | // TypeContains - Returns true if Ty directly contains E in it. |
| 1107 | // |
| 1108 | static bool TypeContains(const Type *Ty, const Type *E) { |
| 1109 | return std::find(Ty->subtype_begin(), Ty->subtype_end(), |
| 1110 | E) != Ty->subtype_end(); |
| 1111 | } |
| 1112 | |
| 1113 | namespace { |
| 1114 | struct UpRefRecord { |
| 1115 | // NestingLevel - The number of nesting levels that need to be popped before |
| 1116 | // this type is resolved. |
| 1117 | unsigned NestingLevel; |
| 1118 | |
| 1119 | // LastContainedTy - This is the type at the current binding level for the |
| 1120 | // type. Every time we reduce the nesting level, this gets updated. |
| 1121 | const Type *LastContainedTy; |
| 1122 | |
| 1123 | // UpRefTy - This is the actual opaque type that the upreference is |
| 1124 | // represented with. |
| 1125 | OpaqueType *UpRefTy; |
| 1126 | |
| 1127 | UpRefRecord(unsigned NL, OpaqueType *URTy) |
| 1128 | : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {} |
| 1129 | }; |
| 1130 | } |
| 1131 | |
| 1132 | // UpRefs - A list of the outstanding upreferences that need to be resolved. |
| 1133 | static std::vector<UpRefRecord> UpRefs; |
| 1134 | |
| 1135 | /// HandleUpRefs - Every time we finish a new layer of types, this function is |
| 1136 | /// called. It loops through the UpRefs vector, which is a list of the |
| 1137 | /// currently active types. For each type, if the up reference is contained in |
| 1138 | /// the newly completed type, we decrement the level count. When the level |
| 1139 | /// count reaches zero, the upreferenced type is the type that is passed in: |
| 1140 | /// thus we can complete the cycle. |
| 1141 | /// |
| 1142 | static PATypeHolder HandleUpRefs(const Type *ty) { |
Chris Lattner | 224f84f | 2006-08-18 17:34:45 +0000 | [diff] [blame] | 1143 | // If Ty isn't abstract, or if there are no up-references in it, then there is |
| 1144 | // nothing to resolve here. |
| 1145 | if (!ty->isAbstract() || UpRefs.empty()) return ty; |
| 1146 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1147 | PATypeHolder Ty(ty); |
| 1148 | UR_OUT("Type '" << Ty->getDescription() << |
| 1149 | "' newly formed. Resolving upreferences.\n" << |
| 1150 | UpRefs.size() << " upreferences active!\n"); |
| 1151 | |
| 1152 | // If we find any resolvable upreferences (i.e., those whose NestingLevel goes |
| 1153 | // to zero), we resolve them all together before we resolve them to Ty. At |
| 1154 | // the end of the loop, if there is anything to resolve to Ty, it will be in |
| 1155 | // this variable. |
| 1156 | OpaqueType *TypeToResolve = 0; |
| 1157 | |
| 1158 | for (unsigned i = 0; i != UpRefs.size(); ++i) { |
| 1159 | UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " |
| 1160 | << UpRefs[i].second->getDescription() << ") = " |
| 1161 | << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); |
| 1162 | if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { |
| 1163 | // Decrement level of upreference |
| 1164 | unsigned Level = --UpRefs[i].NestingLevel; |
| 1165 | UpRefs[i].LastContainedTy = Ty; |
| 1166 | UR_OUT(" Uplevel Ref Level = " << Level << "\n"); |
| 1167 | if (Level == 0) { // Upreference should be resolved! |
| 1168 | if (!TypeToResolve) { |
| 1169 | TypeToResolve = UpRefs[i].UpRefTy; |
| 1170 | } else { |
| 1171 | UR_OUT(" * Resolving upreference for " |
| 1172 | << UpRefs[i].second->getDescription() << "\n"; |
| 1173 | std::string OldName = UpRefs[i].UpRefTy->getDescription()); |
| 1174 | UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve); |
| 1175 | UR_OUT(" * Type '" << OldName << "' refined upreference to: " |
| 1176 | << (const void*)Ty << ", " << Ty->getDescription() << "\n"); |
| 1177 | } |
| 1178 | UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... |
| 1179 | --i; // Do not skip the next element... |
| 1180 | } |
| 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | if (TypeToResolve) { |
| 1185 | UR_OUT(" * Resolving upreference for " |
| 1186 | << UpRefs[i].second->getDescription() << "\n"; |
| 1187 | std::string OldName = TypeToResolve->getDescription()); |
| 1188 | TypeToResolve->refineAbstractTypeTo(Ty); |
| 1189 | } |
| 1190 | |
| 1191 | return Ty; |
| 1192 | } |
| 1193 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1194 | //===----------------------------------------------------------------------===// |
| 1195 | // RunVMAsmParser - Define an interface to this parser |
| 1196 | //===----------------------------------------------------------------------===// |
| 1197 | // |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1198 | static Module* RunParser(Module * M); |
| 1199 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1200 | Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { |
| 1201 | set_scan_file(F); |
| 1202 | |
| 1203 | CurFilename = Filename; |
| 1204 | return RunParser(new Module(CurFilename)); |
| 1205 | } |
| 1206 | |
| 1207 | Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { |
| 1208 | set_scan_string(AsmString); |
| 1209 | |
| 1210 | CurFilename = "from_memory"; |
| 1211 | if (M == NULL) { |
| 1212 | return RunParser(new Module (CurFilename)); |
| 1213 | } else { |
| 1214 | return RunParser(M); |
| 1215 | } |
| 1216 | } |
| 1217 | |
| 1218 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1219 | |
| 1220 | /* Enabling traces. */ |
| 1221 | #ifndef YYDEBUG |
| 1222 | # define YYDEBUG 0 |
| 1223 | #endif |
| 1224 | |
| 1225 | /* Enabling verbose error messages. */ |
| 1226 | #ifdef YYERROR_VERBOSE |
| 1227 | # undef YYERROR_VERBOSE |
| 1228 | # define YYERROR_VERBOSE 1 |
| 1229 | #else |
| 1230 | # define YYERROR_VERBOSE 0 |
| 1231 | #endif |
| 1232 | |
| 1233 | /* Enabling the token table. */ |
| 1234 | #ifndef YYTOKEN_TABLE |
| 1235 | # define YYTOKEN_TABLE 0 |
| 1236 | #endif |
| 1237 | |
| 1238 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 1239 | #line 900 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1240 | typedef union YYSTYPE { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1241 | llvm::Module *ModuleVal; |
| 1242 | llvm::Function *FunctionVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1243 | llvm::BasicBlock *BasicBlockVal; |
| 1244 | llvm::TerminatorInst *TermInstVal; |
| 1245 | llvm::Instruction *InstVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1246 | llvm::Constant *ConstVal; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1247 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1248 | const llvm::Type *PrimType; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1249 | std::list<llvm::PATypeHolder> *TypeList; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1250 | llvm::PATypeHolder *TypeVal; |
| 1251 | llvm::Value *ValueVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1252 | std::vector<llvm::Value*> *ValueList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1253 | llvm::ArgListType *ArgList; |
| 1254 | llvm::TypeWithAttrs TypeWithAttrs; |
| 1255 | llvm::TypeWithAttrsList *TypeWithAttrsList; |
| 1256 | llvm::ValueRefList *ValueRefList; |
| 1257 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1258 | // Represent the RHS of PHI node |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1259 | std::list<std::pair<llvm::Value*, |
| 1260 | llvm::BasicBlock*> > *PHIList; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1261 | std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1262 | std::vector<llvm::Constant*> *ConstVector; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1263 | |
| 1264 | llvm::GlobalValue::LinkageTypes Linkage; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1265 | llvm::GlobalValue::VisibilityTypes Visibility; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 1266 | llvm::FunctionType::ParameterAttributes ParamAttrs; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1267 | int64_t SInt64Val; |
| 1268 | uint64_t UInt64Val; |
| 1269 | int SIntVal; |
| 1270 | unsigned UIntVal; |
| 1271 | double FPVal; |
| 1272 | bool BoolVal; |
| 1273 | |
| 1274 | char *StrVal; // This memory is strdup'd! |
Reid Spencer | 1628cec | 2006-10-26 06:15:43 +0000 | [diff] [blame] | 1275 | llvm::ValID ValIDVal; // strdup'd memory maybe! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1276 | |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1277 | llvm::Instruction::BinaryOps BinaryOpVal; |
| 1278 | llvm::Instruction::TermOps TermOpVal; |
| 1279 | llvm::Instruction::MemoryOps MemOpVal; |
| 1280 | llvm::Instruction::CastOps CastOpVal; |
| 1281 | llvm::Instruction::OtherOps OtherOpVal; |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 1282 | llvm::ICmpInst::Predicate IPredicate; |
| 1283 | llvm::FCmpInst::Predicate FPredicate; |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 1284 | } YYSTYPE; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1285 | /* Line 196 of yacc.c. */ |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 1286 | #line 1287 "llvmAsmParser.tab.c" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1287 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
| 1288 | # define YYSTYPE_IS_DECLARED 1 |
| 1289 | # define YYSTYPE_IS_TRIVIAL 1 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1290 | #endif |
| 1291 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1292 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1293 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1294 | /* Copy the second part of user declarations. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 1295 | |
| 1296 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1297 | /* Line 219 of yacc.c. */ |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 1298 | #line 1299 "llvmAsmParser.tab.c" |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1299 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1300 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) |
| 1301 | # define YYSIZE_T __SIZE_TYPE__ |
| 1302 | #endif |
| 1303 | #if ! defined (YYSIZE_T) && defined (size_t) |
| 1304 | # define YYSIZE_T size_t |
| 1305 | #endif |
| 1306 | #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) |
| 1307 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
| 1308 | # define YYSIZE_T size_t |
| 1309 | #endif |
| 1310 | #if ! defined (YYSIZE_T) |
| 1311 | # define YYSIZE_T unsigned int |
| 1312 | #endif |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 1313 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1314 | #ifndef YY_ |
| 1315 | # if YYENABLE_NLS |
| 1316 | # if ENABLE_NLS |
| 1317 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
| 1318 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
| 1319 | # endif |
| 1320 | # endif |
| 1321 | # ifndef YY_ |
| 1322 | # define YY_(msgid) msgid |
| 1323 | # endif |
| 1324 | #endif |
| 1325 | |
| 1326 | #if ! defined (yyoverflow) || YYERROR_VERBOSE |
| 1327 | |
| 1328 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
| 1329 | |
| 1330 | # ifdef YYSTACK_USE_ALLOCA |
| 1331 | # if YYSTACK_USE_ALLOCA |
| 1332 | # ifdef __GNUC__ |
| 1333 | # define YYSTACK_ALLOC __builtin_alloca |
| 1334 | # else |
| 1335 | # define YYSTACK_ALLOC alloca |
| 1336 | # if defined (__STDC__) || defined (__cplusplus) |
| 1337 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
| 1338 | # define YYINCLUDED_STDLIB_H |
| 1339 | # endif |
| 1340 | # endif |
| 1341 | # endif |
| 1342 | # endif |
| 1343 | |
| 1344 | # ifdef YYSTACK_ALLOC |
| 1345 | /* Pacify GCC's `empty if-body' warning. */ |
| 1346 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
| 1347 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1348 | /* The OS might guarantee only one guard page at the bottom of the stack, |
| 1349 | and a page size can be as small as 4096 bytes. So we cannot safely |
| 1350 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
| 1351 | to allow for a few compiler-allocated temporary stack slots. */ |
| 1352 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ |
| 1353 | # endif |
| 1354 | # else |
| 1355 | # define YYSTACK_ALLOC YYMALLOC |
| 1356 | # define YYSTACK_FREE YYFREE |
| 1357 | # ifndef YYSTACK_ALLOC_MAXIMUM |
| 1358 | # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) |
| 1359 | # endif |
| 1360 | # ifdef __cplusplus |
| 1361 | extern "C" { |
| 1362 | # endif |
| 1363 | # ifndef YYMALLOC |
| 1364 | # define YYMALLOC malloc |
| 1365 | # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 1366 | && (defined (__STDC__) || defined (__cplusplus))) |
| 1367 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
| 1368 | # endif |
| 1369 | # endif |
| 1370 | # ifndef YYFREE |
| 1371 | # define YYFREE free |
| 1372 | # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ |
| 1373 | && (defined (__STDC__) || defined (__cplusplus))) |
| 1374 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
| 1375 | # endif |
| 1376 | # endif |
| 1377 | # ifdef __cplusplus |
| 1378 | } |
| 1379 | # endif |
| 1380 | # endif |
| 1381 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ |
| 1382 | |
| 1383 | |
| 1384 | #if (! defined (yyoverflow) \ |
| 1385 | && (! defined (__cplusplus) \ |
| 1386 | || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) |
| 1387 | |
| 1388 | /* A type that is properly aligned for any stack member. */ |
| 1389 | union yyalloc |
| 1390 | { |
| 1391 | short int yyss; |
| 1392 | YYSTYPE yyvs; |
| 1393 | }; |
| 1394 | |
| 1395 | /* The size of the maximum gap between one aligned stack and the next. */ |
| 1396 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| 1397 | |
| 1398 | /* The size of an array large to enough to hold all stacks, each with |
| 1399 | N elements. */ |
| 1400 | # define YYSTACK_BYTES(N) \ |
| 1401 | ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ |
| 1402 | + YYSTACK_GAP_MAXIMUM) |
| 1403 | |
| 1404 | /* Copy COUNT objects from FROM to TO. The source and destination do |
| 1405 | not overlap. */ |
| 1406 | # ifndef YYCOPY |
| 1407 | # if defined (__GNUC__) && 1 < __GNUC__ |
| 1408 | # define YYCOPY(To, From, Count) \ |
| 1409 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
| 1410 | # else |
| 1411 | # define YYCOPY(To, From, Count) \ |
| 1412 | do \ |
| 1413 | { \ |
| 1414 | YYSIZE_T yyi; \ |
| 1415 | for (yyi = 0; yyi < (Count); yyi++) \ |
| 1416 | (To)[yyi] = (From)[yyi]; \ |
| 1417 | } \ |
| 1418 | while (0) |
| 1419 | # endif |
| 1420 | # endif |
| 1421 | |
| 1422 | /* Relocate STACK from its old location to the new one. The |
| 1423 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
| 1424 | elements in the stack, and YYPTR gives the new location of the |
| 1425 | stack. Advance YYPTR to a properly aligned location for the next |
| 1426 | stack. */ |
| 1427 | # define YYSTACK_RELOCATE(Stack) \ |
| 1428 | do \ |
| 1429 | { \ |
| 1430 | YYSIZE_T yynewbytes; \ |
| 1431 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
| 1432 | Stack = &yyptr->Stack; \ |
| 1433 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
| 1434 | yyptr += yynewbytes / sizeof (*yyptr); \ |
| 1435 | } \ |
| 1436 | while (0) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 1437 | |
| 1438 | #endif |
| 1439 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1440 | #if defined (__STDC__) || defined (__cplusplus) |
| 1441 | typedef signed char yysigned_char; |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 1442 | #else |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1443 | typedef short int yysigned_char; |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 1444 | #endif |
| 1445 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1446 | /* YYFINAL -- State number of the termination state. */ |
| 1447 | #define YYFINAL 40 |
| 1448 | /* YYLAST -- Last index in YYTABLE. */ |
| 1449 | #define YYLAST 1439 |
| 1450 | |
| 1451 | /* YYNTOKENS -- Number of terminals. */ |
| 1452 | #define YYNTOKENS 146 |
| 1453 | /* YYNNTS -- Number of nonterminals. */ |
| 1454 | #define YYNNTS 78 |
| 1455 | /* YYNRULES -- Number of rules. */ |
| 1456 | #define YYNRULES 284 |
| 1457 | /* YYNRULES -- Number of states. */ |
| 1458 | #define YYNSTATES 557 |
| 1459 | |
| 1460 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
| 1461 | #define YYUNDEFTOK 2 |
| 1462 | #define YYMAXUTOK 386 |
| 1463 | |
| 1464 | #define YYTRANSLATE(YYX) \ |
| 1465 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| 1466 | |
| 1467 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
| 1468 | static const unsigned char yytranslate[] = |
| 1469 | { |
| 1470 | 0, 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 | 136, 137, 134, 2, 133, 2, 2, 2, 2, 2, |
| 1475 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1476 | 141, 132, 142, 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, 138, 135, 140, 2, 2, 2, 2, 2, 145, |
| 1480 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1481 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1482 | 139, 2, 2, 143, 2, 144, 2, 2, 2, 2, |
| 1483 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1484 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1485 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1486 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1487 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1488 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1489 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1490 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1491 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1492 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1493 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1494 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1495 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
| 1496 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
| 1497 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 1498 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, |
| 1499 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, |
| 1500 | 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 1501 | 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, |
| 1502 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, |
| 1503 | 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, |
| 1504 | 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 1505 | 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, |
| 1506 | 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, |
| 1507 | 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, |
| 1508 | 125, 126, 127, 128, 129, 130, 131 |
| 1509 | }; |
| 1510 | |
| 1511 | #if YYDEBUG |
| 1512 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
| 1513 | YYRHS. */ |
| 1514 | static const unsigned short int yyprhs[] = |
| 1515 | { |
| 1516 | 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, |
| 1517 | 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, |
| 1518 | 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, |
| 1519 | 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, |
| 1520 | 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, |
| 1521 | 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, |
| 1522 | 119, 121, 122, 125, 126, 128, 130, 133, 134, 136, |
| 1523 | 138, 140, 142, 144, 146, 148, 150, 151, 153, 154, |
| 1524 | 156, 158, 159, 161, 163, 165, 167, 168, 170, 172, |
| 1525 | 174, 176, 178, 181, 183, 185, 187, 189, 190, 193, |
| 1526 | 195, 197, 198, 201, 202, 205, 206, 210, 213, 214, |
| 1527 | 216, 217, 221, 223, 226, 228, 230, 232, 234, 236, |
| 1528 | 238, 241, 243, 246, 252, 258, 264, 270, 274, 277, |
| 1529 | 283, 288, 291, 293, 295, 297, 301, 303, 307, 309, |
| 1530 | 310, 312, 316, 321, 325, 329, 334, 339, 343, 350, |
| 1531 | 356, 359, 362, 365, 368, 371, 374, 377, 380, 383, |
| 1532 | 386, 393, 399, 408, 415, 422, 430, 438, 445, 454, |
| 1533 | 463, 467, 469, 471, 473, 475, 476, 478, 481, 482, |
| 1534 | 486, 487, 491, 495, 497, 501, 505, 506, 513, 514, |
| 1535 | 522, 523, 531, 534, 538, 540, 544, 548, 552, 556, |
| 1536 | 558, 559, 565, 569, 571, 575, 577, 578, 588, 590, |
| 1537 | 592, 597, 599, 601, 604, 608, 609, 611, 613, 615, |
| 1538 | 617, 619, 621, 623, 625, 627, 631, 633, 639, 641, |
| 1539 | 643, 645, 647, 649, 651, 654, 657, 660, 664, 667, |
| 1540 | 668, 670, 673, 676, 680, 690, 700, 709, 724, 726, |
| 1541 | 728, 735, 741, 744, 751, 759, 763, 769, 770, 771, |
| 1542 | 775, 778, 780, 786, 792, 799, 806, 811, 818, 823, |
| 1543 | 828, 835, 842, 845, 854, 856, 858, 859, 863, 870, |
| 1544 | 874, 881, 884, 889, 896 |
| 1545 | }; |
| 1546 | |
| 1547 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
| 1548 | static const short int yyrhs[] = |
| 1549 | { |
| 1550 | 186, 0, -1, 66, -1, 67, -1, 68, -1, 69, |
| 1551 | -1, 70, -1, 71, -1, 72, -1, 73, -1, 74, |
| 1552 | -1, 78, -1, 79, -1, 80, -1, 75, -1, 76, |
| 1553 | -1, 77, -1, 109, -1, 110, -1, 111, -1, 112, |
| 1554 | -1, 113, -1, 114, -1, 115, -1, 116, -1, 117, |
| 1555 | -1, 118, -1, 119, -1, 120, -1, 83, -1, 84, |
| 1556 | -1, 85, -1, 86, -1, 87, -1, 88, -1, 89, |
| 1557 | -1, 90, -1, 91, -1, 92, -1, 93, -1, 94, |
| 1558 | -1, 95, -1, 96, -1, 97, -1, 98, -1, 99, |
| 1559 | -1, 100, -1, 101, -1, 102, -1, 89, -1, 90, |
| 1560 | -1, 91, -1, 92, -1, 21, -1, 22, -1, 9, |
| 1561 | -1, 10, -1, 11, -1, 14, -1, 17, -1, 154, |
| 1562 | -1, -1, 154, 132, -1, -1, 15, -1, 18, -1, |
| 1563 | 157, 132, -1, -1, 35, -1, 37, -1, 36, -1, |
| 1564 | 38, -1, 40, -1, 39, -1, 41, -1, 43, -1, |
| 1565 | -1, 131, -1, -1, 39, -1, 41, -1, -1, 35, |
| 1566 | -1, 36, -1, 37, -1, 40, -1, -1, 54, -1, |
| 1567 | 55, -1, 56, -1, 57, -1, 58, -1, 53, 4, |
| 1568 | -1, 110, -1, 111, -1, 128, -1, 129, -1, -1, |
| 1569 | 166, 165, -1, 127, -1, 165, -1, -1, 168, 167, |
| 1570 | -1, -1, 46, 4, -1, -1, 133, 46, 4, -1, |
| 1571 | 29, 17, -1, -1, 171, -1, -1, 133, 174, 173, |
| 1572 | -1, 171, -1, 46, 4, -1, 9, -1, 10, -1, |
| 1573 | 11, -1, 12, -1, 42, -1, 175, -1, 176, 134, |
| 1574 | -1, 208, -1, 135, 4, -1, 176, 136, 180, 137, |
| 1575 | 168, -1, 8, 136, 180, 137, 168, -1, 138, 4, |
| 1576 | 139, 176, 140, -1, 141, 4, 139, 176, 142, -1, |
| 1577 | 143, 181, 144, -1, 143, 144, -1, 141, 143, 181, |
| 1578 | 144, 142, -1, 141, 143, 144, 142, -1, 176, 166, |
| 1579 | -1, 176, -1, 8, -1, 177, -1, 179, 133, 177, |
| 1580 | -1, 179, -1, 179, 133, 32, -1, 32, -1, -1, |
| 1581 | 176, -1, 181, 133, 176, -1, 176, 138, 184, 140, |
| 1582 | -1, 176, 138, 140, -1, 176, 145, 17, -1, 176, |
| 1583 | 141, 184, 142, -1, 176, 143, 184, 144, -1, 176, |
| 1584 | 143, 144, -1, 176, 141, 143, 184, 144, 142, -1, |
| 1585 | 176, 141, 143, 144, 142, -1, 176, 33, -1, 176, |
| 1586 | 34, -1, 176, 208, -1, 176, 183, -1, 176, 20, |
| 1587 | -1, 152, 3, -1, 152, 4, -1, 9, 21, -1, |
| 1588 | 9, 22, -1, 153, 7, -1, 149, 136, 182, 31, |
| 1589 | 176, 137, -1, 108, 136, 182, 219, 137, -1, 122, |
| 1590 | 136, 182, 133, 182, 133, 182, 137, -1, 147, 136, |
| 1591 | 182, 133, 182, 137, -1, 148, 136, 182, 133, 182, |
| 1592 | 137, -1, 81, 150, 136, 182, 133, 182, 137, -1, |
| 1593 | 82, 151, 136, 182, 133, 182, 137, -1, 124, 136, |
| 1594 | 182, 133, 182, 137, -1, 125, 136, 182, 133, 182, |
| 1595 | 133, 182, 137, -1, 126, 136, 182, 133, 182, 133, |
| 1596 | 182, 137, -1, 184, 133, 182, -1, 182, -1, 27, |
| 1597 | -1, 28, -1, 187, -1, -1, 188, -1, 187, 188, |
| 1598 | -1, -1, 26, 189, 204, -1, -1, 25, 190, 205, |
| 1599 | -1, 51, 50, 194, -1, 19, -1, 156, 13, 176, |
| 1600 | -1, 156, 13, 8, -1, -1, 158, 161, 185, 182, |
| 1601 | 191, 173, -1, -1, 158, 159, 161, 185, 182, 192, |
| 1602 | 173, -1, -1, 158, 160, 161, 185, 176, 193, 173, |
| 1603 | -1, 44, 195, -1, 47, 132, 196, -1, 17, -1, |
| 1604 | 45, 132, 17, -1, 59, 132, 17, -1, 138, 197, |
| 1605 | 140, -1, 197, 133, 17, -1, 17, -1, -1, 198, |
| 1606 | 133, 176, 166, 155, -1, 176, 166, 155, -1, 198, |
| 1607 | -1, 198, 133, 32, -1, 32, -1, -1, 164, 178, |
| 1608 | 157, 136, 199, 137, 168, 172, 169, -1, 23, -1, |
| 1609 | 143, -1, 163, 161, 200, 201, -1, 24, -1, 144, |
| 1610 | -1, 211, 203, -1, 162, 161, 200, -1, -1, 52, |
| 1611 | -1, 3, -1, 4, -1, 7, -1, 21, -1, 22, |
| 1612 | -1, 33, -1, 34, -1, 20, -1, 141, 184, 142, |
| 1613 | -1, 183, -1, 50, 206, 17, 133, 17, -1, 5, |
| 1614 | -1, 6, -1, 154, -1, 157, -1, 208, -1, 207, |
| 1615 | -1, 176, 209, -1, 211, 212, -1, 202, 212, -1, |
| 1616 | 213, 156, 214, -1, 213, 216, -1, -1, 16, -1, |
| 1617 | 60, 210, -1, 60, 8, -1, 61, 12, 209, -1, |
| 1618 | 61, 9, 209, 133, 12, 209, 133, 12, 209, -1, |
| 1619 | 62, 152, 209, 133, 12, 209, 138, 215, 140, -1, |
| 1620 | 62, 152, 209, 133, 12, 209, 138, 140, -1, 63, |
| 1621 | 164, 178, 209, 136, 218, 137, 168, 31, 12, 209, |
| 1622 | 64, 12, 209, -1, 64, -1, 65, -1, 215, 152, |
| 1623 | 207, 133, 12, 209, -1, 152, 207, 133, 12, 209, |
| 1624 | -1, 156, 221, -1, 176, 138, 209, 133, 209, 140, |
| 1625 | -1, 217, 133, 138, 209, 133, 209, 140, -1, 176, |
| 1626 | 209, 166, -1, 218, 133, 176, 209, 166, -1, -1, |
| 1627 | -1, 219, 133, 210, -1, 49, 48, -1, 48, -1, |
| 1628 | 147, 176, 209, 133, 209, -1, 148, 176, 209, 133, |
| 1629 | 209, -1, 81, 150, 176, 209, 133, 209, -1, 82, |
| 1630 | 151, 176, 209, 133, 209, -1, 149, 210, 31, 176, |
| 1631 | -1, 122, 210, 133, 210, 133, 210, -1, 123, 210, |
| 1632 | 133, 176, -1, 124, 210, 133, 210, -1, 125, 210, |
| 1633 | 133, 210, 133, 210, -1, 126, 210, 133, 210, 133, |
| 1634 | 210, -1, 121, 217, -1, 220, 164, 178, 209, 136, |
| 1635 | 218, 137, 168, -1, 223, -1, 30, -1, -1, 103, |
| 1636 | 176, 170, -1, 103, 176, 133, 9, 209, 170, -1, |
| 1637 | 104, 176, 170, -1, 104, 176, 133, 9, 209, 170, |
| 1638 | -1, 105, 210, -1, 222, 106, 176, 209, -1, 222, |
| 1639 | 107, 210, 133, 176, 209, -1, 108, 176, 209, 219, |
| 1640 | -1 |
| 1641 | }; |
| 1642 | |
| 1643 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
| 1644 | static const unsigned short int yyrline[] = |
| 1645 | { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 1646 | 0, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, |
| 1647 | 1047, 1048, 1048, 1048, 1048, 1048, 1048, 1049, 1049, 1049, |
| 1648 | 1049, 1049, 1049, 1050, 1050, 1050, 1050, 1050, 1050, 1053, |
| 1649 | 1053, 1054, 1054, 1055, 1055, 1056, 1056, 1057, 1057, 1061, |
| 1650 | 1061, 1062, 1062, 1063, 1063, 1064, 1064, 1065, 1065, 1066, |
| 1651 | 1066, 1067, 1067, 1068, 1069, 1074, 1075, 1075, 1077, 1077, |
| 1652 | 1078, 1078, 1082, 1086, 1091, 1091, 1093, 1097, 1103, 1104, |
| 1653 | 1105, 1106, 1107, 1111, 1112, 1113, 1117, 1118, 1122, 1123, |
| 1654 | 1124, 1128, 1129, 1130, 1131, 1132, 1135, 1136, 1137, 1138, |
| 1655 | 1139, 1140, 1141, 1148, 1149, 1150, 1151, 1154, 1155, 1160, |
| 1656 | 1161, 1164, 1165, 1172, 1173, 1179, 1180, 1188, 1196, 1197, |
| 1657 | 1202, 1203, 1204, 1209, 1222, 1222, 1222, 1222, 1225, 1229, |
| 1658 | 1233, 1240, 1245, 1253, 1271, 1289, 1294, 1306, 1316, 1320, |
| 1659 | 1330, 1337, 1344, 1351, 1356, 1361, 1368, 1369, 1376, 1383, |
| 1660 | 1391, 1396, 1407, 1435, 1451, 1480, 1508, 1533, 1552, 1577, |
| 1661 | 1596, 1608, 1615, 1681, 1691, 1701, 1707, 1713, 1718, 1723, |
| 1662 | 1731, 1743, 1764, 1772, 1778, 1789, 1794, 1799, 1805, 1811, |
| 1663 | 1820, 1824, 1832, 1832, 1843, 1848, 1856, 1857, 1861, 1861, |
| 1664 | 1865, 1865, 1868, 1871, 1883, 1907, 1918, 1918, 1928, 1928, |
| 1665 | 1936, 1936, 1946, 1949, 1955, 1968, 1972, 1977, 1979, 1984, |
| 1666 | 1989, 1998, 2008, 2019, 2023, 2032, 2041, 2046, 2158, 2158, |
| 1667 | 2160, 2169, 2169, 2171, 2176, 2188, 2192, 2197, 2201, 2205, |
| 1668 | 2209, 2213, 2217, 2221, 2225, 2229, 2254, 2258, 2272, 2276, |
| 1669 | 2280, 2284, 2290, 2290, 2296, 2305, 2309, 2318, 2328, 2337, |
| 1670 | 2349, 2362, 2366, 2370, 2375, 2385, 2404, 2413, 2480, 2484, |
| 1671 | 2491, 2502, 2515, 2525, 2536, 2546, 2554, 2562, 2565, 2566, |
| 1672 | 2573, 2577, 2582, 2603, 2620, 2633, 2646, 2658, 2666, 2673, |
| 1673 | 2679, 2685, 2691, 2706, 2770, 2775, 2779, 2786, 2793, 2801, |
| 1674 | 2808, 2816, 2824, 2838, 2855 |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 1675 | }; |
| 1676 | #endif |
| 1677 | |
| 1678 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
| 1679 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
| 1680 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
| 1681 | static const char *const yytname[] = |
| 1682 | { |
| 1683 | "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", |
| 1684 | "LOCALVAL_ID", "GLOBALVAL_ID", "FPVAL", "VOID", "INTTYPE", "FLOAT", |
| 1685 | "DOUBLE", "LABEL", "TYPE", "LOCALVAR", "GLOBALVAR", "LABELSTR", |
| 1686 | "STRINGCONSTANT", "ATSTRINGCONSTANT", "IMPLEMENTATION", |
| 1687 | "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK", |
| 1688 | "DECLARE", "DEFINE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO", |
| 1689 | "DOTDOTDOT", "NULL_TOK", "UNDEF", "INTERNAL", "LINKONCE", "WEAK", |
| 1690 | "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE", |
| 1691 | "EXTERNAL", "TARGET", "TRIPLE", "ALIGN", "DEPLIBS", "CALL", "TAIL", |
| 1692 | "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK", "FASTCC_TOK", |
| 1693 | "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT", |
| 1694 | "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", |
| 1695 | "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR", |
| 1696 | "XOR", "SHL", "LSHR", "ASHR", "ICMP", "FCMP", "EQ", "NE", "SLT", "SGT", |
| 1697 | "SLE", "SGE", "ULT", "UGT", "ULE", "UGE", "OEQ", "ONE", "OLT", "OGT", |
| 1698 | "OLE", "OGE", "ORD", "UNO", "UEQ", "UNE", "MALLOC", "ALLOCA", "FREE", |
| 1699 | "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT", "SEXT", "FPTRUNC", |
| 1700 | "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI", "FPTOSI", "INTTOPTR", |
| 1701 | "PTRTOINT", "PHI_TOK", "SELECT", "VAARG", "EXTRACTELEMENT", |
| 1702 | "INSERTELEMENT", "SHUFFLEVECTOR", "NORETURN", "INREG", "SRET", "DEFAULT", |
| 1703 | "HIDDEN", "'='", "','", "'*'", "'\\\\'", "'('", "')'", "'['", "'x'", |
| 1704 | "']'", "'<'", "'>'", "'{'", "'}'", "'c'", "$accept", "ArithmeticOps", |
| 1705 | "LogicalOps", "CastOps", "IPredicates", "FPredicates", "IntType", |
| 1706 | "FPType", "LocalName", "OptLocalName", "OptLocalAssign", "GlobalName", |
| 1707 | "OptGlobalAssign", "GVInternalLinkage", "GVExternalLinkage", |
| 1708 | "GVVisibilityStyle", "FunctionDeclareLinkage", "FunctionDefineLinkage", |
| 1709 | "OptCallingConv", "ParamAttr", "OptParamAttrs", "FuncAttr", |
| 1710 | "OptFuncAttrs", "OptAlign", "OptCAlign", "SectionString", "OptSection", |
| 1711 | "GlobalVarAttributes", "GlobalVarAttribute", "PrimType", "Types", |
| 1712 | "ArgType", "ResultTypes", "ArgTypeList", "ArgTypeListI", "TypeListI", |
| 1713 | "ConstVal", "ConstExpr", "ConstVector", "GlobalType", "Module", |
| 1714 | "DefinitionList", "Definition", "@1", "@2", "@3", "@4", "@5", "AsmBlock", |
| 1715 | "TargetDefinition", "LibrariesDefinition", "LibList", "ArgListH", |
| 1716 | "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", |
| 1717 | "Function", "FunctionProto", "OptSideEffect", "ConstValueRef", |
| 1718 | "SymbolicValueRef", "ValueRef", "ResolvedVal", "BasicBlockList", |
| 1719 | "BasicBlock", "InstructionList", "BBTerminatorInst", "JumpTable", "Inst", |
| 1720 | "PHIList", "ValueRefList", "IndexList", "OptTailCall", "InstVal", |
| 1721 | "OptVolatile", "MemoryInst", 0 |
| 1722 | }; |
| 1723 | #endif |
| 1724 | |
| 1725 | # ifdef YYPRINT |
| 1726 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
| 1727 | token YYLEX-NUM. */ |
| 1728 | static const unsigned short int yytoknum[] = |
| 1729 | { |
| 1730 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 1731 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
| 1732 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, |
| 1733 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, |
| 1734 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, |
| 1735 | 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, |
| 1736 | 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, |
| 1737 | 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, |
| 1738 | 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, |
| 1739 | 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, |
| 1740 | 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, |
| 1741 | 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, |
| 1742 | 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, |
| 1743 | 385, 386, 61, 44, 42, 92, 40, 41, 91, 120, |
| 1744 | 93, 60, 62, 123, 125, 99 |
| 1745 | }; |
| 1746 | # endif |
| 1747 | |
| 1748 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
| 1749 | static const unsigned char yyr1[] = |
| 1750 | { |
| 1751 | 0, 146, 147, 147, 147, 147, 147, 147, 147, 147, |
| 1752 | 147, 148, 148, 148, 148, 148, 148, 149, 149, 149, |
| 1753 | 149, 149, 149, 149, 149, 149, 149, 149, 149, 150, |
| 1754 | 150, 150, 150, 150, 150, 150, 150, 150, 150, 151, |
| 1755 | 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, |
| 1756 | 151, 151, 151, 151, 151, 152, 153, 153, 154, 154, |
| 1757 | 155, 155, 156, 156, 157, 157, 158, 158, 159, 159, |
| 1758 | 159, 159, 159, 160, 160, 160, 161, 161, 162, 162, |
| 1759 | 162, 163, 163, 163, 163, 163, 164, 164, 164, 164, |
| 1760 | 164, 164, 164, 165, 165, 165, 165, 166, 166, 167, |
| 1761 | 167, 168, 168, 169, 169, 170, 170, 171, 172, 172, |
| 1762 | 173, 173, 174, 174, 175, 175, 175, 175, 176, 176, |
| 1763 | 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, |
| 1764 | 176, 177, 178, 178, 179, 179, 180, 180, 180, 180, |
| 1765 | 181, 181, 182, 182, 182, 182, 182, 182, 182, 182, |
| 1766 | 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, |
| 1767 | 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, |
| 1768 | 184, 184, 185, 185, 186, 186, 187, 187, 189, 188, |
| 1769 | 190, 188, 188, 188, 188, 188, 191, 188, 192, 188, |
| 1770 | 193, 188, 188, 188, 194, 195, 195, 196, 197, 197, |
| 1771 | 197, 198, 198, 199, 199, 199, 199, 200, 201, 201, |
| 1772 | 202, 203, 203, 204, 205, 206, 206, 207, 207, 207, |
| 1773 | 207, 207, 207, 207, 207, 207, 207, 207, 208, 208, |
| 1774 | 208, 208, 209, 209, 210, 211, 211, 212, 213, 213, |
| 1775 | 213, 214, 214, 214, 214, 214, 214, 214, 214, 214, |
| 1776 | 215, 215, 216, 217, 217, 218, 218, 218, 219, 219, |
| 1777 | 220, 220, 221, 221, 221, 221, 221, 221, 221, 221, |
| 1778 | 221, 221, 221, 221, 221, 222, 222, 223, 223, 223, |
| 1779 | 223, 223, 223, 223, 223 |
| 1780 | }; |
| 1781 | |
| 1782 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
| 1783 | static const unsigned char yyr2[] = |
| 1784 | { |
| 1785 | 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1786 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1787 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1788 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1789 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1790 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1791 | 1, 0, 2, 0, 1, 1, 2, 0, 1, 1, |
| 1792 | 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, |
| 1793 | 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, |
| 1794 | 1, 1, 2, 1, 1, 1, 1, 0, 2, 1, |
| 1795 | 1, 0, 2, 0, 2, 0, 3, 2, 0, 1, |
| 1796 | 0, 3, 1, 2, 1, 1, 1, 1, 1, 1, |
| 1797 | 2, 1, 2, 5, 5, 5, 5, 3, 2, 5, |
| 1798 | 4, 2, 1, 1, 1, 3, 1, 3, 1, 0, |
| 1799 | 1, 3, 4, 3, 3, 4, 4, 3, 6, 5, |
| 1800 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 1801 | 6, 5, 8, 6, 6, 7, 7, 6, 8, 8, |
| 1802 | 3, 1, 1, 1, 1, 0, 1, 2, 0, 3, |
| 1803 | 0, 3, 3, 1, 3, 3, 0, 6, 0, 7, |
| 1804 | 0, 7, 2, 3, 1, 3, 3, 3, 3, 1, |
| 1805 | 0, 5, 3, 1, 3, 1, 0, 9, 1, 1, |
| 1806 | 4, 1, 1, 2, 3, 0, 1, 1, 1, 1, |
| 1807 | 1, 1, 1, 1, 1, 3, 1, 5, 1, 1, |
| 1808 | 1, 1, 1, 1, 2, 2, 2, 3, 2, 0, |
| 1809 | 1, 2, 2, 3, 9, 9, 8, 14, 1, 1, |
| 1810 | 6, 5, 2, 6, 7, 3, 5, 0, 0, 3, |
| 1811 | 2, 1, 5, 5, 6, 6, 4, 6, 4, 4, |
| 1812 | 6, 6, 2, 8, 1, 1, 0, 3, 6, 3, |
| 1813 | 6, 2, 4, 6, 4 |
| 1814 | }; |
| 1815 | |
| 1816 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
| 1817 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
| 1818 | means the default is an error. */ |
| 1819 | static const unsigned short int yydefact[] = |
| 1820 | { |
| 1821 | 67, 58, 64, 59, 65, 183, 180, 178, 0, 0, |
| 1822 | 0, 0, 0, 0, 76, 0, 67, 176, 78, 81, |
| 1823 | 0, 0, 192, 0, 0, 62, 0, 66, 68, 70, |
| 1824 | 69, 71, 73, 72, 74, 75, 77, 76, 76, 0, |
| 1825 | 1, 177, 79, 80, 76, 181, 82, 83, 84, 85, |
| 1826 | 76, 239, 179, 239, 0, 0, 200, 193, 194, 182, |
| 1827 | 228, 229, 185, 114, 115, 116, 117, 118, 0, 0, |
| 1828 | 0, 0, 230, 231, 119, 184, 121, 0, 0, 172, |
| 1829 | 173, 0, 86, 86, 240, 236, 63, 211, 212, 213, |
| 1830 | 235, 195, 196, 199, 0, 139, 122, 0, 0, 0, |
| 1831 | 0, 128, 140, 0, 120, 139, 0, 0, 114, 115, |
| 1832 | 116, 0, 0, 0, 186, 0, 87, 88, 89, 90, |
| 1833 | 91, 0, 214, 0, 276, 238, 0, 197, 138, 97, |
| 1834 | 134, 136, 0, 0, 0, 0, 0, 0, 127, 0, |
| 1835 | 188, 190, 157, 158, 155, 156, 159, 154, 150, 151, |
| 1836 | 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, |
| 1837 | 15, 16, 11, 12, 13, 0, 0, 0, 17, 18, |
| 1838 | 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, |
| 1839 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1840 | 0, 153, 152, 110, 92, 133, 132, 0, 208, 209, |
| 1841 | 210, 275, 261, 0, 0, 0, 0, 86, 248, 249, |
| 1842 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1843 | 0, 0, 0, 0, 0, 237, 86, 252, 0, 274, |
| 1844 | 198, 131, 0, 101, 0, 0, 130, 0, 141, 101, |
| 1845 | 110, 110, 29, 30, 31, 32, 33, 34, 35, 36, |
| 1846 | 37, 38, 0, 53, 54, 49, 50, 51, 52, 39, |
| 1847 | 40, 41, 42, 43, 44, 45, 46, 47, 48, 0, |
| 1848 | 0, 0, 0, 0, 0, 143, 171, 0, 0, 0, |
| 1849 | 147, 0, 144, 0, 0, 0, 0, 187, 0, 260, |
| 1850 | 242, 0, 241, 0, 0, 55, 0, 0, 0, 0, |
| 1851 | 105, 105, 281, 0, 0, 272, 0, 0, 0, 0, |
| 1852 | 0, 0, 0, 0, 0, 0, 0, 93, 94, 95, |
| 1853 | 96, 98, 137, 135, 124, 125, 126, 129, 123, 189, |
| 1854 | 191, 0, 0, 258, 0, 0, 0, 0, 0, 142, |
| 1855 | 128, 140, 0, 145, 146, 0, 0, 0, 0, 0, |
| 1856 | 112, 110, 206, 217, 218, 219, 224, 220, 221, 222, |
| 1857 | 223, 215, 0, 226, 233, 232, 234, 0, 243, 0, |
| 1858 | 0, 0, 0, 0, 277, 0, 279, 258, 0, 0, |
| 1859 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1860 | 0, 99, 100, 102, 0, 0, 0, 0, 0, 0, |
| 1861 | 0, 170, 149, 0, 0, 0, 0, 107, 113, 111, |
| 1862 | 205, 97, 203, 0, 216, 0, 0, 0, 0, 0, |
| 1863 | 0, 0, 0, 0, 0, 284, 0, 0, 0, 268, |
| 1864 | 269, 0, 0, 0, 0, 266, 0, 282, 0, 0, |
| 1865 | 0, 0, 161, 0, 0, 0, 0, 148, 0, 0, |
| 1866 | 0, 61, 0, 101, 0, 225, 0, 0, 257, 0, |
| 1867 | 0, 105, 106, 105, 0, 0, 0, 0, 0, 262, |
| 1868 | 263, 257, 0, 0, 0, 259, 0, 167, 0, 0, |
| 1869 | 163, 164, 160, 60, 202, 204, 97, 108, 0, 0, |
| 1870 | 0, 0, 0, 264, 265, 0, 278, 280, 0, 0, |
| 1871 | 267, 270, 271, 0, 283, 165, 166, 0, 0, 0, |
| 1872 | 61, 109, 103, 227, 0, 0, 97, 0, 101, 253, |
| 1873 | 0, 101, 162, 168, 169, 201, 0, 207, 0, 246, |
| 1874 | 0, 0, 255, 0, 0, 254, 273, 104, 244, 0, |
| 1875 | 245, 0, 97, 0, 0, 0, 256, 0, 0, 0, |
| 1876 | 0, 251, 0, 0, 250, 0, 247 |
| 1877 | }; |
| 1878 | |
| 1879 | /* YYDEFGOTO[NTERM-NUM]. */ |
| 1880 | static const short int yydefgoto[] = |
| 1881 | { |
| 1882 | -1, 188, 189, 190, 252, 269, 111, 112, 72, 484, |
| 1883 | 12, 73, 14, 37, 38, 39, 44, 50, 121, 321, |
| 1884 | 231, 393, 324, 527, 374, 350, 512, 287, 351, 74, |
| 1885 | 113, 130, 197, 131, 132, 103, 276, 363, 277, 81, |
| 1886 | 15, 16, 17, 19, 18, 193, 240, 241, 59, 22, |
| 1887 | 57, 94, 412, 413, 122, 200, 51, 89, 52, 45, |
| 1888 | 415, 364, 76, 366, 292, 53, 85, 86, 225, 531, |
| 1889 | 125, 305, 492, 396, 226, 227, 228, 229 |
| 1890 | }; |
| 1891 | |
| 1892 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
| 1893 | STATE-NUM. */ |
| 1894 | #define YYPACT_NINF -399 |
| 1895 | static const short int yypact[] = |
| 1896 | { |
| 1897 | 406, -399, -399, -399, -399, -399, -399, -399, -26, -114, |
| 1898 | -16, -53, 92, -11, 54, 136, 526, -399, 247, 173, |
| 1899 | 43, 49, -399, 62, 194, -399, 814, -399, -399, -399, |
| 1900 | -399, -399, -399, -399, -399, -399, -399, 134, 134, 99, |
| 1901 | -399, -399, -399, -399, 134, -399, -399, -399, -399, -399, |
| 1902 | 134, 212, -399, -1, 219, 225, 253, -399, -399, -399, |
| 1903 | -399, -399, 135, -399, -399, -399, -399, -399, 271, 275, |
| 1904 | 3, 33, -399, -399, -399, 160, -399, 99, 99, -399, |
| 1905 | -399, 1029, 287, 287, -399, -399, 220, -399, -399, -399, |
| 1906 | -399, -399, -399, -399, 20, 1071, -399, 141, 148, 105, |
| 1907 | 135, -399, 160, -75, -399, 1071, 1029, 1174, 32, 286, |
| 1908 | 293, 151, 294, 590, -399, 298, -399, -399, -399, -399, |
| 1909 | -399, 1190, -399, -13, 1313, -399, 289, -399, -399, 160, |
| 1910 | -399, 170, 167, 1174, 1174, 165, -68, 1174, -399, 174, |
| 1911 | -399, 160, -399, -399, -399, -399, -399, -399, -399, -399, |
| 1912 | -399, -399, -399, -399, -399, -399, -399, -399, -399, -399, |
| 1913 | -399, -399, -399, -399, -399, 495, 591, 176, -399, -399, |
| 1914 | -399, -399, -399, -399, -399, -399, -399, -399, -399, -399, |
| 1915 | 177, 178, 182, 183, 776, 1212, 123, 305, 187, 188, |
| 1916 | 189, -399, -399, 193, -399, 135, 160, 266, -399, -399, |
| 1917 | -399, -399, -399, 284, 1229, 283, 325, 287, -399, -399, |
| 1918 | 495, 591, 1174, 1174, 1174, 1174, 1174, 1174, 1174, 1174, |
| 1919 | 1174, 1174, 1174, 1174, 1174, -399, 287, -399, 144, -399, |
| 1920 | -399, -4, 1110, -399, -63, -110, -399, 204, 160, -399, |
| 1921 | 193, 193, -399, -399, -399, -399, -399, -399, -399, -399, |
| 1922 | -399, -399, 211, -399, -399, -399, -399, -399, -399, -399, |
| 1923 | -399, -399, -399, -399, -399, -399, -399, -399, -399, 214, |
| 1924 | 1029, 1029, 1029, 1029, 1029, -399, -399, 79, 494, -111, |
| 1925 | -399, -66, -399, 1029, 1029, 1029, 39, -399, 216, -399, |
| 1926 | 135, 733, -399, 858, 858, -399, 858, 1190, 1174, 1174, |
| 1927 | 50, 111, -399, 733, 97, 215, 230, 231, 232, 233, |
| 1928 | 234, 733, 733, 322, 1190, 1174, 1174, -399, -399, -399, |
| 1929 | -399, -399, -399, -399, -27, -399, -399, -399, -27, -399, |
| 1930 | -399, 1029, 1029, -399, 235, 236, 239, 240, 1029, -399, |
| 1931 | 237, 590, 26, -399, -399, 241, 242, 345, 360, 374, |
| 1932 | -399, 193, 1126, -399, -399, -399, -399, -399, -399, -399, |
| 1933 | -399, 328, 1029, -399, -399, -399, -399, 249, -399, 252, |
| 1934 | 858, 733, 733, 11, -399, 18, -399, -399, 858, 250, |
| 1935 | 1174, 1174, 1174, 1174, 1174, 256, 257, 1174, 858, 733, |
| 1936 | 259, -399, -399, -399, 262, 264, -34, 1029, 1029, 1029, |
| 1937 | 1029, -399, -399, 258, 1029, 1029, 1174, -399, -399, -399, |
| 1938 | -399, 160, 265, 267, -399, 384, -61, 390, 393, 272, |
| 1939 | 281, 282, 858, 413, 858, 295, 296, 858, 297, 160, |
| 1940 | -399, 301, 302, 858, 858, 160, 300, -399, 1174, 1029, |
| 1941 | 1029, 1174, -399, 304, 285, 306, 307, -399, 308, 310, |
| 1942 | 118, 38, 1145, -399, 311, -399, 858, 858, 1174, 858, |
| 1943 | 858, 315, -399, 315, 858, 316, 1174, 1174, 1174, -399, |
| 1944 | -399, 1174, 733, 317, 319, -399, 1029, -399, 1029, 1029, |
| 1945 | -399, -399, -399, -399, -399, -399, 160, 149, 421, 326, |
| 1946 | 314, 733, 19, -399, -399, 412, -399, -399, 321, 858, |
| 1947 | -399, -399, -399, 36, -399, -399, -399, 327, 329, 330, |
| 1948 | 38, -399, 416, -399, 451, 2, -399, 1174, -399, -399, |
| 1949 | 333, -399, -399, -399, -399, -399, 461, -399, 858, -399, |
| 1950 | 982, 5, -4, 733, 210, -399, -27, -399, -399, 335, |
| 1951 | -399, 982, -399, 457, 464, 344, -4, 858, 858, 468, |
| 1952 | 417, -399, 858, 471, -399, 858, -399 |
| 1953 | }; |
| 1954 | |
| 1955 | /* YYPGOTO[NTERM-NUM]. */ |
| 1956 | static const short int yypgoto[] = |
| 1957 | { |
| 1958 | -399, 361, 362, 363, 274, 279, -198, -399, 0, -19, |
| 1959 | 407, 9, -399, -399, -399, 113, -399, -399, -177, -307, |
| 1960 | -398, -399, -236, -399, -299, 7, -399, -212, -399, -399, |
| 1961 | -25, 263, -210, -399, 391, 398, -69, -109, -180, 179, |
| 1962 | -399, -399, 482, -399, -399, -399, -399, -399, -399, -399, |
| 1963 | -399, -399, -399, -399, 418, -399, -399, -399, -399, -399, |
| 1964 | -399, -369, -73, 100, -158, -399, 454, -399, -399, -399, |
| 1965 | -399, -399, 42, 137, -399, -399, -399, -399 |
| 1966 | }; |
| 1967 | |
| 1968 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
| 1969 | positive, shift that token. If negative, reduce the rule which |
| 1970 | number is the opposite. If zero, do what YYDEFACT says. |
| 1971 | If YYTABLE_NINF, syntax error. */ |
| 1972 | #define YYTABLE_NINF -176 |
| 1973 | static const short int yytable[] = |
| 1974 | { |
| 1975 | 11, 75, 376, 328, 191, 279, 281, 98, 296, 13, |
| 1976 | 198, 295, 114, 451, 295, 84, 11, 392, 23, 20, |
| 1977 | 422, 392, 338, 87, 104, 13, 105, 424, 329, 330, |
| 1978 | 297, 343, 326, 21, 24, -55, -55, 140, 60, 61, |
| 1979 | 192, 100, 63, 64, 65, 66, 102, 1, 2, 314, |
| 1980 | 3, 4, 1, 142, 143, 3, 302, 423, 137, 306, |
| 1981 | 307, 308, 309, 310, 423, 137, 313, 338, 348, 138, |
| 1982 | 129, 104, 338, 105, 102, 67, 237, 325, 344, 25, |
| 1983 | 129, 455, 141, 317, 318, 349, 11, 370, 510, 28, |
| 1984 | 29, 30, 31, 32, 33, 34, 196, 35, 342, 441, |
| 1985 | 391, 319, 320, 442, 388, 26, 317, 318, 234, 235, |
| 1986 | 60, 61, 238, 100, 63, 64, 65, 66, 532, 1, |
| 1987 | 2, 27, 3, 4, 319, 320, 79, 80, 60, 61, |
| 1988 | 199, 100, 108, 109, 110, 66, 40, 1, 2, 409, |
| 1989 | 3, 4, 529, 88, 546, 540, 99, 67, 317, 318, |
| 1990 | 77, 78, 517, 126, 144, 145, 518, 82, 390, 338, |
| 1991 | 127, 539, 496, 83, 497, 67, 319, 320, 68, 517, |
| 1992 | 403, 69, 545, 521, 70, 54, 71, 101, 348, 291, |
| 1993 | 392, 55, 416, 373, 104, 36, 105, 300, 301, 291, |
| 1994 | 303, 304, 291, 291, 291, 291, 291, 311, 312, 291, |
| 1995 | 56, 333, 334, 335, 336, 337, 288, 129, 46, 47, |
| 1996 | 48, 58, 338, 49, 345, 346, 347, 487, 365, 339, |
| 1997 | 365, 365, 428, 365, 430, 431, 432, 392, 84, 392, |
| 1998 | 365, 104, 191, 105, 1, 378, 91, 3, 365, 365, |
| 1999 | 68, 543, 92, 69, 375, 104, 70, 105, 71, 135, |
| 2000 | 315, 316, 104, 341, 105, 482, 106, 107, 68, 317, |
| 2001 | 318, 69, 394, 395, 70, 36, 71, 280, 192, 401, |
| 2002 | 93, 95, 196, 371, 372, 96, 391, 319, 320, 97, |
| 2003 | 133, 2, 534, 475, 4, 536, 42, 134, 43, 196, |
| 2004 | 389, 291, 293, -56, 104, 294, 105, 365, 365, 365, |
| 2005 | -57, 146, 194, 232, 233, 365, 230, 236, 500, 501, |
| 2006 | 502, 239, 270, 271, 272, 365, 365, 530, 273, 274, |
| 2007 | 317, 318, 282, 283, 284, 285, 286, 411, 443, 444, |
| 2008 | 445, 446, 289, 541, 295, 448, 449, 391, 319, 320, |
| 2009 | 115, 116, 117, 118, 119, 120, 327, 331, 379, 365, |
| 2010 | 332, 365, 352, 387, 365, 291, 429, 291, 291, 291, |
| 2011 | 365, 365, 435, 380, 381, 382, 383, 384, 397, 398, |
| 2012 | 473, 474, 399, 400, 404, 405, 406, 407, 408, 402, |
| 2013 | 414, 450, 417, 365, 365, 418, 365, 365, 427, 433, |
| 2014 | 434, 365, 438, 367, 368, 439, 369, 440, 452, 365, |
| 2015 | 447, 454, 456, 377, 453, 457, -175, 507, 458, 508, |
| 2016 | 509, 385, 386, 472, 459, 460, 291, 462, 365, -63, |
| 2017 | 1, 2, 477, 3, 4, 5, 365, 486, 441, 464, |
| 2018 | 466, 6, 7, 491, 467, 468, 471, 476, 513, 478, |
| 2019 | 479, 291, 291, 291, 488, 480, 491, 481, 495, 499, |
| 2020 | 8, 483, 515, 9, 505, 365, 506, 10, 423, 514, |
| 2021 | 365, 519, 526, 528, 522, 537, 523, 524, 544, 547, |
| 2022 | 419, 420, 421, 535, 365, 365, 548, 549, 426, 365, |
| 2023 | 552, 553, 365, 555, 298, 222, 223, 224, 436, 437, |
| 2024 | 299, 525, 533, 124, 511, 323, 139, 136, 41, 60, |
| 2025 | 61, 123, 100, 108, 109, 110, 66, 90, 1, 2, |
| 2026 | 483, 3, 4, 503, 425, 0, 0, 0, 0, 0, |
| 2027 | 0, 0, 461, 0, 463, 0, -174, 465, 0, 0, |
| 2028 | 0, 0, 0, 469, 470, 0, 67, 0, 0, -63, |
| 2029 | 1, 2, 0, 3, 4, 5, 0, 0, 0, 0, |
| 2030 | 0, 6, 7, 0, 0, 0, 489, 490, 0, 493, |
| 2031 | 494, 0, 0, 0, 498, 0, 0, 0, 0, 0, |
| 2032 | 8, 0, 504, 9, 0, 0, 0, 10, 242, 243, |
| 2033 | 244, 245, 246, 247, 248, 249, 250, 251, 0, 0, |
| 2034 | 0, 516, 0, 0, 0, 60, 61, 0, 0, 520, |
| 2035 | 0, 0, 0, 0, 1, 2, 0, 3, 4, 0, |
| 2036 | 147, 0, 253, 254, 0, 0, 0, 0, 0, 0, |
| 2037 | 0, 0, 0, 148, 149, 0, 0, 0, 538, 68, |
| 2038 | 0, 0, 69, 542, 0, 70, 0, 71, 340, 0, |
| 2039 | 0, 0, 0, 0, 0, 0, 0, 550, 551, 0, |
| 2040 | 0, 0, 554, 0, 0, 556, 150, 151, 152, 153, |
| 2041 | 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, |
| 2042 | 164, 165, 166, 0, 0, 0, 0, 0, 0, 0, |
| 2043 | 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
| 2044 | 265, 266, 267, 268, 0, 0, 0, 0, 167, 168, |
| 2045 | 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, |
| 2046 | 179, 0, 180, 0, 181, 182, 183, 0, 0, 0, |
| 2047 | 0, 0, 0, 0, 104, 0, 105, 0, 184, 0, |
| 2048 | 0, 185, 0, 186, 0, 187, 353, 354, 60, 61, |
| 2049 | 355, 0, 0, 0, 0, 0, 0, 1, 2, 0, |
| 2050 | 3, 4, 0, 356, 357, 358, 0, 0, 0, 0, |
| 2051 | 0, 0, 0, 0, 0, 0, 359, 360, 0, 0, |
| 2052 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2053 | 0, 60, 61, 361, 100, 108, 109, 110, 66, 0, |
| 2054 | 1, 2, 0, 3, 4, 0, 0, 0, 0, 150, |
| 2055 | 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, |
| 2056 | 161, 162, 163, 164, 165, 166, 0, 0, 67, 60, |
| 2057 | 61, 0, 62, 63, 64, 65, 66, 0, 1, 2, |
| 2058 | 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, |
| 2059 | 0, 167, 168, 169, 170, 171, 172, 173, 174, 175, |
| 2060 | 176, 177, 178, 179, 0, 180, 67, 181, 182, 183, |
| 2061 | 0, 353, 354, 60, 61, 355, 0, 104, 0, 105, |
| 2062 | 0, 0, 1, 2, 362, 3, 4, 0, 356, 357, |
| 2063 | 358, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2064 | 0, 359, 360, 0, 0, 0, 0, 0, 0, 0, |
| 2065 | 0, 0, 0, 0, 0, 0, 0, 0, 361, 0, |
| 2066 | 0, 68, 0, 0, 69, 0, 275, 70, 0, 71, |
| 2067 | 0, 0, 0, 0, 150, 151, 152, 153, 154, 155, |
| 2068 | 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, |
| 2069 | 166, 0, 0, 0, 0, 0, 0, 0, 0, 68, |
| 2070 | 0, 0, 69, 0, 0, 70, 0, 71, 0, 0, |
| 2071 | 0, 0, 0, 0, 0, 0, 167, 168, 169, 170, |
| 2072 | 171, 172, 173, 174, 175, 176, 177, 178, 179, 0, |
| 2073 | 180, 0, 181, 182, 183, 353, 354, 0, 0, 355, |
| 2074 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 362, |
| 2075 | 0, 0, 356, 357, 358, 0, 0, 0, 0, 0, |
| 2076 | 0, 0, 0, 0, 0, 359, 360, 0, 0, 0, |
| 2077 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2078 | 0, 0, 361, 0, 60, 61, 0, 100, 108, 109, |
| 2079 | 110, 66, 0, 1, 2, 0, 3, 4, 150, 151, |
| 2080 | 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, |
| 2081 | 162, 163, 164, 165, 166, 0, 0, 0, 0, 0, |
| 2082 | 0, 67, 0, 0, 0, 0, 60, 61, 0, 100, |
| 2083 | 63, 64, 65, 66, 0, 1, 2, 0, 3, 4, |
| 2084 | 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, |
| 2085 | 177, 178, 179, 128, 180, 0, 181, 182, 183, 0, |
| 2086 | 0, 0, 0, 67, 0, 60, 61, 0, 100, 63, |
| 2087 | 64, 65, 66, 362, 1, 2, 0, 3, 4, 0, |
| 2088 | 0, 60, 61, 0, 100, 63, 64, 65, 66, 0, |
| 2089 | 1, 2, 322, 3, 4, 0, 0, 0, 0, 0, |
| 2090 | 60, 61, 67, 100, 63, 64, 65, 66, 410, 1, |
| 2091 | 2, 0, 3, 4, 68, 0, 0, 69, 67, 0, |
| 2092 | 70, 0, 71, 0, 0, 0, 0, 485, 0, 60, |
| 2093 | 61, 0, 100, 63, 64, 65, 66, 67, 1, 2, |
| 2094 | 0, 3, 4, 0, 0, 60, 61, 0, 195, 63, |
| 2095 | 64, 65, 66, 0, 1, 2, 68, 3, 4, 69, |
| 2096 | 0, 0, 70, 0, 71, 0, 67, 60, 61, 0, |
| 2097 | 100, 108, 109, 110, 66, 0, 1, 2, 0, 3, |
| 2098 | 4, 0, 67, 0, 60, 61, 0, 290, 63, 64, |
| 2099 | 65, 66, 0, 1, 2, 68, 3, 4, 69, 0, |
| 2100 | 0, 70, 0, 71, 67, 0, 0, 0, 0, 0, |
| 2101 | 0, 68, 0, 0, 69, 0, 0, 70, 0, 71, |
| 2102 | 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2103 | 68, 0, 0, 69, 0, 0, 70, 0, 71, 0, |
| 2104 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2105 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, |
| 2106 | 0, 0, 69, 0, 0, 70, 0, 71, 0, 0, |
| 2107 | 0, 0, 0, 0, 0, 68, 0, 0, 69, 0, |
| 2108 | 0, 70, 0, 71, 0, 0, 0, 0, 0, 0, |
| 2109 | 0, 0, 0, 201, 0, 0, 0, 68, 0, 0, |
| 2110 | 69, 0, 0, 70, 0, 278, 0, 0, 0, 0, |
| 2111 | 0, 202, 203, 0, 68, 0, 0, 69, 0, 0, |
| 2112 | 70, 0, 71, 204, 205, 206, 207, 208, 209, 150, |
| 2113 | 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, |
| 2114 | 161, 162, 163, 164, 210, 211, 0, 0, 0, 0, |
| 2115 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 2116 | 0, 0, 0, 0, 0, 0, 212, 213, 214, 0, |
| 2117 | 0, 215, 168, 169, 170, 171, 172, 173, 174, 175, |
| 2118 | 176, 177, 178, 179, 216, 217, 218, 219, 220, 221 |
| 2119 | }; |
| 2120 | |
| 2121 | static const short int yycheck[] = |
| 2122 | { |
| 2123 | 0, 26, 301, 239, 113, 185, 186, 4, 206, 0, |
| 2124 | 23, 9, 81, 411, 9, 16, 16, 324, 132, 45, |
| 2125 | 9, 328, 133, 24, 134, 16, 136, 9, 240, 241, |
| 2126 | 207, 142, 142, 59, 50, 3, 4, 106, 5, 6, |
| 2127 | 113, 8, 9, 10, 11, 12, 71, 14, 15, 226, |
| 2128 | 17, 18, 14, 21, 22, 17, 214, 46, 133, 217, |
| 2129 | 218, 219, 220, 221, 46, 133, 224, 133, 29, 144, |
| 2130 | 95, 134, 133, 136, 99, 42, 144, 140, 144, 132, |
| 2131 | 105, 142, 107, 110, 111, 46, 86, 297, 486, 35, |
| 2132 | 36, 37, 38, 39, 40, 41, 121, 43, 278, 133, |
| 2133 | 127, 128, 129, 137, 314, 13, 110, 111, 133, 134, |
| 2134 | 5, 6, 137, 8, 9, 10, 11, 12, 516, 14, |
| 2135 | 15, 132, 17, 18, 128, 129, 27, 28, 5, 6, |
| 2136 | 143, 8, 9, 10, 11, 12, 0, 14, 15, 351, |
| 2137 | 17, 18, 140, 144, 542, 140, 143, 42, 110, 111, |
| 2138 | 37, 38, 133, 133, 3, 4, 137, 44, 316, 133, |
| 2139 | 140, 530, 461, 50, 463, 42, 128, 129, 135, 133, |
| 2140 | 144, 138, 541, 137, 141, 132, 143, 144, 29, 204, |
| 2141 | 487, 132, 362, 133, 134, 131, 136, 212, 213, 214, |
| 2142 | 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, |
| 2143 | 138, 270, 271, 272, 273, 274, 197, 232, 35, 36, |
| 2144 | 37, 17, 133, 40, 283, 284, 285, 453, 291, 140, |
| 2145 | 293, 294, 380, 296, 382, 383, 384, 534, 16, 536, |
| 2146 | 303, 134, 341, 136, 14, 138, 17, 17, 311, 312, |
| 2147 | 135, 31, 17, 138, 133, 134, 141, 136, 143, 144, |
| 2148 | 106, 107, 134, 278, 136, 137, 77, 78, 135, 110, |
| 2149 | 111, 138, 331, 332, 141, 131, 143, 144, 341, 338, |
| 2150 | 17, 136, 297, 298, 299, 4, 127, 128, 129, 4, |
| 2151 | 139, 15, 518, 441, 18, 521, 39, 139, 41, 314, |
| 2152 | 315, 316, 9, 7, 134, 12, 136, 370, 371, 372, |
| 2153 | 7, 7, 4, 133, 137, 378, 17, 142, 466, 467, |
| 2154 | 468, 137, 136, 136, 136, 388, 389, 515, 136, 136, |
| 2155 | 110, 111, 17, 136, 136, 136, 133, 352, 397, 398, |
| 2156 | 399, 400, 48, 531, 9, 404, 405, 127, 128, 129, |
| 2157 | 53, 54, 55, 56, 57, 58, 142, 136, 133, 422, |
| 2158 | 136, 424, 136, 31, 427, 380, 381, 382, 383, 384, |
| 2159 | 433, 434, 387, 133, 133, 133, 133, 133, 133, 133, |
| 2160 | 439, 440, 133, 133, 133, 133, 31, 17, 4, 142, |
| 2161 | 52, 406, 133, 456, 457, 133, 459, 460, 138, 133, |
| 2162 | 133, 464, 133, 293, 294, 133, 296, 133, 133, 472, |
| 2163 | 142, 17, 12, 303, 137, 12, 0, 476, 136, 478, |
| 2164 | 479, 311, 312, 438, 133, 133, 441, 4, 491, 13, |
| 2165 | 14, 15, 137, 17, 18, 19, 499, 452, 133, 133, |
| 2166 | 133, 25, 26, 458, 133, 133, 136, 133, 17, 133, |
| 2167 | 133, 466, 467, 468, 133, 137, 471, 137, 133, 133, |
| 2168 | 44, 451, 138, 47, 137, 528, 137, 51, 46, 133, |
| 2169 | 533, 140, 46, 12, 137, 4, 137, 137, 133, 12, |
| 2170 | 370, 371, 372, 140, 547, 548, 12, 133, 378, 552, |
| 2171 | 12, 64, 555, 12, 210, 124, 124, 124, 388, 389, |
| 2172 | 211, 510, 517, 86, 487, 232, 105, 99, 16, 5, |
| 2173 | 6, 83, 8, 9, 10, 11, 12, 53, 14, 15, |
| 2174 | 510, 17, 18, 471, 377, -1, -1, -1, -1, -1, |
| 2175 | -1, -1, 422, -1, 424, -1, 0, 427, -1, -1, |
| 2176 | -1, -1, -1, 433, 434, -1, 42, -1, -1, 13, |
| 2177 | 14, 15, -1, 17, 18, 19, -1, -1, -1, -1, |
| 2178 | -1, 25, 26, -1, -1, -1, 456, 457, -1, 459, |
| 2179 | 460, -1, -1, -1, 464, -1, -1, -1, -1, -1, |
| 2180 | 44, -1, 472, 47, -1, -1, -1, 51, 83, 84, |
| 2181 | 85, 86, 87, 88, 89, 90, 91, 92, -1, -1, |
| 2182 | -1, 491, -1, -1, -1, 5, 6, -1, -1, 499, |
| 2183 | -1, -1, -1, -1, 14, 15, -1, 17, 18, -1, |
| 2184 | 20, -1, 21, 22, -1, -1, -1, -1, -1, -1, |
| 2185 | -1, -1, -1, 33, 34, -1, -1, -1, 528, 135, |
| 2186 | -1, -1, 138, 533, -1, 141, -1, 143, 144, -1, |
| 2187 | -1, -1, -1, -1, -1, -1, -1, 547, 548, -1, |
| 2188 | -1, -1, 552, -1, -1, 555, 66, 67, 68, 69, |
| 2189 | 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 2190 | 80, 81, 82, -1, -1, -1, -1, -1, -1, -1, |
| 2191 | 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, |
| 2192 | 99, 100, 101, 102, -1, -1, -1, -1, 108, 109, |
| 2193 | 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, |
| 2194 | 120, -1, 122, -1, 124, 125, 126, -1, -1, -1, |
| 2195 | -1, -1, -1, -1, 134, -1, 136, -1, 138, -1, |
| 2196 | -1, 141, -1, 143, -1, 145, 3, 4, 5, 6, |
| 2197 | 7, -1, -1, -1, -1, -1, -1, 14, 15, -1, |
| 2198 | 17, 18, -1, 20, 21, 22, -1, -1, -1, -1, |
| 2199 | -1, -1, -1, -1, -1, -1, 33, 34, -1, -1, |
| 2200 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2201 | -1, 5, 6, 50, 8, 9, 10, 11, 12, -1, |
| 2202 | 14, 15, -1, 17, 18, -1, -1, -1, -1, 66, |
| 2203 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 2204 | 77, 78, 79, 80, 81, 82, -1, -1, 42, 5, |
| 2205 | 6, -1, 8, 9, 10, 11, 12, -1, 14, 15, |
| 2206 | -1, 17, 18, -1, -1, -1, -1, -1, -1, -1, |
| 2207 | -1, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 2208 | 117, 118, 119, 120, -1, 122, 42, 124, 125, 126, |
| 2209 | -1, 3, 4, 5, 6, 7, -1, 134, -1, 136, |
| 2210 | -1, -1, 14, 15, 141, 17, 18, -1, 20, 21, |
| 2211 | 22, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2212 | -1, 33, 34, -1, -1, -1, -1, -1, -1, -1, |
| 2213 | -1, -1, -1, -1, -1, -1, -1, -1, 50, -1, |
| 2214 | -1, 135, -1, -1, 138, -1, 140, 141, -1, 143, |
| 2215 | -1, -1, -1, -1, 66, 67, 68, 69, 70, 71, |
| 2216 | 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, |
| 2217 | 82, -1, -1, -1, -1, -1, -1, -1, -1, 135, |
| 2218 | -1, -1, 138, -1, -1, 141, -1, 143, -1, -1, |
| 2219 | -1, -1, -1, -1, -1, -1, 108, 109, 110, 111, |
| 2220 | 112, 113, 114, 115, 116, 117, 118, 119, 120, -1, |
| 2221 | 122, -1, 124, 125, 126, 3, 4, -1, -1, 7, |
| 2222 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 141, |
| 2223 | -1, -1, 20, 21, 22, -1, -1, -1, -1, -1, |
| 2224 | -1, -1, -1, -1, -1, 33, 34, -1, -1, -1, |
| 2225 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2226 | -1, -1, 50, -1, 5, 6, -1, 8, 9, 10, |
| 2227 | 11, 12, -1, 14, 15, -1, 17, 18, 66, 67, |
| 2228 | 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, |
| 2229 | 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, |
| 2230 | -1, 42, -1, -1, -1, -1, 5, 6, -1, 8, |
| 2231 | 9, 10, 11, 12, -1, 14, 15, -1, 17, 18, |
| 2232 | 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, |
| 2233 | 118, 119, 120, 32, 122, -1, 124, 125, 126, -1, |
| 2234 | -1, -1, -1, 42, -1, 5, 6, -1, 8, 9, |
| 2235 | 10, 11, 12, 141, 14, 15, -1, 17, 18, -1, |
| 2236 | -1, 5, 6, -1, 8, 9, 10, 11, 12, -1, |
| 2237 | 14, 15, 32, 17, 18, -1, -1, -1, -1, -1, |
| 2238 | 5, 6, 42, 8, 9, 10, 11, 12, 32, 14, |
| 2239 | 15, -1, 17, 18, 135, -1, -1, 138, 42, -1, |
| 2240 | 141, -1, 143, -1, -1, -1, -1, 32, -1, 5, |
| 2241 | 6, -1, 8, 9, 10, 11, 12, 42, 14, 15, |
| 2242 | -1, 17, 18, -1, -1, 5, 6, -1, 8, 9, |
| 2243 | 10, 11, 12, -1, 14, 15, 135, 17, 18, 138, |
| 2244 | -1, -1, 141, -1, 143, -1, 42, 5, 6, -1, |
| 2245 | 8, 9, 10, 11, 12, -1, 14, 15, -1, 17, |
| 2246 | 18, -1, 42, -1, 5, 6, -1, 8, 9, 10, |
| 2247 | 11, 12, -1, 14, 15, 135, 17, 18, 138, -1, |
| 2248 | -1, 141, -1, 143, 42, -1, -1, -1, -1, -1, |
| 2249 | -1, 135, -1, -1, 138, -1, -1, 141, -1, 143, |
| 2250 | -1, 42, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2251 | 135, -1, -1, 138, -1, -1, 141, -1, 143, -1, |
| 2252 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2253 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 135, |
| 2254 | -1, -1, 138, -1, -1, 141, -1, 143, -1, -1, |
| 2255 | -1, -1, -1, -1, -1, 135, -1, -1, 138, -1, |
| 2256 | -1, 141, -1, 143, -1, -1, -1, -1, -1, -1, |
| 2257 | -1, -1, -1, 30, -1, -1, -1, 135, -1, -1, |
| 2258 | 138, -1, -1, 141, -1, 143, -1, -1, -1, -1, |
| 2259 | -1, 48, 49, -1, 135, -1, -1, 138, -1, -1, |
| 2260 | 141, -1, 143, 60, 61, 62, 63, 64, 65, 66, |
| 2261 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 2262 | 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, |
| 2263 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 2264 | -1, -1, -1, -1, -1, -1, 103, 104, 105, -1, |
| 2265 | -1, 108, 109, 110, 111, 112, 113, 114, 115, 116, |
| 2266 | 117, 118, 119, 120, 121, 122, 123, 124, 125, 126 |
| 2267 | }; |
| 2268 | |
| 2269 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
| 2270 | symbol of state STATE-NUM. */ |
| 2271 | static const unsigned char yystos[] = |
| 2272 | { |
| 2273 | 0, 14, 15, 17, 18, 19, 25, 26, 44, 47, |
| 2274 | 51, 154, 156, 157, 158, 186, 187, 188, 190, 189, |
| 2275 | 45, 59, 195, 132, 50, 132, 13, 132, 35, 36, |
| 2276 | 37, 38, 39, 40, 41, 43, 131, 159, 160, 161, |
| 2277 | 0, 188, 39, 41, 162, 205, 35, 36, 37, 40, |
| 2278 | 163, 202, 204, 211, 132, 132, 138, 196, 17, 194, |
| 2279 | 5, 6, 8, 9, 10, 11, 12, 42, 135, 138, |
| 2280 | 141, 143, 154, 157, 175, 176, 208, 161, 161, 27, |
| 2281 | 28, 185, 161, 161, 16, 212, 213, 24, 144, 203, |
| 2282 | 212, 17, 17, 17, 197, 136, 4, 4, 4, 143, |
| 2283 | 8, 144, 176, 181, 134, 136, 185, 185, 9, 10, |
| 2284 | 11, 152, 153, 176, 182, 53, 54, 55, 56, 57, |
| 2285 | 58, 164, 200, 200, 156, 216, 133, 140, 32, 176, |
| 2286 | 177, 179, 180, 139, 139, 144, 181, 133, 144, 180, |
| 2287 | 182, 176, 21, 22, 3, 4, 7, 20, 33, 34, |
| 2288 | 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, |
| 2289 | 76, 77, 78, 79, 80, 81, 82, 108, 109, 110, |
| 2290 | 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, |
| 2291 | 122, 124, 125, 126, 138, 141, 143, 145, 147, 148, |
| 2292 | 149, 183, 208, 191, 4, 8, 176, 178, 23, 143, |
| 2293 | 201, 30, 48, 49, 60, 61, 62, 63, 64, 65, |
| 2294 | 81, 82, 103, 104, 105, 108, 121, 122, 123, 124, |
| 2295 | 125, 126, 147, 148, 149, 214, 220, 221, 222, 223, |
| 2296 | 17, 166, 133, 137, 176, 176, 142, 144, 176, 137, |
| 2297 | 192, 193, 83, 84, 85, 86, 87, 88, 89, 90, |
| 2298 | 91, 92, 150, 21, 22, 89, 90, 91, 92, 93, |
| 2299 | 94, 95, 96, 97, 98, 99, 100, 101, 102, 151, |
| 2300 | 136, 136, 136, 136, 136, 140, 182, 184, 143, 184, |
| 2301 | 144, 184, 17, 136, 136, 136, 133, 173, 157, 48, |
| 2302 | 8, 176, 210, 9, 12, 9, 152, 164, 150, 151, |
| 2303 | 176, 176, 210, 176, 176, 217, 210, 210, 210, 210, |
| 2304 | 210, 176, 176, 210, 164, 106, 107, 110, 111, 128, |
| 2305 | 129, 165, 32, 177, 168, 140, 142, 142, 168, 173, |
| 2306 | 173, 136, 136, 182, 182, 182, 182, 182, 133, 140, |
| 2307 | 144, 176, 184, 142, 144, 182, 182, 182, 29, 46, |
| 2308 | 171, 174, 136, 3, 4, 7, 20, 21, 22, 33, |
| 2309 | 34, 50, 141, 183, 207, 208, 209, 209, 209, 209, |
| 2310 | 178, 176, 176, 133, 170, 133, 170, 209, 138, 133, |
| 2311 | 133, 133, 133, 133, 133, 209, 209, 31, 178, 176, |
| 2312 | 210, 127, 165, 167, 182, 182, 219, 133, 133, 133, |
| 2313 | 133, 182, 142, 144, 133, 133, 31, 17, 4, 173, |
| 2314 | 32, 176, 198, 199, 52, 206, 184, 133, 133, 209, |
| 2315 | 209, 209, 9, 46, 9, 219, 209, 138, 210, 176, |
| 2316 | 210, 210, 210, 133, 133, 176, 209, 209, 133, 133, |
| 2317 | 133, 133, 137, 182, 182, 182, 182, 142, 182, 182, |
| 2318 | 176, 166, 133, 137, 17, 142, 12, 12, 136, 133, |
| 2319 | 133, 209, 4, 209, 133, 209, 133, 133, 133, 209, |
| 2320 | 209, 136, 176, 182, 182, 210, 133, 137, 133, 133, |
| 2321 | 137, 137, 137, 154, 155, 32, 176, 168, 133, 209, |
| 2322 | 209, 176, 218, 209, 209, 133, 170, 170, 209, 133, |
| 2323 | 210, 210, 210, 218, 209, 137, 137, 182, 182, 182, |
| 2324 | 166, 171, 172, 17, 133, 138, 209, 133, 137, 140, |
| 2325 | 209, 137, 137, 137, 137, 155, 46, 169, 12, 140, |
| 2326 | 152, 215, 166, 176, 168, 140, 168, 4, 209, 207, |
| 2327 | 140, 152, 209, 31, 133, 207, 166, 12, 12, 133, |
| 2328 | 209, 209, 12, 64, 209, 12, 209 |
| 2329 | }; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2330 | |
| 2331 | #define yyerrok (yyerrstatus = 0) |
| 2332 | #define yyclearin (yychar = YYEMPTY) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2333 | #define YYEMPTY (-2) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2334 | #define YYEOF 0 |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2335 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2336 | #define YYACCEPT goto yyacceptlab |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2337 | #define YYABORT goto yyabortlab |
| 2338 | #define YYERROR goto yyerrorlab |
| 2339 | |
| 2340 | |
| 2341 | /* Like YYERROR except do call yyerror. This remains here temporarily |
| 2342 | to ease the transition to the new meaning of YYERROR, for GCC. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2343 | Once GCC version 2 has supplanted version 1, this can go. */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2344 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2345 | #define YYFAIL goto yyerrlab |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2346 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2347 | #define YYRECOVERING() (!!yyerrstatus) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2348 | |
| 2349 | #define YYBACKUP(Token, Value) \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2350 | do \ |
| 2351 | if (yychar == YYEMPTY && yylen == 1) \ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2352 | { \ |
| 2353 | yychar = (Token); \ |
| 2354 | yylval = (Value); \ |
| 2355 | yytoken = YYTRANSLATE (yychar); \ |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2356 | YYPOPSTACK; \ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2357 | goto yybackup; \ |
| 2358 | } \ |
| 2359 | else \ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2360 | { \ |
| 2361 | yyerror (YY_("syntax error: cannot back up")); \ |
| 2362 | YYERROR; \ |
| 2363 | } \ |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2364 | while (0) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2365 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2366 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2367 | #define YYTERROR 1 |
| 2368 | #define YYERRCODE 256 |
| 2369 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2370 | |
| 2371 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
| 2372 | If N is 0, then set CURRENT to the empty location which ends |
| 2373 | the previous symbol: RHS[0] (always defined). */ |
| 2374 | |
| 2375 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
| 2376 | #ifndef YYLLOC_DEFAULT |
| 2377 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
| 2378 | do \ |
| 2379 | if (N) \ |
| 2380 | { \ |
| 2381 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
| 2382 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
| 2383 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
| 2384 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
| 2385 | } \ |
| 2386 | else \ |
| 2387 | { \ |
| 2388 | (Current).first_line = (Current).last_line = \ |
| 2389 | YYRHSLOC (Rhs, 0).last_line; \ |
| 2390 | (Current).first_column = (Current).last_column = \ |
| 2391 | YYRHSLOC (Rhs, 0).last_column; \ |
| 2392 | } \ |
| 2393 | while (0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2394 | #endif |
| 2395 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2396 | |
| 2397 | /* YY_LOCATION_PRINT -- Print the location on the stream. |
| 2398 | This macro was not mandated originally: define only if we know |
| 2399 | we won't break user code: when these are the locations we know. */ |
| 2400 | |
| 2401 | #ifndef YY_LOCATION_PRINT |
| 2402 | # if YYLTYPE_IS_TRIVIAL |
| 2403 | # define YY_LOCATION_PRINT(File, Loc) \ |
| 2404 | fprintf (File, "%d.%d-%d.%d", \ |
| 2405 | (Loc).first_line, (Loc).first_column, \ |
| 2406 | (Loc).last_line, (Loc).last_column) |
| 2407 | # else |
| 2408 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
| 2409 | # endif |
| 2410 | #endif |
| 2411 | |
| 2412 | |
| 2413 | /* YYLEX -- calling `yylex' with the right arguments. */ |
| 2414 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2415 | #ifdef YYLEX_PARAM |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2416 | # define YYLEX yylex (YYLEX_PARAM) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2417 | #else |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2418 | # define YYLEX yylex () |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2419 | #endif |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2420 | |
| 2421 | /* Enable debugging if requested. */ |
| 2422 | #if YYDEBUG |
| 2423 | |
| 2424 | # ifndef YYFPRINTF |
| 2425 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
| 2426 | # define YYFPRINTF fprintf |
| 2427 | # endif |
| 2428 | |
| 2429 | # define YYDPRINTF(Args) \ |
| 2430 | do { \ |
| 2431 | if (yydebug) \ |
| 2432 | YYFPRINTF Args; \ |
| 2433 | } while (0) |
| 2434 | |
| 2435 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
| 2436 | do { \ |
| 2437 | if (yydebug) \ |
| 2438 | { \ |
| 2439 | YYFPRINTF (stderr, "%s ", Title); \ |
| 2440 | yysymprint (stderr, \ |
| 2441 | Type, Value); \ |
| 2442 | YYFPRINTF (stderr, "\n"); \ |
| 2443 | } \ |
| 2444 | } while (0) |
| 2445 | |
| 2446 | /*------------------------------------------------------------------. |
| 2447 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
| 2448 | | TOP (included). | |
| 2449 | `------------------------------------------------------------------*/ |
| 2450 | |
| 2451 | #if defined (__STDC__) || defined (__cplusplus) |
| 2452 | static void |
| 2453 | yy_stack_print (short int *bottom, short int *top) |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2454 | #else |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2455 | static void |
| 2456 | yy_stack_print (bottom, top) |
| 2457 | short int *bottom; |
| 2458 | short int *top; |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2459 | #endif |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2460 | { |
| 2461 | YYFPRINTF (stderr, "Stack now"); |
| 2462 | for (/* Nothing. */; bottom <= top; ++bottom) |
| 2463 | YYFPRINTF (stderr, " %d", *bottom); |
| 2464 | YYFPRINTF (stderr, "\n"); |
| 2465 | } |
| 2466 | |
| 2467 | # define YY_STACK_PRINT(Bottom, Top) \ |
| 2468 | do { \ |
| 2469 | if (yydebug) \ |
| 2470 | yy_stack_print ((Bottom), (Top)); \ |
| 2471 | } while (0) |
| 2472 | |
| 2473 | |
| 2474 | /*------------------------------------------------. |
| 2475 | | Report that the YYRULE is going to be reduced. | |
| 2476 | `------------------------------------------------*/ |
| 2477 | |
| 2478 | #if defined (__STDC__) || defined (__cplusplus) |
| 2479 | static void |
| 2480 | yy_reduce_print (int yyrule) |
| 2481 | #else |
| 2482 | static void |
| 2483 | yy_reduce_print (yyrule) |
| 2484 | int yyrule; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2485 | #endif |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2486 | { |
| 2487 | int yyi; |
| 2488 | unsigned long int yylno = yyrline[yyrule]; |
| 2489 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", |
| 2490 | yyrule - 1, yylno); |
| 2491 | /* Print the symbols being reduced, and their result. */ |
| 2492 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) |
| 2493 | YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); |
| 2494 | YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); |
| 2495 | } |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2496 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2497 | # define YY_REDUCE_PRINT(Rule) \ |
| 2498 | do { \ |
| 2499 | if (yydebug) \ |
| 2500 | yy_reduce_print (Rule); \ |
| 2501 | } while (0) |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2502 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2503 | /* Nonzero means print parse trace. It is left uninitialized so that |
| 2504 | multiple parsers can coexist. */ |
| 2505 | int yydebug; |
| 2506 | #else /* !YYDEBUG */ |
| 2507 | # define YYDPRINTF(Args) |
| 2508 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
| 2509 | # define YY_STACK_PRINT(Bottom, Top) |
| 2510 | # define YY_REDUCE_PRINT(Rule) |
| 2511 | #endif /* !YYDEBUG */ |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2512 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 2513 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2514 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2515 | #ifndef YYINITDEPTH |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2516 | # define YYINITDEPTH 200 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2517 | #endif |
| 2518 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2519 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
| 2520 | if the built-in stack extension method is used). |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2521 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2522 | Do not make this value too large; the results are undefined if |
| 2523 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
| 2524 | evaluated with infinite-precision integer arithmetic. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2525 | |
| 2526 | #ifndef YYMAXDEPTH |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2527 | # define YYMAXDEPTH 10000 |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2528 | #endif |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2529 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2530 | |
| 2531 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2532 | #if YYERROR_VERBOSE |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2533 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2534 | # ifndef yystrlen |
| 2535 | # if defined (__GLIBC__) && defined (_STRING_H) |
| 2536 | # define yystrlen strlen |
| 2537 | # else |
| 2538 | /* Return the length of YYSTR. */ |
| 2539 | static YYSIZE_T |
| 2540 | # if defined (__STDC__) || defined (__cplusplus) |
| 2541 | yystrlen (const char *yystr) |
| 2542 | # else |
| 2543 | yystrlen (yystr) |
| 2544 | const char *yystr; |
| 2545 | # endif |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2546 | { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2547 | const char *yys = yystr; |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2548 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2549 | while (*yys++ != '\0') |
| 2550 | continue; |
| 2551 | |
| 2552 | return yys - yystr - 1; |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2553 | } |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2554 | # endif |
| 2555 | # endif |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2556 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2557 | # ifndef yystpcpy |
| 2558 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) |
| 2559 | # define yystpcpy stpcpy |
| 2560 | # else |
| 2561 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
| 2562 | YYDEST. */ |
| 2563 | static char * |
| 2564 | # if defined (__STDC__) || defined (__cplusplus) |
| 2565 | yystpcpy (char *yydest, const char *yysrc) |
| 2566 | # else |
| 2567 | yystpcpy (yydest, yysrc) |
| 2568 | char *yydest; |
| 2569 | const char *yysrc; |
| 2570 | # endif |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2571 | { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2572 | char *yyd = yydest; |
| 2573 | const char *yys = yysrc; |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2574 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2575 | while ((*yyd++ = *yys++) != '\0') |
| 2576 | continue; |
| 2577 | |
| 2578 | return yyd - 1; |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2579 | } |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2580 | # endif |
| 2581 | # endif |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2582 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2583 | # ifndef yytnamerr |
| 2584 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
| 2585 | quotes and backslashes, so that it's suitable for yyerror. The |
| 2586 | heuristic is that double-quoting is unnecessary unless the string |
| 2587 | contains an apostrophe, a comma, or backslash (other than |
| 2588 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
| 2589 | null, do not copy; instead, return the length of what the result |
| 2590 | would have been. */ |
| 2591 | static YYSIZE_T |
| 2592 | yytnamerr (char *yyres, const char *yystr) |
| 2593 | { |
| 2594 | if (*yystr == '"') |
| 2595 | { |
| 2596 | size_t yyn = 0; |
| 2597 | char const *yyp = yystr; |
| 2598 | |
| 2599 | for (;;) |
| 2600 | switch (*++yyp) |
| 2601 | { |
| 2602 | case '\'': |
| 2603 | case ',': |
| 2604 | goto do_not_strip_quotes; |
| 2605 | |
| 2606 | case '\\': |
| 2607 | if (*++yyp != '\\') |
| 2608 | goto do_not_strip_quotes; |
| 2609 | /* Fall through. */ |
| 2610 | default: |
| 2611 | if (yyres) |
| 2612 | yyres[yyn] = *yyp; |
| 2613 | yyn++; |
| 2614 | break; |
| 2615 | |
| 2616 | case '"': |
| 2617 | if (yyres) |
| 2618 | yyres[yyn] = '\0'; |
| 2619 | return yyn; |
| 2620 | } |
| 2621 | do_not_strip_quotes: ; |
| 2622 | } |
| 2623 | |
| 2624 | if (! yyres) |
| 2625 | return yystrlen (yystr); |
| 2626 | |
| 2627 | return yystpcpy (yyres, yystr) - yyres; |
| 2628 | } |
| 2629 | # endif |
| 2630 | |
| 2631 | #endif /* YYERROR_VERBOSE */ |
| 2632 | |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2633 | |
| 2634 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2635 | #if YYDEBUG |
| 2636 | /*--------------------------------. |
| 2637 | | Print this symbol on YYOUTPUT. | |
| 2638 | `--------------------------------*/ |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 2639 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2640 | #if defined (__STDC__) || defined (__cplusplus) |
| 2641 | static void |
| 2642 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2643 | #else |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2644 | static void |
| 2645 | yysymprint (yyoutput, yytype, yyvaluep) |
| 2646 | FILE *yyoutput; |
| 2647 | int yytype; |
| 2648 | YYSTYPE *yyvaluep; |
| 2649 | #endif |
| 2650 | { |
| 2651 | /* Pacify ``unused variable'' warnings. */ |
| 2652 | (void) yyvaluep; |
| 2653 | |
| 2654 | if (yytype < YYNTOKENS) |
| 2655 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
| 2656 | else |
| 2657 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
| 2658 | |
| 2659 | |
| 2660 | # ifdef YYPRINT |
| 2661 | if (yytype < YYNTOKENS) |
| 2662 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
| 2663 | # endif |
| 2664 | switch (yytype) |
| 2665 | { |
| 2666 | default: |
| 2667 | break; |
| 2668 | } |
| 2669 | YYFPRINTF (yyoutput, ")"); |
| 2670 | } |
| 2671 | |
| 2672 | #endif /* ! YYDEBUG */ |
| 2673 | /*-----------------------------------------------. |
| 2674 | | Release the memory associated to this symbol. | |
| 2675 | `-----------------------------------------------*/ |
| 2676 | |
| 2677 | #if defined (__STDC__) || defined (__cplusplus) |
| 2678 | static void |
| 2679 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
| 2680 | #else |
| 2681 | static void |
| 2682 | yydestruct (yymsg, yytype, yyvaluep) |
| 2683 | const char *yymsg; |
| 2684 | int yytype; |
| 2685 | YYSTYPE *yyvaluep; |
| 2686 | #endif |
| 2687 | { |
| 2688 | /* Pacify ``unused variable'' warnings. */ |
| 2689 | (void) yyvaluep; |
| 2690 | |
| 2691 | if (!yymsg) |
| 2692 | yymsg = "Deleting"; |
| 2693 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
| 2694 | |
| 2695 | switch (yytype) |
| 2696 | { |
| 2697 | |
| 2698 | default: |
| 2699 | break; |
| 2700 | } |
| 2701 | } |
| 2702 | |
| 2703 | |
| 2704 | /* Prevent warnings from -Wmissing-prototypes. */ |
| 2705 | |
| 2706 | #ifdef YYPARSE_PARAM |
| 2707 | # if defined (__STDC__) || defined (__cplusplus) |
| 2708 | int yyparse (void *YYPARSE_PARAM); |
| 2709 | # else |
| 2710 | int yyparse (); |
| 2711 | # endif |
| 2712 | #else /* ! YYPARSE_PARAM */ |
| 2713 | #if defined (__STDC__) || defined (__cplusplus) |
Reid Spencer | e812fb2 | 2006-01-19 01:21:04 +0000 | [diff] [blame] | 2714 | int yyparse (void); |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2715 | #else |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2716 | int yyparse (); |
| 2717 | #endif |
| 2718 | #endif /* ! YYPARSE_PARAM */ |
| 2719 | |
| 2720 | |
| 2721 | |
| 2722 | /* The look-ahead symbol. */ |
| 2723 | int yychar; |
| 2724 | |
| 2725 | /* The semantic value of the look-ahead symbol. */ |
| 2726 | YYSTYPE yylval; |
| 2727 | |
| 2728 | /* Number of syntax errors so far. */ |
| 2729 | int yynerrs; |
| 2730 | |
| 2731 | |
| 2732 | |
| 2733 | /*----------. |
| 2734 | | yyparse. | |
| 2735 | `----------*/ |
| 2736 | |
| 2737 | #ifdef YYPARSE_PARAM |
| 2738 | # if defined (__STDC__) || defined (__cplusplus) |
| 2739 | int yyparse (void *YYPARSE_PARAM) |
| 2740 | # else |
| 2741 | int yyparse (YYPARSE_PARAM) |
| 2742 | void *YYPARSE_PARAM; |
| 2743 | # endif |
| 2744 | #else /* ! YYPARSE_PARAM */ |
| 2745 | #if defined (__STDC__) || defined (__cplusplus) |
| 2746 | int |
| 2747 | yyparse (void) |
| 2748 | #else |
| 2749 | int |
| 2750 | yyparse () |
| 2751 | |
| 2752 | #endif |
| 2753 | #endif |
| 2754 | { |
| 2755 | |
| 2756 | int yystate; |
| 2757 | int yyn; |
| 2758 | int yyresult; |
| 2759 | /* Number of tokens to shift before error messages enabled. */ |
| 2760 | int yyerrstatus; |
| 2761 | /* Look-ahead token as an internal (translated) token number. */ |
| 2762 | int yytoken = 0; |
| 2763 | |
| 2764 | /* Three stacks and their tools: |
| 2765 | `yyss': related to states, |
| 2766 | `yyvs': related to semantic values, |
| 2767 | `yyls': related to locations. |
| 2768 | |
| 2769 | Refer to the stacks thru separate pointers, to allow yyoverflow |
| 2770 | to reallocate them elsewhere. */ |
| 2771 | |
| 2772 | /* The state stack. */ |
| 2773 | short int yyssa[YYINITDEPTH]; |
| 2774 | short int *yyss = yyssa; |
| 2775 | short int *yyssp; |
| 2776 | |
| 2777 | /* The semantic value stack. */ |
| 2778 | YYSTYPE yyvsa[YYINITDEPTH]; |
| 2779 | YYSTYPE *yyvs = yyvsa; |
| 2780 | YYSTYPE *yyvsp; |
| 2781 | |
| 2782 | |
| 2783 | |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2784 | #define YYPOPSTACK (yyvsp--, yyssp--) |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2785 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2786 | YYSIZE_T yystacksize = YYINITDEPTH; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2787 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2788 | /* The variables used to return semantic value and location from the |
| 2789 | action routines. */ |
| 2790 | YYSTYPE yyval; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2791 | |
| 2792 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2793 | /* When reducing, the number of symbols on the RHS of the reduced |
| 2794 | rule. */ |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2795 | int yylen; |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2796 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2797 | YYDPRINTF ((stderr, "Starting parse\n")); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 2798 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2799 | yystate = 0; |
| 2800 | yyerrstatus = 0; |
| 2801 | yynerrs = 0; |
| 2802 | yychar = YYEMPTY; /* Cause a token to be read. */ |
| 2803 | |
| 2804 | /* Initialize stack pointers. |
| 2805 | Waste one element of value and location stack |
| 2806 | so that they stay on the same level as the state stack. |
| 2807 | The wasted elements are never initialized. */ |
| 2808 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2809 | yyssp = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2810 | yyvsp = yyvs; |
| 2811 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2812 | goto yysetstate; |
Jeff Cohen | 66c5fd6 | 2005-10-23 04:37:20 +0000 | [diff] [blame] | 2813 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2814 | /*------------------------------------------------------------. |
| 2815 | | yynewstate -- Push a new state, which is found in yystate. | |
| 2816 | `------------------------------------------------------------*/ |
| 2817 | yynewstate: |
| 2818 | /* In all cases, when you get here, the value and location stacks |
| 2819 | have just been pushed. so pushing a state here evens the stacks. |
| 2820 | */ |
| 2821 | yyssp++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2822 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2823 | yysetstate: |
| 2824 | *yyssp = yystate; |
| 2825 | |
| 2826 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2827 | { |
| 2828 | /* Get the current used size of the three stacks, in elements. */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2829 | YYSIZE_T yysize = yyssp - yyss + 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2830 | |
| 2831 | #ifdef yyoverflow |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2832 | { |
| 2833 | /* Give user a chance to reallocate the stack. Use copies of |
| 2834 | these so that the &'s don't force the real ones into |
| 2835 | memory. */ |
| 2836 | YYSTYPE *yyvs1 = yyvs; |
| 2837 | short int *yyss1 = yyss; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2838 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2839 | |
| 2840 | /* Each stack pointer address is followed by the size of the |
| 2841 | data in use in that stack, in bytes. This used to be a |
| 2842 | conditional around just the two extra args, but that might |
| 2843 | be undefined if yyoverflow is a macro. */ |
| 2844 | yyoverflow (YY_("memory exhausted"), |
| 2845 | &yyss1, yysize * sizeof (*yyssp), |
| 2846 | &yyvs1, yysize * sizeof (*yyvsp), |
| 2847 | |
| 2848 | &yystacksize); |
| 2849 | |
| 2850 | yyss = yyss1; |
| 2851 | yyvs = yyvs1; |
| 2852 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2853 | #else /* no yyoverflow */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2854 | # ifndef YYSTACK_RELOCATE |
| 2855 | goto yyexhaustedlab; |
| 2856 | # else |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2857 | /* Extend the stack our own way. */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2858 | if (YYMAXDEPTH <= yystacksize) |
| 2859 | goto yyexhaustedlab; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2860 | yystacksize *= 2; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2861 | if (YYMAXDEPTH < yystacksize) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2862 | yystacksize = YYMAXDEPTH; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2863 | |
| 2864 | { |
| 2865 | short int *yyss1 = yyss; |
| 2866 | union yyalloc *yyptr = |
| 2867 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
| 2868 | if (! yyptr) |
| 2869 | goto yyexhaustedlab; |
| 2870 | YYSTACK_RELOCATE (yyss); |
| 2871 | YYSTACK_RELOCATE (yyvs); |
| 2872 | |
| 2873 | # undef YYSTACK_RELOCATE |
| 2874 | if (yyss1 != yyssa) |
| 2875 | YYSTACK_FREE (yyss1); |
| 2876 | } |
| 2877 | # endif |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2878 | #endif /* no yyoverflow */ |
| 2879 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2880 | yyssp = yyss + yysize - 1; |
| 2881 | yyvsp = yyvs + yysize - 1; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2882 | |
| 2883 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2884 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
| 2885 | (unsigned long int) yystacksize)); |
| 2886 | |
| 2887 | if (yyss + yystacksize - 1 <= yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2888 | YYABORT; |
| 2889 | } |
| 2890 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2891 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2892 | |
| 2893 | goto yybackup; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2894 | |
| 2895 | /*-----------. |
| 2896 | | yybackup. | |
| 2897 | `-----------*/ |
| 2898 | yybackup: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2899 | |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2900 | /* Do appropriate processing given the current state. */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2901 | /* Read a look-ahead token if we need one and don't already have one. */ |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2902 | /* yyresume: */ |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 2903 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2904 | /* First try to decide what to do without reference to look-ahead token. */ |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2905 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2906 | yyn = yypact[yystate]; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2907 | if (yyn == YYPACT_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2908 | goto yydefault; |
| 2909 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2910 | /* 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] | 2911 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2912 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2913 | if (yychar == YYEMPTY) |
| 2914 | { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2915 | YYDPRINTF ((stderr, "Reading a token: ")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2916 | yychar = YYLEX; |
| 2917 | } |
| 2918 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2919 | if (yychar <= YYEOF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2920 | { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2921 | yychar = yytoken = YYEOF; |
| 2922 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2923 | } |
| 2924 | else |
| 2925 | { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2926 | yytoken = YYTRANSLATE (yychar); |
| 2927 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2928 | } |
| 2929 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2930 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
| 2931 | detect an error, take that action. */ |
| 2932 | yyn += yytoken; |
| 2933 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2934 | goto yydefault; |
| 2935 | yyn = yytable[yyn]; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2936 | if (yyn <= 0) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2937 | { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2938 | if (yyn == 0 || yyn == YYTABLE_NINF) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2939 | goto yyerrlab; |
| 2940 | yyn = -yyn; |
| 2941 | goto yyreduce; |
| 2942 | } |
| 2943 | |
| 2944 | if (yyn == YYFINAL) |
| 2945 | YYACCEPT; |
| 2946 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2947 | /* Shift the look-ahead token. */ |
| 2948 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 2949 | |
| 2950 | /* Discard the token being shifted unless it is eof. */ |
| 2951 | if (yychar != YYEOF) |
| 2952 | yychar = YYEMPTY; |
| 2953 | |
| 2954 | *++yyvsp = yylval; |
| 2955 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2956 | |
| 2957 | /* Count tokens shifted since error; after three, turn off error |
| 2958 | status. */ |
| 2959 | if (yyerrstatus) |
| 2960 | yyerrstatus--; |
Chris Lattner | 0fab59c | 2007-01-12 18:33:30 +0000 | [diff] [blame] | 2961 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2962 | yystate = yyn; |
| 2963 | goto yynewstate; |
| 2964 | |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 2965 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2966 | /*-----------------------------------------------------------. |
| 2967 | | yydefault -- do the default action for the current state. | |
| 2968 | `-----------------------------------------------------------*/ |
| 2969 | yydefault: |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2970 | yyn = yydefact[yystate]; |
| 2971 | if (yyn == 0) |
| 2972 | goto yyerrlab; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2973 | goto yyreduce; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2974 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2975 | |
| 2976 | /*-----------------------------. |
| 2977 | | yyreduce -- Do a reduction. | |
| 2978 | `-----------------------------*/ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2979 | yyreduce: |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2980 | /* yyn is the number of a rule to reduce with. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2981 | yylen = yyr2[yyn]; |
| 2982 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2983 | /* If YYLEN is nonzero, implement the default value of the action: |
| 2984 | `$$ = $1'. |
| 2985 | |
| 2986 | Otherwise, the following line sets YYVAL to garbage. |
| 2987 | This behavior is undocumented and Bison |
| 2988 | users should not rely upon it. Assigning to YYVAL |
| 2989 | unconditionally makes the parser a bit smaller, and it avoids a |
| 2990 | GCC warning that YYVAL may be used uninitialized. */ |
| 2991 | yyval = yyvsp[1-yylen]; |
| 2992 | |
| 2993 | |
| 2994 | YY_REDUCE_PRINT (yyn); |
| 2995 | switch (yyn) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 2996 | { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2997 | case 29: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 2998 | #line 1053 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 2999 | { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;} |
| 3000 | break; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3001 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3002 | case 30: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3003 | #line 1053 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3004 | { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;} |
| 3005 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3006 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3007 | case 31: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3008 | #line 1054 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3009 | { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;} |
| 3010 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3011 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3012 | case 32: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3013 | #line 1054 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3014 | { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;} |
| 3015 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3016 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3017 | case 33: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3018 | #line 1055 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3019 | { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;} |
| 3020 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 3021 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3022 | case 34: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3023 | #line 1055 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3024 | { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;} |
| 3025 | break; |
| 3026 | |
| 3027 | case 35: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3028 | #line 1056 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3029 | { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;} |
| 3030 | break; |
| 3031 | |
| 3032 | case 36: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3033 | #line 1056 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3034 | { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;} |
| 3035 | break; |
| 3036 | |
| 3037 | case 37: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3038 | #line 1057 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3039 | { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;} |
| 3040 | break; |
| 3041 | |
| 3042 | case 38: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3043 | #line 1057 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3044 | { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;} |
| 3045 | break; |
| 3046 | |
| 3047 | case 39: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3048 | #line 1061 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3049 | { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;} |
| 3050 | break; |
| 3051 | |
| 3052 | case 40: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3053 | #line 1061 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3054 | { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;} |
| 3055 | break; |
| 3056 | |
| 3057 | case 41: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3058 | #line 1062 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3059 | { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;} |
| 3060 | break; |
| 3061 | |
| 3062 | case 42: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3063 | #line 1062 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3064 | { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;} |
| 3065 | break; |
| 3066 | |
| 3067 | case 43: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3068 | #line 1063 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3069 | { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;} |
| 3070 | break; |
| 3071 | |
| 3072 | case 44: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3073 | #line 1063 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3074 | { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;} |
| 3075 | break; |
| 3076 | |
| 3077 | case 45: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3078 | #line 1064 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3079 | { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;} |
| 3080 | break; |
| 3081 | |
| 3082 | case 46: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3083 | #line 1064 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3084 | { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;} |
| 3085 | break; |
| 3086 | |
| 3087 | case 47: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3088 | #line 1065 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3089 | { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;} |
| 3090 | break; |
| 3091 | |
| 3092 | case 48: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3093 | #line 1065 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3094 | { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;} |
| 3095 | break; |
| 3096 | |
| 3097 | case 49: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3098 | #line 1066 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3099 | { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;} |
| 3100 | break; |
| 3101 | |
| 3102 | case 50: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3103 | #line 1066 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3104 | { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;} |
| 3105 | break; |
| 3106 | |
| 3107 | case 51: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3108 | #line 1067 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3109 | { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;} |
| 3110 | break; |
| 3111 | |
| 3112 | case 52: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3113 | #line 1067 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3114 | { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;} |
| 3115 | break; |
| 3116 | |
| 3117 | case 53: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3118 | #line 1068 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3119 | { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;} |
| 3120 | break; |
| 3121 | |
| 3122 | case 54: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3123 | #line 1069 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3124 | { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;} |
| 3125 | break; |
| 3126 | |
| 3127 | case 61: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3128 | #line 1078 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3129 | { (yyval.StrVal) = 0; ;} |
| 3130 | break; |
| 3131 | |
| 3132 | case 62: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3133 | #line 1082 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3134 | { |
| 3135 | (yyval.StrVal) = (yyvsp[-1].StrVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3136 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3137 | ;} |
| 3138 | break; |
| 3139 | |
| 3140 | case 63: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3141 | #line 1086 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3142 | { |
| 3143 | (yyval.StrVal) = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3144 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3145 | ;} |
| 3146 | break; |
| 3147 | |
| 3148 | case 66: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3149 | #line 1093 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3150 | { |
| 3151 | (yyval.StrVal) = (yyvsp[-1].StrVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3152 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3153 | ;} |
| 3154 | break; |
| 3155 | |
| 3156 | case 67: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3157 | #line 1097 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3158 | { |
| 3159 | (yyval.StrVal) = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3160 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3161 | ;} |
| 3162 | break; |
| 3163 | |
| 3164 | case 68: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3165 | #line 1103 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3166 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3167 | break; |
| 3168 | |
| 3169 | case 69: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3170 | #line 1104 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3171 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3172 | break; |
| 3173 | |
| 3174 | case 70: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3175 | #line 1105 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3176 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 3177 | break; |
| 3178 | |
| 3179 | case 71: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3180 | #line 1106 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3181 | { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} |
| 3182 | break; |
| 3183 | |
| 3184 | case 72: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3185 | #line 1107 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3186 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 3187 | break; |
| 3188 | |
| 3189 | case 73: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3190 | #line 1111 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3191 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 3192 | break; |
| 3193 | |
| 3194 | case 74: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3195 | #line 1112 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3196 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 3197 | break; |
| 3198 | |
| 3199 | case 75: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3200 | #line 1113 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3201 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3202 | break; |
| 3203 | |
| 3204 | case 76: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3205 | #line 1117 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3206 | { (yyval.Visibility) = GlobalValue::DefaultVisibility; ;} |
| 3207 | break; |
| 3208 | |
| 3209 | case 77: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3210 | #line 1118 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3211 | { (yyval.Visibility) = GlobalValue::HiddenVisibility; ;} |
| 3212 | break; |
| 3213 | |
| 3214 | case 78: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3215 | #line 1122 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3216 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3217 | break; |
| 3218 | |
| 3219 | case 79: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3220 | #line 1123 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3221 | { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} |
| 3222 | break; |
| 3223 | |
| 3224 | case 80: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3225 | #line 1124 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3226 | { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} |
| 3227 | break; |
| 3228 | |
| 3229 | case 81: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3230 | #line 1128 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3231 | { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} |
| 3232 | break; |
| 3233 | |
| 3234 | case 82: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3235 | #line 1129 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3236 | { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} |
| 3237 | break; |
| 3238 | |
| 3239 | case 83: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3240 | #line 1130 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3241 | { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} |
| 3242 | break; |
| 3243 | |
| 3244 | case 84: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3245 | #line 1131 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3246 | { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} |
| 3247 | break; |
| 3248 | |
| 3249 | case 85: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3250 | #line 1132 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3251 | { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} |
| 3252 | break; |
| 3253 | |
| 3254 | case 86: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3255 | #line 1135 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3256 | { (yyval.UIntVal) = CallingConv::C; ;} |
| 3257 | break; |
| 3258 | |
| 3259 | case 87: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3260 | #line 1136 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3261 | { (yyval.UIntVal) = CallingConv::C; ;} |
| 3262 | break; |
| 3263 | |
| 3264 | case 88: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3265 | #line 1137 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3266 | { (yyval.UIntVal) = CallingConv::Fast; ;} |
| 3267 | break; |
| 3268 | |
| 3269 | case 89: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3270 | #line 1138 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3271 | { (yyval.UIntVal) = CallingConv::Cold; ;} |
| 3272 | break; |
| 3273 | |
| 3274 | case 90: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3275 | #line 1139 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3276 | { (yyval.UIntVal) = CallingConv::X86_StdCall; ;} |
| 3277 | break; |
| 3278 | |
| 3279 | case 91: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3280 | #line 1140 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3281 | { (yyval.UIntVal) = CallingConv::X86_FastCall; ;} |
| 3282 | break; |
| 3283 | |
| 3284 | case 92: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3285 | #line 1141 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3286 | { |
| 3287 | if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3288 | GEN_ERROR("Calling conv too large"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3289 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3290 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3291 | ;} |
| 3292 | break; |
| 3293 | |
| 3294 | case 93: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3295 | #line 1148 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3296 | { (yyval.ParamAttrs) = FunctionType::ZExtAttribute; ;} |
| 3297 | break; |
| 3298 | |
| 3299 | case 94: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3300 | #line 1149 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3301 | { (yyval.ParamAttrs) = FunctionType::SExtAttribute; ;} |
| 3302 | break; |
| 3303 | |
| 3304 | case 95: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3305 | #line 1150 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3306 | { (yyval.ParamAttrs) = FunctionType::InRegAttribute; ;} |
| 3307 | break; |
| 3308 | |
| 3309 | case 96: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3310 | #line 1151 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3311 | { (yyval.ParamAttrs) = FunctionType::StructRetAttribute; ;} |
| 3312 | break; |
| 3313 | |
| 3314 | case 97: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3315 | #line 1154 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3316 | { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;} |
| 3317 | break; |
| 3318 | |
| 3319 | case 98: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3320 | #line 1155 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3321 | { |
| 3322 | (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs)); |
| 3323 | ;} |
| 3324 | break; |
| 3325 | |
| 3326 | case 99: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3327 | #line 1160 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3328 | { (yyval.ParamAttrs) = FunctionType::NoReturnAttribute; ;} |
| 3329 | break; |
| 3330 | |
| 3331 | case 101: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3332 | #line 1164 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3333 | { (yyval.ParamAttrs) = FunctionType::NoAttributeSet; ;} |
| 3334 | break; |
| 3335 | |
| 3336 | case 102: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3337 | #line 1165 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3338 | { |
| 3339 | (yyval.ParamAttrs) = FunctionType::ParameterAttributes((yyvsp[-1].ParamAttrs) | (yyvsp[0].ParamAttrs)); |
| 3340 | ;} |
| 3341 | break; |
| 3342 | |
| 3343 | case 103: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3344 | #line 1172 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3345 | { (yyval.UIntVal) = 0; ;} |
| 3346 | break; |
| 3347 | |
| 3348 | case 104: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3349 | #line 1173 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3350 | { |
| 3351 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 3352 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3353 | GEN_ERROR("Alignment must be a power of two"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3354 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3355 | ;} |
| 3356 | break; |
| 3357 | |
| 3358 | case 105: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3359 | #line 1179 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3360 | { (yyval.UIntVal) = 0; ;} |
| 3361 | break; |
| 3362 | |
| 3363 | case 106: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3364 | #line 1180 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3365 | { |
| 3366 | (yyval.UIntVal) = (yyvsp[0].UInt64Val); |
| 3367 | if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3368 | GEN_ERROR("Alignment must be a power of two"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3369 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3370 | ;} |
| 3371 | break; |
| 3372 | |
| 3373 | case 107: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3374 | #line 1188 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3375 | { |
| 3376 | for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) |
| 3377 | if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3378 | GEN_ERROR("Invalid character in section name"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3379 | (yyval.StrVal) = (yyvsp[0].StrVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3380 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3381 | ;} |
| 3382 | break; |
| 3383 | |
| 3384 | case 108: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3385 | #line 1196 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3386 | { (yyval.StrVal) = 0; ;} |
| 3387 | break; |
| 3388 | |
| 3389 | case 109: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3390 | #line 1197 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3391 | { (yyval.StrVal) = (yyvsp[0].StrVal); ;} |
| 3392 | break; |
| 3393 | |
| 3394 | case 110: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3395 | #line 1202 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3396 | {;} |
| 3397 | break; |
| 3398 | |
| 3399 | case 111: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3400 | #line 1203 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3401 | {;} |
| 3402 | break; |
| 3403 | |
| 3404 | case 112: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3405 | #line 1204 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3406 | { |
| 3407 | CurGV->setSection((yyvsp[0].StrVal)); |
| 3408 | free((yyvsp[0].StrVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3409 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3410 | ;} |
| 3411 | break; |
| 3412 | |
| 3413 | case 113: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3414 | #line 1209 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3415 | { |
| 3416 | if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3417 | GEN_ERROR("Alignment must be a power of two"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3418 | CurGV->setAlignment((yyvsp[0].UInt64Val)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3419 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3420 | ;} |
| 3421 | break; |
| 3422 | |
| 3423 | case 118: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3424 | #line 1225 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3425 | { |
| 3426 | (yyval.TypeVal) = new PATypeHolder(OpaqueType::get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3427 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3428 | ;} |
| 3429 | break; |
| 3430 | |
| 3431 | case 119: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3432 | #line 1229 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3433 | { |
| 3434 | (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3435 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3436 | ;} |
| 3437 | break; |
| 3438 | |
| 3439 | case 120: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3440 | #line 1233 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3441 | { // Pointer type? |
| 3442 | if (*(yyvsp[-1].TypeVal) == Type::LabelTy) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3443 | GEN_ERROR("Cannot form a pointer to a basic block"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3444 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal)))); |
| 3445 | delete (yyvsp[-1].TypeVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3446 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3447 | ;} |
| 3448 | break; |
| 3449 | |
| 3450 | case 121: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3451 | #line 1240 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3452 | { // Named types are also simple types... |
| 3453 | const Type* tmp = getTypeVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3454 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3455 | (yyval.TypeVal) = new PATypeHolder(tmp); |
| 3456 | ;} |
| 3457 | break; |
| 3458 | |
| 3459 | case 122: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3460 | #line 1245 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3461 | { // Type UpReference |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3462 | if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3463 | OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3464 | UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector... |
| 3465 | (yyval.TypeVal) = new PATypeHolder(OT); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3466 | UR_OUT("New Upreference!\n"); |
| 3467 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3468 | ;} |
| 3469 | break; |
| 3470 | |
| 3471 | case 123: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3472 | #line 1253 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3473 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3474 | std::vector<const Type*> Params; |
| 3475 | std::vector<FunctionType::ParameterAttributes> Attrs; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3476 | Attrs.push_back((yyvsp[0].ParamAttrs)); |
| 3477 | for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3478 | Params.push_back(I->Ty->get()); |
| 3479 | if (I->Ty->get() != Type::VoidTy) |
| 3480 | Attrs.push_back(I->Attrs); |
| 3481 | } |
| 3482 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3483 | if (isVarArg) Params.pop_back(); |
| 3484 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3485 | FunctionType *FT = FunctionType::get(*(yyvsp[-4].TypeVal), Params, isVarArg, Attrs); |
| 3486 | delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list |
| 3487 | delete (yyvsp[-4].TypeVal); // Delete the return type handle |
| 3488 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 3489 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3490 | ;} |
| 3491 | break; |
| 3492 | |
| 3493 | case 124: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3494 | #line 1271 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3495 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3496 | std::vector<const Type*> Params; |
| 3497 | std::vector<FunctionType::ParameterAttributes> Attrs; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3498 | Attrs.push_back((yyvsp[0].ParamAttrs)); |
| 3499 | for (TypeWithAttrsList::iterator I=(yyvsp[-2].TypeWithAttrsList)->begin(), E=(yyvsp[-2].TypeWithAttrsList)->end(); I != E; ++I) { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3500 | Params.push_back(I->Ty->get()); |
| 3501 | if (I->Ty->get() != Type::VoidTy) |
| 3502 | Attrs.push_back(I->Attrs); |
| 3503 | } |
| 3504 | bool isVarArg = Params.size() && Params.back() == Type::VoidTy; |
| 3505 | if (isVarArg) Params.pop_back(); |
| 3506 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3507 | FunctionType *FT = FunctionType::get((yyvsp[-4].PrimType), Params, isVarArg, Attrs); |
| 3508 | delete (yyvsp[-2].TypeWithAttrsList); // Delete the argument list |
| 3509 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FT)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3510 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3511 | ;} |
| 3512 | break; |
| 3513 | |
| 3514 | case 125: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3515 | #line 1289 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3516 | { // Sized array type? |
| 3517 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); |
| 3518 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3519 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3520 | ;} |
| 3521 | break; |
| 3522 | |
| 3523 | case 126: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3524 | #line 1294 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3525 | { // Packed array type? |
| 3526 | const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get(); |
| 3527 | if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3528 | GEN_ERROR("Unsigned result not equal to signed result"); |
| 3529 | if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) |
| 3530 | GEN_ERROR("Element type of a PackedType must be primitive"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3531 | if (!isPowerOf2_32((yyvsp[-3].UInt64Val))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3532 | GEN_ERROR("Vector length should be a power of 2"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3533 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); |
| 3534 | delete (yyvsp[-1].TypeVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3535 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3536 | ;} |
| 3537 | break; |
| 3538 | |
| 3539 | case 127: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3540 | #line 1306 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3541 | { // Structure type? |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3542 | std::vector<const Type*> Elements; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3543 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(), |
| 3544 | E = (yyvsp[-1].TypeList)->end(); I != E; ++I) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3545 | Elements.push_back(*I); |
| 3546 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3547 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); |
| 3548 | delete (yyvsp[-1].TypeList); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3549 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3550 | ;} |
| 3551 | break; |
| 3552 | |
| 3553 | case 128: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3554 | #line 1316 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3555 | { // Empty structure type? |
| 3556 | (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>())); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3557 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3558 | ;} |
| 3559 | break; |
| 3560 | |
| 3561 | case 129: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3562 | #line 1320 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3563 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3564 | std::vector<const Type*> Elements; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3565 | for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-2].TypeList)->begin(), |
| 3566 | E = (yyvsp[-2].TypeList)->end(); I != E; ++I) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3567 | Elements.push_back(*I); |
| 3568 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3569 | (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); |
| 3570 | delete (yyvsp[-2].TypeList); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3571 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3572 | ;} |
| 3573 | break; |
| 3574 | |
| 3575 | case 130: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3576 | #line 1330 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3577 | { // Empty structure type? |
| 3578 | (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>(), true)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3579 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3580 | ;} |
| 3581 | break; |
| 3582 | |
| 3583 | case 131: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3584 | #line 1337 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3585 | { |
| 3586 | (yyval.TypeWithAttrs).Ty = (yyvsp[-1].TypeVal); |
| 3587 | (yyval.TypeWithAttrs).Attrs = (yyvsp[0].ParamAttrs); |
| 3588 | ;} |
| 3589 | break; |
| 3590 | |
| 3591 | case 132: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3592 | #line 1344 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3593 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3594 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3595 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 3596 | if (!(*(yyvsp[0].TypeVal))->isFirstClassType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3597 | GEN_ERROR("LLVM functions cannot return aggregate types"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3598 | (yyval.TypeVal) = (yyvsp[0].TypeVal); |
| 3599 | ;} |
| 3600 | break; |
| 3601 | |
| 3602 | case 133: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3603 | #line 1351 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3604 | { |
| 3605 | (yyval.TypeVal) = new PATypeHolder(Type::VoidTy); |
| 3606 | ;} |
| 3607 | break; |
| 3608 | |
| 3609 | case 134: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3610 | #line 1356 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3611 | { |
| 3612 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); |
| 3613 | (yyval.TypeWithAttrsList)->push_back((yyvsp[0].TypeWithAttrs)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 3614 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3615 | ;} |
| 3616 | break; |
| 3617 | |
| 3618 | case 135: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3619 | #line 1361 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3620 | { |
| 3621 | ((yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList))->push_back((yyvsp[0].TypeWithAttrs)); |
Reid Spencer | 3da59db | 2006-11-27 01:05:10 +0000 | [diff] [blame] | 3622 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3623 | ;} |
| 3624 | break; |
| 3625 | |
| 3626 | case 137: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3627 | #line 1369 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3628 | { |
| 3629 | (yyval.TypeWithAttrsList)=(yyvsp[-2].TypeWithAttrsList); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3630 | TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet; |
| 3631 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3632 | (yyval.TypeWithAttrsList)->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3633 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3634 | ;} |
| 3635 | break; |
| 3636 | |
| 3637 | case 138: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3638 | #line 1376 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3639 | { |
| 3640 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3641 | TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet; |
| 3642 | TWA.Ty = new PATypeHolder(Type::VoidTy); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3643 | (yyval.TypeWithAttrsList)->push_back(TWA); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3644 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3645 | ;} |
| 3646 | break; |
| 3647 | |
| 3648 | case 139: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3649 | #line 1383 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3650 | { |
| 3651 | (yyval.TypeWithAttrsList) = new TypeWithAttrsList(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3652 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3653 | ;} |
| 3654 | break; |
| 3655 | |
| 3656 | case 140: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3657 | #line 1391 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3658 | { |
| 3659 | (yyval.TypeList) = new std::list<PATypeHolder>(); |
| 3660 | (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3661 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3662 | ;} |
| 3663 | break; |
| 3664 | |
| 3665 | case 141: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3666 | #line 1396 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3667 | { |
| 3668 | ((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] | 3669 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3670 | ;} |
| 3671 | break; |
| 3672 | |
| 3673 | case 142: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3674 | #line 1407 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3675 | { // Nonempty unsized arr |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3676 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3677 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 3678 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3679 | if (ATy == 0) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3680 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3681 | (*(yyvsp[-3].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3682 | const Type *ETy = ATy->getElementType(); |
| 3683 | int NumElements = ATy->getNumElements(); |
| 3684 | |
| 3685 | // Verify that we have the correct size... |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3686 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3687 | GEN_ERROR("Type mismatch: constant sized array initialized with " + |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3688 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3689 | itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3690 | |
| 3691 | // Verify all elements are correct type! |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3692 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 3693 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3694 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3695 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3696 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3697 | } |
| 3698 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3699 | (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector)); |
| 3700 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3701 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3702 | ;} |
| 3703 | break; |
| 3704 | |
| 3705 | case 143: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3706 | #line 1435 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3707 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3708 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3709 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 3710 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3711 | if (ATy == 0) |
| 3712 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3713 | (*(yyvsp[-2].TypeVal))->getDescription() + "'"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3714 | |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3715 | int NumElements = ATy->getNumElements(); |
| 3716 | if (NumElements != -1 && NumElements != 0) |
| 3717 | GEN_ERROR("Type mismatch: constant sized array initialized with 0" |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3718 | " arguments, but has size of " + itostr(NumElements) +""); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3719 | (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>()); |
| 3720 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3721 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3722 | ;} |
| 3723 | break; |
| 3724 | |
| 3725 | case 144: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3726 | #line 1451 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3727 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3728 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3729 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 3730 | const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3731 | if (ATy == 0) |
| 3732 | GEN_ERROR("Cannot make array constant with type: '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3733 | (*(yyvsp[-2].TypeVal))->getDescription() + "'"); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3734 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3735 | int NumElements = ATy->getNumElements(); |
| 3736 | const Type *ETy = ATy->getElementType(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3737 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 3738 | if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal))) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3739 | GEN_ERROR("Can't build string constant of size " + |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3740 | itostr((int)(EndStr-(yyvsp[0].StrVal))) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3741 | " when array has size " + itostr(NumElements) + ""); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3742 | std::vector<Constant*> Vals; |
| 3743 | if (ETy == Type::Int8Ty) { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3744 | for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3745 | C != (unsigned char*)EndStr; ++C) |
| 3746 | Vals.push_back(ConstantInt::get(ETy, *C)); |
| 3747 | } else { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3748 | free((yyvsp[0].StrVal)); |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3749 | GEN_ERROR("Cannot build string arrays of non byte sized elements"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 3750 | } |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3751 | free((yyvsp[0].StrVal)); |
| 3752 | (yyval.ConstVal) = ConstantArray::get(ATy, Vals); |
| 3753 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3754 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3755 | ;} |
| 3756 | break; |
| 3757 | |
| 3758 | case 145: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3759 | #line 1480 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3760 | { // Nonempty unsized arr |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3761 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3762 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 3763 | const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3764 | if (PTy == 0) |
| 3765 | GEN_ERROR("Cannot make packed constant with type: '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3766 | (*(yyvsp[-3].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3767 | const Type *ETy = PTy->getElementType(); |
| 3768 | int NumElements = PTy->getNumElements(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3769 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3770 | // Verify that we have the correct size... |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3771 | if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3772 | GEN_ERROR("Type mismatch: constant sized packed initialized with " + |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3773 | utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3774 | itostr(NumElements) + ""); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3775 | |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3776 | // Verify all elements are correct type! |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3777 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 3778 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3779 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
| 3780 | ETy->getDescription() +"' as required!\nIt is of type '"+ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3781 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3782 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3783 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3784 | (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector)); |
| 3785 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3786 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3787 | ;} |
| 3788 | break; |
| 3789 | |
| 3790 | case 146: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3791 | #line 1508 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3792 | { |
| 3793 | const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3794 | if (STy == 0) |
| 3795 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3796 | (*(yyvsp[-3].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3797 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3798 | if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3799 | GEN_ERROR("Illegal number of initializers for structure type"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3800 | |
| 3801 | // Check to ensure that constants are compatible with the type initializer! |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3802 | for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) |
| 3803 | if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3804 | GEN_ERROR("Expected type '" + |
| 3805 | STy->getElementType(i)->getDescription() + |
| 3806 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3807 | " of structure initializer"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3808 | |
| 3809 | // Check to ensure that Type is not packed |
| 3810 | if (STy->isPacked()) |
| 3811 | GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); |
| 3812 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3813 | (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector)); |
| 3814 | delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3815 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3816 | ;} |
| 3817 | break; |
| 3818 | |
| 3819 | case 147: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3820 | #line 1533 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3821 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3822 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3823 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 3824 | const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3825 | if (STy == 0) |
| 3826 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3827 | (*(yyvsp[-2].TypeVal))->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3828 | |
| 3829 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3830 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3831 | |
| 3832 | // Check to ensure that Type is not packed |
| 3833 | if (STy->isPacked()) |
| 3834 | GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); |
| 3835 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3836 | (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3837 | delete (yyvsp[-2].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3838 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3839 | ;} |
| 3840 | break; |
| 3841 | |
| 3842 | case 148: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3843 | #line 1552 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3844 | { |
| 3845 | const StructType *STy = dyn_cast<StructType>((yyvsp[-5].TypeVal)->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3846 | if (STy == 0) |
| 3847 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3848 | (*(yyvsp[-5].TypeVal))->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3849 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3850 | if ((yyvsp[-2].ConstVector)->size() != STy->getNumContainedTypes()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3851 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3852 | |
| 3853 | // Check to ensure that constants are compatible with the type initializer! |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3854 | for (unsigned i = 0, e = (yyvsp[-2].ConstVector)->size(); i != e; ++i) |
| 3855 | if ((*(yyvsp[-2].ConstVector))[i]->getType() != STy->getElementType(i)) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3856 | GEN_ERROR("Expected type '" + |
| 3857 | STy->getElementType(i)->getDescription() + |
| 3858 | "' for element #" + utostr(i) + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3859 | " of structure initializer"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3860 | |
| 3861 | // Check to ensure that Type is packed |
| 3862 | if (!STy->isPacked()) |
| 3863 | GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); |
| 3864 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3865 | (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-2].ConstVector)); |
| 3866 | delete (yyvsp[-5].TypeVal); delete (yyvsp[-2].ConstVector); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3867 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3868 | ;} |
| 3869 | break; |
| 3870 | |
| 3871 | case 149: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3872 | #line 1577 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3873 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3874 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3875 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription()); |
| 3876 | const StructType *STy = dyn_cast<StructType>((yyvsp[-4].TypeVal)->get()); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3877 | if (STy == 0) |
| 3878 | GEN_ERROR("Cannot make struct constant with type: '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3879 | (*(yyvsp[-4].TypeVal))->getDescription() + "'"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3880 | |
| 3881 | if (STy->getNumContainedTypes() != 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3882 | GEN_ERROR("Illegal number of initializers for structure type"); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3883 | |
| 3884 | // Check to ensure that Type is packed |
| 3885 | if (!STy->isPacked()) |
| 3886 | GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); |
| 3887 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3888 | (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>()); |
| 3889 | delete (yyvsp[-4].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3890 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3891 | ;} |
| 3892 | break; |
| 3893 | |
| 3894 | case 150: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3895 | #line 1596 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3896 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3897 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3898 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 3899 | const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3900 | if (PTy == 0) |
| 3901 | GEN_ERROR("Cannot make null pointer constant with type: '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3902 | (*(yyvsp[-1].TypeVal))->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3903 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3904 | (yyval.ConstVal) = ConstantPointerNull::get(PTy); |
| 3905 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3906 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3907 | ;} |
| 3908 | break; |
| 3909 | |
| 3910 | case 151: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3911 | #line 1608 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3912 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3913 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3914 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 3915 | (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get()); |
| 3916 | delete (yyvsp[-1].TypeVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3917 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3918 | ;} |
| 3919 | break; |
| 3920 | |
| 3921 | case 152: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3922 | #line 1615 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3923 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3924 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3925 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 3926 | const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3927 | if (Ty == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 3928 | GEN_ERROR("Global const reference must be a pointer type"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3929 | |
| 3930 | // ConstExprs can exist in the body of a function, thus creating |
| 3931 | // GlobalValues whenever they refer to a variable. Because we are in |
| 3932 | // the context of a function, getValNonImprovising will search the functions |
| 3933 | // symbol table instead of the module symbol table for the global symbol, |
| 3934 | // which throws things all off. To get around this, we just tell |
| 3935 | // getValNonImprovising that we are at global scope here. |
| 3936 | // |
| 3937 | Function *SavedCurFn = CurFun.CurrentFunction; |
| 3938 | CurFun.CurrentFunction = 0; |
| 3939 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3940 | Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 3941 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3942 | |
| 3943 | CurFun.CurrentFunction = SavedCurFn; |
| 3944 | |
| 3945 | // If this is an initializer for a constant pointer, which is referencing a |
| 3946 | // (currently) undefined variable, create a stub now that shall be replaced |
| 3947 | // in the future with the right type of variable. |
| 3948 | // |
| 3949 | if (V == 0) { |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 3950 | assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3951 | const PointerType *PT = cast<PointerType>(Ty); |
| 3952 | |
| 3953 | // First check to see if the forward references value is already created! |
| 3954 | PerModuleInfo::GlobalRefsType::iterator I = |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3955 | CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal))); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3956 | |
| 3957 | if (I != CurModule.GlobalRefs.end()) { |
| 3958 | V = I->second; // Placeholder already exists, use it... |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3959 | (yyvsp[0].ValIDVal).destroy(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3960 | } else { |
| 3961 | std::string Name; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3962 | if ((yyvsp[0].ValIDVal).Type == ValID::GlobalName) |
| 3963 | Name = (yyvsp[0].ValIDVal).Name; |
| 3964 | else if ((yyvsp[0].ValIDVal).Type != ValID::GlobalID) |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 3965 | GEN_ERROR("Invalid reference to global"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 3966 | |
| 3967 | // Create the forward referenced global. |
| 3968 | GlobalValue *GV; |
| 3969 | if (const FunctionType *FTy = |
| 3970 | dyn_cast<FunctionType>(PT->getElementType())) { |
| 3971 | GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, |
| 3972 | CurModule.CurrentModule); |
| 3973 | } else { |
| 3974 | GV = new GlobalVariable(PT->getElementType(), false, |
| 3975 | GlobalValue::ExternalLinkage, 0, |
| 3976 | Name, CurModule.CurrentModule); |
| 3977 | } |
| 3978 | |
| 3979 | // Keep track of the fact that we have a forward ref to recycle it |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3980 | 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] | 3981 | V = GV; |
| 3982 | } |
| 3983 | } |
| 3984 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3985 | (yyval.ConstVal) = cast<GlobalValue>(V); |
| 3986 | delete (yyvsp[-1].TypeVal); // Free the type handle |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 3987 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3988 | ;} |
| 3989 | break; |
| 3990 | |
| 3991 | case 153: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 3992 | #line 1681 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3993 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 3994 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3995 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 3996 | if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 3997 | GEN_ERROR("Mismatched types for constant expression: " + |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 3998 | (*(yyvsp[-1].TypeVal))->getDescription() + " and " + (yyvsp[0].ConstVal)->getType()->getDescription()); |
| 3999 | (yyval.ConstVal) = (yyvsp[0].ConstVal); |
| 4000 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4001 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4002 | ;} |
| 4003 | break; |
| 4004 | |
| 4005 | case 154: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4006 | #line 1691 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4007 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4008 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4009 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 4010 | const Type *Ty = (yyvsp[-1].TypeVal)->get(); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4011 | if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty)) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4012 | GEN_ERROR("Cannot create a null initialized value of this type"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4013 | (yyval.ConstVal) = Constant::getNullValue(Ty); |
| 4014 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4015 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4016 | ;} |
| 4017 | break; |
| 4018 | |
| 4019 | case 155: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4020 | #line 1701 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4021 | { // integral constants |
| 4022 | if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4023 | GEN_ERROR("Constant value doesn't fit in type"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4024 | (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4025 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4026 | ;} |
| 4027 | break; |
| 4028 | |
| 4029 | case 156: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4030 | #line 1707 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4031 | { // integral constants |
| 4032 | if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4033 | GEN_ERROR("Constant value doesn't fit in type"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4034 | (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4035 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4036 | ;} |
| 4037 | break; |
| 4038 | |
| 4039 | case 157: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4040 | #line 1713 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4041 | { // Boolean constants |
| 4042 | assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 4043 | (yyval.ConstVal) = ConstantInt::getTrue(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4044 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4045 | ;} |
| 4046 | break; |
| 4047 | |
| 4048 | case 158: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4049 | #line 1718 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4050 | { // Boolean constants |
| 4051 | assert(cast<IntegerType>((yyvsp[-1].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 4052 | (yyval.ConstVal) = ConstantInt::getFalse(); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4053 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4054 | ;} |
| 4055 | break; |
| 4056 | |
| 4057 | case 159: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4058 | #line 1723 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4059 | { // Float & Double constants |
| 4060 | if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4061 | GEN_ERROR("Floating point constant invalid for type"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4062 | (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4063 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4064 | ;} |
| 4065 | break; |
| 4066 | |
| 4067 | case 160: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4068 | #line 1731 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4069 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4070 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4071 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 4072 | Constant *Val = (yyvsp[-3].ConstVal); |
| 4073 | const Type *DestTy = (yyvsp[-1].TypeVal)->get(); |
| 4074 | if (!CastInst::castIsValid((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4075 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 4076 | Val->getType()->getDescription() + "' to '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4077 | DestTy->getDescription() + "'"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4078 | (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), DestTy); |
| 4079 | delete (yyvsp[-1].TypeVal); |
| 4080 | ;} |
| 4081 | break; |
| 4082 | |
| 4083 | case 161: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4084 | #line 1743 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4085 | { |
| 4086 | if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4087 | GEN_ERROR("GetElementPtr requires a pointer operand"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4088 | |
| 4089 | const Type *IdxTy = |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4090 | GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4091 | if (!IdxTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4092 | GEN_ERROR("Index list invalid for constant getelementptr"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4093 | |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 4094 | SmallVector<Constant*, 8> IdxVec; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4095 | for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i) |
| 4096 | if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i])) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4097 | IdxVec.push_back(C); |
| 4098 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4099 | GEN_ERROR("Indices to constant getelementptr must be constants"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4100 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4101 | delete (yyvsp[-1].ValueList); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4102 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4103 | (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), &IdxVec[0], IdxVec.size()); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4104 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4105 | ;} |
| 4106 | break; |
| 4107 | |
| 4108 | case 162: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4109 | #line 1764 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4110 | { |
| 4111 | if ((yyvsp[-5].ConstVal)->getType() != Type::Int1Ty) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4112 | GEN_ERROR("Select condition must be of boolean type"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4113 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4114 | GEN_ERROR("Select operand types must match"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4115 | (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4116 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4117 | ;} |
| 4118 | break; |
| 4119 | |
| 4120 | case 163: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4121 | #line 1772 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4122 | { |
| 4123 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4124 | GEN_ERROR("Binary operator types must match"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4125 | CHECK_FOR_ERROR; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4126 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
| 4127 | ;} |
| 4128 | break; |
| 4129 | |
| 4130 | case 164: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4131 | #line 1778 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4132 | { |
| 4133 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4134 | GEN_ERROR("Logical operator types must match"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4135 | if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) { |
| 4136 | if (Instruction::isShift((yyvsp[-5].BinaryOpVal)) || !isa<PackedType>((yyvsp[-3].ConstVal)->getType()) || |
| 4137 | !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isInteger()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4138 | GEN_ERROR("Logical operator requires integral operands"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4139 | } |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4140 | (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4141 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4142 | ;} |
| 4143 | break; |
| 4144 | |
| 4145 | case 165: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4146 | #line 1789 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4147 | { |
| 4148 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4149 | GEN_ERROR("icmp operand types must match"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4150 | (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
| 4151 | ;} |
| 4152 | break; |
| 4153 | |
| 4154 | case 166: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4155 | #line 1794 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4156 | { |
| 4157 | if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4158 | GEN_ERROR("fcmp operand types must match"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4159 | (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
| 4160 | ;} |
| 4161 | break; |
| 4162 | |
| 4163 | case 167: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4164 | #line 1799 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4165 | { |
| 4166 | if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4167 | GEN_ERROR("Invalid extractelement operands"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4168 | (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4169 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4170 | ;} |
| 4171 | break; |
| 4172 | |
| 4173 | case 168: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4174 | #line 1805 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4175 | { |
| 4176 | if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4177 | GEN_ERROR("Invalid insertelement operands"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4178 | (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4179 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4180 | ;} |
| 4181 | break; |
| 4182 | |
| 4183 | case 169: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4184 | #line 1811 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4185 | { |
| 4186 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4187 | GEN_ERROR("Invalid shufflevector operands"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4188 | (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4189 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4190 | ;} |
| 4191 | break; |
| 4192 | |
| 4193 | case 170: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4194 | #line 1820 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4195 | { |
| 4196 | ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4197 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4198 | ;} |
| 4199 | break; |
| 4200 | |
| 4201 | case 171: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4202 | #line 1824 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4203 | { |
| 4204 | (yyval.ConstVector) = new std::vector<Constant*>(); |
| 4205 | (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4206 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4207 | ;} |
| 4208 | break; |
| 4209 | |
| 4210 | case 172: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4211 | #line 1832 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4212 | { (yyval.BoolVal) = false; ;} |
| 4213 | break; |
| 4214 | |
| 4215 | case 173: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4216 | #line 1832 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4217 | { (yyval.BoolVal) = true; ;} |
| 4218 | break; |
| 4219 | |
| 4220 | case 174: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4221 | #line 1843 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4222 | { |
| 4223 | (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4224 | CurModule.ModuleDone(); |
| 4225 | CHECK_FOR_ERROR; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4226 | ;} |
| 4227 | break; |
| 4228 | |
| 4229 | case 175: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4230 | #line 1848 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4231 | { |
| 4232 | (yyval.ModuleVal) = ParserResult = CurModule.CurrentModule; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4233 | CurModule.ModuleDone(); |
| 4234 | CHECK_FOR_ERROR; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4235 | ;} |
| 4236 | break; |
| 4237 | |
| 4238 | case 178: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4239 | #line 1861 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4240 | { CurFun.isDeclare = false; ;} |
| 4241 | break; |
| 4242 | |
| 4243 | case 179: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4244 | #line 1861 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4245 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4246 | CurFun.FunctionDone(); |
| 4247 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4248 | ;} |
| 4249 | break; |
| 4250 | |
| 4251 | case 180: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4252 | #line 1865 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4253 | { CurFun.isDeclare = true; ;} |
| 4254 | break; |
| 4255 | |
| 4256 | case 181: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4257 | #line 1865 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4258 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4259 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4260 | ;} |
| 4261 | break; |
| 4262 | |
| 4263 | case 182: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4264 | #line 1868 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4265 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4266 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4267 | ;} |
| 4268 | break; |
| 4269 | |
| 4270 | case 183: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4271 | #line 1871 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4272 | { |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4273 | // Emit an error if there are any unresolved types left. |
| 4274 | if (!CurModule.LateResolveTypes.empty()) { |
| 4275 | const ValID &DID = CurModule.LateResolveTypes.begin()->first; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4276 | if (DID.Type == ValID::LocalName) { |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4277 | GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'"); |
| 4278 | } else { |
| 4279 | GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num)); |
| 4280 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4281 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4282 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4283 | ;} |
| 4284 | break; |
| 4285 | |
| 4286 | case 184: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4287 | #line 1883 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4288 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4289 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4290 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4291 | // Eagerly resolve types. This is not an optimization, this is a |
| 4292 | // requirement that is due to the fact that we could have this: |
| 4293 | // |
| 4294 | // %list = type { %list * } |
| 4295 | // %list = type { %list * } ; repeated type decl |
| 4296 | // |
| 4297 | // If types are not resolved eagerly, then the two types will not be |
| 4298 | // determined to be the same type! |
| 4299 | // |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4300 | ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4301 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4302 | if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4303 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4304 | // If this is a named type that is not a redefinition, add it to the slot |
| 4305 | // table. |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4306 | CurModule.Types.push_back(*(yyvsp[0].TypeVal)); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4307 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4308 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4309 | delete (yyvsp[0].TypeVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4310 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4311 | ;} |
| 4312 | break; |
Reid Spencer | b0fcf8f | 2007-01-17 02:48:45 +0000 | [diff] [blame] | 4313 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4314 | case 185: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4315 | #line 1907 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4316 | { |
| 4317 | ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].PrimType)); |
| 4318 | |
| 4319 | if (!setTypeName((yyvsp[0].PrimType), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4320 | CHECK_FOR_ERROR |
| 4321 | // If this is a named type that is not a redefinition, add it to the slot |
| 4322 | // table. |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4323 | CurModule.Types.push_back((yyvsp[0].PrimType)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4324 | } |
Reid Spencer | 6e18b7d | 2006-12-03 06:59:29 +0000 | [diff] [blame] | 4325 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4326 | ;} |
| 4327 | break; |
| 4328 | |
| 4329 | case 186: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4330 | #line 1918 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4331 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4332 | /* "Externally Visible" Linkage */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4333 | if ((yyvsp[0].ConstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4334 | GEN_ERROR("Global value initializer is not a constant"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4335 | CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, |
| 4336 | (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4337 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4338 | ;} |
| 4339 | break; |
| 4340 | |
| 4341 | case 187: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4342 | #line 1925 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4343 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4344 | CurGV = 0; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4345 | ;} |
| 4346 | break; |
| 4347 | |
| 4348 | case 188: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4349 | #line 1928 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4350 | { |
| 4351 | if ((yyvsp[0].ConstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4352 | GEN_ERROR("Global value initializer is not a constant"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4353 | CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4354 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4355 | ;} |
| 4356 | break; |
| 4357 | |
| 4358 | case 189: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4359 | #line 1933 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4360 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4361 | CurGV = 0; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4362 | ;} |
| 4363 | break; |
| 4364 | |
| 4365 | case 190: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4366 | #line 1936 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4367 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4368 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4369 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 4370 | CurGV = ParseGlobalVariable((yyvsp[-4].StrVal), (yyvsp[-3].Linkage), (yyvsp[-2].Visibility), (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4371 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4372 | delete (yyvsp[0].TypeVal); |
| 4373 | ;} |
| 4374 | break; |
| 4375 | |
| 4376 | case 191: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4377 | #line 1942 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4378 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4379 | CurGV = 0; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4380 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4381 | ;} |
| 4382 | break; |
| 4383 | |
| 4384 | case 192: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4385 | #line 1946 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4386 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4387 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4388 | ;} |
| 4389 | break; |
| 4390 | |
| 4391 | case 193: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4392 | #line 1949 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4393 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4394 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4395 | ;} |
| 4396 | break; |
| 4397 | |
| 4398 | case 194: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4399 | #line 1955 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4400 | { |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4401 | const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4402 | char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4403 | std::string NewAsm((yyvsp[0].StrVal), EndStr); |
| 4404 | free((yyvsp[0].StrVal)); |
Chris Lattner | 6631601 | 2006-01-24 04:14:29 +0000 | [diff] [blame] | 4405 | |
| 4406 | if (AsmSoFar.empty()) |
| 4407 | CurModule.CurrentModule->setModuleInlineAsm(NewAsm); |
| 4408 | else |
| 4409 | CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4410 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4411 | ;} |
| 4412 | break; |
| 4413 | |
| 4414 | case 195: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4415 | #line 1968 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4416 | { |
| 4417 | CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); |
| 4418 | free((yyvsp[0].StrVal)); |
| 4419 | ;} |
| 4420 | break; |
| 4421 | |
| 4422 | case 196: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4423 | #line 1972 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4424 | { |
| 4425 | CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); |
| 4426 | free((yyvsp[0].StrVal)); |
| 4427 | ;} |
| 4428 | break; |
| 4429 | |
| 4430 | case 198: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4431 | #line 1979 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4432 | { |
| 4433 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 4434 | free((yyvsp[0].StrVal)); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4435 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4436 | ;} |
| 4437 | break; |
| 4438 | |
| 4439 | case 199: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4440 | #line 1984 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4441 | { |
| 4442 | CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); |
| 4443 | free((yyvsp[0].StrVal)); |
Reid Spencer | a54b7cb | 2007-01-12 07:05:14 +0000 | [diff] [blame] | 4444 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4445 | ;} |
| 4446 | break; |
| 4447 | |
| 4448 | case 200: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4449 | #line 1989 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4450 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4451 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4452 | ;} |
| 4453 | break; |
| 4454 | |
| 4455 | case 201: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4456 | #line 1998 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4457 | { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4458 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4459 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 4460 | if (*(yyvsp[-2].TypeVal) == Type::VoidTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4461 | GEN_ERROR("void typed arguments are invalid"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4462 | ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal); |
| 4463 | (yyval.ArgList) = (yyvsp[-4].ArgList); |
| 4464 | (yyvsp[-4].ArgList)->push_back(E); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4465 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4466 | ;} |
| 4467 | break; |
| 4468 | |
| 4469 | case 202: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4470 | #line 2008 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4471 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4472 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4473 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 4474 | if (*(yyvsp[-2].TypeVal) == Type::VoidTy) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4475 | GEN_ERROR("void typed arguments are invalid"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4476 | ArgListEntry E; E.Attrs = (yyvsp[-1].ParamAttrs); E.Ty = (yyvsp[-2].TypeVal); E.Name = (yyvsp[0].StrVal); |
| 4477 | (yyval.ArgList) = new ArgListType; |
| 4478 | (yyval.ArgList)->push_back(E); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4479 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4480 | ;} |
| 4481 | break; |
| 4482 | |
| 4483 | case 203: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4484 | #line 2019 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4485 | { |
| 4486 | (yyval.ArgList) = (yyvsp[0].ArgList); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4487 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4488 | ;} |
| 4489 | break; |
| 4490 | |
| 4491 | case 204: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4492 | #line 2023 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4493 | { |
| 4494 | (yyval.ArgList) = (yyvsp[-2].ArgList); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4495 | struct ArgListEntry E; |
| 4496 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 4497 | E.Name = 0; |
| 4498 | E.Attrs = FunctionType::NoAttributeSet; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4499 | (yyval.ArgList)->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4500 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4501 | ;} |
| 4502 | break; |
| 4503 | |
| 4504 | case 205: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4505 | #line 2032 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4506 | { |
| 4507 | (yyval.ArgList) = new ArgListType; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4508 | struct ArgListEntry E; |
| 4509 | E.Ty = new PATypeHolder(Type::VoidTy); |
| 4510 | E.Name = 0; |
| 4511 | E.Attrs = FunctionType::NoAttributeSet; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4512 | (yyval.ArgList)->push_back(E); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4513 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4514 | ;} |
| 4515 | break; |
| 4516 | |
| 4517 | case 206: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4518 | #line 2041 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4519 | { |
| 4520 | (yyval.ArgList) = 0; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4521 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4522 | ;} |
| 4523 | break; |
| 4524 | |
| 4525 | case 207: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4526 | #line 2047 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4527 | { |
| 4528 | UnEscapeLexed((yyvsp[-6].StrVal)); |
| 4529 | std::string FunctionName((yyvsp[-6].StrVal)); |
| 4530 | free((yyvsp[-6].StrVal)); // Free strdup'd memory! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4531 | |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 4532 | // Check the function result for abstractness if this is a define. We should |
| 4533 | // have no abstract types at this point |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4534 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved((yyvsp[-7].TypeVal))) |
| 4535 | GEN_ERROR("Reference to abstract result: "+ (yyvsp[-7].TypeVal)->get()->getDescription()); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 4536 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4537 | std::vector<const Type*> ParamTypeList; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4538 | std::vector<FunctionType::ParameterAttributes> ParamAttrs; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4539 | ParamAttrs.push_back((yyvsp[-2].ParamAttrs)); |
| 4540 | if ((yyvsp[-4].ArgList)) { // If there are arguments... |
| 4541 | 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] | 4542 | const Type* Ty = I->Ty->get(); |
Reid Spencer | 8c8a2dc | 2007-01-02 21:54:12 +0000 | [diff] [blame] | 4543 | if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty)) |
| 4544 | GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4545 | ParamTypeList.push_back(Ty); |
| 4546 | if (Ty != Type::VoidTy) |
| 4547 | ParamAttrs.push_back(I->Attrs); |
| 4548 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4549 | } |
| 4550 | |
| 4551 | bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; |
| 4552 | if (isVarArg) ParamTypeList.pop_back(); |
| 4553 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4554 | FunctionType *FT = FunctionType::get(*(yyvsp[-7].TypeVal), ParamTypeList, isVarArg, |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4555 | ParamAttrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4556 | const PointerType *PFT = PointerType::get(FT); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4557 | delete (yyvsp[-7].TypeVal); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4558 | |
| 4559 | ValID ID; |
| 4560 | if (!FunctionName.empty()) { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4561 | ID = ValID::createGlobalName((char*)FunctionName.c_str()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4562 | } else { |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4563 | ID = ValID::createGlobalID(CurModule.Values[PFT].size()); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4564 | } |
| 4565 | |
| 4566 | Function *Fn = 0; |
| 4567 | // See if this function was forward referenced. If so, recycle the object. |
| 4568 | if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { |
| 4569 | // Move the function to the end of the list, from whereever it was |
| 4570 | // previously inserted. |
| 4571 | Fn = cast<Function>(FWRef); |
| 4572 | CurModule.CurrentModule->getFunctionList().remove(Fn); |
| 4573 | CurModule.CurrentModule->getFunctionList().push_back(Fn); |
| 4574 | } else if (!FunctionName.empty() && // Merge with an earlier prototype? |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4575 | (Fn = CurModule.CurrentModule->getFunction(FunctionName))) { |
| 4576 | if (Fn->getFunctionType() != FT ) { |
| 4577 | // The existing function doesn't have the same type. This is an overload |
| 4578 | // error. |
| 4579 | GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); |
| 4580 | } else if (!CurFun.isDeclare && !Fn->isDeclaration()) { |
| 4581 | // Neither the existing or the current function is a declaration and they |
| 4582 | // have the same name and same type. Clearly this is a redefinition. |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4583 | GEN_ERROR("Redefinition of function '" + FunctionName + "'"); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4584 | } if (Fn->isDeclaration()) { |
| 4585 | // Make sure to strip off any argument names so we can't get conflicts. |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4586 | for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end(); |
| 4587 | AI != AE; ++AI) |
| 4588 | AI->setName(""); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4589 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4590 | } else { // Not already defined? |
| 4591 | Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, |
| 4592 | CurModule.CurrentModule); |
Anton Korobeynikov | 43e3aad | 2006-09-14 18:25:26 +0000 | [diff] [blame] | 4593 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4594 | InsertValue(Fn, CurModule.Values); |
| 4595 | } |
| 4596 | |
| 4597 | CurFun.FunctionStart(Fn); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4598 | |
| 4599 | if (CurFun.isDeclare) { |
| 4600 | // If we have declaration, always overwrite linkage. This will allow us to |
| 4601 | // correctly handle cases, when pointer to function is passed as argument to |
| 4602 | // another function. |
| 4603 | Fn->setLinkage(CurFun.Linkage); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4604 | Fn->setVisibility(CurFun.Visibility); |
Anton Korobeynikov | 93c2b37 | 2006-09-17 13:06:18 +0000 | [diff] [blame] | 4605 | } |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4606 | Fn->setCallingConv((yyvsp[-8].UIntVal)); |
| 4607 | Fn->setAlignment((yyvsp[0].UIntVal)); |
| 4608 | if ((yyvsp[-1].StrVal)) { |
| 4609 | Fn->setSection((yyvsp[-1].StrVal)); |
| 4610 | free((yyvsp[-1].StrVal)); |
Chris Lattner | e869eef | 2005-11-12 00:11:49 +0000 | [diff] [blame] | 4611 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4612 | |
| 4613 | // Add all of the arguments we parsed to the function... |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4614 | if ((yyvsp[-4].ArgList)) { // Is null if empty... |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4615 | if (isVarArg) { // Nuke the last entry |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4616 | assert((yyvsp[-4].ArgList)->back().Ty->get() == Type::VoidTy && (yyvsp[-4].ArgList)->back().Name == 0 && |
Reid Spencer | a9720f5 | 2007-02-05 17:04:00 +0000 | [diff] [blame] | 4617 | "Not a varargs marker!"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4618 | delete (yyvsp[-4].ArgList)->back().Ty; |
| 4619 | (yyvsp[-4].ArgList)->pop_back(); // Delete the last entry |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4620 | } |
| 4621 | Function::arg_iterator ArgIt = Fn->arg_begin(); |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4622 | Function::arg_iterator ArgEnd = Fn->arg_end(); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4623 | unsigned Idx = 1; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4624 | for (ArgListType::iterator I = (yyvsp[-4].ArgList)->begin(); |
| 4625 | I != (yyvsp[-4].ArgList)->end() && ArgIt != ArgEnd; ++I, ++ArgIt) { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4626 | delete I->Ty; // Delete the typeholder... |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4627 | setValueName(ArgIt, I->Name); // Insert arg into symtab... |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 4628 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4629 | InsertValue(ArgIt); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4630 | Idx++; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4631 | } |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4632 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4633 | delete (yyvsp[-4].ArgList); // We're now done with the argument list |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4634 | } |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4635 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4636 | ;} |
| 4637 | break; |
| 4638 | |
| 4639 | case 210: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4640 | #line 2160 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4641 | { |
| 4642 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4643 | |
| 4644 | // Make sure that we keep track of the linkage type even if there was a |
| 4645 | // previous "declare". |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4646 | (yyval.FunctionVal)->setLinkage((yyvsp[-3].Linkage)); |
| 4647 | (yyval.FunctionVal)->setVisibility((yyvsp[-2].Visibility)); |
| 4648 | ;} |
| 4649 | break; |
| 4650 | |
| 4651 | case 213: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4652 | #line 2171 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4653 | { |
| 4654 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4655 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4656 | ;} |
| 4657 | break; |
| 4658 | |
| 4659 | case 214: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4660 | #line 2176 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4661 | { |
| 4662 | CurFun.CurrentFunction->setLinkage((yyvsp[-2].Linkage)); |
| 4663 | CurFun.CurrentFunction->setVisibility((yyvsp[-1].Visibility)); |
| 4664 | (yyval.FunctionVal) = CurFun.CurrentFunction; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4665 | CurFun.FunctionDone(); |
| 4666 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4667 | ;} |
| 4668 | break; |
| 4669 | |
| 4670 | case 215: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4671 | #line 2188 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4672 | { |
| 4673 | (yyval.BoolVal) = false; |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4674 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4675 | ;} |
| 4676 | break; |
| 4677 | |
| 4678 | case 216: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4679 | #line 2192 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4680 | { |
| 4681 | (yyval.BoolVal) = true; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4682 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4683 | ;} |
| 4684 | break; |
| 4685 | |
| 4686 | case 217: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4687 | #line 2197 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4688 | { // A reference to a direct constant |
| 4689 | (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4690 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4691 | ;} |
| 4692 | break; |
| 4693 | |
| 4694 | case 218: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4695 | #line 2201 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4696 | { |
| 4697 | (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 4698 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4699 | ;} |
| 4700 | break; |
| 4701 | |
| 4702 | case 219: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4703 | #line 2205 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4704 | { // Perhaps it's an FP constant? |
| 4705 | (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4706 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4707 | ;} |
| 4708 | break; |
| 4709 | |
| 4710 | case 220: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4711 | #line 2209 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4712 | { |
| 4713 | (yyval.ValIDVal) = ValID::create(ConstantInt::getTrue()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4714 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4715 | ;} |
| 4716 | break; |
| 4717 | |
| 4718 | case 221: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4719 | #line 2213 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4720 | { |
| 4721 | (yyval.ValIDVal) = ValID::create(ConstantInt::getFalse()); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4722 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4723 | ;} |
| 4724 | break; |
| 4725 | |
| 4726 | case 222: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4727 | #line 2217 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4728 | { |
| 4729 | (yyval.ValIDVal) = ValID::createNull(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4730 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4731 | ;} |
| 4732 | break; |
| 4733 | |
| 4734 | case 223: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4735 | #line 2221 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4736 | { |
| 4737 | (yyval.ValIDVal) = ValID::createUndef(); |
Zhou Sheng | 6b6b6ef | 2007-01-11 12:24:14 +0000 | [diff] [blame] | 4738 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4739 | ;} |
| 4740 | break; |
| 4741 | |
| 4742 | case 224: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4743 | #line 2225 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4744 | { // A vector zero constant. |
| 4745 | (yyval.ValIDVal) = ValID::createZeroInit(); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4746 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4747 | ;} |
| 4748 | break; |
| 4749 | |
| 4750 | case 225: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4751 | #line 2229 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4752 | { // Nonempty unsized packed vector |
| 4753 | const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType(); |
| 4754 | int NumElements = (yyvsp[-1].ConstVector)->size(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4755 | |
| 4756 | PackedType* pt = PackedType::get(ETy, NumElements); |
| 4757 | PATypeHolder* PTy = new PATypeHolder( |
Reid Spencer | a132e04 | 2006-12-03 05:46:11 +0000 | [diff] [blame] | 4758 | HandleUpRefs( |
| 4759 | PackedType::get( |
| 4760 | ETy, |
| 4761 | NumElements) |
| 4762 | ) |
| 4763 | ); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4764 | |
| 4765 | // Verify all elements are correct type! |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4766 | for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { |
| 4767 | if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4768 | GEN_ERROR("Element #" + utostr(i) + " is not of type '" + |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4769 | ETy->getDescription() +"' as required!\nIt is of type '" + |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4770 | (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4771 | } |
| 4772 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4773 | (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector))); |
| 4774 | delete PTy; delete (yyvsp[-1].ConstVector); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 4775 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4776 | ;} |
| 4777 | break; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4778 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4779 | case 226: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4780 | #line 2254 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4781 | { |
| 4782 | (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal)); |
Anton Korobeynikov | 178a352 | 2007-01-12 19:22:51 +0000 | [diff] [blame] | 4783 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4784 | ;} |
| 4785 | break; |
| 4786 | |
| 4787 | case 227: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4788 | #line 2258 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4789 | { |
| 4790 | char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); |
| 4791 | std::string AsmStr = std::string((yyvsp[-2].StrVal), End); |
| 4792 | End = UnEscapeLexed((yyvsp[0].StrVal), true); |
| 4793 | std::string Constraints = std::string((yyvsp[0].StrVal), End); |
| 4794 | (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal)); |
| 4795 | free((yyvsp[-2].StrVal)); |
| 4796 | free((yyvsp[0].StrVal)); |
| 4797 | CHECK_FOR_ERROR |
| 4798 | ;} |
| 4799 | break; |
| 4800 | |
| 4801 | case 228: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4802 | #line 2272 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4803 | { // Is it an integer reference...? |
| 4804 | (yyval.ValIDVal) = ValID::createLocalID((yyvsp[0].UIntVal)); |
| 4805 | CHECK_FOR_ERROR |
| 4806 | ;} |
| 4807 | break; |
| 4808 | |
| 4809 | case 229: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4810 | #line 2276 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4811 | { |
| 4812 | (yyval.ValIDVal) = ValID::createGlobalID((yyvsp[0].UIntVal)); |
| 4813 | CHECK_FOR_ERROR |
| 4814 | ;} |
| 4815 | break; |
| 4816 | |
| 4817 | case 230: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4818 | #line 2280 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4819 | { // Is it a named reference...? |
| 4820 | (yyval.ValIDVal) = ValID::createLocalName((yyvsp[0].StrVal)); |
| 4821 | CHECK_FOR_ERROR |
| 4822 | ;} |
| 4823 | break; |
| 4824 | |
| 4825 | case 231: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4826 | #line 2284 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4827 | { // Is it a named reference...? |
| 4828 | (yyval.ValIDVal) = ValID::createGlobalName((yyvsp[0].StrVal)); |
| 4829 | CHECK_FOR_ERROR |
| 4830 | ;} |
| 4831 | break; |
| 4832 | |
| 4833 | case 234: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4834 | #line 2296 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4835 | { |
| 4836 | if (!UpRefs.empty()) |
| 4837 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 4838 | (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); |
| 4839 | delete (yyvsp[-1].TypeVal); |
| 4840 | CHECK_FOR_ERROR |
| 4841 | ;} |
| 4842 | break; |
| 4843 | |
| 4844 | case 235: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4845 | #line 2305 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4846 | { |
| 4847 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 4848 | CHECK_FOR_ERROR |
| 4849 | ;} |
| 4850 | break; |
| 4851 | |
| 4852 | case 236: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4853 | #line 2309 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4854 | { // Do not allow functions with 0 basic blocks |
| 4855 | (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); |
| 4856 | CHECK_FOR_ERROR |
| 4857 | ;} |
| 4858 | break; |
| 4859 | |
| 4860 | case 237: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4861 | #line 2318 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4862 | { |
| 4863 | setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal)); |
| 4864 | CHECK_FOR_ERROR |
| 4865 | InsertValue((yyvsp[0].TermInstVal)); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4866 | (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal)); |
| 4867 | InsertValue((yyvsp[-2].BasicBlockVal)); |
| 4868 | (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal); |
| 4869 | CHECK_FOR_ERROR |
| 4870 | ;} |
| 4871 | break; |
| 4872 | |
| 4873 | case 238: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4874 | #line 2328 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4875 | { |
| 4876 | if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal))) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4877 | if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0))) |
| 4878 | if (CI2->getParent() == 0) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4879 | (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2); |
| 4880 | (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal)); |
| 4881 | (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 4882 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4883 | ;} |
| 4884 | break; |
| 4885 | |
| 4886 | case 239: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4887 | #line 2337 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4888 | { |
| 4889 | (yyval.BasicBlockVal) = getBBVal(ValID::createLocalID(CurFun.NextBBNum++), true); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4890 | CHECK_FOR_ERROR |
| 4891 | |
| 4892 | // Make sure to move the basic block to the correct location in the |
| 4893 | // function, instead of leaving it inserted wherever it was first |
| 4894 | // referenced. |
| 4895 | Function::BasicBlockListType &BBL = |
| 4896 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4897 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4898 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4899 | ;} |
| 4900 | break; |
| 4901 | |
| 4902 | case 240: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4903 | #line 2349 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4904 | { |
| 4905 | (yyval.BasicBlockVal) = getBBVal(ValID::createLocalName((yyvsp[0].StrVal)), true); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 4906 | CHECK_FOR_ERROR |
| 4907 | |
| 4908 | // Make sure to move the basic block to the correct location in the |
| 4909 | // function, instead of leaving it inserted wherever it was first |
| 4910 | // referenced. |
| 4911 | Function::BasicBlockListType &BBL = |
| 4912 | CurFun.CurrentFunction->getBasicBlockList(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4913 | BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal)); |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4914 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4915 | ;} |
| 4916 | break; |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4917 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4918 | case 241: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4919 | #line 2362 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4920 | { // Return with a result... |
| 4921 | (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal)); |
| 4922 | CHECK_FOR_ERROR |
| 4923 | ;} |
| 4924 | break; |
| 4925 | |
| 4926 | case 242: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4927 | #line 2366 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4928 | { // Return with no result... |
| 4929 | (yyval.TermInstVal) = new ReturnInst(); |
| 4930 | CHECK_FOR_ERROR |
| 4931 | ;} |
| 4932 | break; |
| 4933 | |
| 4934 | case 243: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4935 | #line 2370 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4936 | { // Unconditional Branch... |
| 4937 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
| 4938 | CHECK_FOR_ERROR |
| 4939 | (yyval.TermInstVal) = new BranchInst(tmpBB); |
| 4940 | ;} |
| 4941 | break; |
| 4942 | |
| 4943 | case 244: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4944 | #line 2375 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4945 | { |
| 4946 | assert(cast<IntegerType>((yyvsp[-7].PrimType))->getBitWidth() == 1 && "Not Bool?"); |
| 4947 | BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); |
| 4948 | CHECK_FOR_ERROR |
| 4949 | BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal)); |
| 4950 | CHECK_FOR_ERROR |
| 4951 | Value* tmpVal = getVal(Type::Int1Ty, (yyvsp[-6].ValIDVal)); |
| 4952 | CHECK_FOR_ERROR |
| 4953 | (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal); |
| 4954 | ;} |
| 4955 | break; |
| 4956 | |
| 4957 | case 245: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4958 | #line 2385 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4959 | { |
| 4960 | Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal)); |
| 4961 | CHECK_FOR_ERROR |
| 4962 | BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal)); |
| 4963 | CHECK_FOR_ERROR |
| 4964 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size()); |
| 4965 | (yyval.TermInstVal) = S; |
| 4966 | |
| 4967 | std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(), |
| 4968 | E = (yyvsp[-1].JumpTable)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4969 | for (; I != E; ++I) { |
| 4970 | if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first)) |
| 4971 | S->addCase(CI, I->second); |
| 4972 | else |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 4973 | GEN_ERROR("Switch case is constant, but not a simple integer"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 4974 | } |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4975 | delete (yyvsp[-1].JumpTable); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4976 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4977 | ;} |
| 4978 | break; |
| 4979 | |
| 4980 | case 246: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4981 | #line 2404 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4982 | { |
| 4983 | Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4984 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4985 | BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 4986 | CHECK_FOR_ERROR |
| 4987 | SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4988 | (yyval.TermInstVal) = S; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 4989 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4990 | ;} |
| 4991 | break; |
| 4992 | |
| 4993 | case 247: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 4994 | #line 2414 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 4995 | { |
Reid Spencer | 3822ff5 | 2006-11-08 06:47:33 +0000 | [diff] [blame] | 4996 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 4997 | // Handle the short syntax |
| 4998 | const PointerType *PFTy = 0; |
| 4999 | const FunctionType *Ty = 0; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5000 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-11].TypeVal)->get())) || |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5001 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5002 | // Pull out the types of all of the arguments... |
| 5003 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5004 | FunctionType::ParamAttrsList ParamAttrs; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5005 | ParamAttrs.push_back((yyvsp[-6].ParamAttrs)); |
| 5006 | 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] | 5007 | const Type *Ty = I->Val->getType(); |
| 5008 | if (Ty == Type::VoidTy) |
| 5009 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 5010 | ParamTypes.push_back(Ty); |
| 5011 | ParamAttrs.push_back(I->Attrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5012 | } |
| 5013 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5014 | Ty = FunctionType::get((yyvsp[-11].TypeVal)->get(), ParamTypes, false, ParamAttrs); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5015 | PFTy = PointerType::get(Ty); |
| 5016 | } |
| 5017 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5018 | 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] | 5019 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5020 | BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5021 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5022 | BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal)); |
Reid Spencer | 5b7e753 | 2006-09-28 19:28:24 +0000 | [diff] [blame] | 5023 | CHECK_FOR_ERROR |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5024 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5025 | // Check the arguments |
| 5026 | ValueList Args; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5027 | if ((yyvsp[-8].ValueRefList)->empty()) { // Has no arguments? |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5028 | // Make sure no arguments is a good thing! |
| 5029 | if (Ty->getNumParams() != 0) |
| 5030 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5031 | "expects arguments"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5032 | } else { // Has arguments? |
| 5033 | // Loop through FunctionType's arguments and ensure they are specified |
| 5034 | // correctly! |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5035 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5036 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5037 | ValueRefList::iterator ArgI = (yyvsp[-8].ValueRefList)->begin(), ArgE = (yyvsp[-8].ValueRefList)->end(); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5038 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5039 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5040 | if (ArgI->Val->getType() != *I) |
| 5041 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5042 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5043 | Args.push_back(ArgI->Val); |
| 5044 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5045 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5046 | if (Ty->isVarArg()) { |
| 5047 | if (I == E) |
| 5048 | for (; ArgI != ArgE; ++ArgI) |
| 5049 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 5050 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5051 | GEN_ERROR("Invalid number of parameters detected"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5052 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5053 | |
| 5054 | // Create the InvokeInst |
| 5055 | InvokeInst *II = new InvokeInst(V, Normal, Except, Args); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5056 | II->setCallingConv((yyvsp[-12].UIntVal)); |
| 5057 | (yyval.TermInstVal) = II; |
| 5058 | delete (yyvsp[-8].ValueRefList); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5059 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5060 | ;} |
| 5061 | break; |
| 5062 | |
| 5063 | case 248: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5064 | #line 2480 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5065 | { |
| 5066 | (yyval.TermInstVal) = new UnwindInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5067 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5068 | ;} |
| 5069 | break; |
| 5070 | |
| 5071 | case 249: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5072 | #line 2484 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5073 | { |
| 5074 | (yyval.TermInstVal) = new UnreachableInst(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5075 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5076 | ;} |
| 5077 | break; |
| 5078 | |
| 5079 | case 250: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5080 | #line 2491 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5081 | { |
| 5082 | (yyval.JumpTable) = (yyvsp[-5].JumpTable); |
| 5083 | Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5084 | CHECK_FOR_ERROR |
| 5085 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5086 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5087 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5088 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5089 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5090 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5091 | ;} |
| 5092 | break; |
| 5093 | |
| 5094 | case 251: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5095 | #line 2502 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5096 | { |
| 5097 | (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >(); |
| 5098 | Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5099 | CHECK_FOR_ERROR |
| 5100 | |
| 5101 | if (V == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5102 | GEN_ERROR("May only switch on a constant pool value"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5103 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5104 | BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5105 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5106 | (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); |
| 5107 | ;} |
| 5108 | break; |
| 5109 | |
| 5110 | case 252: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5111 | #line 2515 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5112 | { |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5113 | // Is this definition named?? if so, assign the name... |
| 5114 | setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal)); |
| 5115 | CHECK_FOR_ERROR |
| 5116 | InsertValue((yyvsp[0].InstVal)); |
| 5117 | (yyval.InstVal) = (yyvsp[0].InstVal); |
| 5118 | CHECK_FOR_ERROR |
| 5119 | ;} |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5120 | break; |
| 5121 | |
| 5122 | case 253: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5123 | #line 2525 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5124 | { // Used for PHI nodes |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5125 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5126 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-5].TypeVal))->getDescription()); |
| 5127 | (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >(); |
| 5128 | Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5129 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5130 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5131 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5132 | (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5133 | delete (yyvsp[-5].TypeVal); |
| 5134 | ;} |
| 5135 | break; |
| 5136 | |
| 5137 | case 254: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5138 | #line 2536 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5139 | { |
| 5140 | (yyval.PHIList) = (yyvsp[-6].PHIList); |
| 5141 | Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5142 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5143 | BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5144 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5145 | (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); |
| 5146 | ;} |
| 5147 | break; |
| 5148 | |
| 5149 | case 255: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5150 | #line 2546 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5151 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5152 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5153 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5154 | // Used for call and invoke instructions |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5155 | (yyval.ValueRefList) = new ValueRefList(); |
| 5156 | ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal)); |
| 5157 | (yyval.ValueRefList)->push_back(E); |
| 5158 | ;} |
| 5159 | break; |
| 5160 | |
| 5161 | case 256: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5162 | #line 2554 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5163 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5164 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5165 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 5166 | (yyval.ValueRefList) = (yyvsp[-4].ValueRefList); |
| 5167 | ValueRefListEntry E; E.Attrs = (yyvsp[0].ParamAttrs); E.Val = getVal((yyvsp[-2].TypeVal)->get(), (yyvsp[-1].ValIDVal)); |
| 5168 | (yyval.ValueRefList)->push_back(E); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5169 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5170 | ;} |
| 5171 | break; |
| 5172 | |
| 5173 | case 257: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5174 | #line 2562 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5175 | { (yyval.ValueRefList) = new ValueRefList(); ;} |
| 5176 | break; |
| 5177 | |
| 5178 | case 258: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5179 | #line 2565 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5180 | { (yyval.ValueList) = new std::vector<Value*>(); ;} |
| 5181 | break; |
| 5182 | |
| 5183 | case 259: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5184 | #line 2566 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5185 | { |
| 5186 | (yyval.ValueList) = (yyvsp[-2].ValueList); |
| 5187 | (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5188 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5189 | ;} |
| 5190 | break; |
| 5191 | |
| 5192 | case 260: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5193 | #line 2573 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5194 | { |
| 5195 | (yyval.BoolVal) = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5196 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5197 | ;} |
| 5198 | break; |
| 5199 | |
| 5200 | case 261: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5201 | #line 2577 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5202 | { |
| 5203 | (yyval.BoolVal) = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5204 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5205 | ;} |
| 5206 | break; |
| 5207 | |
| 5208 | case 262: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5209 | #line 2582 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5210 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5211 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5212 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 5213 | if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() && |
| 5214 | !isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5215 | GEN_ERROR( |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5216 | "Arithmetic operator requires integer, FP, or packed operands"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5217 | if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) && |
| 5218 | ((yyvsp[-4].BinaryOpVal) == Instruction::URem || |
| 5219 | (yyvsp[-4].BinaryOpVal) == Instruction::SRem || |
| 5220 | (yyvsp[-4].BinaryOpVal) == Instruction::FRem)) |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5221 | GEN_ERROR("Remainder not supported on packed types"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5222 | Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5223 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5224 | Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5225 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5226 | (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2); |
| 5227 | if ((yyval.InstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5228 | GEN_ERROR("binary operator returned null"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5229 | delete (yyvsp[-3].TypeVal); |
| 5230 | ;} |
| 5231 | break; |
| 5232 | |
| 5233 | case 263: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5234 | #line 2603 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5235 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5236 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5237 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 5238 | if (!(*(yyvsp[-3].TypeVal))->isInteger()) { |
| 5239 | if (Instruction::isShift((yyvsp[-4].BinaryOpVal)) || !isa<PackedType>((yyvsp[-3].TypeVal)->get()) || |
| 5240 | !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isInteger()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5241 | GEN_ERROR("Logical operator requires integral operands"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5242 | } |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5243 | Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5244 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5245 | Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5246 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5247 | (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2); |
| 5248 | if ((yyval.InstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5249 | GEN_ERROR("binary operator returned null"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5250 | delete (yyvsp[-3].TypeVal); |
| 5251 | ;} |
| 5252 | break; |
| 5253 | |
| 5254 | case 264: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5255 | #line 2620 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5256 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5257 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5258 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 5259 | if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) |
Reid Spencer | ac4a1dd | 2007-01-04 02:57:52 +0000 | [diff] [blame] | 5260 | GEN_ERROR("Packed types not supported by icmp instruction"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5261 | Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5262 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5263 | Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5264 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5265 | (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2); |
| 5266 | if ((yyval.InstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5267 | GEN_ERROR("icmp operator returned null"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5268 | ;} |
| 5269 | break; |
| 5270 | |
| 5271 | case 265: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5272 | #line 2633 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5273 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5274 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5275 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-3].TypeVal))->getDescription()); |
| 5276 | if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) |
Reid Spencer | ac4a1dd | 2007-01-04 02:57:52 +0000 | [diff] [blame] | 5277 | GEN_ERROR("Packed types not supported by fcmp instruction"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5278 | Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5279 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5280 | Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5281 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5282 | (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2); |
| 5283 | if ((yyval.InstVal) == 0) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5284 | GEN_ERROR("fcmp operator returned null"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5285 | ;} |
| 5286 | break; |
| 5287 | |
| 5288 | case 266: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5289 | #line 2646 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5290 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5291 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5292 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 5293 | Value* Val = (yyvsp[-2].ValueVal); |
| 5294 | const Type* DestTy = (yyvsp[0].TypeVal)->get(); |
| 5295 | if (!CastInst::castIsValid((yyvsp[-3].CastOpVal), Val, DestTy)) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5296 | GEN_ERROR("invalid cast opcode for cast from '" + |
| 5297 | Val->getType()->getDescription() + "' to '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5298 | DestTy->getDescription() + "'"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5299 | (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), Val, DestTy); |
| 5300 | delete (yyvsp[0].TypeVal); |
| 5301 | ;} |
| 5302 | break; |
| 5303 | |
| 5304 | case 267: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5305 | #line 2658 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5306 | { |
| 5307 | if ((yyvsp[-4].ValueVal)->getType() != Type::Int1Ty) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5308 | GEN_ERROR("select condition must be boolean"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5309 | if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5310 | GEN_ERROR("select value types should match"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5311 | (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5312 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5313 | ;} |
| 5314 | break; |
| 5315 | |
| 5316 | case 268: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5317 | #line 2666 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5318 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5319 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5320 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); |
| 5321 | (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal)); |
| 5322 | delete (yyvsp[0].TypeVal); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5323 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5324 | ;} |
| 5325 | break; |
| 5326 | |
| 5327 | case 269: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5328 | #line 2673 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5329 | { |
| 5330 | if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5331 | GEN_ERROR("Invalid extractelement operands"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5332 | (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5333 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5334 | ;} |
| 5335 | break; |
| 5336 | |
| 5337 | case 270: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5338 | #line 2679 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5339 | { |
| 5340 | if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5341 | GEN_ERROR("Invalid insertelement operands"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5342 | (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] | 5343 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5344 | ;} |
| 5345 | break; |
| 5346 | |
| 5347 | case 271: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5348 | #line 2685 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5349 | { |
| 5350 | if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5351 | GEN_ERROR("Invalid shufflevector operands"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5352 | (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5353 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5354 | ;} |
| 5355 | break; |
| 5356 | |
| 5357 | case 272: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5358 | #line 2691 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5359 | { |
| 5360 | const Type *Ty = (yyvsp[0].PHIList)->front().first->getType(); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5361 | if (!Ty->isFirstClassType()) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5362 | GEN_ERROR("PHI node operands must be of first class type"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5363 | (yyval.InstVal) = new PHINode(Ty); |
| 5364 | ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size()); |
| 5365 | while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) { |
| 5366 | if ((yyvsp[0].PHIList)->front().first->getType() != Ty) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5367 | GEN_ERROR("All elements of a PHI node must be of the same type"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5368 | cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second); |
| 5369 | (yyvsp[0].PHIList)->pop_front(); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5370 | } |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5371 | delete (yyvsp[0].PHIList); // Free the list... |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5372 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5373 | ;} |
| 5374 | break; |
| 5375 | |
| 5376 | case 273: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5377 | #line 2707 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5378 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5379 | |
| 5380 | // Handle the short syntax |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5381 | const PointerType *PFTy = 0; |
| 5382 | const FunctionType *Ty = 0; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5383 | if (!(PFTy = dyn_cast<PointerType>((yyvsp[-5].TypeVal)->get())) || |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5384 | !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) { |
| 5385 | // Pull out the types of all of the arguments... |
| 5386 | std::vector<const Type*> ParamTypes; |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5387 | FunctionType::ParamAttrsList ParamAttrs; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5388 | ParamAttrs.push_back((yyvsp[0].ParamAttrs)); |
| 5389 | 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] | 5390 | const Type *Ty = I->Val->getType(); |
| 5391 | if (Ty == Type::VoidTy) |
| 5392 | GEN_ERROR("Short call syntax cannot be used with varargs"); |
| 5393 | ParamTypes.push_back(Ty); |
| 5394 | ParamAttrs.push_back(I->Attrs); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5395 | } |
| 5396 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5397 | Ty = FunctionType::get((yyvsp[-5].TypeVal)->get(), ParamTypes, false, ParamAttrs); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5398 | PFTy = PointerType::get(Ty); |
| 5399 | } |
| 5400 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5401 | 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] | 5402 | CHECK_FOR_ERROR |
| 5403 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5404 | // Check the arguments |
| 5405 | ValueList Args; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5406 | if ((yyvsp[-2].ValueRefList)->empty()) { // Has no arguments? |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5407 | // Make sure no arguments is a good thing! |
| 5408 | if (Ty->getNumParams() != 0) |
| 5409 | GEN_ERROR("No arguments passed to a function that " |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5410 | "expects arguments"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5411 | } else { // Has arguments? |
| 5412 | // Loop through FunctionType's arguments and ensure they are specified |
| 5413 | // correctly! |
| 5414 | // |
| 5415 | FunctionType::param_iterator I = Ty->param_begin(); |
| 5416 | FunctionType::param_iterator E = Ty->param_end(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5417 | ValueRefList::iterator ArgI = (yyvsp[-2].ValueRefList)->begin(), ArgE = (yyvsp[-2].ValueRefList)->end(); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5418 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5419 | for (; ArgI != ArgE && I != E; ++ArgI, ++I) { |
| 5420 | if (ArgI->Val->getType() != *I) |
| 5421 | GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5422 | (*I)->getDescription() + "'"); |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5423 | Args.push_back(ArgI->Val); |
| 5424 | } |
| 5425 | if (Ty->isVarArg()) { |
| 5426 | if (I == E) |
| 5427 | for (; ArgI != ArgE; ++ArgI) |
| 5428 | Args.push_back(ArgI->Val); // push the remaining varargs |
| 5429 | } else if (I != E || ArgI != ArgE) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5430 | GEN_ERROR("Invalid number of parameters detected"); |
Andrew Lenharth | 6353e05 | 2006-12-08 18:07:09 +0000 | [diff] [blame] | 5431 | } |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5432 | // Create the call node |
| 5433 | CallInst *CI = new CallInst(V, Args); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5434 | CI->setTailCall((yyvsp[-7].BoolVal)); |
| 5435 | CI->setCallingConv((yyvsp[-6].UIntVal)); |
| 5436 | (yyval.InstVal) = CI; |
| 5437 | delete (yyvsp[-2].ValueRefList); |
| 5438 | delete (yyvsp[-5].TypeVal); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5439 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5440 | ;} |
| 5441 | break; |
| 5442 | |
| 5443 | case 274: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5444 | #line 2770 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5445 | { |
| 5446 | (yyval.InstVal) = (yyvsp[0].InstVal); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5447 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5448 | ;} |
| 5449 | break; |
| 5450 | |
| 5451 | case 275: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5452 | #line 2775 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5453 | { |
| 5454 | (yyval.BoolVal) = true; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5455 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5456 | ;} |
| 5457 | break; |
| 5458 | |
| 5459 | case 276: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5460 | #line 2779 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5461 | { |
| 5462 | (yyval.BoolVal) = false; |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5463 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5464 | ;} |
| 5465 | break; |
| 5466 | |
| 5467 | case 277: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5468 | #line 2786 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5469 | { |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5470 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5471 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5472 | (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); |
| 5473 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 6f40790 | 2007-01-13 05:00:46 +0000 | [diff] [blame] | 5474 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5475 | ;} |
| 5476 | break; |
| 5477 | |
| 5478 | case 278: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5479 | #line 2793 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5480 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5481 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5482 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription()); |
| 5483 | Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5484 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5485 | (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); |
| 5486 | delete (yyvsp[-4].TypeVal); |
| 5487 | ;} |
| 5488 | break; |
| 5489 | |
| 5490 | case 279: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5491 | #line 2801 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5492 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5493 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5494 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5495 | (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); |
| 5496 | delete (yyvsp[-1].TypeVal); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5497 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5498 | ;} |
| 5499 | break; |
| 5500 | |
| 5501 | case 280: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5502 | #line 2808 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5503 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5504 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5505 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-4].TypeVal))->getDescription()); |
| 5506 | Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5507 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5508 | (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); |
| 5509 | delete (yyvsp[-4].TypeVal); |
| 5510 | ;} |
| 5511 | break; |
| 5512 | |
| 5513 | case 281: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5514 | #line 2816 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5515 | { |
| 5516 | if (!isa<PointerType>((yyvsp[0].ValueVal)->getType())) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5517 | GEN_ERROR("Trying to free nonpointer type " + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5518 | (yyvsp[0].ValueVal)->getType()->getDescription() + ""); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5519 | (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5520 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5521 | ;} |
| 5522 | break; |
| 5523 | |
| 5524 | case 282: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5525 | #line 2824 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5526 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5527 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5528 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5529 | if (!isa<PointerType>((yyvsp[-1].TypeVal)->get())) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5530 | GEN_ERROR("Can't load from nonpointer type: " + |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5531 | (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5532 | if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType()) |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5533 | GEN_ERROR("Can't load from pointer of non-first-class type: " + |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5534 | (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5535 | Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5536 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5537 | (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal)); |
| 5538 | delete (yyvsp[-1].TypeVal); |
| 5539 | ;} |
| 5540 | break; |
| 5541 | |
| 5542 | case 283: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5543 | #line 2838 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5544 | { |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5545 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5546 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-1].TypeVal))->getDescription()); |
| 5547 | const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5548 | if (!PT) |
| 5549 | GEN_ERROR("Can't store to a nonpointer type: " + |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5550 | (*(yyvsp[-1].TypeVal))->getDescription()); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5551 | const Type *ElTy = PT->getElementType(); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5552 | if (ElTy != (yyvsp[-3].ValueVal)->getType()) |
| 5553 | GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5554 | "' into space of type '" + ElTy->getDescription() + "'"); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5555 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5556 | Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5557 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5558 | (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal)); |
| 5559 | delete (yyvsp[-1].TypeVal); |
| 5560 | ;} |
| 5561 | break; |
| 5562 | |
| 5563 | case 284: |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5564 | #line 2855 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5565 | { |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5566 | if (!UpRefs.empty()) |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5567 | GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[-2].TypeVal))->getDescription()); |
| 5568 | if (!isa<PointerType>((yyvsp[-2].TypeVal)->get())) |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5569 | GEN_ERROR("getelementptr insn requires pointer operand"); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5570 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5571 | if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true)) |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5572 | GEN_ERROR("Invalid getelementptr indices for type '" + |
Reid Spencer | b5334b0 | 2007-02-05 10:18:06 +0000 | [diff] [blame] | 5573 | (*(yyvsp[-2].TypeVal))->getDescription()+ "'"); |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5574 | Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal)); |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5575 | CHECK_FOR_ERROR |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5576 | (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList)); |
| 5577 | delete (yyvsp[-2].TypeVal); |
| 5578 | delete (yyvsp[0].ValueList); |
| 5579 | ;} |
| 5580 | break; |
| 5581 | |
| 5582 | |
| 5583 | default: break; |
| 5584 | } |
| 5585 | |
| 5586 | /* Line 1126 of yacc.c. */ |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5587 | #line 5588 "llvmAsmParser.tab.c" |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 5588 | |
| 5589 | yyvsp -= yylen; |
| 5590 | yyssp -= yylen; |
| 5591 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5592 | |
| 5593 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5594 | |
| 5595 | *++yyvsp = yyval; |
| 5596 | |
| 5597 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5598 | /* Now `shift' the result of the reduction. Determine what state |
| 5599 | that goes to, based on the state we popped back to and the rule |
| 5600 | number reduced by. */ |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5601 | |
| 5602 | yyn = yyr1[yyn]; |
| 5603 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5604 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
| 5605 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5606 | yystate = yytable[yystate]; |
| 5607 | else |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5608 | yystate = yydefgoto[yyn - YYNTOKENS]; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5609 | |
| 5610 | goto yynewstate; |
| 5611 | |
| 5612 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5613 | /*------------------------------------. |
| 5614 | | yyerrlab -- here on detecting error | |
| 5615 | `------------------------------------*/ |
| 5616 | yyerrlab: |
| 5617 | /* If not already recovering from an error, report this error. */ |
| 5618 | if (!yyerrstatus) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5619 | { |
| 5620 | ++yynerrs; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5621 | #if YYERROR_VERBOSE |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 5622 | yyn = yypact[yystate]; |
Anton Korobeynikov | 9adeaa2 | 2007-01-28 13:37:39 +0000 | [diff] [blame] | 5623 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5624 | if (YYPACT_NINF < yyn && yyn < YYLAST) |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 5625 | { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5626 | int yytype = YYTRANSLATE (yychar); |
| 5627 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); |
| 5628 | YYSIZE_T yysize = yysize0; |
| 5629 | YYSIZE_T yysize1; |
| 5630 | int yysize_overflow = 0; |
| 5631 | char *yymsg = 0; |
| 5632 | # define YYERROR_VERBOSE_ARGS_MAXIMUM 5 |
| 5633 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
| 5634 | int yyx; |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 5635 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5636 | #if 0 |
| 5637 | /* This is so xgettext sees the translatable formats that are |
| 5638 | constructed on the fly. */ |
| 5639 | YY_("syntax error, unexpected %s"); |
| 5640 | YY_("syntax error, unexpected %s, expecting %s"); |
| 5641 | YY_("syntax error, unexpected %s, expecting %s or %s"); |
| 5642 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); |
| 5643 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); |
| 5644 | #endif |
| 5645 | char *yyfmt; |
| 5646 | char const *yyf; |
| 5647 | static char const yyunexpected[] = "syntax error, unexpected %s"; |
| 5648 | static char const yyexpecting[] = ", expecting %s"; |
| 5649 | static char const yyor[] = " or %s"; |
| 5650 | char yyformat[sizeof yyunexpected |
| 5651 | + sizeof yyexpecting - 1 |
| 5652 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) |
| 5653 | * (sizeof yyor - 1))]; |
| 5654 | char const *yyprefix = yyexpecting; |
| 5655 | |
| 5656 | /* Start YYX at -YYN if negative to avoid negative indexes in |
| 5657 | YYCHECK. */ |
| 5658 | int yyxbegin = yyn < 0 ? -yyn : 0; |
| 5659 | |
| 5660 | /* Stay within bounds of both yycheck and yytname. */ |
| 5661 | int yychecklim = YYLAST - yyn; |
| 5662 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
| 5663 | int yycount = 1; |
| 5664 | |
| 5665 | yyarg[0] = yytname[yytype]; |
| 5666 | yyfmt = yystpcpy (yyformat, yyunexpected); |
| 5667 | |
| 5668 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
| 5669 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
| 5670 | { |
| 5671 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
| 5672 | { |
| 5673 | yycount = 1; |
| 5674 | yysize = yysize0; |
| 5675 | yyformat[sizeof yyunexpected - 1] = '\0'; |
| 5676 | break; |
| 5677 | } |
| 5678 | yyarg[yycount++] = yytname[yyx]; |
| 5679 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); |
| 5680 | yysize_overflow |= yysize1 < yysize; |
| 5681 | yysize = yysize1; |
| 5682 | yyfmt = yystpcpy (yyfmt, yyprefix); |
| 5683 | yyprefix = yyor; |
| 5684 | } |
| 5685 | |
| 5686 | yyf = YY_(yyformat); |
| 5687 | yysize1 = yysize + yystrlen (yyf); |
| 5688 | yysize_overflow |= yysize1 < yysize; |
| 5689 | yysize = yysize1; |
| 5690 | |
| 5691 | if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) |
| 5692 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
| 5693 | if (yymsg) |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 5694 | { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5695 | /* Avoid sprintf, as that infringes on the user's name space. |
| 5696 | Don't have undefined behavior even if the translation |
| 5697 | produced a string with the wrong number of "%s"s. */ |
| 5698 | char *yyp = yymsg; |
| 5699 | int yyi = 0; |
| 5700 | while ((*yyp = *yyf)) |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 5701 | { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5702 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) |
| 5703 | { |
| 5704 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
| 5705 | yyf += 2; |
| 5706 | } |
| 5707 | else |
| 5708 | { |
| 5709 | yyp++; |
| 5710 | yyf++; |
| 5711 | } |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 5712 | } |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5713 | yyerror (yymsg); |
| 5714 | YYSTACK_FREE (yymsg); |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 5715 | } |
| 5716 | else |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5717 | { |
| 5718 | yyerror (YY_("syntax error")); |
| 5719 | goto yyexhaustedlab; |
| 5720 | } |
Reid Spencer | 5cbf985 | 2007-01-30 20:08:39 +0000 | [diff] [blame] | 5721 | } |
| 5722 | else |
| 5723 | #endif /* YYERROR_VERBOSE */ |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5724 | yyerror (YY_("syntax error")); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5725 | } |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5726 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5727 | |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5728 | |
| 5729 | if (yyerrstatus == 3) |
| 5730 | { |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5731 | /* If just tried and failed to reuse look-ahead token after an |
| 5732 | error, discard it. */ |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5733 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5734 | if (yychar <= YYEOF) |
| 5735 | { |
| 5736 | /* Return failure if at end of input. */ |
| 5737 | if (yychar == YYEOF) |
| 5738 | YYABORT; |
| 5739 | } |
| 5740 | else |
| 5741 | { |
| 5742 | yydestruct ("Error: discarding", yytoken, &yylval); |
| 5743 | yychar = YYEMPTY; |
| 5744 | } |
| 5745 | } |
| 5746 | |
| 5747 | /* Else will try to reuse look-ahead token after shifting the error |
| 5748 | token. */ |
| 5749 | goto yyerrlab1; |
| 5750 | |
| 5751 | |
| 5752 | /*---------------------------------------------------. |
| 5753 | | yyerrorlab -- error raised explicitly by YYERROR. | |
| 5754 | `---------------------------------------------------*/ |
| 5755 | yyerrorlab: |
| 5756 | |
| 5757 | /* Pacify compilers like GCC when the user code never invokes |
| 5758 | YYERROR and the label yyerrorlab therefore never appears in user |
| 5759 | code. */ |
| 5760 | if (0) |
| 5761 | goto yyerrorlab; |
| 5762 | |
| 5763 | yyvsp -= yylen; |
| 5764 | yyssp -= yylen; |
| 5765 | yystate = *yyssp; |
| 5766 | goto yyerrlab1; |
| 5767 | |
| 5768 | |
| 5769 | /*-------------------------------------------------------------. |
| 5770 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
| 5771 | `-------------------------------------------------------------*/ |
| 5772 | yyerrlab1: |
| 5773 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
| 5774 | |
| 5775 | for (;;) |
| 5776 | { |
| 5777 | yyn = yypact[yystate]; |
| 5778 | if (yyn != YYPACT_NINF) |
| 5779 | { |
| 5780 | yyn += YYTERROR; |
| 5781 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
| 5782 | { |
| 5783 | yyn = yytable[yyn]; |
| 5784 | if (0 < yyn) |
| 5785 | break; |
| 5786 | } |
| 5787 | } |
| 5788 | |
| 5789 | /* Pop the current state because it cannot handle the error token. */ |
| 5790 | if (yyssp == yyss) |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5791 | YYABORT; |
| 5792 | |
Reid Spencer | e4d87aa | 2006-12-23 06:05:41 +0000 | [diff] [blame] | 5793 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5794 | yydestruct ("Error: popping", yystos[yystate], yyvsp); |
| 5795 | YYPOPSTACK; |
| 5796 | yystate = *yyssp; |
| 5797 | YY_STACK_PRINT (yyss, yyssp); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5798 | } |
| 5799 | |
| 5800 | if (yyn == YYFINAL) |
| 5801 | YYACCEPT; |
| 5802 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5803 | *++yyvsp = yylval; |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5804 | |
| 5805 | |
| 5806 | /* Shift the error token. */ |
| 5807 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
Reid Spencer | 41dff5e | 2007-01-26 08:05:27 +0000 | [diff] [blame] | 5808 | |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5809 | yystate = yyn; |
| 5810 | goto yynewstate; |
| 5811 | |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 5812 | |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5813 | /*-------------------------------------. |
| 5814 | | yyacceptlab -- YYACCEPT comes here. | |
| 5815 | `-------------------------------------*/ |
| 5816 | yyacceptlab: |
| 5817 | yyresult = 0; |
| 5818 | goto yyreturn; |
| 5819 | |
| 5820 | /*-----------------------------------. |
| 5821 | | yyabortlab -- YYABORT comes here. | |
| 5822 | `-----------------------------------*/ |
| 5823 | yyabortlab: |
| 5824 | yyresult = 1; |
| 5825 | goto yyreturn; |
| 5826 | |
| 5827 | #ifndef yyoverflow |
| 5828 | /*-------------------------------------------------. |
| 5829 | | yyexhaustedlab -- memory exhaustion comes here. | |
| 5830 | `-------------------------------------------------*/ |
| 5831 | yyexhaustedlab: |
| 5832 | yyerror (YY_("memory exhausted")); |
| 5833 | yyresult = 2; |
| 5834 | /* Fall through. */ |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 5835 | #endif |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5836 | |
| 5837 | yyreturn: |
| 5838 | if (yychar != YYEOF && yychar != YYEMPTY) |
| 5839 | yydestruct ("Cleanup: discarding lookahead", |
| 5840 | yytoken, &yylval); |
| 5841 | while (yyssp != yyss) |
| 5842 | { |
| 5843 | yydestruct ("Cleanup: popping", |
| 5844 | yystos[*yyssp], yyvsp); |
| 5845 | YYPOPSTACK; |
Chris Lattner | f7469af | 2007-01-31 04:44:08 +0000 | [diff] [blame] | 5846 | } |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5847 | #ifndef yyoverflow |
| 5848 | if (yyss != yyssa) |
| 5849 | YYSTACK_FREE (yyss); |
| 5850 | #endif |
| 5851 | return yyresult; |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5852 | } |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5853 | |
| 5854 | |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5855 | #line 2872 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y" |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5856 | |
| 5857 | |
Reid Spencer | 1431061 | 2006-12-31 05:40:51 +0000 | [diff] [blame] | 5858 | // common code from the two 'RunVMAsmParser' functions |
| 5859 | static Module* RunParser(Module * M) { |
| 5860 | |
| 5861 | llvmAsmlineno = 1; // Reset the current line number... |
| 5862 | CurModule.CurrentModule = M; |
| 5863 | #if YYDEBUG |
| 5864 | yydebug = Debug; |
| 5865 | #endif |
| 5866 | |
| 5867 | // Check to make sure the parser succeeded |
| 5868 | if (yyparse()) { |
| 5869 | if (ParserResult) |
| 5870 | delete ParserResult; |
| 5871 | return 0; |
| 5872 | } |
| 5873 | |
| 5874 | // Check to make sure that parsing produced a result |
| 5875 | if (!ParserResult) |
| 5876 | return 0; |
| 5877 | |
| 5878 | // Reset ParserResult variable while saving its value for the result. |
| 5879 | Module *Result = ParserResult; |
| 5880 | ParserResult = 0; |
| 5881 | |
| 5882 | return Result; |
| 5883 | } |
| 5884 | |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5885 | void llvm::GenerateError(const std::string &message, int LineNo) { |
| 5886 | if (LineNo == -1) LineNo = llvmAsmlineno; |
| 5887 | // TODO: column number in exception |
| 5888 | if (TheParseError) |
| 5889 | TheParseError->setError(CurFilename, message, LineNo); |
| 5890 | TriggerError = 1; |
| 5891 | } |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5892 | |
| 5893 | int yyerror(const char *ErrorMsg) { |
| 5894 | std::string where |
| 5895 | = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename) |
| 5896 | + ":" + utostr((unsigned) llvmAsmlineno) + ": "; |
Reid Spencer | ef9b9a7 | 2007-02-05 20:47:22 +0000 | [diff] [blame^] | 5897 | std::string errMsg = where + "error: " + std::string(ErrorMsg); |
| 5898 | if (yychar != YYEMPTY && yychar != 0) |
| 5899 | errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+ |
| 5900 | "'"; |
Reid Spencer | 61c83e0 | 2006-08-18 08:43:06 +0000 | [diff] [blame] | 5901 | GenerateError(errMsg); |
Reid Spencer | 68a24bd | 2005-08-27 18:50:39 +0000 | [diff] [blame] | 5902 | return 0; |
| 5903 | } |
Reid Spencer | 832254e | 2007-02-02 02:16:23 +0000 | [diff] [blame] | 5904 | |